nodejs / nodejs/node

Add a way to set the escape timeout directly to stdin

Aperta
#63,990 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

feature request
Lingua principale
JavaScript
Stelle
122k
Fork
37.3k
Merge medio
4g 2h
PR unite (30g)
283

Descrizione

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" =)

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia tracciando la gestione della pressione dei tasti di stdin e il modo in cui l’interfaccia ReadLine utilizza la sua opzione escapeCodeTimeout. Confronta questo comportamento con il percorso separato dell’evento data di stdin descritto nell’issue. Il lavoro è completato quando stdin espone un modo documentato per impostare il timeout di escape, incluso a zero, in modo che escape possa attivarsi immediatamente senza un’interfaccia ReadLine personalizzata o un gestore data separato.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
javascript, nodejs
Ambito
cli
Tipo di issue
Funzionalità
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Tranquilla
Chiarezza
Abbastanza chiara
Idoneità per principianti
48/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.