author | Radek Brich <radek.brich@devl.cz> |
Sat, 21 Feb 2015 12:01:57 +0100 | |
changeset 118 | 8c7970520632 |
parent 110 | cf3d49cdd6e2 |
permissions | -rwxr-xr-x |
110
cf3d49cdd6e2
Add cursesw driver, using curses get_wch() for unicode input. It alse has enabled keypad() to let curses interpret control keys and mouse input.
Radek Brich <radek.brich@devl.cz>
parents:
65
diff
changeset
|
1 |
#!/usr/bin/python3 |
19 | 2 |
|
3 |
import curses |
|
4 |
import locale |
|
5 |
||
6 |
locale.setlocale(locale.LC_ALL,"") |
|
7 |
||
8 |
def doStuff(screen): |
|
9 |
screen.addstr('termname: %s\n' % curses.termname()) |
|
10 |
screen.keypad(0) |
|
11 |
screen.scrollok(1) |
|
12 |
curses.nl() |
|
13 |
curses.mousemask(curses.ALL_MOUSE_EVENTS | curses.REPORT_MOUSE_POSITION) |
|
14 |
while True: |
|
15 |
c = screen.getch() |
|
65
5f0697950f15
DriverCurses: Add support for key modifiers.
Radek Brich <radek.brich@devl.cz>
parents:
20
diff
changeset
|
16 |
s = '' |
19 | 17 |
|
18 |
screen.nodelay(1) |
|
19 |
while c != -1: |
|
65
5f0697950f15
DriverCurses: Add support for key modifiers.
Radek Brich <radek.brich@devl.cz>
parents:
20
diff
changeset
|
20 |
try: |
5f0697950f15
DriverCurses: Add support for key modifiers.
Radek Brich <radek.brich@devl.cz>
parents:
20
diff
changeset
|
21 |
s += chr(c) |
5f0697950f15
DriverCurses: Add support for key modifiers.
Radek Brich <radek.brich@devl.cz>
parents:
20
diff
changeset
|
22 |
except ValueError: |
5f0697950f15
DriverCurses: Add support for key modifiers.
Radek Brich <radek.brich@devl.cz>
parents:
20
diff
changeset
|
23 |
s += '?' |
19 | 24 |
screen.addstr('0x%02x,' % c) |
25 |
c = screen.getch() |
|
26 |
screen.nodelay(0) |
|
27 |
||
65
5f0697950f15
DriverCurses: Add support for key modifiers.
Radek Brich <radek.brich@devl.cz>
parents:
20
diff
changeset
|
28 |
screen.addstr(' %r\n' % s) |
19 | 29 |
|
30 |
screen.refresh() |
|
31 |
||
32 |
curses.wrapper(doStuff) |