quelques fixs, genre l'historique et les accents et tout ca

This commit is contained in:
louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13 2010-01-27 21:44:48 +00:00
parent 9275ded333
commit 5137f86445
4 changed files with 22 additions and 10 deletions

View file

@ -25,7 +25,8 @@ from handler import Handler
from gui import Gui
from curses import wrapper, initscr
sys.stderr = open('/dev/null', 'a')
if len(sys.argv) == 1: # not debug, so hide any error message
sys.stderr = open('/dev/null', 'a')
class Client(object):
"""

View file

@ -145,10 +145,10 @@ class Gui(object):
while 1:
curses.doupdate()
key = stdscr.getkey()
if key == curses.KEY_RESIZE:
self.window.resize(stdscr)
elif str(key) in self.key_func.keys():
if str(key) in self.key_func.keys():
self.key_func[key]()
elif len(key) >= 4:
continue
elif ord(key) == 10:
self.execute()
else:

View file

@ -3,5 +3,6 @@ logfile = logs
resource = poezio
server = louiz.org
port = 5222
rooms = discussion@kikoo.louiz.org/Poefion:test@chat.jabberfr.org/pd
rooms = discussion@kikoo.louiz.org/poetest

View file

@ -142,9 +142,11 @@ class TextWin(object):
break
win.addstr('\n['+line[0].strftime("%H:%M:%S") + "] <")
length = len('['+line[0].strftime("%H:%M:%S") + "] <")
win.attron(curses.color_pair(user.color))
try:win.attron(curses.color_pair(user.color))
except:pass
win.addstr(line[1])
win.attroff(curses.color_pair(user.color))
try:win.attroff(curses.color_pair(user.color))
except:pass
win.addstr("> ")
win.addstr(line[2])
@ -175,11 +177,19 @@ class Input(Win):
self.input.insert_mode = True
self.win.clear()
def key_dc(self):
"""delete char"""
if self.pos == len(self.text):
return
(y, x) = self.win.getyx()
self.text = self.text[:self.pos]+self.text[self.pos+1:]
self.win.delch(y, x-1)
def key_up(self):
self.win.clear()
if self.histo_pos >= 0:
self.histo_pos -= 1
self.win.addstr(self.history[self.histo_pos+1])
self.win.addstr(self.history[self.histo_pos+1].encode('utf-8'))
self.text = self.history[self.histo_pos+1]
self.pos = len(self.text)
self.refresh()
@ -188,7 +198,7 @@ class Input(Win):
self.win.clear()
if self.histo_pos < len(self.history)-1:
self.histo_pos += 1
self.win.addstr(self.history[self.histo_pos])
self.win.addstr(self.history[self.histo_pos].encode('utf-8'))
self.text = self.history[self.histo_pos]
self.pos = len(self.text)
else:
@ -242,7 +252,7 @@ class Input(Win):
self.pos = 0
self.history.append(txt)
self.histo_pos = len(self.history)-1
return txt
return txt.encode('utf-8')
def save_text(self):
self.txt = self.input.gather()