how does vim distinguish ESC key from the escape sequence ?

Programming, for all ages and all languages.
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: how does vim distinguish ESC key from the escape sequenc

Post by Brendan »

Hi,
Sik wrote:I honestly hate how terminals handle keystrokes for anything that isn't a normal character. I get it about old terminals, but how come none of the extensions over time ever fixed this mess? >​:​|
That's easy: it'd be like building a cable car on Mount Everest to make it easy for people to reach the top. Anything that makes the user interface slightly more user-friendly removes the ability for people to brag about mastering one of the worst possible user interfaces ever designed, so it'd ruin the entire point of using VIM in the first place.


Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: how does vim distinguish ESC key from the escape sequenc

Post by Solar »

My, aren't we confrontational today?

Nobody is trying to force you into using Vim, or anything other than your editor (or language, or compiler, or operating system, or interface in general) of choice.

Could you please refrain from calling those who made other choices than you names?
Every good solution is obvious once you've found it.
User avatar
Sik
Member
Member
Posts: 251
Joined: Wed Aug 17, 2016 4:55 am

Re: how does vim distinguish ESC key from the escape sequenc

Post by Sik »

Yeah, my complaint wasn't even about vim (which I don't like but that's another topic), it was about terminal protocols themselves. It makes it a freaking pain to make TUI programs. It's not just the users who get screwed over it, it's also the developers who now have to restrict what they're allowed to do. That's not fun.

Amusingly, my suggestion would have made things easier for vim (as it could just check for CAN instead of doing the timing stuff and hope the stream isn't too laggy to screw that up). One can dream.
User avatar
eekee
Member
Member
Posts: 872
Joined: Mon May 22, 2017 5:56 am
Location: Kerbin
Discord: eekee
Contact:

Re: how does vim distinguish ESC key from the escape sequenc

Post by eekee »

Wow! So much waffle! And this from a guy who's waffled more than anyone else today! :twisted:

The simple answer to the original question is plainly visible if you use any vi in a TTY: it waits to see if there's a character coming immediately after the escape.

I've repeatedly found that delay to be a nuisance, temporarily confusing and alarming me as the editor gets behind my typing, and I curse the day DEC decided to use the escape character in their key sequences. It throws off my train of thought!

As for why it's such a long delay, I can only imagine it's designed to work with 75 baud serial lines, or maybe laggy ssh sessions.
Kaph — a modular OS intended to be easy and fun to administer and code for.
"May wisdom, fun, and the greater good shine forth in all your work." — Leo Brodie
Post Reply