From d184c555803b564148d8391b7a433acf891a8c87 Mon Sep 17 00:00:00 2001 From: Florent Le Coz Date: Tue, 15 Feb 2011 20:55:31 +0100 Subject: [PATCH] ^J now inserts a line break in the input. It is now possible to send multi-lines messages --- src/windows.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/windows.py b/src/windows.py index 45a6d22b..fa17d8ff 100644 --- a/src/windows.py +++ b/src/windows.py @@ -717,6 +717,7 @@ class Input(Win): "M-[1;5C": self.jump_word_right, "KEY_BACKSPACE": self.key_backspace, '^?': self.key_backspace, + '^J': self.add_line_break, } Win.__init__(self) self.text = '' @@ -1008,6 +1009,12 @@ class Input(Win): self.on_input(self.get_text()) return True + def add_line_break(self): + """ + Add a (real) \n to the line + """ + self.do_command('\n') + def get_text(self): """ Clear the input and return the text entered so far @@ -1019,10 +1026,11 @@ class Input(Win): Refresh the line onscreen, from the pos and pos_line """ with g_lock: + text = self.text.replace('\n', '|') self._win.erase() if self.color: self._win.attron(common.curses_color_pair(self.color)) - self.addstr(self.text[self.line_pos:self.line_pos+self.width-1]) + self.addstr(text[self.line_pos:self.line_pos+self.width-1]) if self.color: (y, x) = self._win.getyx() size = self.width-x