commit a25f57035401fff1bb87ce417477a8f52d2e9be6
parent 56588de5d92f8128b8eea7605b16b787cddc9a7b
Author: ecdsa <ecdsa@github>
Date: Mon, 4 Mar 2013 17:18:48 +0100
fix history in console
Diffstat:
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/gui/qt_console.py b/gui/qt_console.py
@@ -69,10 +69,13 @@ class Console(QtGui.QPlainTextEdit):
def setCommand(self, command):
if self.getCommand() == command:
return
+
+ doc = self.document()
+ curr_line = unicode(doc.findBlockByLineNumber(doc.lineCount() - 1).text())
self.moveCursor(QtGui.QTextCursor.End)
- self.moveCursor(QtGui.QTextCursor.StartOfLine, QtGui.QTextCursor.KeepAnchor)
- for i in range(len(self.prompt)):
- self.moveCursor(QtGui.QTextCursor.Right, QtGui.QTextCursor.KeepAnchor)
+ for i in range(len(curr_line) - len(self.prompt)):
+ self.moveCursor(QtGui.QTextCursor.Left, QtGui.QTextCursor.KeepAnchor)
+
self.textCursor().removeSelectedText()
self.textCursor().insertText(command)
self.moveCursor(QtGui.QTextCursor.End)
@@ -151,7 +154,8 @@ class Console(QtGui.QPlainTextEdit):
return ''
def getCursorPosition(self):
- return self.textCursor().columnNumber() - len(self.prompt)
+ c = self.textCursor()
+ return c.position() - c.block().position() - len(self.prompt)
def setCursorPosition(self, position):
self.moveCursor(QtGui.QTextCursor.StartOfLine)