Java Code Examples for org.eclipse.swt.custom.StyledText#redraw()
The following examples show how to use
org.eclipse.swt.custom.StyledText#redraw() .
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: CompositeTab.java From ldparteditor with MIT License | 6 votes |
public void hideSelection() { if (!state.getFileNameObj().getVertexManager().isUpdated()){ return; } final DatFile df = state.getFileNameObj(); final VertexManager vm = df.getVertexManager(); vm.addSnapshot(); final StyledText st = getTextComposite(); int s1 = st.getSelectionRange().x; int s2 = s1 + st.getSelectionRange().y; int fromLine = s1 > -1 ? st.getLineAtOffset(s1) : s1 * -1; int toLine = s2 > -1 ? st.getLineAtOffset(s2) : s2 * -1; fromLine++; toLine++; Text2SelectionConverter.convert(fromLine, toLine, df); vm.hideSelection(); df.addHistory(); st.redraw(0, 0, st.getBounds().width, st.getBounds().height, true); st.forceFocus(); }
Example 2
Source File: CompositeTab.java From ldparteditor with MIT License | 6 votes |
public void showSelection() { if (!state.getFileNameObj().getVertexManager().isUpdated()){ return; } final DatFile df = state.getFileNameObj(); final VertexManager vm = df.getVertexManager(); vm.addSnapshot(); final StyledText st = getTextComposite(); int s1 = st.getSelectionRange().x; int s2 = s1 + st.getSelectionRange().y; int fromLine = s1 > -1 ? st.getLineAtOffset(s1) : s1 * -1; int toLine = s2 > -1 ? st.getLineAtOffset(s2) : s2 * -1; fromLine++; toLine++; Text2SelectionConverter.convert(fromLine, toLine, df); vm.showSelection(); df.addHistory(); st.redraw(0, 0, st.getBounds().width, st.getBounds().height, true); st.forceFocus(); }
Example 3
Source File: KillLineHandler.java From e4macs with Eclipse Public License 1.0 | 5 votes |
/** * When called from a console context, will use ST.CUT * * @see com.mulgasoft.emacsplus.commands.ConsoleCmdHandler#consoleDispatch(TextConsoleViewer, * IConsoleView, ExecutionEvent) */ public Object consoleDispatch(TextConsoleViewer viewer, IConsoleView activePart, ExecutionEvent event) { if (viewer.isEditable()) { IDocument doc = viewer.getDocument(); StyledText st = viewer.getTextWidget(); int offset = st.getCaretOffset(); try { IRegion info = doc.getLineInformationOfOffset(offset); int noffset = info.getOffset() + info.getLength(); if (offset == noffset) { int line = doc.getLineOfOffset(offset); if (++line < doc.getNumberOfLines()) { noffset = doc.getLineOffset(line); if (noffset == doc.getLength()) { noffset = offset; } } } if (offset != noffset) { st.redraw(); st.setSelection(offset, noffset); KillRing.getInstance().setKill(CUT_LINE_TO_END, false); return super.consoleDispatch(viewer, activePart, event); } viewer.refresh(); } catch (BadLocationException e) { } } return null; }
Example 4
Source File: RecenterHandler.java From e4macs with Eclipse Public License 1.0 | 5 votes |
/** * @see com.mulgasoft.emacsplus.commands.IConsoleDispatch#consoleDispatch(TextConsoleViewer, IConsoleView, ExecutionEvent) */ public Object consoleDispatch(TextConsoleViewer viewer, IConsoleView activePart, ExecutionEvent event) { CS saveState = state; try { state = CS.C; StyledText st = viewer.getTextWidget(); st.redraw(); recenter(st); } finally { state = saveState; } return null; }
Example 5
Source File: BaseYankHandler.java From e4macs with Eclipse Public License 1.0 | 5 votes |
/** * When called from a console context, use paste * * @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) { StyledText st = viewer.getTextWidget(); try { // set directly from the widget widgetEol = st.getLineDelimiter(); paste(event,st,activePart.getConsole() instanceof IConsole); } finally { st.redraw(); widgetEol = null; } return null; }
Example 6
Source File: XdsConsoleViewer.java From xds-ide with Eclipse Public License 1.0 | 4 votes |
public void setCurrentLinkRange(int offset, int length, boolean scrollToMakeItVisible) { try { boolean redraw = false; StyledText st = getTextWidget(); if (markedOffset != offset || markedLength != length) { markedOffset = offset; markedLength = length; redraw = true; } if (scrollToMakeItVisible) { redraw = true; int topIdx = st.getTopIndex(); int btmIdx = topIdx + st.getSize().y / st.getLineHeight(); int mTop = st.getLineAtOffset(offset); int mBtm = st.getLineAtOffset(offset + length); int newTop = topIdx; if (mTop < topIdx) { newTop = mTop; } else if (mBtm > btmIdx) { newTop = topIdx + (mBtm - btmIdx); if (newTop < mTop) { newTop = mTop; } } if (newTop != topIdx) { st.setTopIndex(newTop); } } if (redraw) { st.redraw(); } } catch (Exception e) {} }
Example 7
Source File: RemoteCursorStrategy.java From saros with GNU General Public License v2.0 | 4 votes |
/** * {@inheritDoc} * * @param annotation An RemoteCursorAnnotation passed by the {@link AnnotationPainter} * @param offset offset of the end of the Selection * @param length always 0, will be ignored */ @Override public void draw( Annotation annotation, GC gc, StyledText textWidget, int offset, int length, Color color) { Point currentCursorPosition = textWidget.getLocationAtOffset(offset); // clearing mode if (gc == null) { /* * Redraw the surrounding area of the cursor. Because we draw a line * with a width larger than 1, we have to clear the area around the * actual coordinates (start a bit more left, and extend a bit to * the right). */ textWidget.redraw( currentCursorPosition.x - CURSOR_WIDTH / 2, currentCursorPosition.y, CURSOR_WIDTH + 1, textWidget.getLineHeight(), false); return; } final Color oldBackground = gc.getBackground(); final Color oldForeground = gc.getForeground(); /* * Draw the cursor line */ gc.setBackground(color); gc.setForeground(color); gc.setLineWidth(CURSOR_WIDTH); gc.drawLine( currentCursorPosition.x, currentCursorPosition.y, currentCursorPosition.x, currentCursorPosition.y + textWidget.getLineHeight()); // set back the colors like they were before gc.setBackground(oldBackground); gc.setForeground(oldForeground); }