summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2011-02-15 20:25:32 +0100
committerFlorent Le Coz <louiz@louiz.org>2011-02-15 20:25:32 +0100
commit36094c15cf49d0a210a817c6d2f729d99fdc9c3a (patch)
tree906cbdb4faf94021561016c3fa6cbeef615c3b29 /src
parent690d4495605d8b5820eac3f3c88af1a82c93f248 (diff)
downloadpoezio-36094c15cf49d0a210a817c6d2f729d99fdc9c3a.tar.gz
poezio-36094c15cf49d0a210a817c6d2f729d99fdc9c3a.tar.bz2
poezio-36094c15cf49d0a210a817c6d2f729d99fdc9c3a.tar.xz
poezio-36094c15cf49d0a210a817c6d2f729d99fdc9c3a.zip
Keyboard can now read all shortcuts with Ctrl (e.g Ctrl+left)
Any unicode character is accepted after the meta key The meta key can be concatened until a non-meta key is pressed (e.g M-M-M-M-M-M-M-M-e)
Diffstat (limited to 'src')
-rw-r--r--src/keyboard.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/keyboard.py b/src/keyboard.py
index 09652c4c..188e65eb 100644
--- a/src/keyboard.py
+++ b/src/keyboard.py
@@ -50,10 +50,12 @@ def read_char(s):
if first <= 26: # transform Ctrl+* keys
return "^"+chr(first + 64)
if first == 27:
- (first, c) = get_next_byte(s)
- if not isinstance(first, int):
- return None
- return "M-"+chr(first)
+ second = read_char(s)
+ res = 'M-%s' % (second,)
+ if second == '[':
+ for i in range(4):
+ res += read_char(s)
+ return res
if 194 <= first:
(code, c) = get_next_byte(s) # 2 bytes char
char += c
@@ -71,6 +73,10 @@ def read_char(s):
if __name__ == '__main__':
import curses
s = curses.initscr()
+ curses.curs_set(1)
+ curses.noecho()
+ curses.nonl()
+ s.keypad(True)
curses.noecho()
while True:
s.addstr('%s\n' % read_char(s))