[PR #14700] [MERGED] Add support for IRM (Insert Replace Mode) #30220

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

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/14700
Author: @j4james
Created: 1/18/2023
Status: Merged
Merged: 1/19/2023
Merged by: @undefined

Base: mainHead: feature-irm


📝 Commits (5)

  • 913878e Hook up the SM/RM sequences to the dispatcher.
  • 53e2599 Implement insert-replace mode.
  • be8a9c4 Add a unit test to confirm IRM is working..
  • d6be8c0 Update comments.
  • 25953cb Fix TraceLogging constants.

📊 Changes

10 files changed (+128 additions, -11 deletions)

View changed files

📝 src/host/ut_host/ScreenBufferTests.cpp (+77 -0)
📝 src/terminal/adapter/DispatchTypes.hpp (+1 -0)
📝 src/terminal/adapter/ITermDispatch.hpp (+2 -2)
📝 src/terminal/adapter/adaptDispatch.cpp (+25 -5)
📝 src/terminal/adapter/adaptDispatch.hpp (+3 -2)
📝 src/terminal/adapter/termDispatch.hpp (+2 -2)
📝 src/terminal/parser/OutputStateMachineEngine.cpp (+12 -0)
📝 src/terminal/parser/OutputStateMachineEngine.hpp (+2 -0)
📝 src/terminal/parser/telemetry.cpp (+2 -0)
📝 src/terminal/parser/telemetry.hpp (+2 -0)

📄 Description

This PR add support for the ANSI Insert/Replace mode (IRM), which
determines whether output characters are inserted at the active cursor
position, moving existing content to the right, or whether they should
overwrite the content that is already there.

The implementation is a bit of a hack. When that mode is enabled, it
first measures how many cells the string is expected to occupy, then
scrolls the target line right by that amount before writing out the new
text.

In the longer term it might be better if this was implemented entirely
in the TextBuffer itself, so the scrolling could take place at the
same time as the content was being written.

Validation Steps Performed

I've added a very basic unit test that verifies the mode is working as
expected. But I've also done a lot more manual testing, confirming edge
cases like wide characters, double-width lines, and both with and
without wrapping mode enabled.

Closes #1947


🔄 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/14700 **Author:** [@j4james](https://github.com/j4james) **Created:** 1/18/2023 **Status:** ✅ Merged **Merged:** 1/19/2023 **Merged by:** [@undefined](undefined) **Base:** `main` ← **Head:** `feature-irm` --- ### 📝 Commits (5) - [`913878e`](https://github.com/microsoft/terminal/commit/913878e96458909eda9a5186a009f2cc77610ecf) Hook up the SM/RM sequences to the dispatcher. - [`53e2599`](https://github.com/microsoft/terminal/commit/53e25999ac9daf3c8cb45108c4bf8d672ceb58a0) Implement insert-replace mode. - [`be8a9c4`](https://github.com/microsoft/terminal/commit/be8a9c4d4fba6c8658ec88b070135607f55bf875) Add a unit test to confirm IRM is working.. - [`d6be8c0`](https://github.com/microsoft/terminal/commit/d6be8c048ae51f061bdd11ab56d4a2cca5628fe5) Update comments. - [`25953cb`](https://github.com/microsoft/terminal/commit/25953cbd9a2678a63b43b8fa57fa670b66f7301a) Fix TraceLogging constants. ### 📊 Changes **10 files changed** (+128 additions, -11 deletions) <details> <summary>View changed files</summary> 📝 `src/host/ut_host/ScreenBufferTests.cpp` (+77 -0) 📝 `src/terminal/adapter/DispatchTypes.hpp` (+1 -0) 📝 `src/terminal/adapter/ITermDispatch.hpp` (+2 -2) 📝 `src/terminal/adapter/adaptDispatch.cpp` (+25 -5) 📝 `src/terminal/adapter/adaptDispatch.hpp` (+3 -2) 📝 `src/terminal/adapter/termDispatch.hpp` (+2 -2) 📝 `src/terminal/parser/OutputStateMachineEngine.cpp` (+12 -0) 📝 `src/terminal/parser/OutputStateMachineEngine.hpp` (+2 -0) 📝 `src/terminal/parser/telemetry.cpp` (+2 -0) 📝 `src/terminal/parser/telemetry.hpp` (+2 -0) </details> ### 📄 Description This PR add support for the ANSI Insert/Replace mode (`IRM`), which determines whether output characters are inserted at the active cursor position, moving existing content to the right, or whether they should overwrite the content that is already there. The implementation is a bit of a hack. When that mode is enabled, it first measures how many cells the string is expected to occupy, then scrolls the target line right by that amount before writing out the new text. In the longer term it might be better if this was implemented entirely in the `TextBuffer` itself, so the scrolling could take place at the same time as the content was being written. ## Validation Steps Performed I've added a very basic unit test that verifies the mode is working as expected. But I've also done a lot more manual testing, confirming edge cases like wide characters, double-width lines, and both with and without wrapping mode enabled. Closes #1947 --- <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:39:24 +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#30220