-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
windows: detect ANSI support in more terminals #15282
Conversation
@nolanderc Does #15206 fix this issue? |
@perillo I don’t think so, because the code emitting the colors uses hardcoded values for windows unless ANSI escapes are detected. That is, even with the linked PR, the hardcoded values would still be used: Line 662 in 2568da2
|
Color codes are all hardcoded. On Windows we have:
and on an ANSI compatible terminal, we have
that corresponds to white color with bold or increased intensity. So it seems the issue is the use of ANSI colors on a terminal having a white background/light color theme. |
Ah yes, I seem to have forgotten to add a line to my commit... Originally, I had intended to split the |
Nevermind, that was already there... 😅 |
I am in full support of this. @nolanderc you might want to rebase this branch on latest master so that it passes CI to make it more likely to get merged. The new build runner means that on Windows the With the changes in this PR, the colors are preserved (at least with Windows Terminal). Before this PR: After this PR: |
@@ -226,6 +226,13 @@ pub const File = struct { | |||
/// Test whether ANSI escape codes will be treated as such. | |||
pub fn supportsAnsiEscapeCodes(self: File) bool { | |||
if (builtin.os.tag == .windows) { | |||
if (!os.isatty(self.handle)) return false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is redundant and can (should?) be removed, the implementation of os.isatty
on Windows is:
if (isCygwinPty(handle))
return true;
var out: windows.DWORD = undefined;
return windows.kernel32.GetConsoleMode(handle, &out) != 0;
Closing abandoned PR (CI failures, unaddressed review comments). @squeek502 please feel free to pick this up in a new PR if you are interested. |
Checks if the underlying console supports ANSI escape sequences.
Resolves an issue where bold text would render as completely white in Windows Terminal, which was unreadable on a light background.