Interface TextEditingArea<PS,​SEG,​S>

    • Property Detail

      • length

        javafx.beans.value.ObservableValue<java.lang.Integer> lengthProperty
        See Also:
        getLength()
      • text

        javafx.beans.value.ObservableValue<java.lang.String> textProperty
        See Also:
        getText()
      • caretPosition

        default javafx.beans.value.ObservableValue<java.lang.Integer> caretPositionProperty
        See Also:
        getCaretPosition()
      • currentParagraph

        default javafx.beans.value.ObservableValue<java.lang.Integer> currentParagraphProperty
        See Also:
        getCurrentParagraph()
      • caretColumn

        default javafx.beans.value.ObservableValue<java.lang.Integer> caretColumnProperty
        See Also:
        getCaretColumn()
      • caretBounds

        default javafx.beans.value.ObservableValue<java.util.Optional<javafx.geometry.Bounds>> caretBoundsProperty
        See Also:
        getCaretBounds()
      • anchor

        default javafx.beans.value.ObservableValue<java.lang.Integer> anchorProperty
        See Also:
        getAnchor()
      • selection

        default javafx.beans.value.ObservableValue<javafx.scene.control.IndexRange> selectionProperty
        See Also:
        getSelection()
      • selectedText

        default javafx.beans.value.ObservableValue<java.lang.String> selectedTextProperty
        See Also:
        getSelectedText()
      • selectionBounds

        default javafx.beans.value.ObservableValue<java.util.Optional<javafx.geometry.Bounds>> selectionBoundsProperty
        See Also:
        getSelectionBounds()
    • Method Detail

      • getLength

        default int getLength()
        The number of characters in this text-editing area.
      • lengthProperty

        javafx.beans.value.ObservableValue<java.lang.Integer> lengthProperty()
        See Also:
        getLength()
      • getLocale

        default java.util.Locale getLocale()
        This is used to determine word and sentence breaks while navigating or selecting. Override this method if your paragraph or text style accommodates Locales as well.
      • getText

        default java.lang.String getText()
        Text content of this text-editing area.
      • textProperty

        javafx.beans.value.ObservableValue<java.lang.String> textProperty()
        See Also:
        getText()
      • getDocument

        StyledDocument<PS,​SEG,​S> getDocument()
        Rich-text content of this text-editing area. The returned document is immutable, it does not reflect subsequent edits of this text-editing area.
      • getContent

        EditableStyledDocument<PS,​SEG,​S> getContent()
        The underlying document of this area that can be displayed by multiple StyledTextAreas.
      • getSegOps

        SegmentOps<SEG,​S> getSegOps()
        Returns the object used for operating over segments and their styles
      • getCaretPosition

        default int getCaretPosition()
        The current position of the caret, as a character offset in the text. Most of the time, caret is at the boundary of the selection (if there is any selection). However, there are circumstances when the caret is positioned inside or outside the selected text. For example, when the user is dragging the selected text, the caret moves with the cursor to point at the position where the selected text moves upon release.
      • caretPositionProperty

        default javafx.beans.value.ObservableValue<java.lang.Integer> caretPositionProperty()
        See Also:
        getCaretPosition()
      • getCurrentParagraph

        default int getCurrentParagraph()
        Index of the current paragraph, i.e. the paragraph with the caret.
      • currentParagraphProperty

        default javafx.beans.value.ObservableValue<java.lang.Integer> currentParagraphProperty()
        See Also:
        getCurrentParagraph()
      • getCaretColumn

        default int getCaretColumn()
        The caret position within the current paragraph.
      • caretColumnProperty

        default javafx.beans.value.ObservableValue<java.lang.Integer> caretColumnProperty()
        See Also:
        getCaretColumn()
      • getCaretBounds

        default java.util.Optional<javafx.geometry.Bounds> getCaretBounds()
        Gets the bounds of the caret in the Screen's coordinate system or Optional.empty() if caret is not visible in the viewport.
      • caretBoundsProperty

        default javafx.beans.value.ObservableValue<java.util.Optional<javafx.geometry.Bounds>> caretBoundsProperty()
        See Also:
        getCaretBounds()
      • getShowCaret

        default Caret.CaretVisibility getShowCaret()
        Indicates when this text area should display a caret.
      • setShowCaret

        default void setShowCaret​(Caret.CaretVisibility value)
        Sets the value of the property showCaret.
        Property description:
      • getAnchor

        default int getAnchor()
        The anchor of the selection. If there is no selection, this is the same as caret position.
      • anchorProperty

        default javafx.beans.value.ObservableValue<java.lang.Integer> anchorProperty()
        See Also:
        getAnchor()
      • getSelection

        default javafx.scene.control.IndexRange getSelection()
        The selection range. One boundary is always equal to anchor, and the other one is most of the time equal to caret position.
      • selectionProperty

        default javafx.beans.value.ObservableValue<javafx.scene.control.IndexRange> selectionProperty()
        See Also:
        getSelection()
      • getSelectedText

        default java.lang.String getSelectedText()
        The selected text.
      • selectedTextProperty

        default javafx.beans.value.ObservableValue<java.lang.String> selectedTextProperty()
        See Also:
        getSelectedText()
      • getSelectionBounds

        default java.util.Optional<javafx.geometry.Bounds> getSelectionBounds()
        Gets the bounds of the selection in the Screen's coordinate system if something is selected and visible in the viewport or Optional.empty() if selection is not visible in the viewport.
      • selectionBoundsProperty

        default javafx.beans.value.ObservableValue<java.util.Optional<javafx.geometry.Bounds>> selectionBoundsProperty()
        See Also:
        getSelectionBounds()
      • getParagraphs

        javafx.collections.ObservableList<Paragraph<PS,​SEG,​S>> getParagraphs()
        Unmodifiable observable list of paragraphs in this text area.
      • getParagraph

        default Paragraph<PS,​SEG,​S> getParagraph​(int index)
      • getParagraphLength

        default int getParagraphLength​(int index)
      • isBeingUpdated

        default boolean isBeingUpdated()
      • getText

        java.lang.String getText​(int paragraphIndex)
        Returns text content of the given paragraph.
      • getText

        java.lang.String getText​(int start,
                                 int end)
        Returns text content of the given character range.
      • getText

        java.lang.String getText​(javafx.scene.control.IndexRange range)
        Returns text content of the given character range.
      • getText

        default java.lang.String getText​(int startParagraph,
                                         int startColumn,
                                         int endParagraph,
                                         int endColumn)
        Returns text content of the given character range.

        Caution: see getAbsolutePosition(int, int) to know how the column index argument can affect the returned position.

      • subDocument

        StyledDocument<PS,​SEG,​S> subDocument​(int paragraphIndex)
        Returns rich-text content of the given paragraph.
      • subDocument

        default StyledDocument<PS,​SEG,​S> subDocument​(javafx.scene.control.IndexRange range)
        Returns rich-text content of the given character range.
      • subDocument

        StyledDocument<PS,​SEG,​S> subDocument​(int start,
                                                         int end)
        Returns rich-text content of the given character range.
      • subDocument

        default StyledDocument<PS,​SEG,​S> subDocument​(int startParagraph,
                                                                 int startColumn,
                                                                 int endParagraph,
                                                                 int endColumn)
        Returns rich-text content of the given character range.

        Caution: see getAbsolutePosition(int, int) to know how the column index argument can affect the returned position.

      • getParagraphSelection

        default javafx.scene.control.IndexRange getParagraphSelection​(int paragraph)
        Returns the selection range in the given paragraph. Note: this method will return IndexRange(start, paragraph.length() + 1) when the selection includes a newline character.
      • getParagraphSelection

        javafx.scene.control.IndexRange getParagraphSelection​(Selection selection,
                                                              int paragraph)
      • selectRange

        default void selectRange​(int anchor,
                                 int caretPosition)
        Positions the anchor and caretPosition explicitly, effectively creating a selection.
      • selectRange

        default void selectRange​(int anchorParagraph,
                                 int anchorColumn,
                                 int caretPositionParagraph,
                                 int caretPositionColumn)
        Positions the anchor and caretPosition explicitly, effectively creating a selection.

        Caution: see getAbsolutePosition(int, int) to know how the column index argument can affect the returned position.

      • displaceCaret

        void displaceCaret​(int pos)
        Displaces the caret from the selection by positioning only the caret to the new location without also affecting the selection's anchor or the selection. Do not confuse this method with NavigationActions.moveTo(int), which is the normal way of moving the caret. This method can be used to achieve the special case of positioning the caret outside or inside the selection, as opposed to always being at the boundary. Use with care.
      • replaceText

        void replaceText​(int start,
                         int end,
                         java.lang.String text)
        Replaces a range of characters with the given text. It must hold 0 <= start <= end <= getLength().
        Parameters:
        start - Start index of the range to replace, inclusive.
        end - End index of the range to replace, exclusive.
        text - The text to put in place of the deleted range. It must not be null.
      • replaceText

        default void replaceText​(int startParagraph,
                                 int startColumn,
                                 int endParagraph,
                                 int endColumn,
                                 java.lang.String text)
        Replaces a range of characters with the given text. It must hold 0 <= start <= end <= getLength() where start = getAbsolutePosition(startParagraph, startColumn); and is inclusive, and int end = getAbsolutePosition(endParagraph, endColumn); and is exclusive.

        Caution: see getAbsolutePosition(int, int) to know how the column index argument can affect the returned position.

        Parameters:
        text - The text to put in place of the deleted range. It must not be null.
      • replace

        void replace​(int start,
                     int end,
                     StyledDocument<PS,​SEG,​S> replacement)
        Replaces a range of characters with the given rich-text document.
      • replace

        void replace​(int start,
                     int end,
                     SEG seg,
                     S style)
        Replaces a range of characters with the given segment. It must hold 0 <= start <= end <= getLength().
        Parameters:
        start - Start index of the range to replace, inclusive.
        end - End index of the range to replace, exclusive.
        seg - The seg to put in place of the deleted range. It must not be null.
      • replace

        default void replace​(int startParagraph,
                             int startColumn,
                             int endParagraph,
                             int endColumn,
                             SEG seg,
                             S style)
        Replaces a range of characters with the given segment. It must hold 0 <= start <= end <= getLength() where start = getAbsolutePosition(startParagraph, startColumn); and is inclusive, and int end = getAbsolutePosition(endParagraph, endColumn); and is exclusive.

        Caution: see getAbsolutePosition(int, int) to know how the column index argument can affect the returned position.

        Parameters:
        seg - The segment to put in place of the deleted range. It must not be null.
      • replace

        default void replace​(int startParagraph,
                             int startColumn,
                             int endParagraph,
                             int endColumn,
                             StyledDocument<PS,​SEG,​S> replacement)
        Replaces a range of characters with the given rich-text document.

        Caution: see getAbsolutePosition(int, int) to know how the column index argument can affect the returned position.

      • replaceText

        default void replaceText​(javafx.scene.control.IndexRange range,
                                 java.lang.String text)
        Replaces a range of characters with the given text.
        Parameters:
        range - The range to replace. It must not be null.
        text - The text to put in place of the deleted range. It must not be null.
        See Also:
        replaceText(int, int, String)
      • replace

        default void replace​(javafx.scene.control.IndexRange range,
                             SEG seg,
                             S style)
        Replaces a range of characters with the given seg.
        Parameters:
        range - The range to replace. It must not be null.
        seg - The segment to put in place of the deleted range. It must not be null.
        See Also:
        replace(int, int, Object, Object)
      • replace

        default void replace​(javafx.scene.control.IndexRange range,
                             StyledDocument<PS,​SEG,​S> replacement)
        Equivalent to replace(range.getStart(), range.getEnd(), replacement).
      • getAbsolutePosition

        int getAbsolutePosition​(int paragraphIndex,
                                int columnIndex)
        Returns the absolute position (i.e. the spot in-between characters) to the left of the given column in the given paragraph.

        For example, given a text with only one line "text" and the columnIndex value of 1, "position 1" would be returned:

          ┌ character index 0
          | ┌ character index 1
          | |   ┌ character index 3
          | |   |
          v v   v
        
         |t|e|x|t|
        
         ^ ^     ^
         | |     |
         | |     â”” position 4
         | â”” position 1
         â”” position 0
         

        Warning: Off-By-One errors can easily occur

        If the column index spans outside of the given paragraph's length, the returned value will pass on to the previous/next paragraph. In other words, given a document with two paragraphs (where the first paragraph's text is "some" and the second "thing"), then the following statements are true:

        • getAbsolutePosition(0, "some".length()) == 4 == getAbsolutePosition(1, -1)
        • getAbsolutePosition(0, "some".length() + 1) == 5 == getAbsolutePosition(1, 0)
        Parameters:
        paragraphIndex - The index of the paragraph from which to start.
        columnIndex - If positive, the index going forward (the given paragraph's line or the next one(s)). If negative, the index going backward (the previous paragraph's line(s)
      • dispose

        void dispose()
        Disposes this area, preventing memory leaks.