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 Type
    Method
    Description
    void
    Append the specified text.
    void
    Request clear the contents of the control.
    void
    deleteText(int startIdx, int endIdx)
    Request deleting the text within the specified range.
    default void
    Deselect any currently-selected text.
    int
    Get the current caret position.
    Get the selected text as a string.
    int
    Get the ending position for any selection (exclusive).
    default int
    Get the selection length, or 0 if there is no selection.
    int
    Get the starting position for any selection (inclusive).
    Get all the text in the editor;
    void
    insertText(int pos, String text)
    Request inserting the specified text.
    void
    positionCaret(int index)
    Set the caret position to the specified index
    void
    Insert the specified text, replacing any existing selection.
    void
    selectRange(int startIdx, int endIdx)
    Set the range of the selected text.
    void
    Set all the text in the editor.
  • Method Details

    • setText

      void setText(String text)
      Set all the text in the editor.
      Parameters:
      text -
    • getText

      String getText()
      Get all the text in the editor;
      Returns:
    • appendText

      void appendText(String text)
      Append the specified text.
      Parameters:
      text - the text to be appended
    • replaceSelection

      void replaceSelection(String text)
      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

      void insertText(int pos, String text)
      Request inserting the specified text.
      Parameters:
      pos - position to insert the text
      text - 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 than getSelectionStart() this means there is no selection.
      Returns:
    • getSelectionLength

      default int getSelectionLength()
      Get the selection length, or 0 if there is no selection.
      Returns: