Keyboard reading modified #143
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
When using the Spy prompt in a terminal, pressing Delete (and other navigation keys) inserted a literal ~ instead of doing the expected action.
This happened because those keys on Linux terminals send a multi-byte sequence like ESC [ 3 ~. Our code read up to the number (which was before not recognized by code) but didn’t consume the final ~, so it got echoed on screen.
Changes introduced in this PR
Linux terminal:
ESC [ 2 ~ → Insert: now cleanly ignored
ESC [ 3 ~ → Delete: delete char at cursor
ESC [ 5 ~ → Page Up: previous command in history
ESC [ 6 ~ → Page Down: next command in history / clear if none
ESC [ H → Home: move cursor to start of line
ESC [ F → End: move cursor to end of line
Windows console:
Insert = 82 (ignored)
Delete = 83
Page Up = 73
Page Down = 81
Home = 71
End = 79