author | Radek Brich <radek.brich@devl.cz> |
Wed, 23 Jan 2013 00:50:23 +0100 | |
changeset 65 | 5f0697950f15 |
parent 20 | 472a753664f9 |
child 110 | cf3d49cdd6e2 |
permissions | -rwxr-xr-x |
19 | 1 |
#!/usr/bin/python |
2 |
# -*- coding: utf-8 -*- |
|
3 |
||
4 |
import curses |
|
5 |
import locale |
|
6 |
||
7 |
locale.setlocale(locale.LC_ALL,"") |
|
8 |
||
9 |
def doStuff(screen): |
|
10 |
screen.addstr('termname: %s\n' % curses.termname()) |
|
11 |
screen.keypad(0) |
|
12 |
screen.scrollok(1) |
|
13 |
curses.nl() |
|
14 |
curses.mousemask(curses.ALL_MOUSE_EVENTS | curses.REPORT_MOUSE_POSITION) |
|
15 |
while True: |
|
16 |
c = screen.getch() |
|
65
5f0697950f15
DriverCurses: Add support for key modifiers.
Radek Brich <radek.brich@devl.cz>
parents:
20
diff
changeset
|
17 |
s = '' |
19 | 18 |
|
19 |
screen.nodelay(1) |
|
20 |
while c != -1: |
|
65
5f0697950f15
DriverCurses: Add support for key modifiers.
Radek Brich <radek.brich@devl.cz>
parents:
20
diff
changeset
|
21 |
try: |
5f0697950f15
DriverCurses: Add support for key modifiers.
Radek Brich <radek.brich@devl.cz>
parents:
20
diff
changeset
|
22 |
s += chr(c) |
5f0697950f15
DriverCurses: Add support for key modifiers.
Radek Brich <radek.brich@devl.cz>
parents:
20
diff
changeset
|
23 |
except ValueError: |
5f0697950f15
DriverCurses: Add support for key modifiers.
Radek Brich <radek.brich@devl.cz>
parents:
20
diff
changeset
|
24 |
s += '?' |
19 | 25 |
screen.addstr('0x%02x,' % c) |
26 |
c = screen.getch() |
|
27 |
screen.nodelay(0) |
|
28 |
||
65
5f0697950f15
DriverCurses: Add support for key modifiers.
Radek Brich <radek.brich@devl.cz>
parents:
20
diff
changeset
|
29 |
screen.addstr(' %r\n' % s) |
19 | 30 |
|
31 |
screen.refresh() |
|
32 |
||
33 |
curses.wrapper(doStuff) |