Giter VIP home page Giter VIP logo

Comments (6)

utoddl avatar utoddl commented on August 26, 2024 1

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.

vigna avatar vigna commented on August 26, 2024

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.

jooadam avatar jooadam commented on August 26, 2024

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

from ne.

jooadam avatar jooadam commented on August 26, 2024

@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.

utoddl avatar utoddl commented on August 26, 2024

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.

jooadam avatar jooadam commented on August 26, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.