Class RTextAreaEditorKit.DumbCompleteWordAction

  • All Implemented Interfaces:
    java.awt.event.ActionListener, java.io.Serializable, java.lang.Cloneable, java.util.EventListener, javax.swing.Action
    Direct Known Subclasses:
    RSyntaxTextAreaEditorKit.DumbCompleteWordAction
    Enclosing class:
    RTextAreaEditorKit

    public static class RTextAreaEditorKit.DumbCompleteWordAction
    extends RecordableTextAction
    Finds the most recent word in the document that matches the "word" up to the current caret position, and auto-completes the rest. Repeatedly calling this action at the same location in the document goes one match back each time it is called.
    See Also:
    Serialized Form
    • Field Detail

      • lastWordStart

        private int lastWordStart
      • lastDot

        private int lastDot
      • searchOffs

        private int searchOffs
      • lastPrefix

        private java.lang.String lastPrefix
    • Constructor Detail

      • DumbCompleteWordAction

        public DumbCompleteWordAction()
    • Method Detail

      • getMacroID

        public final java.lang.String getMacroID()
        Description copied from class: RecordableTextAction
        Returns the identifier for this macro. This method makes it so that you can create an instance of the RTextAreaEditorKit.CutAction action, for example, rename it to "Remove", and it will still be recorded as a "cut" action. Subclasses should return a unique string from this method; preferably the name of the action.

        If you subclass a RecordableTextAction, you should NOT override this method; if you do, the action may not be properly recorded in a macro.

        Specified by:
        getMacroID in class RecordableTextAction
        Returns:
        The internally-used macro ID.
      • getPreviousWord

        protected int getPreviousWord​(RTextArea textArea,
                                      int offs)
                               throws javax.swing.text.BadLocationException
        Throws:
        javax.swing.text.BadLocationException
      • getWordEnd

        protected int getWordEnd​(RTextArea textArea,
                                 int offs)
                          throws javax.swing.text.BadLocationException
        Throws:
        javax.swing.text.BadLocationException
      • getWordStart

        protected int getWordStart​(RTextArea textArea,
                                   int offs)
                            throws javax.swing.text.BadLocationException
        Throws:
        javax.swing.text.BadLocationException
      • isAcceptablePrefix

        protected boolean isAcceptablePrefix​(java.lang.String prefix)
        Utilities.getWordStart() treats spans of whitespace and single non-letter chars as "words." This method is used to filter that kind of thing out - non-words should not be suggested by this action.
        Parameters:
        prefix - The prefix characters before the caret.
        Returns:
        Whether the prefix could be part of a "word" in the context of the text area's current content.