/** * Creates a StyledText instance with a given content, and an SwtWindow * which will be installed as * VerifyKeylistener, FocusListener, KeyListener and Mouselistener */ public static StyledText newStyledText(final Composite parent, final int style, final StyledTextContent styledTextContent, final SwtWindow swtWindow, final int firstVisibleLine) { if (Thread.currentThread() != getDisplay().getThread()) { Resultable res = new Resultable() {public void run() {result = newStyledText(parent, style, styledTextContent, swtWindow, firstVisibleLine);}}; getDisplay().syncExec(res); return (StyledText) res.result; } else { StyledText styledText = new StyledText(parent, style); styledText.setContent(styledTextContent); styledText.setTopIndex(firstVisibleLine); styledText.addVerifyKeyListener(swtWindow); styledText.addFocusListener(swtWindow); styledText.addKeyListener(swtWindow); styledText.addMouseListener(swtWindow); return styledText; } }
public SwtWindowWidget(Composite parent, StyledTextContent styledTextContent, int firstVisibleLine) { super(parent, 0); setBackground(new Color(getDisplay(), 0, 0, 0)); GridLayout layout = new GridLayout(); layout.numColumns = 1; layout.horizontalSpacing = layout.verticalSpacing = 2; layout.marginWidth = layout.marginHeight = 2; setLayout(layout); styledText = new StyledText(this, SWT.H_SCROLL | SWT.V_SCROLL); styledText.setContent(styledTextContent); styledText.setTopIndex(firstVisibleLine); styledText.setLayoutData(new GridData(GridData.FILL_BOTH)); modeline = new StyledText(this, SWT.SINGLE | SWT.READ_ONLY); modeline.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); }
/** * Shows the texts in the GUI from the current cursor position. */ public void showTexts(){ for(int i = 0; i < 7; i++){ StyledTextContent field = null; switch(i){ case CODE: field = gui.getCodeText(); break; case HEAP: field = gui.getHeapText(); break; case TRAIL: field = gui.getTrailText(); break; case RUNTIMEVARS: field = gui.getRuntimeVariablesText(); break; case TRACE: field = gui.getTraceText(); break; case STACK: field = gui.getStackText(); break; case REGISTERS: field = gui.getRegistersText(); break; } field.setText(data[i].get(cursor)); } }
private static Method getSetContentMethod(Object styledTextRenderer) throws NoSuchMethodException { // if (SET_CONTENT_METHOD == null) { Method SET_CONTENT_METHOD = styledTextRenderer.getClass().getDeclaredMethod("setContent", new Class[] { StyledTextContent.class }); SET_CONTENT_METHOD.setAccessible(true); // } return SET_CONTENT_METHOD; }
public static void setContent(final StyledText styledText, final StyledTextContent bufferContent) { if (Thread.currentThread() != getDisplay().getThread()) { Runnable run = new Resultable() {public void run() {setContent (styledText, bufferContent);}}; getDisplay().syncExec(run); } else { styledText.setContent(bufferContent); } }
private boolean getStyledTextContentChangedAndStoreNew() { StyledTextContent currentContent = this.styledText.getContent(); StyledTextContent oldContent = this.content; if (currentContent != oldContent) { //Important: the content may change during runtime, so, we have to stop listening the old one and //start listening the new one. if (oldContent != null) { oldContent.removeTextChangeListener(this); } this.content = currentContent; currentContent.addTextChangeListener(this); return true; } return false; }
public StyledTextContent getBufferContent() { return bufferContent; }
public void setTextContent(StyledTextContent textContent) { this.textContent = textContent; }
public StyledTextContent getTextContent() { return textContent; }
public StyledTextContent getCodeText() { return styledText_5.getContent(); }
public StyledTextContent getStackText() { return styledText_3.getContent(); }
public StyledTextContent getTraceText() { return styledText_6.getContent(); }
public StyledTextContent getTrailText() { return styledText_4.getContent(); }
public StyledTextContent getRuntimeVariablesText() { return styledText.getContent(); }
public StyledTextContent getRegistersText() { return styledText_1.getContent(); }
public StyledTextContent getHeapText() { return styledText_2.getContent(); }
/** * Draw the given line range. * * @param gc * the GC * @param startLine * first line number * @param endLine * last line number (inclusive) * @param x * the X-coordinate of the drawing range * @param w * the width of the drawing range */ private void drawLineRange(GC gc, int startLine, int endLine, int x, int w) { int tabs = fTextWidget.getTabs(); StyledTextContent content = fTextWidget.getContent(); for (int line = startLine; line <= endLine; line++) { int widgetOffset = fTextWidget.getOffsetAtLine(line); if (!isFoldedLine(content.getLineAtOffset(widgetOffset))) { String text = fTextWidget.getLine(line); int extend = 0; if (skipCommentBlock && assumeCommentBlock(text, tabs)) { extend -= tabs; } if (drawBlankLine && text.trim().length() == 0) { int prevLine = line; while (--prevLine >= 0) { text = fTextWidget.getLine(prevLine); if (text.trim().length() > 0) { int postLine = line; int lineCount = fTextWidget.getLineCount(); while (++postLine < lineCount) { String tmp = fTextWidget.getLine(postLine); if (tmp.trim().length() > 0) { if (countSpaces(text, tabs) < countSpaces( tmp, tabs)) { extend += tabs; } break; } } break; } } } int count = countSpaces(text, tabs) + extend; for (int i = drawLeftEnd ? 0 : tabs; i < count; i += tabs) { draw(gc, widgetOffset, i); } } } }
private Point selectWord(final int inPosition) { final StyledTextContent lContent = widget.getContent(); final int lLineIndex = lContent.getLineAtOffset(inPosition); return selectWord(inPosition, lContent.getOffsetAtLine(lLineIndex), lContent.getLine(lLineIndex).toCharArray()); }