From e273c57235c6007de13fa2fccf757e06c70d43dd Mon Sep 17 00:00:00 2001 From: "louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13" Date: Sun, 31 Jan 2010 00:25:17 +0000 Subject: fixed #1123 --- src/gui.py | 9 ++++++++- src/window.py | 31 +++++++++++++++++++++++++++---- 2 files changed, 35 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/gui.py b/src/gui.py index d8fb8cb4..3f6de323 100644 --- a/src/gui.py +++ b/src/gui.py @@ -169,6 +169,7 @@ class Gui(object): 'next': (self.rotate_rooms_left, 'Usage: /next\nNext: Go to the next room.'), 'prev': (self.rotate_rooms_right, 'Usage: /prev\nPrev: Go to the previous room.'), 'part': (self.command_part, 'Usage: /part [message]\nPart: disconnect from a room. You can specify an optionnal message.'), + 'show': (self.command_show, 'Usage: /show [status]\nStatus: Change your availability and (optionnaly) your status. The argument is one off "dnd, busy, away, afk, "'), 'nick': (self.command_nick, 'Usage: /nick \nNick: Change your nickname in the current room') } @@ -306,7 +307,10 @@ class Gui(object): room = self.get_room_by_name(from_room) if not room: self.information("presence received for a non-existing room: %s" % (name)) - msg = room.on_presence(stanza, from_nick) + if stanza.getType() == 'error': + msg = "Error: %s" % stanza.getError() + else: + msg = room.on_presence(stanza, from_nick) if room == self.current_room(): self.window.text_win.add_line(room, (datetime.now(), msg)) self.window.text_win.refresh(room.name) @@ -381,6 +385,9 @@ class Gui(object): if not r: # if the room window exists, we don't recreate it. self.join_room(room, nick) + def command_show(self, args): + pass + def command_part(self, args): reason = None room = self.current_room() diff --git a/src/window.py b/src/window.py index c4774342..5f599790 100644 --- a/src/window.py +++ b/src/window.py @@ -215,26 +215,49 @@ class Input(Win): def key_home(self): self.pos = 0 + if len(self.text) >= self.width-1: + txt = self.text[:self.width-1] + self.clear_text() + self.win.addstr(txt) self.win.move(0, 0) self.refresh() def key_end(self): self.pos = len(self.text) - self.win.move(0, len(self.text)) + if len(self.text) >= self.width-1: + txt = self.text[-(self.width-1):] + self.clear_text() + self.win.addstr(txt) + self.win.move(0, self.width-1) + else: + self.win.move(0, len(self.text)) self.refresh() def key_left(self): (y, x) = self.win.getyx() if self.pos > 0: self.pos -= 1 - self.win.move(y, x-1) + if x == 0: + txt = self.text[self.pos:self.pos+self.width-1] + self.clear_text() + self.win.addstr(txt) + self.win.move(y, 0) + else: + self.win.move(y, x-1) self.refresh() def key_right(self): (y, x) = self.win.getyx() if self.pos < len(self.text): self.pos += 1 - self.win.move(y, x+1) + if x == self.width-1: + txt = self.text[self.pos-(self.width-1):self.pos] + open('fion', 'w').write(txt) + self.clear_text() + self.win.addstr(txt) + self.win.move(y, self.width-1) + else: + self.win.move(y, x+1) self.refresh() def key_backspace(self): @@ -249,7 +272,7 @@ class Input(Win): (y, x) = self.win.getyx() if x == self.width-1: self.win.delch(0, 0) - self.win.move(y, x) + self.win.move(y, x-1) x -= 1 try: self.text = self.text[:self.pos]+key.decode('utf-8')+self.text[self.pos:] -- cgit v1.2.3