Package org.fife.ui.rsyntaxtextarea
Class RSyntaxTextAreaHighlighter
java.lang.Object
javax.swing.text.LayeredHighlighter
javax.swing.text.DefaultHighlighter
javax.swing.plaf.basic.BasicTextUI.BasicHighlighter
org.fife.ui.rtextarea.RTextAreaHighlighter
org.fife.ui.rsyntaxtextarea.RSyntaxTextAreaHighlighter
- All Implemented Interfaces:
UIResource
,Highlighter
The highlighter implementation used by
RSyntaxTextArea
s. It knows to
always paint "marked occurrences" highlights below selection highlights,
and squiggle underline highlights above all other highlights.Most of this code is copied from javax.swing.text.DefaultHighlighter; unfortunately, we cannot re-use much of it since it is package private.
- Version:
- 1.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
Highlight info implementation used for parser notices and marked occurrences.Nested classes/interfaces inherited from class org.fife.ui.rtextarea.RTextAreaHighlighter
RTextAreaHighlighter.HighlightInfo, RTextAreaHighlighter.HighlightInfoImpl, RTextAreaHighlighter.LayeredHighlightInfo, RTextAreaHighlighter.LayeredHighlightInfoImpl
Nested classes/interfaces inherited from class javax.swing.text.DefaultHighlighter
DefaultHighlighter.DefaultHighlightPainter
Nested classes/interfaces inherited from class javax.swing.text.LayeredHighlighter
LayeredHighlighter.LayerPainter
Nested classes/interfaces inherited from interface javax.swing.text.Highlighter
Highlighter.Highlight, Highlighter.HighlightPainter
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Color
The default color used for parser notices when none is specified.Marked occurrences in the document (to be painted separately from other highlights).Highlights from document parsers.Fields inherited from class org.fife.ui.rtextarea.RTextAreaHighlighter
textArea
Fields inherited from class javax.swing.text.DefaultHighlighter
DefaultPainter
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) Object
addMarkedOccurrenceHighlight
(int start, int end, SmartHighlightPainter p) Adds a special "marked occurrence" highlight.(package private) RTextAreaHighlighter.HighlightInfo
Adds a highlight from a parser.(package private) void
Removes all "marked occurrences" highlights from the view.(package private) void
Removes all parser highlights.void
clearParserHighlights
(Parser parser) Removes all the highlights for a specific parser.void
Returns a list of "marked occurrences" in the text area.void
paintLayeredHighlights
(Graphics g, int lineStart, int lineEnd, Shape viewBounds, JTextComponent editor, View view) Paints the "marked occurrences" highlights, then any other standard layered highlights (e.g.void
paintParserHighlights
(Graphics g, int lineStart, int lineEnd, Shape viewBounds, JTextComponent editor, View view) Paints any highlights fromParser
s.(package private) void
Removes a parser highlight from this view.Methods inherited from class org.fife.ui.rtextarea.RTextAreaHighlighter
getMarkAllHighlightCount, getMarkAllHighlightRanges, install, paintListLayered, repaintListHighlight
Methods inherited from class javax.swing.text.DefaultHighlighter
addHighlight, changeHighlight, getDrawsLayeredHighlights, getHighlights, paint, removeAllHighlights, removeHighlight, setDrawsLayeredHighlights
-
Field Details
-
markedOccurrences
Marked occurrences in the document (to be painted separately from other highlights). -
parserHighlights
Highlights from document parsers. These should be painted "on top of" all other highlights to ensure they are always above the selection. -
DEFAULT_PARSER_NOTICE_COLOR
The default color used for parser notices when none is specified.
-
-
Constructor Details
-
RSyntaxTextAreaHighlighter
public RSyntaxTextAreaHighlighter()Constructor.
-
-
Method Details
-
addMarkedOccurrenceHighlight
Object addMarkedOccurrenceHighlight(int start, int end, SmartHighlightPainter p) throws BadLocationException Adds a special "marked occurrence" highlight.- Parameters:
start
- The start offset.end
- The end offset, exclusive.p
- The painter to use.- Returns:
- A tag to reference the highlight later.
- Throws:
BadLocationException
- If the specified range is invalid.- See Also:
-
addParserHighlight
RTextAreaHighlighter.HighlightInfo addParserHighlight(ParserNotice notice, Highlighter.HighlightPainter p) throws BadLocationException Adds a highlight from a parser.- Parameters:
notice
- The notice from aParser
.- Returns:
- A tag with which to reference the highlight.
- Throws:
BadLocationException
- If the specified notice references invalid offsets.- See Also:
-
clearMarkOccurrencesHighlights
void clearMarkOccurrencesHighlights()Removes all "marked occurrences" highlights from the view.- See Also:
-
clearParserHighlights
void clearParserHighlights()Removes all parser highlights.- See Also:
-
clearParserHighlights
Removes all the highlights for a specific parser.- Parameters:
parser
- The parser.
-
deinstall
- Specified by:
deinstall
in interfaceHighlighter
- Overrides:
deinstall
in classRTextAreaHighlighter
-
getMarkedOccurrences
Returns a list of "marked occurrences" in the text area. If there are no marked occurrences, this will be an empty list.- Returns:
- The list of marked occurrences, or an empty list if none. The
contents of this list will be of type
DocumentRange
.
-
paintLayeredHighlights
public void paintLayeredHighlights(Graphics g, int lineStart, int lineEnd, Shape viewBounds, JTextComponent editor, View view) Paints the "marked occurrences" highlights, then any other standard layered highlights (e.g. the text selection).- Overrides:
paintLayeredHighlights
in classRTextAreaHighlighter
- Parameters:
g
- The graphics context.lineStart
- The starting offset of the line.lineEnd
- The end offset of the line.viewBounds
- The bounds of the view.editor
- The parent text component.view
- The view instance being rendered.- See Also:
-
paintParserHighlights
public void paintParserHighlights(Graphics g, int lineStart, int lineEnd, Shape viewBounds, JTextComponent editor, View view) Paints any highlights fromParser
s.- Parameters:
g
- The graphics context.lineStart
- The starting offset of the line.lineEnd
- The end offset of the line.viewBounds
- The bounds of the view.editor
- The parent text component.view
- The view instance being rendered.- See Also:
-
removeParserHighlight
Removes a parser highlight from this view.- Parameters:
tag
- The reference to the highlight.- See Also:
-