org.eclipse.debug.ui.console.IConsoleLineTracker Java Examples

The following examples show how to use org.eclipse.debug.ui.console.IConsoleLineTracker. 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: ScriptConsoleDocumentListenerTest.java    From Pydev with Eclipse Public License 1.0 4 votes vote down vote up
@Override
protected void setUp() throws Exception {
    super.setUp();
    this.doc = new Document();
    final List<String> commandsHandled = new ArrayList<String>();

    ScriptConsolePrompt prompt = new ScriptConsolePrompt(">>> ", "... ");
    listener = new ScriptConsoleDocumentListener(
            new IScriptConsoleViewer2ForDocumentListener() {

                @Override
                public IDocument getDocument() {
                    return doc;
                }

                @Override
                public IConsoleStyleProvider getStyleProvider() {
                    return null;
                }

                @Override
                public void revealEndOfDocument() {
                    //do nothing
                }

                @Override
                public void setCaretOffset(int length, boolean async) {
                    //do nothing
                }

                @Override
                public int getCommandLineOffset() {
                    return 0;
                }

                @Override
                public int getConsoleWidthInCharacters() {
                    return 0;
                }

                @Override
                public int getCaretOffset() {
                    return 0;
                }

                @Override
                public IScriptConsoleSession getConsoleSession() {
                    return null;
                }
            },

            new ICommandHandler() {

                @Override
                public void beforeHandleCommand(String userInput,
                        ICallback<Object, InterpreterResponse> onResponseReceived) {
                    commandsHandled.add(userInput);
                }

                @Override
                public void handleCommand(String userInput,
                        ICallback<Object, InterpreterResponse> onResponseReceived) {
                    boolean more = false;
                    if (userInput.endsWith(":") || userInput.endsWith("\\")) {
                        more = true;
                    }
                    onResponseReceived.call(new InterpreterResponse(more, false));
                }

                @Override
                public ICompletionProposalHandle[] getTabCompletions(String commandLine, int cursorPosition) {
                    return null;
                }

                @Override
                public void setOnContentsReceivedCallback(
                        ICallback<Object, Tuple<String, String>> onContentsReceived) {
                }

                @Override
                public boolean isOnStateWhereCommandHandlingShouldStop(String commandLine) {
                    return false;
                }

            },

            prompt, new ScriptConsoleHistory(), new ArrayList<IConsoleLineTracker>(), "",
            new PyAutoIndentStrategy(new IAdaptable() {

                @Override
                public <T> T getAdapter(Class<T> adapter) {
                    return null;
                }
            }));

    PyAutoIndentStrategy strategy = (PyAutoIndentStrategy) listener.getIndentStrategy();
    strategy.setIndentPrefs(new TestIndentPrefs(true, 4));
    listener.setDocument(doc);
}
 
Example #2
Source File: ScriptConsoleDocumentListener.java    From Pydev with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Constructor
 *
 * @param viewer this is the viewer to which this listener is attached. It's the main viewer. Other viewers
 * may be added later through addViewer() for sharing the same listener and being properly updated.
 *
 * @param handler this is the object that'll handle the commands
 * @param prompt shows the prompt to the user
 * @param history keeps track of the commands added by the user.
 * @param initialCommands the commands that should be initially added
 */
public ScriptConsoleDocumentListener(IScriptConsoleViewer2ForDocumentListener viewer, ICommandHandler handler,
        ScriptConsolePrompt prompt, ScriptConsoleHistory history, List<IConsoleLineTracker> consoleLineTrackers,
        String initialCommands, IHandleScriptAutoEditStrategy strategy) {
    this.lastChangeMillis = System.currentTimeMillis();

    this.strategy = strategy;

    this.prompt = prompt;

    this.handler = handler;

    this.history = history;

    this.viewer = viewer;

    this.readOnlyColumnsInCurrentBeforePrompt = 0;

    this.historyFullLine = 0;

    this.doc = null;

    this.consoleLineTrackers = consoleLineTrackers;

    this.initialCommands = initialCommands;

    final ICallback<Object, Tuple<String, String>> onContentsReceived = new ICallback<Object, Tuple<String, String>>() {

        @Override
        public Object call(final Tuple<String, String> result) {
            if (result.o1.length() > 0 || result.o2.length() > 0) {
                Runnable runnable = new Runnable() {

                    @Override
                    public void run() {
                        startDisconnected();
                        PromptContext pc;
                        try {
                            pc = removeUserInput();
                            IScriptConsoleSession consoleSession = ScriptConsoleDocumentListener.this.viewer
                                    .getConsoleSession();
                            if (result.o1.length() > 0) {
                                if (consoleSession != null) {
                                    consoleSession.onStdoutContentsReceived(result.o1);
                                }
                                addToConsoleView(result.o1, true, true);
                            }
                            if (result.o2.length() > 0) {
                                if (consoleSession != null) {
                                    consoleSession.onStderrContentsReceived(result.o2);
                                }
                                addToConsoleView(result.o2, false, true);
                            }
                            if (pc.removedPrompt) {
                                appendInvitation(false);
                            }
                        } finally {
                            stopDisconnected();
                        }

                        if (pc.removedPrompt) {
                            appendText(pc.userInput);
                            ScriptConsoleDocumentListener.this.viewer.setCaretOffset(doc.getLength()
                                    - pc.cursorOffset, false);
                        }

                    }
                };
                RunInUiThread.async(runnable);
            }
            return null;
        }

    };

    handler.setOnContentsReceivedCallback(onContentsReceived);
}
 
Example #3
Source File: PydevConsole.java    From Pydev with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Overridden to get the line trackers that'll add hyperlinks to the console.
 */
@Override
public List<IConsoleLineTracker> createLineTrackers(final TextConsole console) {
    return staticCreateLineTrackers(console);
}
 
Example #4
Source File: ScriptConsole.java    From Pydev with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * @return a list of trackers that'll identify links in the console passed.
 */
public abstract List<IConsoleLineTracker> createLineTrackers(final TextConsole console);