Interface Caret

  • All Known Subinterfaces:
    CaretSelectionBind<PS,​SEG,​S>
    All Known Implementing Classes:
    CaretNode

    public interface Caret
    An object for encapsulating a caret in a given area.

    "Position" refers to the place in-between characters. In other words, every "|" in "|t|e|x|t|" is a valid position. There are two kinds of positions used here:

    1. getPosition(), which refers to a position somewhere in the entire area's content. It's bounds are 0 <= x <= area.getLength().
    2. getColumnPosition(), which refers to a position somewhere in the current paragraph. It's bounds are 0 <= x <= area.getParagraphLength(index).
    Note: when parameter names are "position" without the "column" prefix, they refer to the position in the entire area.

    "Line" refers either to a single paragraph when the area does not wrap its text or to a line on a multi-line paragraph when the area does wrap its text.

    • Property Summary

      Properties 
      Type Property Description
      javafx.beans.value.ObservableValue<java.lang.Boolean> beingUpdated  
      javafx.beans.value.ObservableValue<javafx.util.Duration> blinkRate  
      javafx.beans.value.ObservableValue<java.util.Optional<javafx.geometry.Bounds>> caretBounds
      The selectionBoundsProperty of the caret in the Screen's coordinate system or Optional.empty() if caret is not visible in the viewport.
      javafx.beans.value.ObservableValue<java.lang.Integer> columnPosition
      The column position of the caret on its given line
      javafx.beans.value.ObservableValue<java.util.OptionalInt> lineIndex
      The line index of a multi-line paragraph that contains this caret
      javafx.beans.value.ObservableValue<java.lang.Integer> paragraphIndex
      The paragraph index that contains this caret
      javafx.beans.value.ObservableValue<java.lang.Integer> position
      The position of the caret within the text
      Var<Caret.CaretVisibility> showCaret
      Whether to display the caret or not.
      javafx.beans.value.ObservableValue<java.lang.Boolean> visible
      Whether the caret is being shown in the viewport
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Interface Description
      static class  Caret.CaretVisibility
      Determines whether the caret is visible.
    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      javafx.beans.value.ObservableValue<java.lang.Boolean> beingUpdatedProperty()  
      javafx.beans.value.ObservableValue<javafx.util.Duration> blinkRateProperty()  
      javafx.beans.value.ObservableValue<java.util.Optional<javafx.geometry.Bounds>> caretBoundsProperty()
      The selectionBoundsProperty of the caret in the Screen's coordinate system or Optional.empty() if caret is not visible in the viewport.
      void clearTargetOffset()
      Clears the caret's x offset
      javafx.beans.value.ObservableValue<java.lang.Integer> columnPositionProperty()
      The column position of the caret on its given line
      void dispose()
      Disposes the caret and prevents memory leaks
      GenericStyledArea<?,​?,​?> getArea()
      Gets the area with which this caret is associated.
      javafx.util.Duration getBlinkRate()
      Gets the value of the property blinkRate.
      java.util.Optional<javafx.geometry.Bounds> getCaretBounds()
      Gets the value of the property caretBounds.
      java.lang.String getCaretName()
      Gets the name of this caret.
      int getColumnPosition()
      Gets the value of the property columnPosition.
      java.util.OptionalInt getLineIndex()
      Gets the value of the property lineIndex.
      int getParagraphIndex()
      Gets the value of the property paragraphIndex.
      int getPosition()
      Gets the value of the property position.
      Caret.CaretVisibility getShowCaret()
      Gets the value of the property showCaret.
      org.fxmisc.richtext.ParagraphBox.CaretOffsetX getTargetOffset()
      Stores the caret's current column position, so that moving the caret vertically will keep it close to its original offset in a line.
      boolean isBeingUpdated()  
      boolean isVisible()  
      javafx.beans.value.ObservableValue<java.util.OptionalInt> lineIndexProperty()
      The line index of a multi-line paragraph that contains this caret
      void moveBreaksBackwards​(int numOfBreaks, java.text.BreakIterator breakIterator)
      Moves the caret backwards by the number of breaks.
      void moveBreaksForwards​(int numOfBreaks, java.text.BreakIterator breakIterator)
      Moves the caret forwards by the number of breaks.
      default void moveSentenceBreaksBackwards​(int numOfSentenceBreaks)  
      default void moveSentenceBreaksForwards​(int numOfSentenceBreaks)  
      void moveTo​(int position)
      Moves the caret to the given position in the area.
      void moveTo​(int paragraphIndex, int columnPosition)
      Moves the caret to the given position in the area.
      void moveToAreaEnd()
      Moves the caret to the end of the area.
      default void moveToAreaStart()
      Moves the caret to the beginning of the area.
      void moveToNextChar()
      Moves the caret forward one char in the text.
      void moveToParEnd()
      Moves the caret to the end of the current paragraph.
      void moveToParStart()
      Moves the caret to the beginning of the current paragraph.
      void moveToPrevChar()
      Moves the caret backward one char in the text.
      default void moveWordBreaksBackwards​(int numOfWordBreaks)  
      default void moveWordBreaksForwards​(int numOfWordBreaks)  
      javafx.beans.value.ObservableValue<java.lang.Integer> paragraphIndexProperty()
      The paragraph index that contains this caret
      javafx.beans.value.ObservableValue<java.lang.Integer> positionProperty()
      The position of the caret within the text
      void setBlinkRate​(javafx.util.Duration blinkRate)
      Sets the value of the property blinkRate.
      void setShowCaret​(Caret.CaretVisibility value)
      Sets the value of the property showCaret.
      Var<Caret.CaretVisibility> showCaretProperty()
      Whether to display the caret or not.
      javafx.beans.value.ObservableValue<java.lang.Boolean> visibleProperty()
      Whether the caret is being shown in the viewport
    • Property Detail

      • position

        javafx.beans.value.ObservableValue<java.lang.Integer> positionProperty
        The position of the caret within the text
        See Also:
        getPosition()
      • paragraphIndex

        javafx.beans.value.ObservableValue<java.lang.Integer> paragraphIndexProperty
        The paragraph index that contains this caret
        See Also:
        getParagraphIndex()
      • lineIndex

        javafx.beans.value.ObservableValue<java.util.OptionalInt> lineIndexProperty
        The line index of a multi-line paragraph that contains this caret
        See Also:
        getLineIndex()
      • columnPosition

        javafx.beans.value.ObservableValue<java.lang.Integer> columnPositionProperty
        The column position of the caret on its given line
        See Also:
        getColumnPosition()
      • visible

        javafx.beans.value.ObservableValue<java.lang.Boolean> visibleProperty
        Whether the caret is being shown in the viewport
      • caretBounds

        javafx.beans.value.ObservableValue<java.util.Optional<javafx.geometry.Bounds>> caretBoundsProperty
        The selectionBoundsProperty of the caret in the Screen's coordinate system or Optional.empty() if caret is not visible in the viewport.
        See Also:
        getCaretBounds()
      • beingUpdated

        javafx.beans.value.ObservableValue<java.lang.Boolean> beingUpdatedProperty
    • Method Detail

      • positionProperty

        javafx.beans.value.ObservableValue<java.lang.Integer> positionProperty()
        The position of the caret within the text
        See Also:
        getPosition()
      • getPosition

        int getPosition()
        Gets the value of the property position.
        Property description:
        The position of the caret within the text
      • paragraphIndexProperty

        javafx.beans.value.ObservableValue<java.lang.Integer> paragraphIndexProperty()
        The paragraph index that contains this caret
        See Also:
        getParagraphIndex()
      • getParagraphIndex

        int getParagraphIndex()
        Gets the value of the property paragraphIndex.
        Property description:
        The paragraph index that contains this caret
      • lineIndexProperty

        javafx.beans.value.ObservableValue<java.util.OptionalInt> lineIndexProperty()
        The line index of a multi-line paragraph that contains this caret
        See Also:
        getLineIndex()
      • getLineIndex

        java.util.OptionalInt getLineIndex()
        Gets the value of the property lineIndex.
        Property description:
        The line index of a multi-line paragraph that contains this caret
      • columnPositionProperty

        javafx.beans.value.ObservableValue<java.lang.Integer> columnPositionProperty()
        The column position of the caret on its given line
        See Also:
        getColumnPosition()
      • getColumnPosition

        int getColumnPosition()
        Gets the value of the property columnPosition.
        Property description:
        The column position of the caret on its given line
      • visibleProperty

        javafx.beans.value.ObservableValue<java.lang.Boolean> visibleProperty()
        Whether the caret is being shown in the viewport
      • isVisible

        boolean isVisible()
      • getBlinkRate

        javafx.util.Duration getBlinkRate()
        Gets the value of the property blinkRate.
        Property description:
      • setBlinkRate

        void setBlinkRate​(javafx.util.Duration blinkRate)
        Sets the value of the property blinkRate.
        Property description:
      • caretBoundsProperty

        javafx.beans.value.ObservableValue<java.util.Optional<javafx.geometry.Bounds>> caretBoundsProperty()
        The selectionBoundsProperty of the caret in the Screen's coordinate system or Optional.empty() if caret is not visible in the viewport.
        See Also:
        getCaretBounds()
      • getCaretBounds

        java.util.Optional<javafx.geometry.Bounds> getCaretBounds()
        Gets the value of the property caretBounds.
        Property description:
        The selectionBoundsProperty of the caret in the Screen's coordinate system or Optional.empty() if caret is not visible in the viewport.
      • clearTargetOffset

        void clearTargetOffset()
        Clears the caret's x offset
      • getTargetOffset

        org.fxmisc.richtext.ParagraphBox.CaretOffsetX getTargetOffset()
        Stores the caret's current column position, so that moving the caret vertically will keep it close to its original offset in a line.
      • isBeingUpdated

        boolean isBeingUpdated()
      • beingUpdatedProperty

        javafx.beans.value.ObservableValue<java.lang.Boolean> beingUpdatedProperty()
      • moveTo

        void moveTo​(int paragraphIndex,
                    int columnPosition)
        Moves the caret to the given position in the area. If this caret is bound to a CaretSelectionBind, it displaces the caret from the selection by positioning only the caret to the new location without also affecting the CaretSelectionBind.getAnchorPosition() bounded selection's anchor} or the Selection.getRange() selection}.
        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.

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

      • moveTo

        void moveTo​(int position)
        Moves the caret to the given position in the area. If this caret is bound to a CaretSelectionBind, it displaces the caret from the selection by positioning only the caret to the new location without also affecting the CaretSelectionBind.getAnchorPosition() bounded selection's anchor} or the Selection.getRange() selection}.
        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.
      • moveToParStart

        void moveToParStart()
        Moves the caret to the beginning of the current paragraph.
      • moveToParEnd

        void moveToParEnd()
        Moves the caret to the end of the current paragraph.
      • moveToAreaStart

        default void moveToAreaStart()
        Moves the caret to the beginning of the area.
      • moveToAreaEnd

        void moveToAreaEnd()
        Moves the caret to the end of the area.
      • moveToPrevChar

        void moveToPrevChar()
        Moves the caret backward one char in the text.
      • moveToNextChar

        void moveToNextChar()
        Moves the caret forward one char in the text.
      • moveBreaksForwards

        void moveBreaksForwards​(int numOfBreaks,
                                java.text.BreakIterator breakIterator)
        Moves the caret forwards by the number of breaks.
      • moveWordBreaksForwards

        default void moveWordBreaksForwards​(int numOfWordBreaks)
      • moveSentenceBreaksForwards

        default void moveSentenceBreaksForwards​(int numOfSentenceBreaks)
      • moveBreaksBackwards

        void moveBreaksBackwards​(int numOfBreaks,
                                 java.text.BreakIterator breakIterator)
        Moves the caret backwards by the number of breaks.
      • moveWordBreaksBackwards

        default void moveWordBreaksBackwards​(int numOfWordBreaks)
      • moveSentenceBreaksBackwards

        default void moveSentenceBreaksBackwards​(int numOfSentenceBreaks)
      • dispose

        void dispose()
        Disposes the caret and prevents memory leaks
      • getArea

        GenericStyledArea<?,​?,​?> getArea()
        Gets the area with which this caret is associated.
      • getCaretName

        java.lang.String getCaretName()
        Gets the name of this caret. Each caret that is added to an area must have a unique name since it is used to distinguish it from others in a Set.