Java Code Examples for org.eclipse.swt.custom.StyledText#getLineCount()

The following examples show how to use org.eclipse.swt.custom.StyledText#getLineCount() . 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: InteractiveConsoleView.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
private void insertHistory(final boolean back) {

		if (history.size() == 0) {
			ViewsHelper.requestUserAttention(this, "No history");
			return;
		}
		if (indexInHistory <= 0) {
			if (back) {
				ViewsHelper.requestUserAttention(this, "No more history");
			}
			indexInHistory = 0;
		} else if (indexInHistory >= history.size() - 1) {
			if (!back) {
				ViewsHelper.requestUserAttention(this, "No more history");
			}
			indexInHistory = history.size() - 1;
		}
		try {
			final StyledText text = viewer.getTextWidget();
			final int lineIndex = text.getLineCount() - 1;
			final int nbChars = text.getCharCount();
			final int firstOffset = text.getOffsetAtLine(lineIndex) + PROMPT.length();
			viewer.getDocument().replace(firstOffset, nbChars - firstOffset, history.get(indexInHistory));
			text.setCaretOffset(text.getCharCount());
			if (back) {
				indexInHistory--;
			} else {
				indexInHistory++;
			}
		} catch (final org.eclipse.jface.text.BadLocationException e1) {}

	}
 
Example 2
Source File: JavaPreview.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
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;
}
 
Example 3
Source File: CopiedOverviewRuler.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
protected int getLineCount(StyledText textWidget) {
    int lineCount = textWidget.getLineCount();
    if (lineCount < 100) {
        lineCount = 100;
    }
    return lineCount;
}