diff options
author | louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13 <louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13> | 2011-01-06 20:46:38 +0000 |
---|---|---|
committer | louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13 <louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13> | 2011-01-06 20:46:38 +0000 |
commit | af651cbc46e5227ff815689ee7cf3ce4b3ffe0be (patch) | |
tree | f9ba624f54baa24f1e2044a6d3e3c7afdcc2df7a | |
parent | c2344d0d339bd3538be1210b841e0340ca3b44a2 (diff) | |
download | poezio-af651cbc46e5227ff815689ee7cf3ce4b3ffe0be.tar.gz poezio-af651cbc46e5227ff815689ee7cf3ce4b3ffe0be.tar.bz2 poezio-af651cbc46e5227ff815689ee7cf3ce4b3ffe0be.tar.xz poezio-af651cbc46e5227ff815689ee7cf3ce4b3ffe0be.zip |
MessageInput now have a 'draft' option. When you're typing a new message, ↑ and ↓ will keep the unfinished (and unsent) message in the history. fixed #1852
-rw-r--r-- | src/windows.py | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/windows.py b/src/windows.py index dc4092f2..b6113bf0 100644 --- a/src/windows.py +++ b/src/windows.py @@ -1024,9 +1024,12 @@ class MessageInput(Input): """ Get the previous line in the history """ - if not len(MessageInput.history): - return self.reset_completion() + if self.histo_pos == -1 and self.get_text(): + if not MessageInput.history or MessageInput.history[0] != self.get_text(): + # add the message to history, we do not want to lose it + MessageInput.history.insert(0, self.get_text()) + self.histo_pos += 1 if self.histo_pos < len(MessageInput.history) - 1: self.histo_pos += 1 self.text = MessageInput.history[self.histo_pos] @@ -1036,12 +1039,16 @@ class MessageInput(Input): """ Get the next line in the history """ - if not len(MessageInput.history): - return self.reset_completion() if self.histo_pos > 0: self.histo_pos -= 1 self.text = MessageInput.history[self.histo_pos] + elif self.histo_pos <= 0 and self.get_text(): + if not MessageInput.history or MessageInput.history[0] != self.get_text(): + # add the message to history, we do not want to lose it + MessageInput.history.insert(0, self.get_text()) + self.text = '' + self.histo_pos = -1 self.key_end() def key_enter(self): |