Skip to content

Add support for the DECSCNM Screen Mode #3773

@j4james

Description

@j4james

Description of the new feature/enhancement

The DECSCNM (screen mode) escape sequence is a DEC private mode for switching the display between normal and reverse - often referred to as dark and light backgrounds on monochrome terminals. I doubt it's widely used in practice, but it's needed to pass some of the tests in the Vttest suite.

In the DEC STD 070 manual, the behaviour of the DECSCNM mode is described as follows:

Changing between normal and reverse screen mode will affect which attribute bits from display memory are used to render the text foreground and background color. It does not affect the current rendition, or how the current rendition is applied to the character attribute bits associated with each character in display memory.

I take that to mean that the background attributes of a cell will be used to render the text foreground and the foreground attributes will be used for the background. This seems to be how it's implemented in Konsole and the Linux virtual terminal, but there is quite a lot of variation in how other terminals interpret it. Without a clear consensus, though, I'd be inclined to follow the standard. As long as it passes Vttest, I don't think it really matters.

Proposed technical implementation details

Looking at the conhost side of things, I think this can be achieved with a new flag in the Settings class, and then updates to the LookupForegroundColor and LookupBackgroundColor methods, to switch the returned foreground and background colors when the flag is set. This seems to be enough to make the renderer draw everything with the correct colors, including underlines.

We'll also need a new private API in the ConGetSet interface, which can be called from the AdaptDispatch class to actually toggle the mode, and trigger a redraw of the display. And the HardReset implementation should probably be updated to reset the mode back to normal.

As for the Windows Terminal, my preliminary tests suggest it doesn't require anything special. Whatever is rendered on the conhost side seems to be passed through correctly via conpty as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-VTVirtual Terminal sequence supportHelp WantedWe encourage anyone to jump in on these.Issue-TaskIt's a feature request, but it doesn't really need a major design.Product-ConhostFor issues in the Console codebaseResolution-Fix-CommittedFix is checked in, but it might be 3-4 weeks until a release.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions