Package org.eclipse.jface.text
Class JFaceTextUtil
java.lang.Object
org.eclipse.jface.text.JFaceTextUtil
A collection of JFace Text functions.
 
This class is neither intended to be instantiated nor subclassed.
- Since:
- 3.3
- Restriction:
- This class is not intended to be instantiated by clients.
- 
Method SummaryModifier and TypeMethodDescriptionstatic RectanglecomputeArea(IRegion region, ITextViewer textViewer) Determines the graphical area covered by the given text region in the given viewer.static intcomputeLineHeight(StyledText styledText, int widgetLine) Computes the full line height for the text line corresponding to the given widget line, considering the possible line wrapping.static intcomputeLineHeight(StyledText textWidget, int startLine, int endLine, int lineCount) Computes the line height for the given line range.static intgetAverageCharWidth(Control control) Returns the average character width of the given control's font.static intgetBottomIndex(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 intgetHiddenTopLinePixels(StyledText textWidget) Returns the number of hidden pixels of the first partially visible line.static intgetLineIndex(StyledText textWidget, int y) static intgetLinePixel(StyledText textWidget, int line) static intReturns the offset in the given viewer that corresponds to the current cursor location.static intgetPartialBottomIndex(ITextViewer viewer) Returns the last, possibly partially, visible line in the view port.static intgetPartialBottomIndex(StyledText widget) Returns the index of the last (possibly only partially) visible line of the widgetstatic intgetPartialTopIndex(ITextViewer viewer) Returns the line index of the first visible model line in the viewer.static intgetPartialTopIndex(StyledText widget) Returns the index of the first (possibly only partially) visible line of the widgetstatic ILineRangegetVisibleModelLines(ITextViewer viewer) Returns the range of lines that is visible in the viewer, including any partially visible lines.static booleanisEmpty(ITextViewer viewer, ITextSelection selection) Returnstrueif the text covered byselectiondoes not contain any characters in the given viewer.static booleanisShowingEntireContents(StyledText widget) Returnstrueif the widget displays the entire contents, i.e. it cannot be vertically scrolled.static intmodelLineToWidgetLine(ITextViewer viewer, int modelLine) Converts a model (i.e.static intwidgetLine2ModelLine(ITextViewer viewer, int widgetLine) Converts a widget line into a model (i.e.
- 
Method Details- 
computeLineHeightComputes the full line height for the text line corresponding to the given widget line, considering the possible line wrapping.- Parameters:
- styledText- the widget
- widgetLine- the widget line
- Returns:
- the full real height of the corresponding line of text (which might wrap to multiple widget lines) in the widget
- Since:
- 3.11
 
- 
computeLineHeightpublic static int computeLineHeight(StyledText textWidget, int startLine, int endLine, int lineCount) Computes the line height for the given line range.- Parameters:
- textWidget- the- StyledTextwidget
- startLine- the start line
- endLine- the end line (exclusive)
- lineCount- the line count used by the old API
- Returns:
- the height of all lines starting with startLineand ending aboveendLime
 
- 
getBottomIndexReturns the last fully visible line of the widget. The exact semantics of "last fully visible line" are:- the last line of which the last pixel is visible, if any
- otherwise, the only line that is partially visible
 - Parameters:
- widget- the widget
- Returns:
- the last fully visible line
 
- 
getPartialTopIndexReturns the index of the first (possibly only partially) visible line of the widget- Parameters:
- widget- the widget
- Returns:
- the index of the first line of which a pixel is visible
 
- 
getPartialBottomIndexReturns the index of the last (possibly only partially) visible line of the widget- Parameters:
- widget- the text widget
- Returns:
- the index of the last line of which a pixel is visible
 
- 
getPartialTopIndexReturns the line index of the first visible model line in the viewer. The line may be only partially visible.- Parameters:
- viewer- the text viewer
- Returns:
- the first line of which a pixel is visible, or -1 for no line
 
- 
getPartialBottomIndexReturns the last, possibly partially, visible line in the view port.- Parameters:
- viewer- the text viewer
- Returns:
- the last, possibly partially, visible line in the view port
 
- 
getVisibleModelLinesReturns the range of lines that is visible in the viewer, including any partially visible lines.- Parameters:
- viewer- the viewer
- Returns:
- the range of lines that is visible in the viewer, nullif no lines are visible
 
- 
widgetLine2ModelLineConverts a widget line into a model (i.e.IDocument) line using theITextViewerExtension5if available, otherwise by adapting the widget line to the viewer'svisible region.- Parameters:
- viewer- the viewer
- widgetLine- the widget line to convert.
- Returns:
- the model line corresponding to widgetLineor -1 to signal that there is no corresponding model line
 
- 
modelLineToWidgetLineConverts a model (i.e.IDocument) line into a widget line using theITextViewerExtension5if available, otherwise by adapting the model line to the viewer'svisible region.- Parameters:
- viewer- the viewer
- modelLine- the model line to convert.
- Returns:
- the widget line corresponding to modelLineor -1 to signal that there is no corresponding widget line
 
- 
getHiddenTopLinePixelsReturns the number of hidden pixels of the first partially visible line. If there is no partially visible line, zero is returned.- Parameters:
- textWidget- the widget
- Returns:
- the number of hidden pixels of the first partial line, always >= 0
 
- 
getLinePixel
- 
getLineIndex
- 
isShowingEntireContentsReturnstrueif the widget displays the entire contents, i.e. it cannot be vertically scrolled.- Parameters:
- widget- the widget
- Returns:
- trueif the widget displays the entire contents, i.e. it cannot be vertically scrolled,- falseotherwise
 
- 
computeAreaDetermines the graphical area covered by the given text region in the given viewer.- Parameters:
- region- the region whose graphical extend must be computed
- textViewer- the text viewer containing the region
- Returns:
- the graphical extend of the given region in the given viewer
- Since:
- 3.4
 
- 
getAverageCharWidthReturns the average character width of the given control's font.- Parameters:
- control- the control to calculate the average char width for
- Returns:
- the average character width of the controls font
- Since:
- 3.4
 
- 
isEmptypublic static boolean isEmpty(ITextViewer viewer, ITextSelection selection) throws BadLocationException Returnstrueif the text covered byselectiondoes not contain any characters in the given viewer. Note the difference toISelection.isEmpty(), which returnstrueonly for invalid selections.- Parameters:
- viewer- the viewer
- selection- the selection
- Returns:
- trueif- selectiondoes not contain any text,- falseotherwise
- Throws:
- BadLocationException- if accessing the document failed
- Since:
- 3.5
 
- 
getCoveredRangespublic static IRegion[] getCoveredRanges(ITextViewer viewer, ITextSelection selection) throws BadLocationException Returns the text regions covered by the given selection in the given viewer.- Parameters:
- viewer- the viewer
- selection- the selection
- Returns:
- the text regions corresponding to selection
- Throws:
- BadLocationException- if accessing the document failed
- Since:
- 3.5
 
- 
getOffsetForCursorLocationReturns the offset in the given viewer that corresponds to the current cursor location.- Parameters:
- viewer- the viewer
- Returns:
- the offset for the current cursor location or -1 if not available
- Since:
- 3.5
 
 
-