Class TextEditorUtil

java.lang.Object
com.illumon.iris.gui.util.TextEditorUtil

public class TextEditorUtil
extends Object
A utility class with methods for helping text editors.
  • Constructor Details

  • Method Details

    • getSelectionStart

      public static int getSelectionStart​(Caret caret)
      Gets the start offset of a selection.
      Parameters:
      caret - the text component caret
      Returns:
      the start offset of a selection
    • getSelectionEnd

      public static int getSelectionEnd​(Caret caret)
      Gets the end offset of a selection.
      Parameters:
      caret - the text component caret
      Returns:
      the end offset of a selection
    • getLineNumber

      public static int getLineNumber​(JTextComponent comp, int offset) throws BadLocationException
      Gets the line number for an offset.
      Parameters:
      comp - the text component
      offset - the offset
      Returns:
      the line number
      Throws:
      BadLocationException - if the offset is outside the document range
    • getElementByLineNumber

      public static Element getElementByLineNumber​(JTextComponent comp, int line) throws BadLocationException
      Gets the element for a line number.
      Parameters:
      comp - the text component
      line - the line number
      Returns:
      the element for the line number
      Throws:
      BadLocationException - if the line number is outside the document range