[PR #13894] [MERGED] Add support for DECBKM (Backarrow Key Mode) #29818

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

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/13894
Author: @j4james
Created: 9/1/2022
Status: Merged
Merged: 9/6/2022
Merged by: @undefined

Base: mainHead: feature-decbkm


📝 Commits (5)

  • 6e38ddf Add support for backarrow key mode.
  • add6352 Handle specifics of focus mode in its own method.
  • 887ea6d Reset DECBKM in RIS.
  • 97e7ea6 Add unit test for backarrow key mode.
  • 5522352 Add DECBKM to dictionary.

📊 Changes

6 files changed (+99 additions, -28 deletions)

View changed files

📝 .github/actions/spelling/expect/expect.txt (+1 -0)
📝 src/terminal/adapter/DispatchTypes.hpp (+1 -0)
📝 src/terminal/adapter/adaptDispatch.cpp (+10 -18)
📝 src/terminal/adapter/ut_adapter/inputTest.cpp (+63 -0)
📝 src/terminal/input/terminalInput.cpp (+23 -10)
📝 src/terminal/input/terminalInput.hpp (+1 -0)

📄 Description

This PR adds support for the DECBKM sequence, which provides a way for
applications to specify whether the Backspace key should generate a
BS character or a DEL character.

On the original VT100 terminals, the Backarrow key generated a BS,
and there was a separate Delete key that generated DEL. However, on
the VT220 and later, there was only the Backarrow key. By default it
generated DEL, but from the VT320 onwards there was an option to make
it generate BS, and the DECBKM sequence provided a way to control
that behavior programmatically.

On modern terminals, the Backspace key serves as the equivalent of the
VT Backarrow, and typically generates DEL, while Ctrl+Backspace
generates BS. When DECBKM is enabled (for those that support it),
that behavior is reversed, i.e. Backspace generates BS and
Ctrl+Backspace generates DEL.

This PR also gets the other Backspace modifiers more closely aligned
with the expected behavior for modern terminals. The Shift modifier
typically has no effect, and the Alt modifier typically prefixes the
generated sequence with an ESC character.

While not strictly related to DECBKM, I noticed while testing that the
_SetInputMode method was doing unnecessary work that was specific to
the FocusEvent mode. I've now moved that additional processing into
the EnableFocusEventMode method, which I think makes things somewhat
simpler.

Validation Steps Performed

I've tested the basic DECBKM functionality in Vttest, and I've
manually tested all the modifier key combinations to make sure they
match what most modern terminals generate.

I've also added a unit test that confirms that the expected sequences
are generated correctly when the DECBKM mode is toggled.

Closes #13884


🔄 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/13894 **Author:** [@j4james](https://github.com/j4james) **Created:** 9/1/2022 **Status:** ✅ Merged **Merged:** 9/6/2022 **Merged by:** [@undefined](undefined) **Base:** `main` ← **Head:** `feature-decbkm` --- ### 📝 Commits (5) - [`6e38ddf`](https://github.com/microsoft/terminal/commit/6e38ddfb9c1f3b9cf04d7f1c43793ef038724ae3) Add support for backarrow key mode. - [`add6352`](https://github.com/microsoft/terminal/commit/add635230cf684c70be20d50885a9bffce4a9994) Handle specifics of focus mode in its own method. - [`887ea6d`](https://github.com/microsoft/terminal/commit/887ea6d33476564f6256215f065260d47d53432c) Reset DECBKM in RIS. - [`97e7ea6`](https://github.com/microsoft/terminal/commit/97e7ea628f1d6fe904f78cc9d4dc6655860b4fd0) Add unit test for backarrow key mode. - [`5522352`](https://github.com/microsoft/terminal/commit/5522352b769904c1c9718c2232466586ba5ff1ab) Add DECBKM to dictionary. ### 📊 Changes **6 files changed** (+99 additions, -28 deletions) <details> <summary>View changed files</summary> 📝 `.github/actions/spelling/expect/expect.txt` (+1 -0) 📝 `src/terminal/adapter/DispatchTypes.hpp` (+1 -0) 📝 `src/terminal/adapter/adaptDispatch.cpp` (+10 -18) 📝 `src/terminal/adapter/ut_adapter/inputTest.cpp` (+63 -0) 📝 `src/terminal/input/terminalInput.cpp` (+23 -10) 📝 `src/terminal/input/terminalInput.hpp` (+1 -0) </details> ### 📄 Description This PR adds support for the `DECBKM` sequence, which provides a way for applications to specify whether the `Backspace` key should generate a `BS` character or a `DEL` character. On the original VT100 terminals, the `Backarrow` key generated a `BS`, and there was a separate `Delete` key that generated `DEL`. However, on the VT220 and later, there was only the `Backarrow` key. By default it generated `DEL`, but from the VT320 onwards there was an option to make it generate `BS`, and the `DECBKM` sequence provided a way to control that behavior programmatically. On modern terminals, the `Backspace` key serves as the equivalent of the VT `Backarrow`, and typically generates `DEL`, while `Ctrl`+`Backspace` generates `BS`. When `DECBKM` is enabled (for those that support it), that behavior is reversed, i.e. `Backspace` generates `BS` and `Ctrl`+`Backspace` generates `DEL`. This PR also gets the other `Backspace` modifiers more closely aligned with the expected behavior for modern terminals. The `Shift` modifier typically has no effect, and the `Alt` modifier typically prefixes the generated sequence with an `ESC` character. While not strictly related to `DECBKM`, I noticed while testing that the `_SetInputMode` method was doing unnecessary work that was specific to the `FocusEvent` mode. I've now moved that additional processing into the `EnableFocusEventMode` method, which I think makes things somewhat simpler. ## Validation Steps Performed I've tested the basic `DECBKM` functionality in Vttest, and I've manually tested all the modifier key combinations to make sure they match what most modern terminals generate. I've also added a unit test that confirms that the expected sequences are generated correctly when the `DECBKM` mode is toggled. Closes #13884 --- <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:37:04 +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#29818