Proper handling of ESC

192 views
Skip to first unread message

Scott Gray

unread,
Mar 17, 2012, 7:16:24 PM3/17/12
to jline-dev
This might be considered a relatively radical solution for a mild
annoyance, but for users of the "vi" mode it might be a pretty
frustrating annoyance.

There is an ambiguity with the ESC key. It can either be a literal
ESC, as hit by the user, or it could be a component of a terminal
escape sequence. Given the ESC is a major aspect of vi, all of the vi
implementations (vi, vim, readline, etc.) take an approach where when
ESC is hit, they do a very brief read--typically just a couple of
ms.-- to see if another character is coming. If nothing is coming
then the ESC is assumed to be literal.

JLine currently takes the approach that it does not interpret the ESC
key at all until the next key/byte is received. If the ESC is followed
by a key that is not part of a terminal escape sequence, then it is
assumed to be a literal ESC.

The problem right now is that once ESC it hit, there is no cursor at
all on the terminal until another key is hit, so there is temporarily
no frame of reference. I can solve this in the same manner as vim and
readline, but only if I implement non-blocking or interruptable I/O
and, to do this, I need to use the Java New I/O libraries (with "new"
meaning a version that was released 10 years ago - 1.4).

Before I go investing time into exploring this route are there
concerns about switching to the "nio" API's? Given that even Java 1.4
is now officially deprecated, there technically shouldn't be any
arguments about backward compatibility (but, you never know!).

Jason Dillon

unread,
Mar 17, 2012, 7:30:50 PM3/17/12
to jlin...@googlegroups.com
BTW, for the most part we are only using the jline-users list. I was going to setup this for scm changes and such, but github + google groups are not very happy.

I'd recommend reposting this to jline-users.

Scott Gray

unread,
Mar 17, 2012, 7:32:44 PM3/17/12
to jlin...@googlegroups.com
LOL. I did notice a pretty poor membership., but I seem to remember a recent e-mail about "opening up discussion to the whole developer list".  No worries. I'll repost!
Reply all
Reply to author
Forward
0 new messages