nodejs / nodejs/node

Add a way to set the escape timeout directly to stdin

Offen
#63,990 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

feature request
Vorherrschende Sprache
JavaScript
Sterne
122k
Forks
37.3k
Ø Merge
4 T. 2 Std.
Gemergte PRs (30 T.)
283

Beschreibung

What is the problem this feature will solve?

Prevent extremely jarring terminal menu behaviour in contexts where "esc" is expected to immediately trigger exit behaviour, whether that's popping up a prompt or invoking process.exit (i.e. almost every terminal menu presented to users).

Especially in combination with input overloading so that "esc", "q", and "ctrl-x" all do the same thing, the fact that everything except escape is instant leads to an incredibly bad user experience.

What is the feature you are proposing to solve the problem?

Add a function to stdin that lets users explicitly set the escape timeout for that input. E.g. stdin.setEscapeTimeout(0)

What alternatives have you considered?

Two alternatives, neither good:

  1. use a custom ReadLine interface with the escapeCodeTimeout value set to zero. This is a hack for any code where "lines" don't mean anything, e.g. terminal menu navigation that relies on direct keyboard input rather than "text input where the user sees what they're typing and signals they are finished via newline".
  2. use a separate stdin.on(`data`, (d) => d.length === 1 && d[0] === 0x1b && process.exit()) event handler on top of keypress monitoring, just so we don't get stuck in whatever code path enforces the 500ms delay before sending "esc" on as keypress event. This works "great", but is obviously also a hack: one should not need "not a keypress listener" just to smooth over a problem with "keypress" =)

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne damit, die Verarbeitung von Tastendrücken über stdin nachzuverfolgen und zu untersuchen, wie die ReadLine-Schnittstelle ihre Option escapeCodeTimeout verwendet. Vergleiche dieses Verhalten mit dem im Issue beschriebenen separaten Pfad für das stdin-data-Ereignis. Als erledigt gilt die Aufgabe, wenn stdin eine dokumentierte Möglichkeit bietet, das Escape-Timeout einschließlich des Werts null festzulegen, sodass Escape sofort ausgelöst werden kann, ohne eine benutzerdefinierte ReadLine-Schnittstelle oder einen separaten data-Handler.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
javascript, nodejs
Bereich
cli
Issue-Typ
Feature
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Ruhig
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
48/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.