org.eclipse.jface.text.JFaceTextUtil Java Examples
The following examples show how to use
org.eclipse.jface.text.JFaceTextUtil.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BookmarkRulerColumn.java From xds-ide with Eclipse Public License 1.0 | 6 votes |
/** * Draws the ruler column. * * @param gc the GC to draw into * @param visibleLines the visible model lines */ private void doPaint(GC gc, ILineRange visibleLines) { Display display= fCachedTextWidget.getDisplay(); int lastLine = visibleLines.getStartLine() + visibleLines.getNumberOfLines(); int y = -JFaceTextUtil.getHiddenTopLinePixels(fCachedTextWidget); if (mapMarks != null) { for (int line= visibleLines.getStartLine(); line < lastLine; line++) { int widgetLine= JFaceTextUtil.modelLineToWidgetLine(fCachedTextViewer, line); if (widgetLine == -1) continue; int lineHeight= fCachedTextWidget.getLineHeight(fCachedTextWidget.getOffsetAtLine(widgetLine)); if (mapMarks != null && mapMarks.containsKey(line)) { paintLine(line, mapMarks.get(line), y, lineHeight, gc, display); } y += lineHeight; } } }
Example #2
Source File: BookmarkRulerColumn.java From xds-ide with Eclipse Public License 1.0 | 5 votes |
/** * Returns the viewer's first visible line, even if only partially visible. * * @return the viewer's first visible line */ private int getInclusiveTopIndex() { if (fCachedTextWidget != null && !fCachedTextWidget.isDisposed()) { return JFaceTextUtil.getPartialTopIndex(fCachedTextViewer); } return -1; }
Example #3
Source File: BookmarkRulerColumn.java From xds-ide with Eclipse Public License 1.0 | 5 votes |
private int getVisibleLinesInViewport() { if (fCachedTextWidget != null) { Rectangle clArea= fCachedTextWidget.getClientArea(); if (!clArea.isEmpty()) { int firstPixel= 0; // what about margins? don't take trims as they include scrollbars: int lastPixel= clArea.height - 1; int first= JFaceTextUtil.getLineIndex(fCachedTextWidget, firstPixel); int last= JFaceTextUtil.getLineIndex(fCachedTextWidget, lastPixel); return last - first; } } return -1; }
Example #4
Source File: CommonLineNumberRulerColumn.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
/** * Returns the viewer's first visible line, even if only partially visible. * * @return the viewer's first visible line */ private int getInclusiveTopIndex() { if (fCachedTextWidget != null && !fCachedTextWidget.isDisposed()) { return JFaceTextUtil.getPartialTopIndex(fCachedTextViewer); } return -1; }
Example #5
Source File: CommonLineNumberRulerColumn.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
void doPaint(GC gc, ILineRange visibleLines) { Display display = fCachedTextWidget.getDisplay(); // draw diff info int y = -JFaceTextUtil.getHiddenTopLinePixels(fCachedTextWidget); List<LineMap> lineMap = getLineMap(fCachedTextWidget, visibleLines); int lineCount = fCachedTextWidget.getLineCount(); int lineMapSize = lineMap.size(); for (int i = 0; i < lineMapSize; i++) { LineMap map = lineMap.get(i); int line = map.documentLine; int widgetLine = map.widgetLine; try { int lineHeight = fCachedTextWidget.getLineHeight(fCachedTextWidget.getOffsetAtLine(widgetLine)); paintLine(line, y, lineHeight, gc, display); int distanceFromPrevious = 1; if (line < lineCount - 1 && i + 1 < lineMapSize) { distanceFromPrevious = lineMap.get(i + 1).visualLine - map.visualLine; } y += (lineHeight * distanceFromPrevious); } catch (Exception e) { IdeLog.logError(EditorEplPlugin.getDefault(), MessageFormat.format("Error painting line number: {0}", map), e); //$NON-NLS-1$ } } }
Example #6
Source File: CommonLineNumberRulerColumn.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
/** * Returns the number of lines in the view port. * * @param textWidget the styled text widget * @return the number of lines visible in the view port <code>-1</code> if there's no client * area * @deprecated this method should not be used - it relies on the widget using a uniform line * height */ static int getVisibleLinesInViewport(StyledText textWidget) { if (textWidget != null) { Rectangle clArea= textWidget.getClientArea(); if (!clArea.isEmpty()) { int firstPixel= 0; int lastPixel= clArea.height - 1; // XXX: what about margins? don't take trims as they include scrollbars int first= JFaceTextUtil.getLineIndex(textWidget, firstPixel); int last= JFaceTextUtil.getLineIndex(textWidget, lastPixel); return last - first; } } return -1; }
Example #7
Source File: CommonLineNumberRulerColumn.java From APICloud-Studio with GNU General Public License v3.0 | 3 votes |
/** * Paints the line. After this method is called the line numbers are painted on top * of the result of this method. * * @param line the line of the document which the ruler is painted for * @param y the y-coordinate of the box being painted for <code>line</code>, relative to <code>gc</code> * @param lineheight the height of one line (and therefore of the box being painted) * @param gc the drawing context the client may choose to draw on. * @param display the display the drawing occurs on * @since 3.0 */ protected void paintLine(int line, int y, int lineheight, GC gc, Display display) { int widgetLine= JFaceTextUtil.modelLineToWidgetLine(fCachedTextViewer, line); String s= createDisplayString(line); int indentation= fIndentation[s.length()]; int baselineBias= getBaselineBias(gc, widgetLine); gc.drawString(s, indentation, y + baselineBias, true); }
Example #8
Source File: CommonLineNumberRulerColumn.java From APICloud-Studio with GNU General Public License v3.0 | 2 votes |
/** * Returns <code>true</code> if the viewport displays the entire viewer contents, i.e. the * viewer is not vertically scrollable. * * @return <code>true</code> if the viewport displays the entire contents, <code>false</code> otherwise * @since 3.2 */ protected final boolean isViewerEntirelyShown() { return JFaceTextUtil.isShowingEntireContents(fCachedTextWidget); }