Package qupath.lib.gui.scripting
Interface EditableText
- All Known Subinterfaces:
ScriptEditorControl<T>
- All Known Implementing Classes:
CodeAreaControl,TextAreaControl
public interface EditableText
Interface for objects that manage editable text, including a caret position and selection.
This is used to define some useful scripting functionality independently of any particular user interface.
- Since:
- v0.4.0
- Author:
- Pete Bankhead
-
Method Summary
Modifier and TypeMethodDescriptionvoidappendText(String text) Append the specified text.voidclear()Request clear the contents of the control.voiddeleteText(int startIdx, int endIdx) Request deleting the text within the specified range.default voiddeselect()Deselect any currently-selected text.intGet the current caret position.Get the selected text as a string.intGet the ending position for any selection (exclusive).default intGet the selection length, or 0 if there is no selection.intGet the starting position for any selection (inclusive).getText()Get all the text in the editor;voidinsertText(int pos, String text) Request inserting the specified text.voidpositionCaret(int index) Set the caret position to the specified indexvoidreplaceSelection(String text) Insert the specified text, replacing any existing selection.voidselectRange(int startIdx, int endIdx) Set the range of the selected text.voidSet all the text in the editor.
-
Method Details
-
setText
Set all the text in the editor.- Parameters:
text-
-
getText
String getText()Get all the text in the editor;- Returns:
-
appendText
Append the specified text.- Parameters:
text- the text to be appended
-
replaceSelection
Insert the specified text, replacing any existing selection.- Parameters:
text- the text to insert
-
clear
void clear()Request clear the contents of the control. -
getCaretPosition
int getCaretPosition()Get the current caret position.- Returns:
-
insertText
Request inserting the specified text.- Parameters:
pos- position to insert the texttext- the text to insert
-
deleteText
void deleteText(int startIdx, int endIdx) Request deleting the text within the specified range.- Parameters:
startIdx-endIdx-
-
positionCaret
void positionCaret(int index) Set the caret position to the specified index- Parameters:
index-
-
deselect
default void deselect()Deselect any currently-selected text. -
getSelectedText
String getSelectedText()Get the selected text as a string.- Returns:
-
selectRange
void selectRange(int startIdx, int endIdx) Set the range of the selected text.- Parameters:
startIdx-endIdx-
-
getSelectionStart
int getSelectionStart()Get the starting position for any selection (inclusive).- Returns:
-
getSelectionEnd
int getSelectionEnd()Get the ending position for any selection (exclusive). If this is equal to or less thangetSelectionStart()this means there is no selection.- Returns:
-
getSelectionLength
default int getSelectionLength()Get the selection length, or 0 if there is no selection.- Returns:
-