fix history in console
This commit is contained in:
parent
56588de5d9
commit
a25f570354
|
@ -69,10 +69,13 @@ class Console(QtGui.QPlainTextEdit):
|
||||||
def setCommand(self, command):
|
def setCommand(self, command):
|
||||||
if self.getCommand() == command:
|
if self.getCommand() == command:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
doc = self.document()
|
||||||
|
curr_line = unicode(doc.findBlockByLineNumber(doc.lineCount() - 1).text())
|
||||||
self.moveCursor(QtGui.QTextCursor.End)
|
self.moveCursor(QtGui.QTextCursor.End)
|
||||||
self.moveCursor(QtGui.QTextCursor.StartOfLine, QtGui.QTextCursor.KeepAnchor)
|
for i in range(len(curr_line) - len(self.prompt)):
|
||||||
for i in range(len(self.prompt)):
|
self.moveCursor(QtGui.QTextCursor.Left, QtGui.QTextCursor.KeepAnchor)
|
||||||
self.moveCursor(QtGui.QTextCursor.Right, QtGui.QTextCursor.KeepAnchor)
|
|
||||||
self.textCursor().removeSelectedText()
|
self.textCursor().removeSelectedText()
|
||||||
self.textCursor().insertText(command)
|
self.textCursor().insertText(command)
|
||||||
self.moveCursor(QtGui.QTextCursor.End)
|
self.moveCursor(QtGui.QTextCursor.End)
|
||||||
|
@ -151,7 +154,8 @@ class Console(QtGui.QPlainTextEdit):
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
def getCursorPosition(self):
|
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):
|
def setCursorPosition(self, position):
|
||||||
self.moveCursor(QtGui.QTextCursor.StartOfLine)
|
self.moveCursor(QtGui.QTextCursor.StartOfLine)
|
||||||
|
|
Loading…
Reference in New Issue