[Urwid] Changing interrupt and quit characters (untested low-level code)

Ian Ward ian at excess.org
Tue Jul 25 09:54:05 EDT 2006


Derek Peschel wrote:
> This little example keeps the signals on, and demonstrates how to change
> the quit character from ^\ to ^^ and the interrupt character from ^C to ^\.
> You get 'ctrl c' printouts if it works.  It is totally specific to POSIX
> and does a bad job of detecting errors.  I haven't tested it with raw_display
> or on any machine besides mine.  If you already have any signal set to ^^,
> it will stop working.  If you have any program (telnet or screen, say) that
> checks for ^^, Python won't get quit signals unless you have the program
> send another ^^.  But my code does two things right, thanks to curses and to
> a try/finally block: the changes are undone on exit, undone on suspend, and
> redone on resume.

Would you reorganize that code into remap_keyboard_interrupt() and 
restore_keyboard_interrupt() functions so that they can be used by other 
programs?  I'm sure other people would find that code useful and I'd be 
happy to post it with the Urwid examples if it was more generic.

Ian




More information about the Urwid mailing list