org.eclipse.ui.console.TextConsoleViewer Java Examples
The following examples show how to use
org.eclipse.ui.console.TextConsoleViewer.
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: SexpBaseForwardHandler.java From e4macs with Eclipse Public License 1.0 | 6 votes |
/** * @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) { IDocument document = viewer.getDocument(); ITextSelection currentSelection = (ITextSelection)viewer.getSelectionProvider().getSelection(); ITextSelection selection = new TextSelection(document, viewer.getTextWidget().getCaretOffset(), 0); try { selection = getNextSexp(document, selection); if (selection == null) { selection = currentSelection; unbalanced(activePart,true); return null; } else { return endTransform(viewer, selection.getOffset() + selection.getLength(), currentSelection, selection); } } catch (BadLocationException e) { } 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: 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 #5
Source File: BackwardUpListHandler.java From e4macs with Eclipse Public License 1.0 | 6 votes |
/** * @see com.mulgasoft.emacsplus.commands.SexpBaseBackwardHandler#consoleDispatch(TextConsoleViewer, IConsoleView, ExecutionEvent) */ public Object consoleDispatch(final TextConsoleViewer viewer, final IConsoleView activePart, ExecutionEvent event) { IDocument doc = viewer.getDocument(); boolean isBackup = getUniversalCount() > 0; // normal direction ITextSelection selection = (ITextSelection) viewer.getSelectionProvider().getSelection(); try { int offset = doTransform(doc, selection, viewer.getTextWidget().getCaretOffset(),isBackup); if (offset == NO_OFFSET) { unbalanced(activePart,false); } else { endTransform(viewer, offset, selection, new TextSelection(null,offset,offset - selection.getOffset())); } } catch (BadLocationException e) {} return null; }
Example #6
Source File: SexpBaseBackwardHandler.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) { IDocument document = viewer.getDocument(); ITextSelection currentSelection = (ITextSelection)viewer.getSelectionProvider().getSelection(); ITextSelection selection = null; try { selection = getNextSexp(document, currentSelection); if (selection == null) { selection = currentSelection; unbalanced(activePart,true); return null; } else { return endTransform(viewer, selection.getOffset(), currentSelection, selection); } } catch (BadLocationException e) { } return null; }
Example #7
Source File: SexpHandler.java From e4macs with Eclipse Public License 1.0 | 5 votes |
protected int noSelectTransform(TextConsoleViewer viewer, int offset, ITextSelection selection, boolean moveit) { // move the cursor if moveit == true int newOffset = selection.getOffset(); newOffset = (moveit ? newOffset + selection.getLength() : newOffset); viewer.setSelectedRange(newOffset, 0); return NO_OFFSET; }
Example #8
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 #9
Source File: ConsoleCmdHandler.java From e4macs with Eclipse Public License 1.0 | 5 votes |
protected void setUpUndo(TextConsoleViewer viewer) { IDocumentUndoManager undoer = DocumentUndoManagerRegistry.getDocumentUndoManager(viewer.getDocument()); if (undoer == null) { DocumentUndoManagerRegistry.connect(viewer.getDocument()); // undoer = DocumentUndoManagerRegistry.getDocumentUndoManager(viewer.getDocument()); // viewer.setUndoManager((IUndoManager) undoer); } }
Example #10
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 #11
Source File: DeleteNextHandler.java From e4macs with Eclipse Public License 1.0 | 5 votes |
/** * @see com.mulgasoft.emacsplus.commands.ConsoleCmdHandler#getId(ExecutionEvent, TextConsoleViewer) */ @Override protected String getId(ExecutionEvent event, TextConsoleViewer viewer) { String id = IEmacsPlusCommandDefinitionIds.DELETE_NEXT_WORD; KillRing.getInstance().setKill(id, false); return id; }
Example #12
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 #13
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 #14
Source File: ConsoleCopyCutHandler.java From e4macs with Eclipse Public License 1.0 | 5 votes |
/** * @see com.mulgasoft.emacsplus.commands.ConsoleCmdHandler#consoleDispatch(TextConsoleViewer, IConsoleView, ExecutionEvent) */ @Override public Object consoleDispatch(TextConsoleViewer viewer, IConsoleView activePart, ExecutionEvent event) { Object result = null; IDocument doc = viewer.getDocument(); try { IWorkbenchPartSite site = activePart.getSite(); if (site != null) { IHandlerService service = (IHandlerService) site.getService(IHandlerService.class); if (doc != null && service != null) { doc.addDocumentListener(KillRing.getInstance()); String cmdId = getId(event, viewer); if (cmdId != null) { result = service.executeCommand(cmdId, null); } } } } catch (CommandException e) { // Shouldn't happen as the Command id will be null or valid e.printStackTrace(); } finally { if (doc != null) { doc.removeDocumentListener(KillRing.getInstance()); } // clear kill command flag KillRing.getInstance().setKill(null, false); } MarkUtils.clearConsoleMark(viewer); return result; }
Example #15
Source File: ConsoleCopyCutHandler.java From e4macs with Eclipse Public License 1.0 | 5 votes |
/** * @see com.mulgasoft.emacsplus.commands.ConsoleCmdHandler#getId(ExecutionEvent, TextConsoleViewer) */ @Override protected String getId(ExecutionEvent event, TextConsoleViewer viewer) { String result = null; if (IEmacsPlusCommandDefinitionIds.CONSOLE_CUT.equals(event.getCommand().getId())){ result = IEmacsPlusCommandDefinitionIds.EMP_CUT; KillRing.getInstance().setKill(result, false); } else if (IEmacsPlusCommandDefinitionIds.CONSOLE_COPY.equals(event.getCommand().getId())){ result = IEmacsPlusCommandDefinitionIds.EMP_COPY; } return result; }
Example #16
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 #17
Source File: SexpHandler.java From e4macs with Eclipse Public License 1.0 | 5 votes |
protected int selectTransform(TextConsoleViewer viewer, int offset, ITextSelection origSelection, ITextSelection selection) { // we're expanding a mark selection int mark = viewer.getMark(); if (mark != -1) { viewer.setSelectedRange(mark, offset - mark); } return NO_OFFSET; }
Example #18
Source File: DownListHandler.java From e4macs with Eclipse Public License 1.0 | 5 votes |
/** * @see com.mulgasoft.emacsplus.commands.SexpBaseForwardHandler#consoleDispatch(TextConsoleViewer, IConsoleView, ExecutionEvent) */ public Object consoleDispatch(final TextConsoleViewer viewer, final IConsoleView activePart, ExecutionEvent event) { IDocument doc = viewer.getDocument(); ITextSelection currentSelection = (ITextSelection) viewer.getSelectionProvider().getSelection(); ITextSelection selection = downList(doc, currentSelection); if (selection == null) { unbalanced(activePart,false); } else { endTransform(viewer,selection.getOffset() + selection.getLength(), currentSelection, selection); } return null; }
Example #19
Source File: BackwardUpListHandler.java From e4macs with Eclipse Public License 1.0 | 5 votes |
/** * @see com.mulgasoft.emacsplus.commands.SexpHandler#endTransform(TextConsoleViewer, int, ITextSelection, ITextSelection) */ @Override protected int endTransform(TextConsoleViewer viewer, int offset, ITextSelection origSelection, ITextSelection selection) { if (isMarkEnabled(viewer, origSelection)) { return selectTransform(viewer, offset, origSelection, selection); } else { return noSelectTransform(viewer, offset, selection, false); } }
Example #20
Source File: MarkSetHandler.java From e4macs with Eclipse Public License 1.0 | 5 votes |
/** * Support simple mark on TextConsole * * @see com.mulgasoft.emacsplus.commands.IConsoleDispatch#consoleDispatch(TextConsoleViewer, IConsoleView, ExecutionEvent) */ public Object consoleDispatch(TextConsoleViewer viewer, IConsoleView activePart, ExecutionEvent event) { int offset = viewer.getTextWidget().getCaretOffset(); viewer.setSelectedRange(offset, 0); viewer.setMark(offset); return null; }
Example #21
Source File: DownListHandler.java From e4macs with Eclipse Public License 1.0 | 5 votes |
/** * @see com.mulgasoft.emacsplus.commands.SexpHandler#endTransform(org.eclipse.ui.console.TextConsoleViewer, int, org.eclipse.jface.text.ITextSelection, org.eclipse.jface.text.ITextSelection) */ @Override protected int endTransform(TextConsoleViewer viewer, int offset, ITextSelection origSelection, ITextSelection selection) { if (isMarkEnabled(viewer, origSelection)) { return selectTransform(viewer, offset, origSelection, selection); } else { return noSelectTransform(viewer, offset, selection, true); } }
Example #22
Source File: DeletePreviousHandler.java From e4macs with Eclipse Public License 1.0 | 5 votes |
/** * @see com.mulgasoft.emacsplus.commands.ConsoleCmdHandler#getId(ExecutionEvent, TextConsoleViewer) */ @Override protected String getId(ExecutionEvent event, TextConsoleViewer viewer) { String id = IEmacsPlusCommandDefinitionIds.DELETE_PREVIOUS_WORD; KillRing.getInstance().setKill(id, true); return id; }
Example #23
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 #24
Source File: ScriptConsolePage.java From Pydev with Eclipse Public License 1.0 | 5 votes |
@Override protected TextConsoleViewer createViewer(Composite parent) { ScriptConsole console = (ScriptConsole) getConsole(); viewer = new ScriptConsoleViewer(parent, console, this, console.createStyleProvider(), console.getInitialCommands(), console.getFocusOnStart(), console.getBackspaceAction(), console.getAutoEditStrategy(), console.getTabCompletionEnabled(), true); viewer.configure(cfg); return viewer; }
Example #25
Source File: ToolsConsolePage.java From goclipse with Eclipse Public License 1.0 | 4 votes |
@Override protected TextConsoleViewer createViewer(Composite parent) { return new IOConsoleViewer(parent, (TextConsole)getConsole()); }
Example #26
Source File: DeleteCharHandler.java From e4macs with Eclipse Public License 1.0 | 4 votes |
protected String getId(ExecutionEvent event, TextConsoleViewer viewer) { return IEmacsPlusCommandDefinitionIds.DELETE_NEXT; }
Example #27
Source File: BrowseKillRingHandler.java From e4macs with Eclipse Public License 1.0 | 4 votes |
/** * @see com.mulgasoft.emacsplus.execute.IEmacsPlusConsoleKey#handleKey(org.eclipse.swt.events.VerifyEvent, org.eclipse.ui.console.TextConsoleViewer) */ public void handleKey(VerifyEvent event, TextConsoleViewer viewer) { // mask away any extraneous modifier characters for any direct equality tests. see SWT.MODIFIER_MASK int sm = event.stateMask & SWT.MODIFIER_MASK; if (viewer != null && (sm == 0 || sm == SWT.SHIFT)) {// && 'i' == event.character) { int offset; boolean reactivate = false; switch (event.character){ case 'i': // insert case 'y': case ' ': reactivate = true; case '\r': case '\n': event.doit = false; offset = getLineOffset(viewer); if (offset >= 0) { KilledText kill = offsetHash.get(offset); if (kill != null) { insertFromBrowseRing(kill.text); } } if (reactivate) { EmacsPlusConsole.getInstance().setFocus(false); } break; case 'n': // next event.doit = false; browseRing(viewer,FORWARD); break; case 'p': // previous event.doit = false; browseRing(viewer,BACKWARD); break; case 'g': // refresh event.doit = false; updateBrowseRing(); break; case 'q': // quit activateEditor(); break; case 'U': // undo event.doit = false; undoEditor(); break; } } }
Example #28
Source File: ScriptConsoleViewerWrapper.java From Pydev with Eclipse Public License 1.0 | 4 votes |
public ScriptConsoleViewerWrapper(TextConsoleViewer viewer, IInterpreterInfo info) { this.viewer = viewer; this.info = info; }
Example #29
Source File: N4IDEXpectView.java From n4js with Eclipse Public License 1.0 | 4 votes |
@Override public void createPartControl(Composite parent) { FillLayout fillLayout = new FillLayout(SWT.VERTICAL); fillLayout.marginHeight = 5; fillLayout.marginWidth = 5; parent.setLayout(fillLayout); // main container container = new Composite(parent, SWT.BORDER); container.setLayout(new FillLayout()); // create container for stack trace data Composite stacktraceDataContainer = new Composite(parent, SWT.BORDER); FormLayout formLayout = new FormLayout(); formLayout.marginHeight = 5; formLayout.marginWidth = 5; formLayout.spacing = 5; stacktraceDataContainer.setLayout(formLayout); Composite stackLabelContainer = new Composite(stacktraceDataContainer, SWT.NO_SCROLL | SWT.SHADOW_NONE); stackLabelContainer.setLayout(new GridLayout()); FormData stackLabelFormData = new FormData(); stackLabelFormData.top = new FormAttachment(0); stackLabelFormData.left = new FormAttachment(0); stackLabelFormData.right = new FormAttachment(100); stackLabelFormData.bottom = new FormAttachment(20); stackLabelContainer.setLayoutData(stackLabelFormData); Composite stackTraceContainer = new Composite(stacktraceDataContainer, SWT.NO_SCROLL | SWT.SHADOW_NONE); stackTraceContainer.setLayout(new FillLayout()); FormData stackTraceFormData = new FormData(); stackTraceFormData.top = new FormAttachment(stackLabelContainer); stackTraceFormData.left = new FormAttachment(0); stackTraceFormData.right = new FormAttachment(100); stackTraceFormData.bottom = new FormAttachment(100); stackTraceContainer.setLayoutData(stackTraceFormData); // Create viewer for test tree in main container testTreeViewer = new TreeViewer(container); testTreeViewer.setContentProvider(new XpectContentProvider()); testTreeViewer.setLabelProvider(new XpectLabelProvider(this.testsExecutionStatus)); testTreeViewer.setInput(null); // create stack trace label stacktraceLabel = new Label(stackLabelContainer, SWT.SHADOW_OUT); FontData fontData = stacktraceLabel.getFont().getFontData()[0]; Display display = Display.getCurrent(); // may be null if outside the UI thread if (display == null) display = Display.getDefault(); Font font = new Font(display, new FontData(fontData.getName(), fontData .getHeight(), SWT.BOLD)); // Make stack trace label bold stacktraceLabel.setFont(font); stacktraceLabel.setText(NO_TRACE_MSG); // create stack trace console MessageConsole messageConsole = new MessageConsole("trace", null); stacktraceConsole = new TraceConsole(messageConsole); stacktraceConsoleViewer = new TextConsoleViewer(stackTraceContainer, messageConsole); // context menu getSite().setSelectionProvider(testTreeViewer); MenuManager contextMenu = new MenuManager(); contextMenu.setRemoveAllWhenShown(true); getSite().registerContextMenu(contextMenu, testTreeViewer); Control control = testTreeViewer.getControl(); Menu menu = contextMenu.createContextMenu(control); control.setMenu(menu); activateContext(); createSelectionActions(); }
Example #30
Source File: SexpKillForwardHandler.java From e4macs with Eclipse Public License 1.0 | 4 votes |
protected int noSelectTransform(TextConsoleViewer viewer, int offset, ITextSelection selection, boolean moveit) { super.noSelectTransform(viewer, offset, selection, moveit); return offset; }