EscTimeoutInVi

HomePage | RecentChanges | EditorIndex | TextEditorFamilies | Preferences

The most annoying problem with implementing a modal editor for a modern keyboard is that the escapec key is used twice: as the key to enter command mode and as the start of an escape sequence like an arrow key would typically send.

The result of this is that to implement a responsive vi-like editor you need to set a timeout before you decide the user just pressed escape and not a arrow key. This timeout will always fail under certain circumstances !

Of course one could wait with evaluating the escape till the next character is known but this will feel very bad to the user because the editor doesn't seem to respond at first.

So maybe vi should have had an other key for command mode, or keyboard designers should have taken another control char for their sequences instead of the escape (which is control-[ itself), but that's history :(


Well, part of the problem is that we use VI like editors in terminal emulators that are simulating a computing environment that is now 30+ years old where ESC [ A and ESC [ 7 0 m mean things! Thus, there has to be a bit of a delay to determine if the escape was a single keystroke or part of a compound key. Since VI actually uses ESC for a purpose, it causes problems. -- RonPerrella


The \e[ stuff was all part of the ANSI 3.64 standard for terminal controls. "Dumb" terminals fell into two general categories: ASCII and ANSI terminals. The DEC VT52 was the canonical ASCII terminal, and the VT-100 was the canonical ANSI terminal. No terminal I'm aware implemented all of ANSI 3.64.

Under MS-DOS, the ANSI.SYS driver provided a subset of ANSI escape sequences, and a variety of programs used it. Replacements for ANSI.SYS soon appeared, like Dan Kegel's NANSI.SYS, which was faster, and added the VT-102 Add Line and Delete Line instructions. The shareware FANSI Conso9le product claimed to implement the entire ANSI 3.64 specification.

ANSI terminals were a step up from ASCII devices when supporting terminals on Unix. Consider the Wyse 50 termianl, an ASCII device. Both the back space key and the left arrow key sent Control-H when pressed, which made distinguishing between them impossible. --DMcCunney


Note that emacs has a similar problem with CTRL-S and CTRL-Q, which are normally used for flow-control on serial lines. Today, that's quite unnecessary since flow control is done through hardware. However, I'm always surprised at how many systems still use XonXoff? flow control. -- RonPerrella
Richard Stallman flatly refused to alter the emacs key assignments to free Ctrl-S and Ctrl-Q for flow control. He felt any terminal that required that was broken, as it should be done in hardware, and he wasn't going to support broken equipment.

Terminals I've dealt with could use software or hardware flow control. I used hardware flow control where possible. --DMcCunney


HomePage | RecentChanges | EditorIndex | TextEditorFamilies | Preferences
Edit text of this page | View other revisions
Last edited September 27, 2008 11:43 pm (diff)
Search: