Class CodeAreaControl
java.lang.Object
qupath.lib.gui.scripting.richtextfx.CodeAreaControl
- All Implemented Interfaces:
TextAppendable,EditableText,ScriptEditorControl<org.fxmisc.flowless.VirtualizedScrollPane<org.fxmisc.richtext.CodeArea>>
public class CodeAreaControl
extends Object
implements ScriptEditorControl<org.fxmisc.flowless.VirtualizedScrollPane<org.fxmisc.richtext.CodeArea>>
Code area control using RichTextFX.
-
Property Summary
PropertiesTypePropertyDescriptionProperty for the current caret position.Text currently selected in the editor control.Text currently in the editor control.Request wordwrap. -
Method Summary
Modifier and TypeMethodDescriptionvoidappendText(String text) Append the specified text to the appendable.Property for the current caret position.voidclear()Request clear the contents of the control.voidcopy()Request copy the current selection.static CodeAreaControlCreate an editable control for writing code.static CodeAreaControlCreate a non-editable control for showing log messages.voidcut()Request cut the current selection.voiddeleteText(int startIdx, int endIdx) Request deleting the text within the specified range.voiddeselect()Deselect any currently-selected text.intGets the value of thecaretPositionproperty.Get the context menu for the control.Get any language stored for text to be displayed by this control.org.fxmisc.flowless.VirtualizedScrollPane<org.fxmisc.richtext.CodeArea> Get the region representing this control, so it may be added to a scene.Gets the value of theselectedTextproperty.Get the range of the currently-selected text.booleanCheck whether smart editing is requested.getText()Gets the value of thetextproperty.voidinsertText(int pos, String text) Request inserting the specified text.booleanReturns true if 'redo' can be applied to the control.booleanReturns true if 'undo' can be applied to the control.voidpaste()Request paste from the system clipboard.voidpositionCaret(int index) Set the caret position to the specified indexvoidredo()Request redo.voidreplaceSelection(String text) Insert the specified text, replacing any existing selection.voidRequest that the control is focused.voidRequest that the X and Y scrolls are adjusted to ensure the caret is visible.Text currently selected in the editor control.voidselectRange(int startIdx, int endIdx) Set the range of the selected text.voidsetContextMenu(ContextMenu menu) Set the context menu for the control.voidsetLanguage(ScriptLanguage language) Set the language for text to be displayed by this control.voidsetSmartEditing(boolean smartEditing) Request smart editing, e.g.voidSets the value of thetextproperty.Text currently in the editor control.voidundo()Request undo.Request wordwrap.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface qupath.lib.gui.scripting.EditableText
getSelectionLengthMethods inherited from interface qupath.lib.gui.scripting.ScriptEditorControl
getSelectionEnd, getSelectionStart
-
Property Details
-
text
- Specified by:
textPropertyin interfaceScriptEditorControl<org.fxmisc.flowless.VirtualizedScrollPane<org.fxmisc.richtext.CodeArea>>- Returns:
- See Also:
-
selectedText
- Specified by:
selectedTextPropertyin interfaceScriptEditorControl<org.fxmisc.flowless.VirtualizedScrollPane<org.fxmisc.richtext.CodeArea>>- Returns:
- See Also:
-
wrapText
- Specified by:
wrapTextPropertyin interfaceScriptEditorControl<org.fxmisc.flowless.VirtualizedScrollPane<org.fxmisc.richtext.CodeArea>>- Returns:
- See Also:
-
caretPosition
- Specified by:
caretPositionPropertyin interfaceScriptEditorControl<org.fxmisc.flowless.VirtualizedScrollPane<org.fxmisc.richtext.CodeArea>>- Returns:
- See Also:
-
-
Method Details
-
createCodeEditor
Create an editable control for writing code.- Returns:
-
createLog
Create a non-editable control for showing log messages.- Returns:
-
textProperty
Description copied from interface:ScriptEditorControlText currently in the editor control.- Specified by:
textPropertyin interfaceScriptEditorControl<org.fxmisc.flowless.VirtualizedScrollPane<org.fxmisc.richtext.CodeArea>>- Returns:
- the
textproperty - See Also:
-
setText
Sets the value of thetextproperty.- Specified by:
setTextin interfaceEditableText- Property description:
- Parameters:
text- the value for thetextproperty- See Also:
-
getText
Gets the value of thetextproperty.- Specified by:
getTextin interfaceEditableText- Property description:
- Returns:
- the value of the
textproperty - See Also:
-
selectedTextProperty
Description copied from interface:ScriptEditorControlText currently selected in the editor control.- Specified by:
selectedTextPropertyin interfaceScriptEditorControl<org.fxmisc.flowless.VirtualizedScrollPane<org.fxmisc.richtext.CodeArea>>- Returns:
- the
selectedTextproperty - See Also:
-
getSelectedText
Gets the value of theselectedTextproperty.- Specified by:
getSelectedTextin interfaceEditableText- Property description:
- Returns:
- the value of the
selectedTextproperty - See Also:
-
getRegion
public org.fxmisc.flowless.VirtualizedScrollPane<org.fxmisc.richtext.CodeArea> getRegion()Description copied from interface:ScriptEditorControlGet the region representing this control, so it may be added to a scene.- Specified by:
getRegionin interfaceScriptEditorControl<org.fxmisc.flowless.VirtualizedScrollPane<org.fxmisc.richtext.CodeArea>>- Returns:
-
isUndoable
public boolean isUndoable()Description copied from interface:ScriptEditorControlReturns true if 'undo' can be applied to the control.- Specified by:
isUndoablein interfaceScriptEditorControl<org.fxmisc.flowless.VirtualizedScrollPane<org.fxmisc.richtext.CodeArea>>- Returns:
-
isRedoable
public boolean isRedoable()Description copied from interface:ScriptEditorControlReturns true if 'redo' can be applied to the control.- Specified by:
isRedoablein interfaceScriptEditorControl<org.fxmisc.flowless.VirtualizedScrollPane<org.fxmisc.richtext.CodeArea>>- Returns:
-
undo
public void undo()Description copied from interface:ScriptEditorControlRequest undo.- Specified by:
undoin interfaceScriptEditorControl<org.fxmisc.flowless.VirtualizedScrollPane<org.fxmisc.richtext.CodeArea>>
-
redo
public void redo()Description copied from interface:ScriptEditorControlRequest redo.- Specified by:
redoin interfaceScriptEditorControl<org.fxmisc.flowless.VirtualizedScrollPane<org.fxmisc.richtext.CodeArea>>
-
copy
public void copy()Description copied from interface:ScriptEditorControlRequest copy the current selection.- Specified by:
copyin interfaceScriptEditorControl<org.fxmisc.flowless.VirtualizedScrollPane<org.fxmisc.richtext.CodeArea>>
-
cut
public void cut()Description copied from interface:ScriptEditorControlRequest cut the current selection.- Specified by:
cutin interfaceScriptEditorControl<org.fxmisc.flowless.VirtualizedScrollPane<org.fxmisc.richtext.CodeArea>>
-
paste
public void paste()Description copied from interface:ScriptEditorControlRequest paste from the system clipboard.- Specified by:
pastein interfaceScriptEditorControl<org.fxmisc.flowless.VirtualizedScrollPane<org.fxmisc.richtext.CodeArea>>
-
appendText
Description copied from interface:TextAppendableAppend the specified text to the appendable.- Specified by:
appendTextin interfaceEditableText- Specified by:
appendTextin interfaceTextAppendable- Parameters:
text- the text to be appended
-
clear
public void clear()Description copied from interface:EditableTextRequest clear the contents of the control.- Specified by:
clearin interfaceEditableText
-
getCaretPosition
public int getCaretPosition()Gets the value of thecaretPositionproperty.- Specified by:
getCaretPositionin interfaceEditableText- Property description:
- Returns:
- the value of the
caretPositionproperty - See Also:
-
insertText
Description copied from interface:EditableTextRequest inserting the specified text.- Specified by:
insertTextin interfaceEditableText- Parameters:
pos- position to insert the texttext- the text to insert
-
deleteText
public void deleteText(int startIdx, int endIdx) Description copied from interface:EditableTextRequest deleting the text within the specified range.- Specified by:
deleteTextin interfaceEditableText- Parameters:
startIdx-endIdx-
-
deselect
public void deselect()Description copied from interface:EditableTextDeselect any currently-selected text.- Specified by:
deselectin interfaceEditableText
-
getSelection
Description copied from interface:ScriptEditorControlGet the range of the currently-selected text.- Specified by:
getSelectionin interfaceScriptEditorControl<org.fxmisc.flowless.VirtualizedScrollPane<org.fxmisc.richtext.CodeArea>>- Returns:
-
selectRange
public void selectRange(int startIdx, int endIdx) Description copied from interface:EditableTextSet the range of the selected text.- Specified by:
selectRangein interfaceEditableText- Parameters:
startIdx-endIdx-
-
wrapTextProperty
Description copied from interface:ScriptEditorControlRequest wordwrap.- Specified by:
wrapTextPropertyin interfaceScriptEditorControl<org.fxmisc.flowless.VirtualizedScrollPane<org.fxmisc.richtext.CodeArea>>- Returns:
- the
wrapTextproperty
-
positionCaret
public void positionCaret(int index) Description copied from interface:EditableTextSet the caret position to the specified index- Specified by:
positionCaretin interfaceEditableText- Parameters:
index-
-
requestFollowCaret
public void requestFollowCaret()Description copied from interface:ScriptEditorControlRequest that the X and Y scrolls are adjusted to ensure the caret is visible.This method does nothing by default. This means that a class extending this interface must specifically implement this method if a different behavior is expected.
- Specified by:
requestFollowCaretin interfaceScriptEditorControl<org.fxmisc.flowless.VirtualizedScrollPane<org.fxmisc.richtext.CodeArea>>
-
replaceSelection
Description copied from interface:EditableTextInsert the specified text, replacing any existing selection.- Specified by:
replaceSelectionin interfaceEditableText- Parameters:
text- the text to insert
-
setContextMenu
Description copied from interface:ScriptEditorControlSet the context menu for the control.- Specified by:
setContextMenuin interfaceScriptEditorControl<org.fxmisc.flowless.VirtualizedScrollPane<org.fxmisc.richtext.CodeArea>>- Parameters:
menu-
-
getContextMenu
Description copied from interface:ScriptEditorControlGet the context menu for the control.- Specified by:
getContextMenuin interfaceScriptEditorControl<org.fxmisc.flowless.VirtualizedScrollPane<org.fxmisc.richtext.CodeArea>>- Returns:
-
requestFocus
public void requestFocus()Description copied from interface:ScriptEditorControlRequest that the control is focused.- Specified by:
requestFocusin interfaceScriptEditorControl<org.fxmisc.flowless.VirtualizedScrollPane<org.fxmisc.richtext.CodeArea>>
-
caretPositionProperty
Description copied from interface:ScriptEditorControlProperty for the current caret position.- Specified by:
caretPositionPropertyin interfaceScriptEditorControl<org.fxmisc.flowless.VirtualizedScrollPane<org.fxmisc.richtext.CodeArea>>- Returns:
- the
caretPositionproperty - See Also:
-
setLanguage
Description copied from interface:ScriptEditorControlSet the language for text to be displayed by this control.The default implementation does nothing. Implementing classes may choose to change the control's behavior based on the language.
- Specified by:
setLanguagein interfaceScriptEditorControl<org.fxmisc.flowless.VirtualizedScrollPane<org.fxmisc.richtext.CodeArea>>- Parameters:
language-
-
getLanguage
Description copied from interface:ScriptEditorControlGet any language stored for text to be displayed by this control.The default implementation always returns null. Implementing classes may choose to store any set language, and modify the control's behavior accordingly.
- Specified by:
getLanguagein interfaceScriptEditorControl<org.fxmisc.flowless.VirtualizedScrollPane<org.fxmisc.richtext.CodeArea>>- Returns:
-
setSmartEditing
public void setSmartEditing(boolean smartEditing) Request smart editing, e.g. to insert closing parentheses.- Parameters:
smartEditing-
-
getSmartEditing
public boolean getSmartEditing()Check whether smart editing is requested.- Returns:
-