private void sendLineToConsole( @NotNull final ConsoleCommunication.ConsoleCodeFragment code, @NotNull final LanguageConsoleImpl console, @NotNull final Editor currentEditor) { if (myConsoleCommunication != null) { final boolean waitedForInputBefore = myConsoleCommunication.isWaitingForInput(); if (myConsoleCommunication.isWaitingForInput()) { myInputBuffer.setLength(0); } else { executingPrompt(console); } myConsoleCommunication.execInterpreter( code, new Function<InterpreterResponse, Object>() { @Override public Object fun(final InterpreterResponse interpreterResponse) { // clear myInputBuffer = null; // Handle prompt if (interpreterResponse.more) { more(console, currentEditor); if (myCurrentIndentSize == 0) { // compute current indentation setCurrentIndentSize( IndentHelperImpl.getIndent( getProject(), PythonFileType.INSTANCE, lastLine(code.getText()), false) + getPythonIndent()); // In this case we can insert indent automatically UIUtil.invokeLaterIfNeeded( new Runnable() { @Override public void run() { indentEditor(currentEditor, myCurrentIndentSize); } }); } } else { if (!myConsoleCommunication.isWaitingForInput()) { ordinaryPrompt(console, currentEditor); } setCurrentIndentSize(0); } return null; } }); // After requesting input we got no call back to change prompt, change it manually if (waitedForInputBefore && !myConsoleCommunication.isWaitingForInput()) { console.setPrompt(PyConsoleUtil.ORDINARY_PROMPT); PyConsoleUtil.scrollDown(currentEditor); } } }
private void ordinaryPrompt(LanguageConsoleImpl console, Editor currentEditor) { if (!myConsoleCommunication.isExecuting()) { if (!PyConsoleUtil.ORDINARY_PROMPT.equals(console.getPrompt())) { console.setPrompt(PyConsoleUtil.ORDINARY_PROMPT); PyConsoleUtil.scrollDown(currentEditor); } } else { executingPrompt(console); } }