private void execNext() { clearData(); int start = inputCmd.getLineAtOffset(inputCmd.getCaretOffset()); int end = inputCmd.getLineCount(); for (int i = start; i < end; i++) { String cmd = inputCmd.getLine(i); if (execCmd(cmd)) break; } } private void clearData(){
@Override public void textChanged(TextEvent event) { if (event.getViewerRedrawState() && fCachedTextWidget.getLineCount() != previousLineCount) { previousLineCount= fCachedTextWidget.getLineCount(); postRedraw(); } } };
private int getHeightOfAllLines(StyledText styledText) { int height= 0; int lineCount= styledText.getLineCount(); for (int i= 0; i < lineCount; i++) height= height + styledText.getLineHeight(styledText.getOffsetAtLine(i)); return height; }
@Override public void task() { if (consoleText != null && !consoleText.isDisposed()) { consoleText.setTopIndex(consoleText.getLineCount() - 1); } } });
private int getHeightOfAllLines(StyledText styledText) { int height= 0; int lineCount= styledText.getLineCount(); for (int i= 0; i < lineCount; i++) height= height + styledText.getLineHeight(styledText.getOffsetAtLine(i)); return height; }
private int getHeightOfAllLines(StyledText styledText) { int height= 0; int lineCount= styledText.getLineCount(); for (int i= 0; i < lineCount; i++) height= height + styledText.getLineHeight(styledText.getOffsetAtLine(i)); return height; }
public void run(){ text.append(str); if(autoScroolToBottom){ text.setTopIndex(text.getLineCount() - 1); text.setCaretOffset(text.getText().length()); } } });
private void scrollToEndOfDocument() { StyledText textWidget = getTextWidget(); if (textWidget != null && !textWidget.isDisposed()) { int lineCount = textWidget.getLineCount(); textWidget.setTopIndex(lineCount > 0 ? lineCount - 1 : 0); } }
public IStatus runInUIThread(IProgressMonitor monitor) { StyledText textWidget = getTextWidget(); if (textWidget != null && !textWidget.isDisposed()) { int lineCount = textWidget.getLineCount(); textWidget.setTopIndex(lineCount - 1); } return Status.OK_STATUS; } };
@Override public void lineGetStyle(LineStyleEvent event) { StyleRange range = new StyleRange(); range.foreground = Display.getCurrent().getSystemColor(SWT.COLOR_GRAY); int maxNumLine = styledText.getLineCount(); int bulletLength = Integer.toString(maxNumLine).length(); // right padding int widthBullet = ((bulletLength + 1) * styledText.getLineHeight()) / 2; range.metrics = new GlyphMetrics(0, 0, widthBullet); event.bullet = new Bullet(ST.BULLET_TEXT, range); event.bullet.text = String.format("%" + bulletLength + "s", styledText.getLineAtOffset(event.lineOffset) + 1); }
/** * Returns <code>true</code> if the widget displays the entire contents, i.e. it cannot * be vertically scrolled. * * @param widget the widget * @return <code>true</code> if the widget displays the entire contents, i.e. it cannot * be vertically scrolled, <code>false</code> otherwise */ public static boolean isShowingEntireContents(StyledText widget) { if (widget.getTopPixel() != 0) // more efficient shortcut return false; int lastVisiblePixel= computeLastVisiblePixel(widget); int lastPossiblePixel= widget.getLinePixel(widget.getLineCount()); return lastPossiblePixel <= lastVisiblePixel; }
@Override public int toDocumentLineNumber(int y_coordinate) { if (fTextViewer == null || y_coordinate == -1) return -1; StyledText text= fTextViewer.getTextWidget(); int line= text.getLineIndex(y_coordinate); if (line == text.getLineCount() - 1) { // check whether y_coordinate exceeds last line if (y_coordinate > text.getLinePixel(line + 1)) return -1; } return widgetLine2ModelLine(fTextViewer, line); }
@Override public int toDocumentLineNumber(int y_coordinate) { if (fTextViewer == null || y_coordinate == -1) return -1; StyledText text= fTextViewer.getTextWidget(); int line= text.getLineIndex(y_coordinate); if (line == text.getLineCount() - 1) { // check whether y_coordinate exceeds last line if (y_coordinate > text.getLinePixel(line + 1)) return -1; } return widgetLine2ModelLine(fTextViewer, line); }
@Override public int toDocumentLineNumber(int y_coordinate) { if (fTextViewer == null || y_coordinate == -1) return -1; StyledText text= fTextViewer.getTextWidget(); int line= text.getLineIndex(y_coordinate); if (line == text.getLineCount() - 1) { // check whether y_coordinate exceeds last line if (y_coordinate > text.getLinePixel(line + 1)) return -1; } return widgetLine2ModelLine(fTextViewer, line); }
@Override public int toDocumentLineNumber(int y_coordinate) { if (fTextViewer == null || y_coordinate == -1) return -1; StyledText text= fTextViewer.getTextWidget(); int line= text.getLineIndex(y_coordinate); if (line == text.getLineCount() - 1) { // check whether y_coordinate exceeds last line if (y_coordinate > text.getLinePixel(line + 1)) return -1; } return widgetLine2ModelLine(fTextViewer, line); }
private boolean checkEndOfDocument() { StyledText textWidget = getTextWidget(); if (textWidget != null && !textWidget.isDisposed()) { int partialBottomIndex = JFaceTextUtil.getPartialBottomIndex(textWidget); int lineCount = textWidget.getLineCount(); int delta = textWidget.getVerticalBar().getIncrement(); return lineCount - partialBottomIndex < delta; } return false; }
protected Collection<Box> visibleBoxes() { Rectangle r0 = boxText.getClientArea(); int start = boxText.getHorizontalIndex() + boxText.getOffsetAtLine(boxText.getTopIndex()); int end = boxText.getCharCount() -1; int lineIndex = boxText.getLineIndex(r0.height); if (lineIndex < boxText.getLineCount()-1) end = boxText.getOffsetAtLine(lineIndex); List<Box> result = new ArrayList<Box>(); for (Box b : boxes) if (b.intersects(start, end)) result.add(b); calcBounds(result); return result; }
private void configureStyledText(String text, boolean enabled) { if (fStyledText == null) return; fStyledText.setText(text); int count= fStyledText.getCharCount(); if (count == 0) return; Color foreground= enabled ? null : Display.getDefault().getSystemColor(SWT.COLOR_DARK_GRAY); fStyledText.setStyleRange(new StyleRange(0, count, foreground, null)); StyleRange styleRange= new StyleRange(0, count, foreground, null); styleRange.metrics= new GlyphMetrics(0, 0, 20); fStyledText.setLineBullet(0, fStyledText.getLineCount(), new Bullet(styleRange)); fStyledText.setEnabled(enabled); } }
private void configureStyledText(String text, boolean enabled) { if (fStyledText == null) return; fStyledText.setText(text); int count= fStyledText.getCharCount(); if (count == 0) return; Color foreground= enabled ? null : Display.getDefault().getSystemColor(SWT.COLOR_DARK_GRAY); fStyledText.setStyleRange(new StyleRange(0, count, foreground, null)); StyleRange styleRange= new StyleRange(0, count, foreground, null); styleRange.metrics= new GlyphMetrics(0, 0, 20); fStyledText.setLineBullet(0, fStyledText.getLineCount(), new Bullet(styleRange)); fStyledText.setEnabled(enabled); } }
private void configureStyledText(String text, boolean enabled) { if (fStyledText == null) return; fStyledText.setText(text); int count= fStyledText.getCharCount(); if (count == 0) return; Color foreground= enabled ? null : Display.getDefault().getSystemColor(SWT.COLOR_DARK_GRAY); fStyledText.setStyleRange(new StyleRange(0, count, foreground, null)); StyleRange styleRange= new StyleRange(0, count, foreground, null); styleRange.metrics= new GlyphMetrics(0, 0, 20); fStyledText.setLineBullet(0, fStyledText.getLineCount(), new Bullet(styleRange)); fStyledText.setEnabled(enabled); } }