public final class JFaceTextUtil extends Object
This class is neither intended to be instantiated nor subclassed.
Modifier and Type | Method and Description |
---|---|
static Rectangle |
computeArea(IRegion region,
ITextViewer textViewer)
Determines the graphical area covered by the given text region in
the given viewer.
|
static int |
computeLineHeight(StyledText textWidget,
int startLine,
int endLine,
int lineCount)
Computes the line height for the given line range.
|
static int |
getAverageCharWidth(Control control)
Returns the average character width of the given control's font.
|
static int |
getBottomIndex(StyledText widget)
Returns the last fully visible line of the widget.
|
static IRegion[] |
getCoveredRanges(ITextViewer viewer,
ITextSelection selection)
Returns the text regions covered by the given selection in the given viewer.
|
static int |
getHiddenTopLinePixels(StyledText textWidget)
Returns the number of hidden pixels of the first partially visible line.
|
static int |
getLineIndex(StyledText textWidget,
int y) |
static int |
getLinePixel(StyledText textWidget,
int line) |
static int |
getOffsetForCursorLocation(ITextViewer viewer)
Returns the offset in the given viewer that corresponds to the current cursor location.
|
static int |
getPartialBottomIndex(ITextViewer viewer)
Returns the last, possibly partially, visible line in the view port.
|
static int |
getPartialBottomIndex(StyledText widget)
Returns the index of the last (possibly only partially) visible line of the widget
|
static int |
getPartialTopIndex(ITextViewer viewer)
Returns the line index of the first visible model line in the viewer.
|
static int |
getPartialTopIndex(StyledText widget)
Returns the index of the first (possibly only partially) visible line of the widget
|
static ILineRange |
getVisibleModelLines(ITextViewer viewer)
Returns the range of lines that is visible in the viewer, including any partially visible
lines.
|
static boolean |
isEmpty(ITextViewer viewer,
ITextSelection selection)
Returns
true if the text covered by selection does not contain any
characters in the given viewer. |
static boolean |
isShowingEntireContents(StyledText widget)
Returns
true if the widget displays the entire contents, i.e. it cannot
be vertically scrolled. |
static int |
modelLineToWidgetLine(ITextViewer viewer,
int modelLine)
Converts a model (i.e.
|
static int |
widgetLine2ModelLine(ITextViewer viewer,
int widgetLine)
Converts a widget line into a model (i.e.
|
public static int computeLineHeight(StyledText textWidget, int startLine, int endLine, int lineCount)
textWidget
- the StyledText
widgetstartLine
- the start lineendLine
- the end line (exclusive)lineCount
- the line count used by the old APIstartLine
and ending above endLime
public static int getBottomIndex(StyledText widget)
widget
- the widgetpublic static int getPartialTopIndex(StyledText widget)
widget
- the widgetpublic static int getPartialBottomIndex(StyledText widget)
widget
- the text widgetpublic static int getPartialTopIndex(ITextViewer viewer)
viewer
- the text viewerpublic static int getPartialBottomIndex(ITextViewer viewer)
viewer
- the text viewerpublic static ILineRange getVisibleModelLines(ITextViewer viewer)
viewer
- the viewernull
if no lines are
visiblepublic static int widgetLine2ModelLine(ITextViewer viewer, int widgetLine)
IDocument
) line using the
ITextViewerExtension5
if available, otherwise by adapting the widget line to the
viewer's visible region
.viewer
- the viewerwidgetLine
- the widget line to convert.widgetLine
or -1 to signal that there
is no corresponding model linepublic static int modelLineToWidgetLine(ITextViewer viewer, int modelLine)
IDocument
) line into a widget line using the
ITextViewerExtension5
if available, otherwise by adapting the model line to the
viewer's visible region
.viewer
- the viewermodelLine
- the model line to convert.modelLine
or -1 to signal that there
is no corresponding widget linepublic static int getHiddenTopLinePixels(StyledText textWidget)
textWidget
- the widgetpublic static int getLinePixel(StyledText textWidget, int line)
public static int getLineIndex(StyledText textWidget, int y)
public static boolean isShowingEntireContents(StyledText widget)
true
if the widget displays the entire contents, i.e. it cannot
be vertically scrolled.widget
- the widgettrue
if the widget displays the entire contents, i.e. it cannot
be vertically scrolled, false
otherwisepublic static Rectangle computeArea(IRegion region, ITextViewer textViewer)
region
- the region whose graphical extend must be computedtextViewer
- the text viewer containing the regionpublic static int getAverageCharWidth(Control control)
control
- the control to calculate the average char width forpublic static boolean isEmpty(ITextViewer viewer, ITextSelection selection) throws BadLocationException
true
if the text covered by selection
does not contain any
characters in the given viewer. Note the difference to ISelection.isEmpty()
,
which returns true
only for invalid selections.viewer
- the viewerselection
- the selectiontrue
if selection
does not contain any text,
false
otherwiseBadLocationException
- if accessing the document failedpublic static IRegion[] getCoveredRanges(ITextViewer viewer, ITextSelection selection) throws BadLocationException
viewer
- the viewerselection
- the selectionselection
BadLocationException
- if accessing the document failedpublic static int getOffsetForCursorLocation(ITextViewer viewer)
viewer
- the viewer
Copyright (c) 2000, 2014 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.