author | Radek Brich <radek.brich@devl.cz> |
Sun, 15 Feb 2015 12:48:23 +0100 | |
changeset 114 | 26c02bd94bd9 |
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:
20
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('%s\n' % curses.termname()) |
|
10 |
screen.keypad(1) |
|
11 |
screen.scrollok(1) |
|
12 |
curses.nl() |
|
13 |
curses.mousemask(curses.ALL_MOUSE_EVENTS | curses.REPORT_MOUSE_POSITION) |
|
14 |
curses.mouseinterval(0) # do not wait to detect clicks, we use only press/release |
|
15 |
while True: |
|
16 |
c = screen.getch() |
|
17 |
char = ' ' |
|
18 |
if c < 256: |
|
19 |
char = curses.unctrl(c) |
|
20 |
screen.addstr('key: %x %s\n' % (c, char)) |
|
21 |
||
22 |
if c == curses.KEY_MOUSE: |
|
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:
20
diff
changeset
|
23 |
id_, x, y, z, bstate = curses.getmouse() |
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:
20
diff
changeset
|
24 |
screen.addstr('(%d %d %d %d %s)\n' % (id_, x, y, z, bin(bstate))) |
19 | 25 |
|
26 |
screen.refresh() |
|
27 |
||
28 |
curses.wrapper(doStuff) |