Package snap.text

Class SubText

All Implemented Interfaces:
CharSequence, Cloneable, PropChange.DoChange, CharSequenceX

public class SubText extends TextDoc
This TextDoc subclass wraps a TextDoc for a character range.
  • Field Details

    • _startCharIndexInDoc

      protected int _startCharIndexInDoc
    • _endCharIndexInDoc

      protected int _endCharIndexInDoc
  • Constructor Details

    • SubText

      public SubText(TextDoc aTextDoc, int aStart, int anEnd)
      Constructor.
  • Method Details

    • getTextDoc

      public TextDoc getTextDoc()
      Returns the TextDoc that this SubText references.
    • getStartCharIndex

      public int getStartCharIndex()
      Returns the start char index.
      Overrides:
      getStartCharIndex in class TextDoc
    • getEndCharIndex

      public int getEndCharIndex()
      Returns the end char index.
    • isRichText

      public boolean isRichText()
      Whether this text supports multiple styles (font, color, etc.).
      Overrides:
      isRichText in class TextDoc
    • getSourceURL

      public WebURL getSourceURL()
      Returns the source URL.
      Overrides:
      getSourceURL in class TextDoc
    • setDefaultStyle

      public void setDefaultStyle(TextStyle aStyle)
      Sets the default style.
      Overrides:
      setDefaultStyle in class TextDoc
    • setDefaultLineStyle

      public void setDefaultLineStyle(TextLineStyle aLineStyle)
      Sets the default line style.
      Overrides:
      setDefaultLineStyle in class TextDoc
    • addChars

      public void addChars(CharSequence theChars, TextStyle theStyle, int charIndex)
      Adds characters with attributes to this text at given index.
      Overrides:
      addChars in class TextDoc
    • removeChars

      public void removeChars(int startCharIndex, int endCharIndex)
      Removes characters in given range.
      Overrides:
      removeChars in class TextDoc
    • setStyle

      public void setStyle(TextStyle aStyle, int startCharIndex, int endCharIndex)
      Sets a given style to a given range.
      Overrides:
      setStyle in class TextDoc
    • setStyleValue

      public void setStyleValue(String aKey, Object aValue, int startCharIndex, int endCharIndex)
      Sets a given attribute to a given value for a given range.
      Overrides:
      setStyleValue in class TextDoc
    • setLineStyle

      public void setLineStyle(TextLineStyle aStyle, int startCharIndex, int endCharIndex)
      Sets a given style to a given range.
      Overrides:
      setLineStyle in class TextDoc
    • setLineStyleValue

      public void setLineStyleValue(String aKey, Object aValue, int startCharIndex, int endCharIndex)
      Sets a given style to a given range.
      Overrides:
      setLineStyleValue in class TextDoc
    • writeToSourceFile

      public void writeToSourceFile() throws Exception
      Save TextDoc text to Source file.
      Overrides:
      writeToSourceFile in class TextDoc
      Throws:
      Exception
    • createTokensForTextLine

      protected TextToken[] createTokensForTextLine(TextLine aTextLine)
      Override to use TextDoc tokenizer.
      Overrides:
      createTokensForTextLine in class TextDoc
    • dispose

      public void dispose()
      Called when SubText is no longer needed to remove TextDoc prop listener.