Package snap.text

Class TextSel

java.lang.Object
snap.text.TextSel

public class TextSel extends Object
A class to represent a selection of text.
  • Constructor Summary

    Constructors
    Constructor
    Description
    TextSel(TextBox aTextBox, double x1, double y1, double x2, double y2, boolean isWordSel, boolean isParaSel)
    Returns the selected range that would result from the given two points.
    TextSel(TextBox aTextBox, int aStart, int aEnd)
    Creates a new selection.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Returns the selection anchor (initial char of multi-char selection - usually start).
    int
    Moves the selection index down a line, trying preserve distance from beginning of line.
    int
    Moves the selection index backward a character (or if a range is selected, moves to beginning of range).
    int
    Moves the selection index forward a character (or if a range is selected, moves to end of range).
    int
    Moves the selection index up a line, trying to preserve distance from beginning of line.
    int
    Returns the selection end.
    Returns the line at selection end.
    int
    Returns the cursor position (final char of multi-char selection - usually end).
    int
    Moves the insertion point to next newline or text end.
    int
    Moves the insertion point to the beginning of line.
    Returns a path for two char indexes - it will be a a simple box with extensions for first/last lines.
    int
    The length.
    int
    Returns the selection start.
    Returns the line at selection start.
    Returns the selected text string.
    Returns the text.
    boolean
    Returns whether selection is at line end.
    boolean
    Returns whether selection is empty.
    protected boolean
    isWordChar(char c)
    Returns whether a character should be considered is part of a word when WordSelecting.
    Standard toString implementation.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • TextSel

      public TextSel(TextBox aTextBox, int aStart, int aEnd)
      Creates a new selection.
    • TextSel

      public TextSel(TextBox aTextBox, double x1, double y1, double x2, double y2, boolean isWordSel, boolean isParaSel)
      Returns the selected range that would result from the given two points.
  • Method Details

    • getTextBox

      public TextBox getTextBox()
      Returns the text.
    • getAnchor

      public int getAnchor()
      Returns the selection anchor (initial char of multi-char selection - usually start).
    • getIndex

      public int getIndex()
      Returns the cursor position (final char of multi-char selection - usually end).
    • getStart

      public int getStart()
      Returns the selection start.
    • getEnd

      public int getEnd()
      Returns the selection end.
    • getSize

      public int getSize()
      The length.
    • isEmpty

      public boolean isEmpty()
      Returns whether selection is empty.
    • getString

      public String getString()
      Returns the selected text string.
    • getCharRight

      public int getCharRight()
      Moves the selection index forward a character (or if a range is selected, moves to end of range).
    • getCharLeft

      public int getCharLeft()
      Moves the selection index backward a character (or if a range is selected, moves to beginning of range).
    • getCharUp

      public int getCharUp()
      Moves the selection index up a line, trying to preserve distance from beginning of line.
    • getCharDown

      public int getCharDown()
      Moves the selection index down a line, trying preserve distance from beginning of line.
    • getLineStart

      public int getLineStart()
      Moves the insertion point to the beginning of line.
    • getLineEnd

      public int getLineEnd()
      Moves the insertion point to next newline or text end.
    • getStartLine

      public TextBoxLine getStartLine()
      Returns the line at selection start.
    • getEndLine

      public TextBoxLine getEndLine()
      Returns the line at selection end.
    • isAtLineEnd

      public boolean isAtLineEnd()
      Returns whether selection is at line end.
    • getPath

      public Shape getPath()
      Returns a path for two char indexes - it will be a a simple box with extensions for first/last lines.
    • isWordChar

      protected boolean isWordChar(char c)
      Returns whether a character should be considered is part of a word when WordSelecting.
    • toString

      public String toString()
      Standard toString implementation.
      Overrides:
      toString in class Object