Class MarkOccurrencesSupport
java.lang.Object
org.fife.ui.rsyntaxtextarea.MarkOccurrencesSupport
- All Implemented Interfaces:
ActionListener, EventListener, CaretListener
Marks all occurrences of the token at the current caret position, if it is
an identifier.
- Version:
- 1.0
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final ColorThe default color used to mark occurrences.(package private) static final intThe default delay.private SmartHighlightPainterprivate RSyntaxTextAreaprivate Timer -
Constructor Summary
ConstructorsConstructorDescriptionConstructor.MarkOccurrencesSupport(int delay) Constructor.MarkOccurrencesSupport(int delay, Color color) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidCalled after the caret has been moved and a fixed time delay has elapsed.voidCalled when the caret moves in the text area.(package private) voidclear()Removes all highlights added to the text area by this listener.voidImmediately marks all occurrences of the token at the current caret position.getColor()Returns the color being used to mark occurrences.intgetDelay()Returns the delay, in milliseconds.booleanReturns whether a border is painted around marked occurrences.voidinstall(RSyntaxTextArea textArea) Installs this listener on a text area.voidSets the color to use when marking occurrences.voidsetDelay(int delay) Sets the delay between the last caret position change and when the text is scanned for matching identifiers.voidsetPaintBorder(boolean paint) Toggles whether a border is painted around marked highlights.voidUninstalls this listener from the current text area.
-
Field Details
-
textArea
-
timer
-
p
-
DEFAULT_COLOR
The default color used to mark occurrences. -
DEFAULT_DELAY_MS
static final int DEFAULT_DELAY_MSThe default delay.- See Also:
-
-
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 benull.
-
-
Method Details
-
actionPerformed
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:
actionPerformedin interfaceActionListener- Parameters:
e- The event.- See Also:
-
caretUpdate
Called when the caret moves in the text area.- Specified by:
caretUpdatein interfaceCaretListener- 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
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
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
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:
-