Interface CaretSelectionBind<PS,SEG,S>
-
- Type Parameters:
PS- type forStyledDocument's paragraph style; only necessary when using the "selectedDocument" getter or propertySEG- type forStyledDocument's segment type; only necessary when using the "selectedDocument" getter or propertyS- type forStyledDocument's segment style; only necessary when using the "selectedDocument" getter or property
public interface CaretSelectionBind<PS,SEG,S> extends Selection<PS,SEG,S>, Caret
An object for encapsulating a caret and a selection in a given area where the caret and selection are bound to one another. In other words, selecting some range in the area (viaselectRangeExpl(int, int),selectRange(int, int, int, int)) will move the caret in the same call, except if one usesdisplaceSelection(int, int). Updating the selection via any method with an "update" prefix fromSelectionwill also move the caret if it has beendisplacedor the anchor is not the boundary (i.e. the selection's the start or end position) that is being updated. Likewise, moving the caret via the "move" prefix methods fromCaretwill clear the selection in the same call, except if one usesdisplaceCaret(int)."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:-
Selection.getStartPosition()/Selection.getEndPosition(), which refers to a position somewhere in the entire area's content. It's bounds are0 <= x <= area.getLength(). -
Selection.getStartColumnPosition()/Selection.getEndColumnPosition(), which refers to a position somewhere in the current paragraph. It's bounds are0 <= x <= area.getParagraphLength(index).
The selection is typically made using the
anchor's positionand the underlyingcaret's position. Hence,selectRangeExpl(int, int)is the typical method to use, althoughselectRange(int, int)can also be used.For type safety,
Selection.getSelectedDocument()requires the same generic types fromStyledDocument. This means that one must write a lot of boilerplate for the generics:CaretSelectionBind<Collection<String>, StyledText<Collection<String>>, Collection<String>> selection. However, this is only necessary if one is usingSelection.getSelectedDocument()orSelection.selectedDocumentProperty(). If you are not going to use the "selectedDocument" getter or property, then just write the much simplerCaretSelectionBind<?, ?, ?> selection.
-
-
Property Summary
Properties Type Property Description ObservableValue<Integer>anchorColPositionObservableValue<Integer>anchorParIndexObservableValue<Integer>anchorPosition-
Properties inherited from interface org.fxmisc.richtext.Caret
beingUpdated, blinkRate, caretBounds, columnPosition, lineIndex, paragraphIndex, position, showCaret, visible
-
Properties inherited from interface org.fxmisc.richtext.Selection
beingUpdated, endColumnPosition, endParagraphIndex, endPosition, length, paragraphSpan, range, selectedDocument, selectedText, selectionBounds, startColumnPosition, startParagraphIndex, startPosition
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.fxmisc.richtext.Caret
Caret.CaretVisibility
-
Nested classes/interfaces inherited from interface org.fxmisc.richtext.Selection
Selection.Direction
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description ObservableValue<Integer>anchorColPositionProperty()ObservableValue<Integer>anchorParIndexProperty()ObservableValue<Integer>anchorPositionProperty()voiddeselect()Clears the selection while keeping the caret position the same.voiddisplaceCaret(int position)Displaces the caret from the selection by positioning only the caret to the new location without also affecting the selection'sgetAnchorPosition()anchor} or theSelection.getRange()selection}.voiddisplaceSelection(int startPosition, int endPosition)Displaces the caret from the selection by positioning only the selection to the new location without also affecting thecaret's position.intgetAnchorColPosition()Gets the value of the property anchorColPosition.intgetAnchorParIndex()Gets the value of the property anchorParIndex.intgetAnchorPosition()Gets the value of the property anchorPosition.CaretNodegetUnderlyingCaret()Selection<PS,SEG,S>getUnderlyingSelection()voidmoveBreaksBackwards(int numOfBreaks, BreakIterator breakIterator)Moves the caret backwards by the number of breaks and clears any selectionvoidmoveBreaksForwards(int numOfBreaks, BreakIterator breakIterator)Moves the caret forwards by the number of breaks and clears any selectiondefault voidmoveTo(int position)Moves the caret to the given position in the text and clears any selection.default voidmoveTo(int paragraphIndex, int columnPosition)Moves the caret to the position returned fromTextEditingArea.getAbsolutePosition(int, int)and clears any selection.voidmoveTo(int paragraphIndex, int columnIndex, NavigationActions.SelectionPolicy selectionPolicy)Moves the caret to the position returned fromTextEditingArea.getAbsolutePosition(int, int).default voidmoveTo(int pos, NavigationActions.SelectionPolicy selectionPolicy)Moves the caret to the position indicated bypos.default voidmoveToAreaEnd()Moves the caret to the end of the area and clears any selectionvoidmoveToAreaEnd(NavigationActions.SelectionPolicy selectionPolicy)default voidmoveToAreaStart()Moves the caret to the beginning of the area and clears any selectionvoidmoveToAreaStart(NavigationActions.SelectionPolicy selectionPolicy)default voidmoveToNextChar()Moves the caret forward one char in the text and clears any selectionvoidmoveToNextChar(NavigationActions.SelectionPolicy selectionPolicy)Moves the caret forward one char in the text.default voidmoveToParEnd()Moves the caret to the end of the current paragraph and clears any selectionvoidmoveToParEnd(NavigationActions.SelectionPolicy selectionPolicy)default voidmoveToParStart()Moves the caret to the beginning of the current paragraph and clears any selectionvoidmoveToParStart(NavigationActions.SelectionPolicy selectionPolicy)default voidmoveToPrevChar()Moves the caret backward one char in the text and clears any selectionvoidmoveToPrevChar(NavigationActions.SelectionPolicy selectionPolicy)Moves the caret backward one char in the text.voidselectAll()Selects everything in the area and moves the caret to either the start of the new selection if the anchor was equal to the original start or the end if the anchor was equal to the original enddefault voidselectParagraph()voidselectParagraph(int paragraphIndex)Selects the given paragraph and moves the caret to either the start of the new selection if the anchor was equal to the original start or the end if the anchor was equal to the original endvoidselectRange(int startPosition, int endPosition)Selects the given range and moves the caret to either the start of the new selection if the anchor was equal to the original start or the end if the anchor was equal to the original endvoidselectRange(int startParagraphIndex, int startColPosition, int endParagraphIndex, int endColPosition)Selects the given range and moves the caret to either the start of the new selection if the anchor was equal to the original start or the end if the anchor was equal to the original endvoidselectRangeExpl(int anchorPosition, int caretPosition)Positions the anchor and caretPosition explicitly, effectively creating a selection.voidselectRangeExpl(int anchorParagraph, int anchorColumn, int caretParagraph, int caretColumn)Positions the anchor and caretPosition explicitly, effectively creating a selection.default voidselectWord()Selects the word closest to the caretvoidselectWord(int wordPositionInArea)Selects the closest word to the given position in the area and moves the caret to either the start of the new selection if the anchor was equal to the original start or the end if the anchor was equal to the original endvoidupdateEndBy(int amount, Selection.Direction direction)voidupdateEndByBreaksBackward(int numOfBreaks, BreakIterator breakIterator)voidupdateEndByBreaksForward(int numOfBreaks, BreakIterator breakIterator)voidupdateEndTo(int position)voidupdateEndTo(int paragraphIndex, int columnPosition)voidupdateStartBy(int amount, Selection.Direction direction)voidupdateStartByBreaksBackward(int numOfBreaks, BreakIterator breakIterator)voidupdateStartByBreaksForward(int numOfBreaks, BreakIterator breakIterator)voidupdateStartTo(int position)voidupdateStartTo(int paragraphIndex, int columnPosition)-
Methods inherited from interface org.fxmisc.richtext.Caret
beingUpdatedProperty, blinkRateProperty, caretBoundsProperty, clearTargetOffset, columnPositionProperty, dispose, getArea, getBlinkRate, getCaretBounds, getCaretName, getColumnPosition, getLineIndex, getParagraphIndex, getPosition, getShowCaret, getTargetOffset, isBeingUpdated, isVisible, lineIndexProperty, moveSentenceBreaksBackwards, moveSentenceBreaksForwards, moveWordBreaksBackwards, moveWordBreaksForwards, paragraphIndexProperty, positionProperty, setBlinkRate, setShowCaret, showCaretProperty, visibleProperty
-
Methods inherited from interface org.fxmisc.richtext.Selection
beingUpdatedProperty, configureSelectionPath, dispose, endColumnPositionProperty, endParagraphIndexProperty, endPositionProperty, getArea, getEndColumnPosition, getEndParagraphIndex, getEndPosition, getLength, getParagraphSpan, getRange, getSelectedDocument, getSelectedText, getSelectionBounds, getSelectionName, getStartColumnPosition, getStartParagraphIndex, getStartPosition, isBeingUpdated, lengthProperty, paragraphSpanProperty, rangeProperty, selectedDocumentProperty, selectedTextProperty, selectionBoundsProperty, startColumnPositionProperty, startParagraphIndexProperty, startPositionProperty
-
-
-
-
Property Detail
-
anchorPosition
ObservableValue<Integer> anchorPositionProperty
- See Also:
getAnchorPosition()
-
anchorParIndex
ObservableValue<Integer> anchorParIndexProperty
- See Also:
getAnchorParIndex()
-
anchorColPosition
ObservableValue<Integer> anchorColPositionProperty
- See Also:
getAnchorColPosition()
-
-
Method Detail
-
getUnderlyingCaret
CaretNode getUnderlyingCaret()
-
getAnchorPosition
int getAnchorPosition()
Gets the value of the property anchorPosition.- Property description:
-
anchorPositionProperty
ObservableValue<Integer> anchorPositionProperty()
- See Also:
getAnchorPosition()
-
getAnchorParIndex
int getAnchorParIndex()
Gets the value of the property anchorParIndex.- Property description:
-
anchorParIndexProperty
ObservableValue<Integer> anchorParIndexProperty()
- See Also:
getAnchorParIndex()
-
getAnchorColPosition
int getAnchorColPosition()
Gets the value of the property anchorColPosition.- Property description:
-
anchorColPositionProperty
ObservableValue<Integer> anchorColPositionProperty()
- See Also:
getAnchorColPosition()
-
moveTo
default void moveTo(int position)
Moves the caret to the given position in the text and clears any selection.
-
moveTo
default void moveTo(int paragraphIndex, int columnPosition)Moves the caret to the position returned fromTextEditingArea.getAbsolutePosition(int, int)and clears any selection.
-
moveToParStart
default void moveToParStart()
Moves the caret to the beginning of the current paragraph and clears any selection- Specified by:
moveToParStartin interfaceCaret
-
moveToParEnd
default void moveToParEnd()
Moves the caret to the end of the current paragraph and clears any selection- Specified by:
moveToParEndin interfaceCaret
-
moveToAreaStart
default void moveToAreaStart()
Moves the caret to the beginning of the area and clears any selection- Specified by:
moveToAreaStartin interfaceCaret
-
moveToAreaEnd
default void moveToAreaEnd()
Moves the caret to the end of the area and clears any selection- Specified by:
moveToAreaEndin interfaceCaret
-
moveToPrevChar
default void moveToPrevChar()
Moves the caret backward one char in the text and clears any selection- Specified by:
moveToPrevCharin interfaceCaret
-
moveToNextChar
default void moveToNextChar()
Moves the caret forward one char in the text and clears any selection- Specified by:
moveToNextCharin interfaceCaret
-
moveBreaksForwards
void moveBreaksForwards(int numOfBreaks, BreakIterator breakIterator)Moves the caret forwards by the number of breaks and clears any selection- Specified by:
moveBreaksForwardsin interfaceCaret
-
moveBreaksBackwards
void moveBreaksBackwards(int numOfBreaks, BreakIterator breakIterator)Moves the caret backwards by the number of breaks and clears any selection- Specified by:
moveBreaksBackwardsin interfaceCaret
-
selectRange
void selectRange(int startParagraphIndex, int startColPosition, int endParagraphIndex, int endColPosition)Selects the given range and moves the caret to either the start of the new selection if the anchor was equal to the original start or the end if the anchor was equal to the original endCaution: see
TextEditingArea.getAbsolutePosition(int, int)to know how the column index argument can affect the returned position.- Specified by:
selectRangein interfaceSelection<PS,SEG,S>
-
selectRange
void selectRange(int startPosition, int endPosition)Selects the given range and moves the caret to either the start of the new selection if the anchor was equal to the original start or the end if the anchor was equal to the original end- Specified by:
selectRangein interfaceSelection<PS,SEG,S>
-
updateStartBy
void updateStartBy(int amount, Selection.Direction direction)- Specified by:
updateStartByin interfaceSelection<PS,SEG,S>
-
updateEndBy
void updateEndBy(int amount, Selection.Direction direction)- Specified by:
updateEndByin interfaceSelection<PS,SEG,S>
-
updateStartTo
void updateStartTo(int position)
- Specified by:
updateStartToin interfaceSelection<PS,SEG,S>
-
updateStartTo
void updateStartTo(int paragraphIndex, int columnPosition)- Specified by:
updateStartToin interfaceSelection<PS,SEG,S>
-
updateStartByBreaksForward
void updateStartByBreaksForward(int numOfBreaks, BreakIterator breakIterator)- Specified by:
updateStartByBreaksForwardin interfaceSelection<PS,SEG,S>
-
updateStartByBreaksBackward
void updateStartByBreaksBackward(int numOfBreaks, BreakIterator breakIterator)- Specified by:
updateStartByBreaksBackwardin interfaceSelection<PS,SEG,S>
-
updateEndTo
void updateEndTo(int position)
- Specified by:
updateEndToin interfaceSelection<PS,SEG,S>
-
updateEndTo
void updateEndTo(int paragraphIndex, int columnPosition)- Specified by:
updateEndToin interfaceSelection<PS,SEG,S>
-
updateEndByBreaksForward
void updateEndByBreaksForward(int numOfBreaks, BreakIterator breakIterator)- Specified by:
updateEndByBreaksForwardin interfaceSelection<PS,SEG,S>
-
updateEndByBreaksBackward
void updateEndByBreaksBackward(int numOfBreaks, BreakIterator breakIterator)- Specified by:
updateEndByBreaksBackwardin interfaceSelection<PS,SEG,S>
-
selectAll
void selectAll()
Selects everything in the area and moves the caret to either the start of the new selection if the anchor was equal to the original start or the end if the anchor was equal to the original end
-
selectParagraph
void selectParagraph(int paragraphIndex)
Selects the given paragraph and moves the caret to either the start of the new selection if the anchor was equal to the original start or the end if the anchor was equal to the original end- Specified by:
selectParagraphin interfaceSelection<PS,SEG,S>
-
selectWord
void selectWord(int wordPositionInArea)
Selects the closest word to the given position in the area and moves the caret to either the start of the new selection if the anchor was equal to the original start or the end if the anchor was equal to the original end- Specified by:
selectWordin interfaceSelection<PS,SEG,S>
-
deselect
void deselect()
Clears the selection while keeping the caret position the same.
-
selectRangeExpl
void selectRangeExpl(int anchorParagraph, int anchorColumn, int caretParagraph, int caretColumn)Positions the anchor and caretPosition explicitly, effectively creating a selection.
-
selectRangeExpl
void selectRangeExpl(int anchorPosition, int caretPosition)Positions the anchor and caretPosition explicitly, effectively creating a selection.
-
moveTo
default void moveTo(int pos, NavigationActions.SelectionPolicy selectionPolicy)Moves the caret to the position indicated bypos. Based on the selection policy, the selection is either cleared (i.e. anchor is set to the same position as caret), adjusted (i.e. anchor is not moved at all), or extended (i.e.posbecomes the new caret and, ifpospoints outside the current selection, the far end of the current selection becomes the anchor.
-
moveTo
void moveTo(int paragraphIndex, int columnIndex, NavigationActions.SelectionPolicy selectionPolicy)Moves the caret to the position returned fromTextEditingArea.getAbsolutePosition(int, int).
-
moveToPrevChar
void moveToPrevChar(NavigationActions.SelectionPolicy selectionPolicy)
Moves the caret backward one char in the text. Based on the given selection policy, anchor either moves with the caret, stays put, or moves to the former caret position.
-
moveToNextChar
void moveToNextChar(NavigationActions.SelectionPolicy selectionPolicy)
Moves the caret forward one char in the text. Based on the given selection policy, anchor either moves with the caret, stays put, or moves to the former caret position.
-
moveToParStart
void moveToParStart(NavigationActions.SelectionPolicy selectionPolicy)
-
moveToParEnd
void moveToParEnd(NavigationActions.SelectionPolicy selectionPolicy)
-
moveToAreaStart
void moveToAreaStart(NavigationActions.SelectionPolicy selectionPolicy)
-
moveToAreaEnd
void moveToAreaEnd(NavigationActions.SelectionPolicy selectionPolicy)
-
selectParagraph
default void selectParagraph()
-
selectWord
default void selectWord()
Selects the word closest to the caret
-
displaceCaret
void displaceCaret(int position)
Displaces the caret from the selection by positioning only the caret to the new location without also affecting the selection'sgetAnchorPosition()anchor} or theSelection.getRange()selection}. Do not confuse this method withmoveTo(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.
-
displaceSelection
void displaceSelection(int startPosition, int endPosition)Displaces the caret from the selection by positioning only the selection to the new location without also affecting thecaret's position. This method can be used to achieve the special case of selecting some range in the area without affecting the caret's position. Use with care.
-
-