nodejs / nodejs/node

Add a way to set the escape timeout directly to stdin

Abierto
#63,990 1 comentario 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

feature request
Lenguaje dominante
JavaScript
Estrellas
122k
Forks
37.3k
Merge medio
4 d 2 h
PR fusionados (30 d)
283

Descripción

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

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Empieza rastreando el manejo de las pulsaciones de teclas de stdin y cómo la interfaz ReadLine utiliza su opción escapeCodeTimeout. Compara ese comportamiento con la ruta independiente del evento de datos de stdin descrita en el issue. Se considera terminado cuando stdin expone una forma documentada de establecer el tiempo de espera de escape, incluido el valor cero, de modo que escape pueda activarse inmediatamente sin una interfaz ReadLine personalizada ni un manejador de datos independiente.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
javascript, nodejs
Área
cli
Tipo de issue
Nueva funcionalidad
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Tranquilo
Claridad
Bastante claro
Aptitud para principiantes
48/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.