Package org.fxmisc.richtext
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:-
getPosition()
, which refers to a position somewhere in the entire area's content. It's bounds are0 <= x <= area.getLength()
. -
getColumnPosition()
, which refers to a position somewhere in the current paragraph. It's bounds are0 <= x <= area.getParagraphLength(index)
.
"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 ObservableValue<Boolean>
beingUpdated
ObservableValue<Duration>
blinkRate
ObservableValue<Optional<Bounds>>
caretBounds
The selectionBoundsProperty of the caret in the Screen's coordinate system orOptional.empty()
if caret is not visible in the viewport.ObservableValue<Integer>
columnPosition
The column position of the caret on its given lineObservableValue<OptionalInt>
lineIndex
The line index of a multi-line paragraph that contains this caretObservableValue<Integer>
paragraphIndex
The paragraph index that contains this caretObservableValue<Integer>
position
The position of the caret within the textVar<Caret.CaretVisibility>
showCaret
Whether to display the caret or not.ObservableValue<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 ObservableValue<Boolean>
beingUpdatedProperty()
ObservableValue<Duration>
blinkRateProperty()
ObservableValue<Optional<Bounds>>
caretBoundsProperty()
The selectionBoundsProperty of the caret in the Screen's coordinate system orOptional.empty()
if caret is not visible in the viewport.void
clearTargetOffset()
Clears the caret's x offsetObservableValue<Integer>
columnPositionProperty()
The column position of the caret on its given linevoid
dispose()
Disposes the caret and prevents memory leaksGenericStyledArea<?,?,?>
getArea()
Gets the area with which this caret is associated.Duration
getBlinkRate()
Gets the value of the property blinkRate.Optional<Bounds>
getCaretBounds()
Gets the value of the property caretBounds.String
getCaretName()
Gets the name of this caret.int
getColumnPosition()
Gets the value of the property columnPosition.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()
ObservableValue<OptionalInt>
lineIndexProperty()
The line index of a multi-line paragraph that contains this caretvoid
moveBreaksBackwards(int numOfBreaks, BreakIterator breakIterator)
Moves the caret backwards by the number of breaks.void
moveBreaksForwards(int numOfBreaks, 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)
ObservableValue<Integer>
paragraphIndexProperty()
The paragraph index that contains this caretObservableValue<Integer>
positionProperty()
The position of the caret within the textvoid
setBlinkRate(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.ObservableValue<Boolean>
visibleProperty()
Whether the caret is being shown in the viewport
-
-
-
Property Detail
-
position
ObservableValue<Integer> positionProperty
The position of the caret within the text- See Also:
getPosition()
-
paragraphIndex
ObservableValue<Integer> paragraphIndexProperty
The paragraph index that contains this caret- See Also:
getParagraphIndex()
-
lineIndex
ObservableValue<OptionalInt> lineIndexProperty
The line index of a multi-line paragraph that contains this caret- See Also:
getLineIndex()
-
columnPosition
ObservableValue<Integer> columnPositionProperty
The column position of the caret on its given line- See Also:
getColumnPosition()
-
showCaret
Var<Caret.CaretVisibility> showCaretProperty
Whether to display the caret or not. Default value isCaret.CaretVisibility.AUTO
.
-
visible
ObservableValue<Boolean> visibleProperty
Whether the caret is being shown in the viewport
-
blinkRate
ObservableValue<Duration> blinkRateProperty
- See Also:
getBlinkRate()
,setBlinkRate(Duration)
-
caretBounds
ObservableValue<Optional<Bounds>> caretBoundsProperty
The selectionBoundsProperty of the caret in the Screen's coordinate system orOptional.empty()
if caret is not visible in the viewport.- See Also:
getCaretBounds()
-
beingUpdated
ObservableValue<Boolean> beingUpdatedProperty
-
-
Method Detail
-
positionProperty
ObservableValue<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
ObservableValue<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
ObservableValue<OptionalInt> lineIndexProperty()
The line index of a multi-line paragraph that contains this caret- See Also:
getLineIndex()
-
getLineIndex
OptionalInt getLineIndex()
Gets the value of the property lineIndex.- Property description:
- The line index of a multi-line paragraph that contains this caret
-
columnPositionProperty
ObservableValue<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
-
showCaretProperty
Var<Caret.CaretVisibility> showCaretProperty()
Whether to display the caret or not. Default value isCaret.CaretVisibility.AUTO
.
-
getShowCaret
Caret.CaretVisibility getShowCaret()
Gets the value of the property showCaret.- Property description:
- Whether to display the caret or not. Default value is
Caret.CaretVisibility.AUTO
.
-
setShowCaret
void setShowCaret(Caret.CaretVisibility value)
Sets the value of the property showCaret.- Property description:
- Whether to display the caret or not. Default value is
Caret.CaretVisibility.AUTO
.
-
visibleProperty
ObservableValue<Boolean> visibleProperty()
Whether the caret is being shown in the viewport
-
isVisible
boolean isVisible()
-
blinkRateProperty
ObservableValue<Duration> blinkRateProperty()
- See Also:
getBlinkRate()
,setBlinkRate(Duration)
-
getBlinkRate
Duration getBlinkRate()
Gets the value of the property blinkRate.- Property description:
-
setBlinkRate
void setBlinkRate(Duration blinkRate)
Sets the value of the property blinkRate.- Property description:
-
caretBoundsProperty
ObservableValue<Optional<Bounds>> caretBoundsProperty()
The selectionBoundsProperty of the caret in the Screen's coordinate system orOptional.empty()
if caret is not visible in the viewport.- See Also:
getCaretBounds()
-
getCaretBounds
Optional<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
ObservableValue<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 aCaretSelectionBind
, it displaces the caret from the selection by positioning only the caret to the new location without also affecting theCaretSelectionBind.getAnchorPosition()
bounded selection's anchor} or theSelection.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 aCaretSelectionBind
, it displaces the caret from the selection by positioning only the caret to the new location without also affecting theCaretSelectionBind.getAnchorPosition()
bounded selection's anchor} or theSelection.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, 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, 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
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.
-
-