summaryrefslogtreecommitdiff
path: root/src/window.py
diff options
context:
space:
mode:
authorlouiz@4325f9fc-e183-4c21-96ce-0ab188b42d13 <louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13>2010-01-27 19:46:08 +0000
committerlouiz@4325f9fc-e183-4c21-96ce-0ab188b42d13 <louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13>2010-01-27 19:46:08 +0000
commit9275ded3338b6f1fa356aaa4ee306dcb1e20b019 (patch)
treef1973ac2e25be977cbd964a10302d6481ca96860 /src/window.py
parent038038b728f7e6c4aaf5e24c85bf7047532a3aad (diff)
downloadpoezio-9275ded3338b6f1fa356aaa4ee306dcb1e20b019.tar.gz
poezio-9275ded3338b6f1fa356aaa4ee306dcb1e20b019.tar.bz2
poezio-9275ded3338b6f1fa356aaa4ee306dcb1e20b019.tar.xz
poezio-9275ded3338b6f1fa356aaa4ee306dcb1e20b019.zip
historique, edition de ligne correcte, affichage du texte OK, gestion des caracteres unicodes (reception et envoie) et d'autres trucs
Diffstat (limited to 'src/window.py')
-rw-r--r--src/window.py77
1 files changed, 68 insertions, 9 deletions
diff --git a/src/window.py b/src/window.py
index 5699151f..97c1f6d0 100644
--- a/src/window.py
+++ b/src/window.py
@@ -162,10 +162,12 @@ class Input(Win):
"""
def __init__(self, height, width, y, x, stdscr):
Win.__init__(self, height, width, y, x, stdscr)
- self.input = curses.textpad.Textbox(self.win)
- self.input.insert_mode = True
- self.win.keypad(True)
- self.text = ''
+ # self.input = curses.textpad.Textbox(self.win)
+ # self.input.insert_mode = True
+ self.history = []
+ self.text = u''
+ self.pos = 0
+ self.histo_pos = 0
def resize(self, height, width, y, x, stdscr):
self._resize(height, width, y, x, stdscr)
@@ -173,16 +175,73 @@ class Input(Win):
self.input.insert_mode = True
self.win.clear()
- def add_char(self, char):
- self.text += char
+ 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.text = self.history[self.histo_pos+1]
+ self.pos = len(self.text)
+ self.refresh()
+
+ def key_down(self):
+ self.win.clear()
+ if self.histo_pos < len(self.history)-1:
+ self.histo_pos += 1
+ self.win.addstr(self.history[self.histo_pos])
+ self.text = self.history[self.histo_pos]
+ self.pos = len(self.text)
+ else:
+ self.histo_pos = len(self.history)-1
+ self.text = u''
+ self.pos = 0
+ self.refresh()
+
+ def key_home(self):
+ self.pos = 0
+ self.win.move(0, 0)
+ self.refresh()
+
+ def key_end(self):
+ self.pos = len(self.text)
+ 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)
+ 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)
+ self.refresh()
+
+ def key_backspace(self):
+ (y, x) = self.win.getyx()
+ if len(self.text) > 0 and self.pos != 0:
+ self.text = self.text[:self.pos-1]+self.text[self.pos:]
+ self.pos -= 1
+ self.win.delch(y, x-1)
+ self.refresh()
def do_command(self, key):
- self.text += chr(key)
- self.input.do_command(key)
+ (y, x) = self.win.getyx()
+ self.text = self.text[:self.pos]+key.decode('utf-8')+self.text[self.pos:]
+ self.win.insstr(key)
+ self.win.move(y, x+1)
+ self.pos += 1
def get_text(self):
txt = self.text
- self.text = ''
+ self.text = u''
+ self.pos = 0
+ self.history.append(txt)
+ self.histo_pos = len(self.history)-1
return txt
def save_text(self):