tests/curses_keycodes.py
author Radek Brich <radek.brich@devl.cz>
Mon, 01 Sep 2014 08:45:51 +0200
changeset 104 742e504ec053
parent 65 5f0697950f15
child 110 cf3d49cdd6e2
permissions -rwxr-xr-x
Update TextBox: Replace "spot" with "cursor".

#!/usr/bin/python
# -*- coding: utf-8 -*-

import curses
import locale

locale.setlocale(locale.LC_ALL,"")

def doStuff(screen):
    screen.addstr('termname: %s\n' % curses.termname())
    screen.keypad(0)
    screen.scrollok(1)
    curses.nl()
    curses.mousemask(curses.ALL_MOUSE_EVENTS | curses.REPORT_MOUSE_POSITION)
    while True:
        c = screen.getch()
        s = ''

        screen.nodelay(1)
        while c != -1:
            try:
                s += chr(c)
            except ValueError:
                s += '?'
            screen.addstr('0x%02x,' % c)
            c = screen.getch()
        screen.nodelay(0)

        screen.addstr(' %r\n' % s)

        screen.refresh()

curses.wrapper(doStuff)