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:
javax.swing.plaf.UIResource
,javax.swing.text.Highlighter
public class RSyntaxTextAreaHighlighter extends RTextAreaHighlighter
The highlighter implementation used byRSyntaxTextArea
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 Classes Modifier and Type Class Description private static class
RSyntaxTextAreaHighlighter.SyntaxLayeredHighlightInfoImpl
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
javax.swing.text.DefaultHighlighter.DefaultHighlightPainter
-
-
Field Summary
Fields Modifier and Type Field Description private static java.awt.Color
DEFAULT_PARSER_NOTICE_COLOR
The default color used for parser notices when none is specified.private java.util.List<RSyntaxTextAreaHighlighter.SyntaxLayeredHighlightInfoImpl>
markedOccurrences
Marked occurrences in the document (to be painted separately from other highlights).private java.util.List<RSyntaxTextAreaHighlighter.SyntaxLayeredHighlightInfoImpl>
parserHighlights
Highlights from document parsers.-
Fields inherited from class org.fife.ui.rtextarea.RTextAreaHighlighter
textArea
-
-
Constructor Summary
Constructors Constructor Description RSyntaxTextAreaHighlighter()
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) java.lang.Object
addMarkedOccurrenceHighlight(int start, int end, SmartHighlightPainter p)
Adds a special "marked occurrence" highlight.(package private) RTextAreaHighlighter.HighlightInfo
addParserHighlight(ParserNotice notice, javax.swing.text.Highlighter.HighlightPainter p)
Adds a highlight from a parser.(package private) void
clearMarkOccurrencesHighlights()
Removes all "marked occurrences" highlights from the view.(package private) void
clearParserHighlights()
Removes all parser highlights.void
clearParserHighlights(Parser parser)
Removes all the highlights for a specific parser.void
deinstall(javax.swing.text.JTextComponent c)
java.util.List<DocumentRange>
getMarkedOccurrences()
Returns a list of "marked occurrences" in the text area.void
paintLayeredHighlights(java.awt.Graphics g, int lineStart, int lineEnd, java.awt.Shape viewBounds, javax.swing.text.JTextComponent editor, javax.swing.text.View view)
Paints the "marked occurrences" highlights, then any other standard layered highlights (e.g.void
paintParserHighlights(java.awt.Graphics g, int lineStart, int lineEnd, java.awt.Shape viewBounds, javax.swing.text.JTextComponent editor, javax.swing.text.View view)
Paints any highlights fromParser
s.(package private) void
removeParserHighlight(RTextAreaHighlighter.HighlightInfo tag)
Removes a parser highlight from this view.-
Methods inherited from class org.fife.ui.rtextarea.RTextAreaHighlighter
getMarkAllHighlightCount, getMarkAllHighlightRanges, install, paintListLayered, repaintListHighlight
-
-
-
-
Field Detail
-
markedOccurrences
private java.util.List<RSyntaxTextAreaHighlighter.SyntaxLayeredHighlightInfoImpl> markedOccurrences
Marked occurrences in the document (to be painted separately from other highlights).
-
parserHighlights
private java.util.List<RSyntaxTextAreaHighlighter.SyntaxLayeredHighlightInfoImpl> 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
private static final java.awt.Color DEFAULT_PARSER_NOTICE_COLOR
The default color used for parser notices when none is specified.
-
-
Method Detail
-
addMarkedOccurrenceHighlight
java.lang.Object addMarkedOccurrenceHighlight(int start, int end, SmartHighlightPainter p) throws javax.swing.text.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:
javax.swing.text.BadLocationException
- If the specified range is invalid.- See Also:
clearMarkOccurrencesHighlights()
-
addParserHighlight
RTextAreaHighlighter.HighlightInfo addParserHighlight(ParserNotice notice, javax.swing.text.Highlighter.HighlightPainter p) throws javax.swing.text.BadLocationException
Adds a highlight from a parser.- Parameters:
notice
- The notice from aParser
.- Returns:
- A tag with which to reference the highlight.
- Throws:
javax.swing.text.BadLocationException
- If the specified notice references invalid offsets.- See Also:
clearParserHighlights()
,clearParserHighlights(Parser)
-
clearMarkOccurrencesHighlights
void clearMarkOccurrencesHighlights()
Removes all "marked occurrences" highlights from the view.
-
clearParserHighlights
void clearParserHighlights()
Removes all parser highlights.
-
clearParserHighlights
public void clearParserHighlights(Parser parser)
Removes all the highlights for a specific parser.- Parameters:
parser
- The parser.
-
deinstall
public void deinstall(javax.swing.text.JTextComponent c)
- Specified by:
deinstall
in interfacejavax.swing.text.Highlighter
- Overrides:
deinstall
in classRTextAreaHighlighter
-
getMarkedOccurrences
public java.util.List<DocumentRange> 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(java.awt.Graphics g, int lineStart, int lineEnd, java.awt.Shape viewBounds, javax.swing.text.JTextComponent editor, javax.swing.text.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(Graphics, int, int, Shape, JTextComponent, View)
-
paintParserHighlights
public void paintParserHighlights(java.awt.Graphics g, int lineStart, int lineEnd, java.awt.Shape viewBounds, javax.swing.text.JTextComponent editor, javax.swing.text.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:
paintLayeredHighlights(Graphics, int, int, Shape, JTextComponent, View)
-
removeParserHighlight
void removeParserHighlight(RTextAreaHighlighter.HighlightInfo tag)
Removes a parser highlight from this view.- Parameters:
tag
- The reference to the highlight.- See Also:
addParserHighlight(ParserNotice, javax.swing.text.Highlighter.HighlightPainter)
-
-