Add a way to set the escape timeout directly to stdin
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- JavaScript
- Star
- 122k
- Fork
- 37.3k
- Merge trung bình
- 4 ngày 2 giờ
- Pull request đã merge (30 ngày)
- 283
Mô tả
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" =)
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu bằng cách lần theo việc xử lý phím nhấn của stdin và cách giao diện ReadLine sử dụng tùy chọn escapeCodeTimeout. So sánh hành vi đó với đường dẫn sự kiện data riêng biệt của stdin được mô tả trong issue. Công việc được xem là hoàn tất khi stdin cung cấp một cách có tài liệu để thiết lập thời gian chờ escape, bao gồm cả giá trị bằng không, ताकि escape có thể được kích hoạt ngay lập tức mà không cần giao diện ReadLine tùy chỉnh hoặc trình xử lý data riêng biệt.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- javascript, nodejs
- Lĩnh vực
- cli
- Loại issue
- Tính năng
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Ít trao đổi
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 48/100