mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
fix prompt setting in PydevConsoleExecuteActionHandler
GitOrigin-RevId: 97cf650b67a6bf2e2ff04ec80667ddfc017e26b1
This commit is contained in:
committed by
intellij-monorepo-bot
parent
2c7306f60c
commit
dbc05e8224
@@ -24,6 +24,8 @@ class ConsolePromptDecorator(private val myEditorEx: EditorEx) : EditorLinePaint
|
||||
var mainPrompt: String = ""
|
||||
set(mainPrompt) {
|
||||
if (this.mainPrompt != mainPrompt) {
|
||||
// to be compatible with LanguageConsoleView we should reset the indent prompt
|
||||
indentPrompt = ""
|
||||
field = mainPrompt
|
||||
update()
|
||||
}
|
||||
@@ -38,7 +40,7 @@ class ConsolePromptDecorator(private val myEditorEx: EditorEx) : EditorLinePaint
|
||||
|
||||
var indentPrompt: String = ""
|
||||
set(indentPrompt) {
|
||||
field = extend(indentPrompt, mainPrompt.length)
|
||||
field = indentPrompt
|
||||
update()
|
||||
}
|
||||
|
||||
@@ -80,16 +82,6 @@ class ConsolePromptDecorator(private val myEditorEx: EditorEx) : EditorLinePaint
|
||||
|
||||
companion object {
|
||||
private val promptColor = ColorKey.createColorKey("CONSOLE_PROMPT_COLOR")
|
||||
|
||||
private fun extend(s: String, len: Int): String {
|
||||
var res = s
|
||||
while (res.length < len) {
|
||||
res = " $res"
|
||||
}
|
||||
|
||||
return res
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,21 +1,8 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.jetbrains.python.console
|
||||
|
||||
import com.intellij.codeInsight.hint.HintManager
|
||||
import com.intellij.execution.console.LanguageConsoleImpl
|
||||
import com.intellij.execution.console.LanguageConsoleView
|
||||
import com.intellij.execution.process.ProcessHandler
|
||||
import com.intellij.execution.ui.ConsoleViewContentType
|
||||
@@ -116,6 +103,7 @@ open class PydevConsoleExecuteActionHandler(private val myConsoleView: LanguageC
|
||||
private fun ordinaryPrompt() {
|
||||
if (PyConsoleUtil.ORDINARY_PROMPT != myConsoleView.prompt) {
|
||||
myConsoleView.prompt = PyConsoleUtil.ORDINARY_PROMPT
|
||||
myConsoleView.indentPrompt = PyConsoleUtil.INDENT_PROMPT
|
||||
PyConsoleUtil.scrollDown(myConsoleView.currentEditor)
|
||||
}
|
||||
}
|
||||
@@ -124,7 +112,7 @@ open class PydevConsoleExecuteActionHandler(private val myConsoleView: LanguageC
|
||||
get() = PyConsoleUtil.getOrCreateIPythonData(myConsoleView.virtualFile).isIPythonEnabled
|
||||
|
||||
private fun ipythonInPrompt() {
|
||||
myConsoleView.setPromptAttributes(object : ConsoleViewContentType("", ConsoleViewContentType.USER_INPUT_KEY) {
|
||||
myConsoleView.setPromptAttributes(object : ConsoleViewContentType("", USER_INPUT_KEY) {
|
||||
override fun getAttributes(): TextAttributes {
|
||||
val attrs = super.getAttributes()
|
||||
attrs.fontType = Font.PLAIN
|
||||
@@ -132,17 +120,22 @@ open class PydevConsoleExecuteActionHandler(private val myConsoleView: LanguageC
|
||||
}
|
||||
})
|
||||
|
||||
myConsoleView.prompt = "In[$myIpythonInputPromptCount]:"
|
||||
val prompt = "In[$myIpythonInputPromptCount]:"
|
||||
val indentPrompt = PyConsoleUtil.IPYTHON_INDENT_PROMPT.padStart(prompt.length)
|
||||
myConsoleView.prompt = prompt
|
||||
myConsoleView.indentPrompt = indentPrompt
|
||||
PyConsoleUtil.scrollDown(myConsoleView.currentEditor)
|
||||
}
|
||||
|
||||
private fun executingPrompt() {
|
||||
myConsoleView.prompt = PyConsoleUtil.EXECUTING_PROMPT
|
||||
myConsoleView.indentPrompt = PyConsoleUtil.EXECUTING_PROMPT
|
||||
}
|
||||
|
||||
private fun waitingForInputPrompt() {
|
||||
if (PyConsoleUtil.INPUT_PROMPT != myConsoleView.prompt && PyConsoleUtil.HELP_PROMPT != myConsoleView.prompt) {
|
||||
myConsoleView.prompt = PyConsoleUtil.INPUT_PROMPT
|
||||
myConsoleView.indentPrompt = PyConsoleUtil.INPUT_PROMPT
|
||||
PyConsoleUtil.scrollDown(myConsoleView.currentEditor)
|
||||
}
|
||||
}
|
||||
@@ -156,6 +149,7 @@ open class PydevConsoleExecuteActionHandler(private val myConsoleView: LanguageC
|
||||
}
|
||||
if (prompt != myConsoleView.prompt) {
|
||||
myConsoleView.prompt = prompt
|
||||
myConsoleView.indentPrompt = prompt
|
||||
PyConsoleUtil.scrollDown(myConsoleView.currentEditor)
|
||||
}
|
||||
}
|
||||
@@ -237,3 +231,11 @@ open class PydevConsoleExecuteActionHandler(private val myConsoleView: LanguageC
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private var LanguageConsoleView.indentPrompt: String
|
||||
get() {
|
||||
return (this as? LanguageConsoleImpl)?.consolePromptDecorator?.indentPrompt ?: ""
|
||||
}
|
||||
set(value) {
|
||||
(this as? LanguageConsoleImpl)?.consolePromptDecorator?.indentPrompt = value
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.jetbrains.python.console;
|
||||
|
||||
import com.intellij.execution.console.ConsolePromptDecorator;
|
||||
@@ -82,7 +82,6 @@ public class PythonConsoleView extends LanguageConsoleImpl implements Observable
|
||||
*/
|
||||
public PythonConsoleView(final Project project, final String title, @Nullable final Sdk sdk, final boolean testMode) {
|
||||
super(project, title, PythonLanguage.getInstance());
|
||||
ConsolePromptDecorator promptDecorator = getConsolePromptDecorator();
|
||||
myTestMode = testMode;
|
||||
isShowVars = PyConsoleOptions.getInstance(project).isShowVariableByDefault();
|
||||
VirtualFile virtualFile = getVirtualFile();
|
||||
@@ -103,8 +102,6 @@ public class PythonConsoleView extends LanguageConsoleImpl implements Observable
|
||||
}
|
||||
myPyHighlighter = new PyHighlighter(languageLevel);
|
||||
myScheme = getConsoleEditor().getColorsScheme();
|
||||
PythonConsoleData data = PyConsoleUtil.getOrCreateIPythonData(getVirtualFile());
|
||||
promptDecorator.setIndentPrompt((data.isIPythonEnabled()) ? PyConsoleUtil.IPYTHON_INDENT_PROMPT : PyConsoleUtil.INDENT_PROMPT);
|
||||
}
|
||||
|
||||
public void setConsoleCommunication(final ConsoleCommunication communication) {
|
||||
|
||||
Reference in New Issue
Block a user