[PR #5021] [MERGED] Add enhanced key support for ConPty #26081

Open
opened 2026-01-31 09:13:48 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/5021
Author: @carlos-zamora
Created: 3/19/2020
Status: Merged
Merged: 3/24/2020
Merged by: @undefined

Base: masterHead: dev/cazamor/conpty/enhanced-key


📝 Commits (5)

  • b020f4b conpty: add enhanced key support
  • df38dc1 add testing and polish enhanced keys
  • 305ce4e don't allow CSI_F# to be enhanced
  • 0ca2c0d Griese PR Comments
  • dbec9b0 fix 'possible loss of data'

📊 Changes

3 files changed (+97 additions, -11 deletions)

View changed files

📝 src/terminal/parser/InputStateMachineEngine.cpp (+39 -9)
📝 src/terminal/parser/InputStateMachineEngine.hpp (+1 -1)
📝 src/terminal/parser/ut_parser/InputEngineTest.cpp (+57 -1)

📄 Description

Summary of the Pull Request

ConPty did not set the ENHANCED_KEY flag when generating new input. This change helps detect when it's supposed to do so, and sends it.

References

Enhanced Key Documentation

PR Checklist

Detailed Description of the Pull Request / Additional comments

KEY_EVENT_RECORD modifiers VT encodable? Detectable on the way out?
CAPSLOCK_ON No No
ENHANCED_KEY No Yes**
LEFT_ALT_PRESSED Yes* Yes*
LEFT_CTRL_PRESSED Yes* Yes*
NUMLOCK_ON No No
RIGHT_ALT_PRESSED Yes* Yes*
RIGHT_CTRL_PRESSED Yes* Yes*
SCROLLLOCK_ON No No
SHIFT_PRESSED Yes Yes
* We can detect Alt and Ctrl, but not necessarily which one
** Enhanced Keys are limited to the following:
    - off keypad: INS, DEL, HOME, END, PAGE UP, PAGE DOWN, direction keys
    - on keypad: / and ENTER
   Since we can't detect the keypad keys, those will _not_ send the ENHANCED_KEY modifier.
   For the following CSI action codes, we can assume that they are Enhanced Keys:
     case CsiActionCodes::ArrowUp:
     case CsiActionCodes::ArrowDown:
     case CsiActionCodes::ArrowRight:
     case CsiActionCodes::ArrowLeft:
     case CsiActionCodes::Home:
     case CsiActionCodes::End:
     case CsiActionCodes::CSI_F1:
     case CsiActionCodes::CSI_F3:
     case CsiActionCodes::CSI_F2:
     case CsiActionCodes::CSI_F4:
   These cases are handled in ActionCsiDispatch

Validation Steps Performed

Followed bug repro steps. It now matches!


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/microsoft/terminal/pull/5021 **Author:** [@carlos-zamora](https://github.com/carlos-zamora) **Created:** 3/19/2020 **Status:** ✅ Merged **Merged:** 3/24/2020 **Merged by:** [@undefined](undefined) **Base:** `master` ← **Head:** `dev/cazamor/conpty/enhanced-key` --- ### 📝 Commits (5) - [`b020f4b`](https://github.com/microsoft/terminal/commit/b020f4bf09324473f81822c4b5518c3e63d008d6) conpty: add enhanced key support - [`df38dc1`](https://github.com/microsoft/terminal/commit/df38dc14fcce179fe16e2bf0e81f36ce035eabf9) add testing and polish enhanced keys - [`305ce4e`](https://github.com/microsoft/terminal/commit/305ce4eaa62fa594ffd28b022c2c3671bf4a2d29) don't allow CSI_F# to be enhanced - [`0ca2c0d`](https://github.com/microsoft/terminal/commit/0ca2c0de3971495bbd42d5c62b107fa307222262) Griese PR Comments - [`dbec9b0`](https://github.com/microsoft/terminal/commit/dbec9b0fd07159fa35aea93ee97ed435a0a78b19) fix 'possible loss of data' ### 📊 Changes **3 files changed** (+97 additions, -11 deletions) <details> <summary>View changed files</summary> 📝 `src/terminal/parser/InputStateMachineEngine.cpp` (+39 -9) 📝 `src/terminal/parser/InputStateMachineEngine.hpp` (+1 -1) 📝 `src/terminal/parser/ut_parser/InputEngineTest.cpp` (+57 -1) </details> ### 📄 Description ## Summary of the Pull Request ConPty did not set the ENHANCED_KEY flag when generating new input. This change helps detect when it's supposed to do so, and sends it. ## References [Enhanced Key Documentation](https://docs.microsoft.com/en-us/windows/console/key-event-record-str) ## PR Checklist * [X] Closes #2397 ## Detailed Description of the Pull Request / Additional comments | KEY_EVENT_RECORD modifiers | VT encodable? | Detectable on the way out? | |----------------------------|---------------|----------------------------| | CAPSLOCK_ON | No | No | | ENHANCED_KEY | No | Yes** | | LEFT_ALT_PRESSED | Yes* | Yes* | | LEFT_CTRL_PRESSED | Yes* | Yes* | | NUMLOCK_ON | No | No | | RIGHT_ALT_PRESSED | Yes* | Yes* | | RIGHT_CTRL_PRESSED | Yes* | Yes* | | SCROLLLOCK_ON | No | No | | SHIFT_PRESSED | Yes | Yes | ``` * We can detect Alt and Ctrl, but not necessarily which one ** Enhanced Keys are limited to the following: - off keypad: INS, DEL, HOME, END, PAGE UP, PAGE DOWN, direction keys - on keypad: / and ENTER Since we can't detect the keypad keys, those will _not_ send the ENHANCED_KEY modifier. For the following CSI action codes, we can assume that they are Enhanced Keys: case CsiActionCodes::ArrowUp: case CsiActionCodes::ArrowDown: case CsiActionCodes::ArrowRight: case CsiActionCodes::ArrowLeft: case CsiActionCodes::Home: case CsiActionCodes::End: case CsiActionCodes::CSI_F1: case CsiActionCodes::CSI_F3: case CsiActionCodes::CSI_F2: case CsiActionCodes::CSI_F4: These cases are handled in ActionCsiDispatch ``` ## Validation Steps Performed Followed bug repro steps. It now matches! --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-31 09:13:48 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#26081