[PR #15469] Add support for Erase Color Mode (DECECM) #30647

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

Original Pull Request: https://github.com/microsoft/terminal/pull/15469

State: closed
Merged: Yes


The Erase Color Mode determines what attributes are written to the
buffer when erasing content, or when new content is scrolled onto the
screen. When the mode is reset (which is the default), we erase with the
active colors, but with rendition attributes cleared. When the mode is
set, we erase with the default attributes, i.e. with neither color nor
rendition attributes applied.

This could be used to address the problem described in issue #10556.

Most of the affected operations are handled within the AdaptDispatch
class, so I've simply updated them all to use a new helper method which
returns the appropriate erase attributes for the active mode.

However, there were a couple of operations that are handled elsewhere,
and which now require the erase attributes to be passed to them as a
parameter.

  • The TextBuffer::IncrementCircularBuffer method, which is used to
    recycle the topmost row when scrolling past the bottom of the buffer.

  • The TextBuffer::SetCurrentLineRendition method, which has to clear
    the second half of the line when switching to a double width rendition.

  • The ITerminalApi::UseAlternateScreenBuffer method, which has to
    clear the screen when switching to the alternate buffer.

Then there is also a Clear Buffer action in Windows Terminal, which is
ultimately handled by the SCREEN_INFORMATION::ClearBuffer method in
ConHost. That class has no access to the erase color mode, so has no way
of knowing which attributes to use. So I've now rewritten it to use the
AdaptDispatch::EraseInDisplay method to handle the erasing.

Validation Steps Performed

I wrote a little test script that exercises the operations affected by
DECECM, which @al20878 kindly tested for us on a real DEC VT525, and
provided screenshots of the output. I've manually confirmed that our
implementation exactly matches those results.

I've also added a unit test that runs through the same set of operations
and verified that each of them is using the appropriate attributes when
DECECM is enabled and enabled.

Closes #14983

**Original Pull Request:** https://github.com/microsoft/terminal/pull/15469 **State:** closed **Merged:** Yes --- The _Erase Color Mode_ determines what attributes are written to the buffer when erasing content, or when new content is scrolled onto the screen. When the mode is reset (which is the default), we erase with the active colors, but with rendition attributes cleared. When the mode is set, we erase with the default attributes, i.e. with neither color nor rendition attributes applied. This could be used to address the problem described in issue #10556. Most of the affected operations are handled within the `AdaptDispatch` class, so I've simply updated them all to use a new helper method which returns the appropriate erase attributes for the active mode. However, there were a couple of operations that are handled elsewhere, and which now require the erase attributes to be passed to them as a parameter. * The `TextBuffer::IncrementCircularBuffer` method, which is used to recycle the topmost row when scrolling past the bottom of the buffer. * The `TextBuffer::SetCurrentLineRendition` method, which has to clear the second half of the line when switching to a double width rendition. * The `ITerminalApi::UseAlternateScreenBuffer` method, which has to clear the screen when switching to the alternate buffer. Then there is also a Clear Buffer action in Windows Terminal, which is ultimately handled by the `SCREEN_INFORMATION::ClearBuffer` method in ConHost. That class has no access to the erase color mode, so has no way of knowing which attributes to use. So I've now rewritten it to use the `AdaptDispatch::EraseInDisplay` method to handle the erasing. ## Validation Steps Performed I wrote a little test script that exercises the operations affected by `DECECM`, which @al20878 kindly tested for us on a real DEC VT525, and provided screenshots of the output. I've manually confirmed that our implementation exactly matches those results. I've also added a unit test that runs through the same set of operations and verified that each of them is using the appropriate attributes when `DECECM` is enabled and enabled. Closes #14983
claunia added the pull-request label 2026-01-31 09:42:05 +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#30647