Class RSyntaxTextAreaEditorKit.InsertBreakAction

All Implemented Interfaces:
ActionListener, Serializable, Cloneable, EventListener, Action
Direct Known Subclasses:
AbstractJFlexCTokenMaker.CStyleInsertBreakAction
Enclosing class:
RSyntaxTextAreaEditorKit

public static class RSyntaxTextAreaEditorKit.InsertBreakAction extends RTextAreaEditorKit.InsertBreakAction
Action for when the user presses the Enter key. This is here so we can be smart and "auto-indent" for programming languages.
See Also:
  • Field Details

  • Constructor Details

    • InsertBreakAction

      public InsertBreakAction()
  • Method Details

    • actionPerformedImpl

      public void actionPerformedImpl(ActionEvent e, RTextArea textArea)
      Description copied from class: RecordableTextAction
      The actual meat of the action. If you wish to subclass this action and modify its behavior, this is the method to override.
      Overrides:
      actionPerformedImpl in class RTextAreaEditorKit.InsertBreakAction
      Parameters:
      e - The action being performed.
      textArea - The text area "receiving" the action.
      See Also:
    • atEndOfLine

      private static int atEndOfLine(int pos, String s, int sLen)
      Returns:
      The first location in the string past pos that is NOT a whitespace char, or -1 if only whitespace chars follow pos (or it is the end position in the string).
    • getOpenBraceCount

      private static int getOpenBraceCount(RSyntaxDocument doc, int languageIndex)
    • handleInsertBreak

      protected void handleInsertBreak(RSyntaxTextArea textArea, boolean noSelection)
      Actually inserts the newline into the document, and auto-indents if appropriate. This method can be called by token makers who implement a custom action for inserting newlines.
      Parameters:
      textArea - The text area to examine.
      noSelection - Whether there is no selection.
    • handleInsertBreakWithoutSelection

      private void handleInsertBreakWithoutSelection(RSyntaxTextArea textArea) throws BadLocationException
      Throws:
      BadLocationException
    • isAllWhitespace

      private static boolean isAllWhitespace(String str, int from, int to)
    • possiblyCloseCurlyBrace

      private void possiblyCloseCurlyBrace(RSyntaxTextArea textArea, String leadingWS)