TextPos (JavaFX 27)
Description: declaration: module: jfx.incubator.richtext, package: jfx.incubator.scene.control.richtext, class: TextPos

# Class TextPos

java.lang.Object
jfx.incubator.scene.control.richtext.TextPos

All Implemented Interfaces:
  `Comparable<TextPos>`

public final class TextPos extends Object implements Comparable<TextPos>
An immutable position within the text.

Because it is immutable, it cannot track locations in the document which is being edited. For that, use `Marker`.

Since:
  24

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final TextPos`
  `ZERO`
  A text position at the start of the document.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `TextPos(int index, int offset, int charIndex, boolean leading)`
  Creates a new text position.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `int`
  `charIndex()`
  Returns the character index.
  `int`
  `compareTo(TextPos p)`
  `int`
  `index()`
  Returns the paragraph index.
  `boolean`
  `isLeading()`
  Determines whether the text position is leading or trailing.
  `boolean`
  `isSameInsertionIndex(TextPos p)`
  Returns true if the specified insertion point is the same.
  `int`
  `offset()`
  Returns the offset into the plain text string (insertion index).
  `static TextPos`
  `ofLeading(int index, int offset)`
  Creates a new text position at the leading edge of the character at the specified text offset.

  ### Methods declared in class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### ZERO

    public static final TextPos ZERO
    A text position at the start of the document.

- ## Constructor Details

  - ### TextPos

    public TextPos(int index, int offset, int charIndex, boolean leading)
    Creates a new text position.
    Parameters:
      `index` - the paragraph index
      `offset` - the offset in the text which corresponds to the insertion position
      `charIndex` - the character index
      `leading` - indicates whether the position is at the leading edge of the character at `charIndex`

- ## Method Details

  - ### ofLeading

    public static TextPos ofLeading(int index, int offset)
    Creates a new text position at the leading edge of the character at the specified text offset.
    Parameters:
      `index` - the paragraph index
      `offset` - the text offset
    Returns:
      the instance of `TextPos`

  - ### index

    public int index()
    Returns the paragraph index.
    Returns:
      the paragraph index

  - ### offset

    public int offset()
    Returns the offset into the plain text string (insertion index).
    Returns:
      the offset

  - ### charIndex

    public int charIndex()
    Returns the character index.
    Returns:
      the character index

  - ### isLeading

    public boolean isLeading()
    Determines whether the text position is leading or trailing.
    Returns:
      true if leading text position

  - ### compareTo

    public int compareTo(TextPos p)
    Specified by:
      `compareTo` in interface `Comparable<TextPos>`

  - ### isSameInsertionIndex

    public boolean isSameInsertionIndex(TextPos p)
    Returns true if the specified insertion point is the same.
    Parameters:
      `p` - text position
    Returns:
      true if same insertion index