fixed #1123

parent ad00f721
......@@ -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 <show> [status]\nStatus: Change your availability and (optionnaly) your status. The <show> argument is one off "dnd, busy, away, afk, "'),
'nick': (self.command_nick, 'Usage: /nick <nickname>\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()
......
......@@ -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:]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment