Class MarkOccurrencesSupport

java.lang.Object
org.fife.ui.rsyntaxtextarea.MarkOccurrencesSupport
All Implemented Interfaces:
ActionListener, EventListener, CaretListener

class MarkOccurrencesSupport extends Object implements CaretListener, ActionListener
Marks all occurrences of the token at the current caret position, if it is an identifier.
Version:
1.0
See Also:
  • Field Details

  • Constructor Details

    • MarkOccurrencesSupport

      MarkOccurrencesSupport()
      Constructor. Creates a listener with a 1-second delay.
    • MarkOccurrencesSupport

      MarkOccurrencesSupport(int delay)
      Constructor.
      Parameters:
      delay - The delay between when the caret last moves and when the text should be scanned for matching occurrences. This should be in milliseconds.
    • MarkOccurrencesSupport

      MarkOccurrencesSupport(int delay, Color color)
      Constructor.
      Parameters:
      delay - The delay between when the caret last moves and when the text should be scanned for matching occurrences. This should be in milliseconds.
      color - The color to use to mark the occurrences. This cannot be null.
  • Method Details

    • actionPerformed

      public void actionPerformed(ActionEvent e)
      Called after the caret has been moved and a fixed time delay has elapsed. This locates and highlights all occurrences of the identifier at the caret position, if any.

      Callers should not call this method directly, but should rather prefer doMarkOccurrences() to mark occurrences.

      Specified by:
      actionPerformed in interface ActionListener
      Parameters:
      e - The event.
      See Also:
    • caretUpdate

      public void caretUpdate(CaretEvent e)
      Called when the caret moves in the text area.
      Specified by:
      caretUpdate in interface CaretListener
      Parameters:
      e - The event.
    • clear

      void clear()
      Removes all highlights added to the text area by this listener.
    • doMarkOccurrences

      public void doMarkOccurrences()
      Immediately marks all occurrences of the token at the current caret position.
    • getColor

      public Color getColor()
      Returns the color being used to mark occurrences.
      Returns:
      The color being used.
      See Also:
    • getDelay

      public int getDelay()
      Returns the delay, in milliseconds.
      Returns:
      The delay.
      See Also:
    • getPaintBorder

      public boolean getPaintBorder()
      Returns whether a border is painted around marked occurrences.
      Returns:
      Whether a border is painted.
      See Also:
    • install

      public void install(RSyntaxTextArea textArea)
      Installs this listener on a text area. If it is already installed on another text area, it is uninstalled first.
      Parameters:
      textArea - The text area to install on.
    • setColor

      public void setColor(Color color)
      Sets the color to use when marking occurrences.
      Parameters:
      color - The color to use.
      See Also:
    • setDelay

      public void setDelay(int delay)
      Sets the delay between the last caret position change and when the text is scanned for matching identifiers. A delay is recommended to prevent repeated scanning while the user is typing.
      Parameters:
      delay - The new delay.
      See Also:
    • setPaintBorder

      public void setPaintBorder(boolean paint)
      Toggles whether a border is painted around marked highlights.
      Parameters:
      paint - Whether to paint a border.
      See Also:
    • uninstall

      public void uninstall()
      Uninstalls this listener from the current text area. Does nothing if it not currently installed on any text area.
      See Also: