Add a way to set the escape timeout directly to stdin
まだ誰も着手していません。
- 主要言語
- JavaScript
- スター
- 122k
- フォーク
- 37.3k
- 平均マージ
- 4日 2時間
- マージ済み PR(30日)
- 283
説明
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:
- use a custom ReadLine interface with the
escapeCodeTimeoutvalue 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". - 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" =)
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、stdin のキー押下処理を追跡し、ReadLine インターフェースが escapeCodeTimeout オプションをどのように使用しているかを確認します。その動作を、issue で説明されている stdin の別個の data イベント経路と比較します。stdin に、ゼロを含む escape timeout を設定するための文書化された方法が用意され、カスタムの ReadLine インターフェースや別個の data ハンドラーなしで escape を即座にトリガーできれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- javascript, nodejs
- 領域
- cli
- issue の種類
- 機能追加
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 静か
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 48/100