Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Teach PSReadline to not force the background color during render #1626

Merged
merged 2 commits into from
Jul 3, 2020
Merged

Teach PSReadline to not force the background color during render #1626

merged 2 commits into from
Jul 3, 2020

Conversation

DHowett
Copy link
Contributor

@DHowett DHowett commented Jun 30, 2020

PR Summary

Upcoming versions of the Windows Console will be able to differentiate
a color set by the Win32 API from a color set by VT. This code
transforms a Win32 color into a VT color, and then uses that VT color
during rendering. When an enlightened console host receives this VT, it
may handle it differently (translate it differently, reverse it
differently, store it differently).

I've switched the defaults over to "39;49" (the well-supported SGR
codes for "foreground, background to default") and taught the two
console translators how to handle them. I went back to the Windows
source code and confirmed: conhost supports 39;49 everywhere
ENABLE_VIRTUAL_TERMINAL_PROCESSING is supported.

The first commit that introduced 39/49 is in Windows 10 TH2, the very
same release that introduced VT handling.

There's a lot more information in #830 (comment)

Fixes #830.
Related to microsoft/terminal#5952

PR Checklist

  • PR has a meaningful title
    • Use the present tense and imperative mood when describing your changes
  • Summarized changes
  • Make sure you've added one or more new tests (tests updated to handle this)
  • User-facing changes
    • Not Applicable
    • OR
    • Documentation needed at PowerShell-Docs
      • Doc Issue filed:
Microsoft Reviewers: Open in CodeFlow

Upcoming versions of the Windows Console will be able to differentiate
a color set by the Win32 API from a color set by VT. This code
transforms a Win32 color into a VT color, and then uses that VT color
during rendering. When an enlightened console host receives this VT, it
may handle it differently (translate it differently, reverse it
differently, store it differently).

Fixes #830.
@DHowett

This comment has been minimized.

We'll also teach the various console implementations how to
handle it.
@DHowett
Copy link
Contributor Author

DHowett commented Jun 30, 2020

Alright, I went with a different approach. SGR 39 and 49 exist to restore the console color to the default. I've taught the mock and legacywin32 consoles how to handle this (in the same way as the windows console handles it), and switched the "reset to the default colors" sequence to set 39;49.

This does change the behavior of Render. Where it would previously enforce the current colors, it now prefers the default colors. This does not appear to be true; I cannot get PSReadline (before my change) to respect the active colors.

For what reasons were we keeping the "current" colors? Are they incontrovertible?

@DHowett
Copy link
Contributor Author

DHowett commented Jun 30, 2020

Tested in the legacy console:
image

Copy link
Member

@daxian-dbw daxian-dbw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DHowett Thanks for the contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Stop setting the background color when erasing
2 participants