Package org.eclipse.jface.text
Class TextPresentation
java.lang.Object
org.eclipse.jface.text.TextPresentation
Describes the presentation styles for a section of an indexed text such as a
document or string. A text presentation defines a default style for the whole
section and in addition style differences for individual subsections. Text
presentations can be narrowed down to a particular result window. All methods
are result window aware, i.e. ranges outside the result window are always
ignored.
All iterators provided by a text presentation assume that they enumerate non
overlapping, consecutive ranges inside the default range. Thus, all these
iterators do not include the default range. The default style range must be
explicitly asked for using getDefaultStyleRange
.
-
Constructor Summary
ConstructorDescriptionCreates a new empty text presentation.TextPresentation
(int sizeHint) Creates a new empty text presentation.TextPresentation
(IRegion extent, int sizeHint) Creates a new empty text presentation with the given extent. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addStyleRange
(StyleRange range) Add the given range to the presentation.static void
applyTextPresentation
(TextPresentation presentation, StyledText text) Applies the given presentation to the given text widget.void
clear()
Clears this presentation by resetting all applied changes.Returns an iterator which enumerates all style ranges of this presentation except the default style range.Returns the coverage of this presentation as clipped by the presentation's result window.Returns this presentation's default style range.int
Returns the number of style ranges in the presentation not counting the default style range.Returns the extent of this presentation clipped by the presentation's result window.Returns the style range with the smallest offset ignoring the default style range or null if the presentation is empty.Returns the style range with the highest offset ignoring the default style range.Returns an iterator which enumerates all style ranged which define a style different from the presentation's default style range.boolean
isEmpty()
Returns whether this collection contains any style range including the default style range.void
mergeStyleRange
(StyleRange range) Merges the given range into this presentation.void
mergeStyleRanges
(StyleRange[] ranges) Merges the given ranges into this presentation.void
replaceStyleRange
(StyleRange range) Replaces the given range in this presentation.void
replaceStyleRanges
(StyleRange[] ranges) Replaces the given ranges in this presentation.void
setDefaultStyleRange
(StyleRange range) Set the default style range of this presentation.void
setResultWindow
(IRegion resultWindow) Sets the result window for this presentation.
-
Constructor Details
-
TextPresentation
public TextPresentation()Creates a new empty text presentation. -
TextPresentation
public TextPresentation(int sizeHint) Creates a new empty text presentation.sizeHint
tells the expected size of this presentation.- Parameters:
sizeHint
- the expected size of this presentation, must be positive
-
TextPresentation
Creates a new empty text presentation with the given extent.sizeHint
tells the expected size of this presentation.- Parameters:
extent
- the extent of the createdTextPresentation
sizeHint
- the expected size of this presentation, must be positive- Since:
- 3.0
-
-
Method Details
-
applyTextPresentation
Applies the given presentation to the given text widget. Helper method.- Parameters:
presentation
- the style informationtext
- the widget to which to apply the style information- Since:
- 2.0
-
setResultWindow
Sets the result window for this presentation. When dealing with this presentation all ranges which are outside the result window are ignored. For example, the size of the presentation is 0 when there is no range inside the window even if there are ranges outside the window. All methods are aware of the result window.- Parameters:
resultWindow
- the result window
-
setDefaultStyleRange
Set the default style range of this presentation. The default style range defines the overall area covered by this presentation and its style information.- Parameters:
range
- the range describing the default region
-
getDefaultStyleRange
Returns this presentation's default style range. The returnedStyleRange
is relative to the start of the result window.- Returns:
- this presentation's default style range
-
addStyleRange
Add the given range to the presentation. The range must be a subrange of the presentation's default range.- Parameters:
range
- the range to be added
-
replaceStyleRange
Replaces the given range in this presentation. The range must be a subrange of the presentation's default range.- Parameters:
range
- the range to be added- Since:
- 3.0
-
mergeStyleRange
Merges the given range into this presentation. The range must be a subrange of the presentation's default range.- Parameters:
range
- the range to be added- Since:
- 3.0
-
replaceStyleRanges
Replaces the given ranges in this presentation. Each range must be a subrange of the presentation's default range. The ranges must be ordered by increasing offset and must not overlap (but may be adjacent).- Parameters:
ranges
- the ranges to be added- Since:
- 3.0
-
mergeStyleRanges
Merges the given ranges into this presentation. Each range must be a subrange of the presentation's default range. The ranges must be ordered by increasing offset and must not overlap (but may be adjacent).- Parameters:
ranges
- the ranges to be added- Since:
- 3.0
-
getNonDefaultStyleRangeIterator
Returns an iterator which enumerates all style ranged which define a style different from the presentation's default style range. The default style range is not enumerated.- Returns:
- a style range iterator
-
getAllStyleRangeIterator
Returns an iterator which enumerates all style ranges of this presentation except the default style range. The returnedStyleRange
s are relative to the start of the presentation's result window.- Returns:
- a style range iterator
-
isEmpty
public boolean isEmpty()Returns whether this collection contains any style range including the default style range.- Returns:
true
if there is no style range in this presentation
-
getDenumerableRanges
public int getDenumerableRanges()Returns the number of style ranges in the presentation not counting the default style range.- Returns:
- the number of style ranges in the presentation excluding the default style range
-
getFirstStyleRange
Returns the style range with the smallest offset ignoring the default style range or null if the presentation is empty.- Returns:
- the style range with the smallest offset different from the default style range
-
getLastStyleRange
Returns the style range with the highest offset ignoring the default style range.- Returns:
- the style range with the highest offset different from the default style range
-
getCoverage
Returns the coverage of this presentation as clipped by the presentation's result window.- Returns:
- the coverage of this presentation
-
getExtent
Returns the extent of this presentation clipped by the presentation's result window.- Returns:
- the clipped extent
- Since:
- 3.0
-
clear
public void clear()Clears this presentation by resetting all applied changes.- Since:
- 2.0
-