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)
This commit is contained in:
parent
690d449560
commit
36094c15cf
1 changed files with 10 additions and 4 deletions
|
@ -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))
|
||||
|
|
Loading…
Reference in a new issue