Interface DocumentModel

All Superinterfaces:
VersionedObject<DocumentModel>
All Known Implementing Classes:
DefaultDocumentModel, DocumentModelFilter

public interface DocumentModel extends VersionedObject<DocumentModel>
DocumentModel is a container for text that provides basic editing interaction as used by things like TextField.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Deletes the character immediately before the current carat position.
    Deep clones this document model.
    Returns a VersionedReference that can be watched for changes to the carat position.
    void
    Deletes the character immediately after the current carat position.
    void
    deleteCharAt(int pos)
    Deletes the character at the specified position.
    int
    Moves the carat position to the next line if there is one.
    int
    end(boolean currentLine)
    Moves the carat to the document's end position or the current line's end position depending on the specified 'currentLine' value.
    int
    During text selection, this is one end of the selection where the other end is the carat position.
    int
    Returns the column number of the current anchor position in the line returned by getAnchorLine().
    int
    Returns the line number containing the current anchor position.
    int
    Returns the current 'carat' position.
    int
    Returns the column number of the current carat position in the line returned by getCaratLine().
    int
    Returns the line number containing the current carat position.
    getLine(int line)
    Returns the string representing just the specified line of text.
    int
    Returns the current number of lines in this document.
    Returns the current text value contained in this DocumentModel.
    int
    home(boolean currentLine)
    Moves the carat to the document's home position or the current line's home position depending on the specified 'currentLine' value.
    void
    insert(char c)
    Inserts a character at the current carat position.
    void
    insert(String text)
    Bulk inserts a string of text.
    void
    Inserts a new line at the current carat position.
    int
    Moves the carat one position to the left, potentially moving it to the previous line depending on the actual DocumentModel implementation.
    int
    Moves the carat one position to the right, potentially moving it to the next line depending on the actual DocumentModel implementation.
    void
    Replaces the text contained in this DocumentModel.
    int
    up()
    Moves the carat position to the previous line if there is one.

    Methods inherited from interface com.simsilica.lemur.core.VersionedObject

    createReference, getObject, getVersion
  • Method Details

    • clone

      DocumentModel clone()
      Deep clones this document model.
    • setText

      void setText(String text)
      Replaces the text contained in this DocumentModel.
    • getText

      String getText()
      Returns the current text value contained in this DocumentModel.
    • getLine

      String getLine(int line)
      Returns the string representing just the specified line of text.
    • getLineCount

      int getLineCount()
      Returns the current number of lines in this document.
    • getCarat

      int getCarat()
      Returns the current 'carat' position. The 'carat' is where new text characters will be inserted. It's the current edit position.
    • getCaratLine

      int getCaratLine()
      Returns the line number containing the current carat position.
    • getCaratColumn

      int getCaratColumn()
      Returns the column number of the current carat position in the line returned by getCaratLine().
    • getAnchorLine

      int getAnchorLine()
      Returns the line number containing the current anchor position.
    • getAnchorColumn

      int getAnchorColumn()
      Returns the column number of the current anchor position in the line returned by getAnchorLine().
    • getAnchor

      int getAnchor()
      During text selection, this is one end of the selection where the other end is the carat position.
    • home

      int home(boolean currentLine)
      Moves the carat to the document's home position or the current line's home position depending on the specified 'currentLine' value. If currentLine is true then the home position is just before the first character in the current line. If the currentLine parameter is false then the home position is just before the first character in the whole document.
    • end

      int end(boolean currentLine)
      Moves the carat to the document's end position or the current line's end position depending on the specified 'currentLine' value. If currentLine is true then the end position is just after the last character in the current line. If the currentLine parameter is false then the end position is just after the last character in the whole document.
    • up

      int up()
      Moves the carat position to the previous line if there is one. After this call, the new column position is implementation dependent.
    • down

      int down()
      Moves the carat position to the next line if there is one. After this call, the new column position is implementation dependent.
    • left

      int left()
      Moves the carat one position to the left, potentially moving it to the previous line depending on the actual DocumentModel implementation.
    • right

      int right()
      Moves the carat one position to the right, potentially moving it to the next line depending on the actual DocumentModel implementation.
    • insertNewLine

      void insertNewLine()
      Inserts a new line at the current carat position.
    • deleteCharAt

      void deleteCharAt(int pos)
      Deletes the character at the specified position.
    • backspace

      void backspace()
      Deletes the character immediately before the current carat position. This may move the carat to the previous line if the carat was previously at the beginning of a line.
    • delete

      void delete()
      Deletes the character immediately after the current carat position.
    • insert

      void insert(char c)
      Inserts a character at the current carat position.
    • insert

      void insert(String text)
      Bulk inserts a string of text.
    • createCaratReference

      VersionedReference<Integer> createCaratReference()
      Returns a VersionedReference that can be watched for changes to the carat position.