Java Code Examples for org.eclipse.swt.custom.StyledText#setRedraw()
The following examples show how to use
org.eclipse.swt.custom.StyledText#setRedraw() .
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: MarkExchangeHandler.java From e4macs with Eclipse Public License 1.0 | 6 votes |
/** * Support exchange for simple mark on TextConsole * * @see com.mulgasoft.emacsplus.commands.IConsoleDispatch#consoleDispatch(org.eclipse.ui.console.TextConsoleViewer, org.eclipse.ui.console.IConsoleView, org.eclipse.core.commands.ExecutionEvent) */ public Object consoleDispatch(TextConsoleViewer viewer, IConsoleView activePart, ExecutionEvent event) { int mark = viewer.getMark(); StyledText st = viewer.getTextWidget(); if (mark != -1) { try { st.setRedraw(false); int offset = st.getCaretOffset(); viewer.setMark(offset); st.setCaretOffset(mark); int len = offset - mark; viewer.setSelectedRange(offset, -len); } finally { st.setRedraw(true); } } return null; }
Example 2
Source File: SearchReplaceMinibuffer.java From e4macs with Eclipse Public License 1.0 | 6 votes |
/** * Refine target search to not proceed beyond a region limit, if present * * @see com.mulgasoft.emacsplus.minibuffer.SearchMinibuffer#findTarget(org.eclipse.jface.text.IFindReplaceTarget, java.lang.String, int, boolean) */ protected int findTarget(IFindReplaceTarget target, String searchStr, int searchIndex, boolean forward) { int result = WRAP_INDEX; StyledText text = getTextWidget(); try { text.setRedraw(false); result = super.findTarget(target,searchStr,searchIndex,forward); // if present, check if we've gone past the end of the region if (getLimit() != WRAP_INDEX && result != WRAP_INDEX) { int pos = MarkUtils.widget2ModelOffset(getViewer(), result); // include length of search result in check if (pos + target.getSelection().y > getLimit()) { result = WRAP_INDEX; // restore last position the region setSelection(searchIndex); } } } finally { text.setRedraw(true); } return result; }
Example 3
Source File: MainShell.java From RepDev with GNU General Public License v3.0 | 6 votes |
public void ReplaceTabs(){ StyledText txt = ((EditorComposite) mainfolder.getSelection().getControl()).getStyledText(); //RepgenParser parser = ((EditorComposite)cur.getControl()).getParser(); RepgenParser parser = ((EditorComposite) mainfolder.getSelection().getControl()).getParser(); txt.setRedraw(false); if( parser != null) parser.setReparse(false); // Do the replace txt.setText(txt.getText().replaceAll("\t", EditorComposite.getTabStr())); if( parser != null){ parser.setReparse(true); parser.reparseAll(); } txt.setRedraw(true); }
Example 4
Source File: PythonSourceViewer.java From Pydev with Eclipse Public License 1.0 | 6 votes |
/** * Sets the font for the given viewer sustaining selection and scroll position. * * @param font the font */ private void applyFont(Font font) { IDocument doc = getDocument(); if (doc != null && doc.getLength() > 0) { Point selection = getSelectedRange(); int topIndex = getTopIndex(); StyledText styledText = getTextWidget(); styledText.setRedraw(false); styledText.setFont(font); setSelectedRange(selection.x, selection.y); setTopIndex(topIndex); styledText.setRedraw(true); } else { getTextWidget().setFont(font); } }
Example 5
Source File: XtextEditor.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
/** * Copied from {@link org.eclipse.ui.texteditor.AbstractTextEditor#selectAndReveal(int, int)}� and removed selection * functionality. */ public void reveal(int offset, int length) { if (getSourceViewer() == null) return; StyledText widget = getSourceViewer().getTextWidget(); widget.setRedraw(false); { adjustHighlightRange(offset, length); getSourceViewer().revealRange(offset, length); markInNavigationHistory(); } widget.setRedraw(true); }
Example 6
Source File: TextViewerJoinLinesAction.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Override public void run() { ITextViewer viewer= getTextViewer(); if (viewer == null) return; if (!canModifyViewer()) return; IDocument document= viewer.getDocument(); if (document == null) return; ITextSelection selection= getSelection(viewer); if (selection == null) return; int startLine= selection.getStartLine(); int endLine= selection.getEndLine(); try { int caretOffset= joinLines(document, startLine, endLine); if (caretOffset > -1) { StyledText widget= viewer.getTextWidget(); widget.setRedraw(false); adjustHighlightRange(viewer, caretOffset, 0); viewer.revealRange(caretOffset, 0); viewer.setSelectedRange(caretOffset, 0); widget.setRedraw(true); } } catch (BadLocationException e) { // should not happen } }
Example 7
Source File: JavaPreview.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public void update() { if (fWorkingValues == null) { fPreviewDocument.set(""); //$NON-NLS-1$ return; } // update the print margin final String value= fWorkingValues.get(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT); final int lineWidth= getPositiveIntValue(value, 0); fMarginPainter.setMarginRulerColumn(lineWidth); // update the tab size final int tabSize= getPositiveIntValue(fWorkingValues.get(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE), 0); if (tabSize != fTabSize) fSourceViewer.getTextWidget().setTabs(tabSize); fTabSize= tabSize; final StyledText widget= (StyledText)fSourceViewer.getControl(); final int height= widget.getClientArea().height; final int top0= widget.getTopPixel(); final int totalPixels0= getHeightOfAllLines(widget); final int topPixelRange0= totalPixels0 > height ? totalPixels0 - height : 0; widget.setRedraw(false); doFormatPreview(); fSourceViewer.setSelection(null); final int totalPixels1= getHeightOfAllLines(widget); final int topPixelRange1= totalPixels1 > height ? totalPixels1 - height : 0; final int top1= topPixelRange0 > 0 ? (int)(topPixelRange1 * top0 / (double)topPixelRange0) : 0; widget.setTopPixel(top1); widget.setRedraw(true); }
Example 8
Source File: YankPopHandler.java From e4macs with Eclipse Public License 1.0 | 5 votes |
/** * Simulate yank pop * * @see com.mulgasoft.emacsplus.commands.BaseYankHandler#paste(org.eclipse.core.commands.ExecutionEvent, org.eclipse.swt.custom.StyledText) */ protected void paste(ExecutionEvent event, StyledText widget, boolean isProcess) { KillRing kb = KillRing.getInstance(); if (kb.isYanked()) { String cacheText = KillRing.getInstance().getClipboardText(); String prevText = convertDelimiters(kb.lastYank(),isProcess); String yankText = convertDelimiters(kb.yankPop(),isProcess); try { int offset = widget.getCaretOffset(); if (prevText == null || !prevText.equals(widget.getText(offset-prevText.length(), offset-1))) { kb.setYanked(false); EmacsPlusUtils.showMessage(HandlerUtil.getActivePart(event), EmacsPlusActivator.getString(YP_DISABLED),false); return; } widget.setRedraw(false); widget.setSelection(offset - prevText.length(), offset); kb.setClipboardText(yankText); super.paste(event, widget); } finally { if (cacheText != null) { kb.setClipboardText(cacheText); } widget.setRedraw(true); } } else { EmacsPlusUtils.showMessage(HandlerUtil.getActivePart(event), EmacsPlusActivator.getString(YP_DISABLED),false); } }
Example 9
Source File: TypeScriptEditor.java From typescript.java with MIT License | 4 votes |
/** * Highlights and moves to a corresponding element in editor * * @param reference * corresponding entity in editor * @param moveCursor * if true, moves cursor to the reference */ private void setSelection(NavigationBarItem reference, boolean moveCursor) { if (reference == null) { return; } if (moveCursor) { markInNavigationHistory(); } ISourceViewer sourceViewer = getSourceViewer(); if (sourceViewer == null) { return; } StyledText textWidget = sourceViewer.getTextWidget(); if (textWidget == null) { return; } try { Location start = reference.getSpans().get(0).getStart(); Location end = reference.getSpans().get(0).getEnd(); if (start == null || end == null) return; ITypeScriptFile tsFile = getTypeScriptFile(); int offset = tsFile.getPosition(start); int length = tsFile.getPosition(end) - offset; if (offset < 0 || length < 0 || length > sourceViewer.getDocument().getLength()) { return; } textWidget.setRedraw(false); // Uncomment that if we wish to select only variable and not the // whole block. // but there is a bug with this code with // private a: string. it's the first 'a' (of private) which is // selected and not the second. // String documentPart = sourceViewer.getDocument().get(offset, // length); // // // Try to find name because position returns for whole block // String name = reference.getText(); // if (name != null) { // int nameoffset = documentPart.indexOf(name); // if (nameoffset != -1) { // offset += nameoffset; // length = name.length(); // } // } if (length > 0) { setHighlightRange(offset, length, moveCursor); } if (!moveCursor) { return; } if (offset > -1 && length > 0) { sourceViewer.revealRange(offset, length); // Selected region begins one index after offset sourceViewer.setSelectedRange(offset, length); markInNavigationHistory(); } } catch (Exception e) { } finally { textWidget.setRedraw(true); } }