From af651cbc46e5227ff815689ee7cf3ce4b3ffe0be Mon Sep 17 00:00:00 2001 From: "louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13" Date: Thu, 6 Jan 2011 20:46:38 +0000 Subject: =?UTF-8?q?MessageInput=20now=20have=20a=20'draft'=20option.=20Whe?= =?UTF-8?q?n=20you're=20typing=20a=20new=20message,=20=E2=86=91=20and=20?= =?UTF-8?q?=E2=86=93=20will=20keep=20the=20unfinished=20(and=20unsent)=20m?= =?UTF-8?q?essage=20in=20the=20history.=20fixed=20#1852?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/windows.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'src') 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): -- cgit v1.2.3