public interface HighlightsContainer
Modifier and Type | Field and Description |
---|---|
static String |
ATTR_EXTENDS_EMPTY_LINE
The attribute key for highlights that need to show up on empty lines.
|
static String |
ATTR_EXTENDS_EOL
The attribute key for highlights that need to span across a whole line.
|
Modifier and Type | Method and Description |
---|---|
void |
addHighlightsChangeListener(HighlightsChangeListener listener)
Adds a listener to this highlights container.
|
HighlightsSequence |
getHighlights(int startOffset,
int endOffset)
Provides the list of highlighted areas that should be used for rendering
a document.
|
void |
removeHighlightsChangeListener(HighlightsChangeListener listener)
Removes a listener from this highlights container.
|
static final String ATTR_EXTENDS_EOL
Typically highlights only affect rendering of a small part of text (perhaps just several characters). Some layers, however, need to highlight a whole line in an editor window regardless of how much text the line contains. The highlighting of a line with a caret is an example of such a layer.
If you want a highlight that spans accross the whole editor pane you
can add this attribute key to the highlight's AttributeSet
and set its value to Boolean.TRUE
. The highlighted area must
contain the new-line character at the end of the line.
static final String ATTR_EXTENDS_EMPTY_LINE
If you use this key for a highlight which contains the new-line character
at the end of an empty line and set the value of this attribute to
Boolean.TRUE
then the highlight will be drawn as
a half-character-wide stripe at the beginning of the line.
HighlightsSequence getHighlights(int startOffset, int endOffset)
The returned highlighted areas (highlights) must obey the following rules:
startOffset
and endOffset
parameters. Any highlights outside of this range will be clipped by the
rendering infrastructure.
The editor infrastructure will log any problems it may encounter with provided implementations of this interface. Although the infrastructure will try to do its best to render all highlights supplied by the implementors, if the above rules are violated the results can't be garanteed.
startOffset
- The starting offset of the area which the caller
attempts to repaint (or create views for). The staring offset is always >=0.endOffset
- The ending offset of the rendered area. The Integer.MAX_VALUE
can be passed in if the end offset is unknown to the caller.
The highlights container is then expected to return all highlights
up to the end of the document.void addHighlightsChangeListener(HighlightsChangeListener listener)
listener
- The listener to add.void removeHighlightsChangeListener(HighlightsChangeListener listener)
listener
- The listener to remove.Built on June 4 2024. | Copyright © 2017-2024 Apache Software Foundation. All Rights Reserved.