Merge pull request #6387 from verretor/clear-console
Keep current input when clearing Python console
This commit is contained in:
@@ -91,17 +91,18 @@ class Console(QtWidgets.QPlainTextEdit):
|
|||||||
|
|
||||||
def showMessage(self, message):
|
def showMessage(self, message):
|
||||||
self.appendPlainText(message)
|
self.appendPlainText(message)
|
||||||
self.newPrompt()
|
self.newPrompt('')
|
||||||
|
|
||||||
def clear(self):
|
def clear(self):
|
||||||
|
curr_line = self.getCommand()
|
||||||
self.setPlainText('')
|
self.setPlainText('')
|
||||||
self.newPrompt()
|
self.newPrompt(curr_line)
|
||||||
|
|
||||||
def newPrompt(self):
|
def newPrompt(self, curr_line):
|
||||||
if self.construct:
|
if self.construct:
|
||||||
prompt = '.' * len(self.prompt)
|
prompt = '.' * len(self.prompt)
|
||||||
else:
|
else:
|
||||||
prompt = self.prompt
|
prompt = self.prompt + curr_line
|
||||||
|
|
||||||
self.completions_pos = self.textCursor().position()
|
self.completions_pos = self.textCursor().position()
|
||||||
self.completions_visible = False
|
self.completions_visible = False
|
||||||
@@ -244,7 +245,7 @@ class Console(QtWidgets.QPlainTextEdit):
|
|||||||
if type(self.namespace.get(command)) == type(lambda:None):
|
if type(self.namespace.get(command)) == type(lambda:None):
|
||||||
self.appendPlainText("'{}' is a function. Type '{}()' to use it in the Python console."
|
self.appendPlainText("'{}' is a function. Type '{}()' to use it in the Python console."
|
||||||
.format(command, command))
|
.format(command, command))
|
||||||
self.newPrompt()
|
self.newPrompt('')
|
||||||
return
|
return
|
||||||
|
|
||||||
sys.stdout = stdoutProxy(self.appendPlainText)
|
sys.stdout = stdoutProxy(self.appendPlainText)
|
||||||
@@ -269,7 +270,7 @@ class Console(QtWidgets.QPlainTextEdit):
|
|||||||
traceback_lines.pop(i)
|
traceback_lines.pop(i)
|
||||||
self.appendPlainText('\n'.join(traceback_lines))
|
self.appendPlainText('\n'.join(traceback_lines))
|
||||||
sys.stdout = tmp_stdout
|
sys.stdout = tmp_stdout
|
||||||
self.newPrompt()
|
self.newPrompt('')
|
||||||
self.set_json(False)
|
self.set_json(False)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user