David Clymer | 30 Apr 2005 16:22
Favicon
Gravatar

Urwid Esc handling

Is there a way to change how urwid (or maybe it's ncurses, I don't know)
does Esc detection? I'm writing a program with VI-like keybindings, so
Esc is used frequently to change between editing modes. Currently, I
have to hit Esc, then wait a approx 1 second before typing anything else
in order to make it clear to urwid that I am not attempting to enter a
control sequence of some sort. If there was a way to turn that off, it
would be mighty handy.

-davidc

Ian Ward | 30 Apr 2005 19:01
Favicon
Gravatar

Urwid Esc handling

David Clymer wrote:

>Is there a way to change how urwid (or maybe it's ncurses, I don't know)
>does Esc detection? I'm writing a program with VI-like keybindings, so
>Esc is used frequently to change between editing modes. Currently, I
>have to hit Esc, then wait a approx 1 second before typing anything else
>in order to make it clear to urwid that I am not attempting to enter a
>control sequence of some sort. If there was a way to turn that off, it
>would be mighty handy.
>
ncurses is responsible for the 1s delay.

In curses_display.py line line 182 reads:
   self.s.keypad(1)
change it to:
   self.s.keypad(0)

This turns off ncurses' interpretation of some escape sequences, which 
is a good thing, but I'll have to update curses_display.Screen to handle 
the escape sequences that ncurses was detecting (mostly F-keys and 
keypad keys).  I'll try to get this change into the next release.

You can run curses_display.py as a script to test keyboard input before 
and after the change.

Ian

David Clymer | 1 May 2005 01:51
Favicon
Gravatar

Urwid Esc handling

On Sat, 2005-04-30 at 16:57 -0400, Ian Ward wrote:
> David Clymer wrote:
> 
> >Is there a way to change how urwid (or maybe it's ncurses, I don't know)
> >does Esc detection? I'm writing a program with VI-like keybindings, so
> >Esc is used frequently to change between editing modes. Currently, I
> >have to hit Esc, then wait a approx 1 second before typing anything else
> >in order to make it clear to urwid that I am not attempting to enter a
> >control sequence of some sort. If there was a way to turn that off, it
> >would be mighty handy.
> >
> ncurses is responsible for the 1s delay.
> 
> In curses_display.py line line 182 reads:
>    self.s.keypad(1)
> change it to:
>    self.s.keypad(0)
> 
> This turns off ncurses' interpretation of some escape sequences, which 
> is a good thing, but I'll have to update curses_display.Screen to handle 
> the escape sequences that ncurses was detecting (mostly F-keys and 
> keypad keys).  I'll try to get this change into the next release.
> 
> You can run curses_display.py as a script to test keyboard input before 
> and after the change.

Many thanks. That does the trick for me.

-davidc

(Continue reading)

Ian Ward | 7 May 2005 15:40
Favicon
Gravatar

Urwid Esc handling

I've put up a patch with a new method of input handling:
http://excess.org/urwid/patch-0.8.7.1.diff

It can detect more escape sequences and should be easier for me to 
maintain. Now it builds a lexical trie from a "raw" list of escape 
sequences instead of passing keycodes into a deeply nested set of if 
statements.

It will wait 1/10s if it detects a partial escape sequence, so there is 
still a delay required after pressing ESC, but not a full second the way 
ncurses does it.

Ian


Gmane