Fix rl-unix-line-discard by reimplementing QLineEdit::home.

This commit is contained in:
Florian Bruhin 2014-09-03 21:30:30 +02:00
parent e3bb3af7ba
commit 15b8c553c8

View File

@ -85,6 +85,13 @@ class CommandLineEdit(QLineEdit):
self._validator.prompt = text
self._promptlen = len(text)
def home(self, mark):
"""Override home so it works properly with our cursor restriction."""
oldpos = self.cursorPosition()
self.setCursorPosition(self._promptlen)
if mark:
self.setSelection(self._promptlen, oldpos - self._promptlen)
def __repr__(self):
return '<{} "{}">'.format(self.__class__.__name__, self.text())