Comments (6)
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?
from ne.
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.
from ne.
@vigna Can you elaborate, just so that I understand what happens here?
from ne.
@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?
from ne.
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.
from ne.
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.
from ne.
Related Issues (20)
- Feature Request: Bracketed Paste Mode HOT 13
- [Question] Contribution Guidelines
- [Bug Report] Configured Coding Languages are not Highlighted HOT 2
- [Feature Request] copy current line HOT 3
- Avoid FTBFS when using binutils-gold HOT 1
- build fails in archlinux HOT 8
- copy-paste doesn't work well HOT 1
- yaml syntax highlighting of single-quoted strings incorrect HOT 2
- curses.h HOT 2
- Suggestion: preserve cur_buffer->find_string when playing a macro HOT 2
- compile ne for RiskV64 HOT 3
- Memory leak after opening file from file browser HOT 4
- [Feature Request] Soft wrapping Flag. HOT 1
- Single ESC breaks ne HOT 10
- Table of contents at the end? HOT 5
- [Feature Request] a way to move cursor to end of paste HOT 6
- "0x" prefix "tolerated" in ~/.ne/.keys file HOT 5
- autocomplete (or tab complete) macro names?
- truncation warning HOT 1
- Empty initializer list HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ne.