Java Code Examples for org.eclipse.ui.console.TextConsoleViewer#getTextWidget()
The following examples show how to use
org.eclipse.ui.console.TextConsoleViewer#getTextWidget() .
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: EmacsMovementHandler.java From e4macs with Eclipse Public License 1.0 | 6 votes |
/** * @see com.mulgasoft.emacsplus.commands.IConsoleDispatch#consoleDispatch(TextConsoleViewer, IConsoleView, ExecutionEvent) */ public Object consoleDispatch(TextConsoleViewer viewer, IConsoleView activePart, ExecutionEvent event) { StyledText st = viewer.getTextWidget(); String id = event.getCommand().getId(); boolean isSelect = isMarkEnabled(viewer,(ITextSelection)viewer.getSelection()); int action = getDispatchId(id,isSelect); if (action > -1) { st.invokeAction(action); } else if ((id = getId(isSelect)) != null) { // support sexps try { EmacsPlusUtils.executeCommand(id, null, activePart); } catch (Exception e) { e.printStackTrace(); } } return null; }
Example 3
Source File: ConsoleCmdHandler.java From e4macs with Eclipse Public License 1.0 | 6 votes |
/** * @see com.mulgasoft.emacsplus.commands.IConsoleDispatch#consoleDispatch(org.eclipse.ui.console.TextConsoleViewer, IConsoleView, ExecutionEvent) */ public Object consoleDispatch(TextConsoleViewer viewer, IConsoleView activePart, ExecutionEvent event) { IDocument doc = viewer.getDocument(); int action = -1; try { StyledText st = viewer.getTextWidget(); action = getDispatchId(getId(event, viewer)); if (action > -1) { // set up for kill ring doc.addDocumentListener(KillRing.getInstance()); // setUpUndo(viewer); st.invokeAction(action); } } finally { // remove kill ring behavior if (action > -1) { doc.removeDocumentListener(KillRing.getInstance()); } KillRing.getInstance().setKill(null, false); } return null; }
Example 4
Source File: MarkUtils.java From e4macs with Eclipse Public License 1.0 | 5 votes |
/** * Support simple clear mark/selection on TextConsole * * @param viewer */ public static void clearConsoleMark(TextConsoleViewer viewer) { if (viewer != null) { StyledText st = viewer.getTextWidget(); st.setSelection(st.getCaretOffset()); viewer.setMark(-1); } }
Example 5
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 6
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 7
Source File: BrowseKillRingHandler.java From e4macs with Eclipse Public License 1.0 | 5 votes |
/** * Navigate up or down the ring entry by entry * * @param viewer the viewer on the console * @param dir FORWARD or BACKWARD */ private void browseRing(TextConsoleViewer viewer, int dir) { IDocument doc = viewer.getDocument(); StyledText st = viewer.getTextWidget(); if (doc != null && st != null) { int lines = doc.getNumberOfLines(); int off = st.getCaretOffset(); try { int l = doc.getLineOfOffset(off); KilledText okill = offsetHash.get(doc.getLineOffset(l)); KilledText nkill = null; int noff = -1; while ((l = l+dir) > -1 && l < lines){ off = doc.getLineOffset(l); KilledText tkill = offsetHash.get(off); if (nkill == null) { if (tkill != null && tkill != okill) { nkill = offsetHash.get(off); noff = off; if (dir == FORWARD) { break; } } } else { if (tkill != null && tkill != nkill){ break; } else { noff = off; } } } if (noff > -1) { st.setCaretOffset(noff); viewer.revealRange(noff, 0); } }catch (BadLocationException e) { } } }
Example 8
Source File: BrowseKillRingHandler.java From e4macs with Eclipse Public License 1.0 | 5 votes |
/** * Get the line offset of the cursor * * @param viewer the console viewer * @return the line offset */ private int getLineOffset(TextConsoleViewer viewer) { int result = -1; IDocument doc = viewer.getDocument(); StyledText st = viewer.getTextWidget(); if (doc != null && st != null) { int off = st.getCaretOffset(); try { IRegion info = doc.getLineInformationOfOffset(off); result = info.getOffset(); }catch (BadLocationException e) { } } return result; }
Example 9
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; }