terminal
terminal copied to clipboard
Add support for DECARM (Auto Repeat Mode)
Summary of the Pull Request
This PR adds support for the DECARM (Auto Repeat Mode) sequence, which
controls whether a keypress automatically repeats if you keep it held
down for long enough.
References
Note that this won't fully work in Windows Terminal until issue #8440 is resolved.
PR Checklist
- [x] Closes #13919
- [x] CLA signed.
- [x] Tests added/passed
- [ ] Documentation updated.
- [ ] Schema updated.
- [x] I've discussed this with core contributors already. Issue number where discussion took place: #13919
Detailed Description of the Pull Request / Additional comments
Every time we receive a KeyDown event, we record the virtual key code
to track that as the last key pressed. If we receive a KeyUp event the
matches that last key code, we reset that field. Then if the Auto Repeat
Mode is reset, and we receive a KeyDown event that matches the last
key code, we simply ignore it.
Validation Steps Performed
I've manually tested the DECARM functionality in Vttest and confirmed
that it's working as expected. Although note that in Windows Terminal
this only applies to non-alphanumeric keys for now (e.g. Tab, BackSpace,
arrow keys, etc.)
I've also added a basic unit test that verifies that repeated key
presses are suppressed when the DECARM mode is disabled.