Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Esc-F1 in menu inserts string 'OP' into buffer #15

Closed
jooadam opened this issue Jul 2, 2016 · 6 comments
Closed

Esc-F1 in menu inserts string 'OP' into buffer #15

jooadam opened this issue Jul 2, 2016 · 6 comments

Comments

@jooadam
Copy link
Contributor

jooadam commented Jul 2, 2016

Hitting Esc followed by F1 (without waiting for Esc to time out) while the menu is open, inserts the literal string 'OP' into the buffer at the cursor position.

I’m not sure if this is a feature :)

@jooadam jooadam changed the title Esc-F1 in menu inserts string 'OP' insto buffer Esc-F1 in menu inserts string 'OP' into buffer Jul 4, 2016
@vigna
Copy link
Owner

vigna commented Jul 6, 2016

There's no way to avoid that. There's no way to know whether you genuinely hit ESC twice to exit the menus, and then wrote "OP", or if you hit ESC and F1.

@vigna vigna closed this as completed Jul 6, 2016
@jooadam
Copy link
Contributor Author

jooadam commented Jul 7, 2016

@vigna Can you elaborate, just so that I understand what happens here?

@utoddl
Copy link
Collaborator

utoddl commented Jul 8, 2016

A GUI editor can receive "events" from the GUI, so it can tell that a user hit a key with or without these modifiers (left or right shift, alt, "Win", ctrl, etc.) at a particular timestamp, followed by another and another and another.

A terminal editor does not see keystrokes. It sees instead a stream of bytes arriving at irregular intervals. When you hit F1 for example, an "escape sequence" is generated, i.e. a stream of bytes starting with Esc and followed by, in this case "O" and "P". F1 generates Esc, "O", and "Q" on my system. Ctrl-F1 generates Esc, "[", "1", ";", "5", and "P".

The thing is, except for the timing, there's no clue as to whether I hit "Ctrl-F1" or "Esc" followed by the keys "[", "1", ";", "5", and "P".

In the case you're describing, ne is seeing Esc, Esc, "O", and "P". Is that four separate keystrokes, or Esc followed by F1? There's no way to know. One thing that is known, though, is that no defined escape sequences contain escapes anywhere but at the beginning. Ne sees the first Esc, then waits up to the default EscapeTime/10 seconds (see "Help EscapeTime") for the rest of the escape sequence to come in. You throw Esc, "O" and "P" into the stream, and ne sees the 2nd Esc and figures you hit Esc twice (which is what people use instead of F1when they can't use F1 for other reasons to bring up the menu).

I'm going to stop typing now, but this is why we can't distinguish between, say, left and right ctrl keys on stream input: we can't see any modifier keys, just bytes.

Does that help?

@jooadam
Copy link
Contributor Author

jooadam commented Jul 11, 2016

@utoddl Yeah, it’s clear now, thanks. Am I right that this could have been avoided if ESC is not allowed anywhere except as the first character of an escape sequence, i.e. if ESC, ESC is not defined? If so, is there some particular reasoning for using it, or was it just a mistake?

@utoddl
Copy link
Collaborator

utoddl commented Jul 11, 2016

We're spoiled by our fancy 101+ key keyboards, but not all terminals are so blessed. The ADM3a terminal I started on had NO function keys. Esc was it. A user on such a terminal can hit Esc and wait for EscapeTimeout/10 seconds -- or hit Esc twice -- to get a menu. Given the problem, I think the double-Esc is a pretty good choice.

Is there a compelling need to hit Esc-F1 while in a menu? Even with boxing gloves on, StrongBad can hit single keys. Hit Esc twice. Or hit F1. You'll be happier.

@jooadam
Copy link
Contributor Author

jooadam commented Jul 11, 2016

Well, on a limited terminal the user could – as a last resort – manually enter the sequence with which there’s no key associated or maybe a sequence defined by ne specifically for this purpose.

There’s no need really, I must have hit them by accident, and I was wondering if it was a bug, and if not, what’s the underlying reason. At this point I’m just trying to understand the design decisions ne took.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants