curses woes

Iñigo Serna inigoserna at terra.es
Tue Jul 10 19:06:29 EDT 2001


El día 10 Jul 2001 12:11:39 +0400, Oleg Broytmann escribió
> On Tue, 10 Jul 2001, Rainy wrote:
> > while 1:
> >     c = win.getch()
> >     if c == curses.KEY_BACKSPACE:
> >         do_something()
> >
> > The problem is that backspace key shows up as ^? and doesn't match the above
> > test. I also tried doing c == 14 but also without luck. I'm using
> > curses.wrapper() here.
> 
>    Your terminal is incorrectly configured.
> 
> man 5 terminfo
> man tic
> man stty

you can use

print 'key: \'%s\' <=> %c <=> 0x%X <=> %d' % (curses.keyname(c), c & 255, c, c)

to learn the key code which is generated and then use it in your code,
but, of course, this is the wrong way (tm).

In my system (a much-modified RedHat Linux 7.1 with ncurses-5.2-8),
backspace generates code 8 (Ctrl-H) in xterm and gnome-terminal, but
curses.KEY_BACKSPACE in rxvt.

Greetings,

Iñigo Serna






More information about the Python-list mailing list