fix: try to enable vt or disable colors on startup on Windows#383
Conversation
|
|
||
| // Check if VT processing is already enabled | ||
| if mode&ENABLE_VIRTUAL_TERMINAL_PROCESSING != 0 { | ||
| return true |
There was a problem hiding this comment.
On a normal system, we always hit this return.
| ) | ||
|
|
||
| // Attempt to enable VT processing or disable colors if we can't | ||
| initWindowsConsole() |
There was a problem hiding this comment.
since we're differentiating this between systems using go:build can we pick a better name for this? like initVTProcessing or something like that?
| @@ -0,0 +1,72 @@ | |||
| //go:build windows | |||
There was a problem hiding this comment.
this goes below the copyright header but above the package line. It just needs to have empty lines surrounding it.
Alternatively, if the filename just ends with _windows.go then you don't even actually need this line 😄
| @@ -0,0 +1,19 @@ | |||
| //go:build !windows | |||
There was a problem hiding this comment.
move this down below the copyright header but above the package line. it just needs to be surrounded by empty lines. See
Line 15 in 1f119d0
|
Just a few nitpicks 😄 |
Co-authored-by: Matt Topol <zotthewizard@gmail.com>
|
I reorganized things in 0c9b0cb. How does that look? |
|
LGTM |
Resolves conflict in cmd/dbc/main.go: ports the initVTProcessing() call added on main (#383) into the new main() that calls runStartup(), instead of the pre-refactor main() body that no longer exists on this branch.
Fixes an issue a user reported privately where they were seeing ANSI escapes in dbc's output. I was able to reproduce their issue by setting
HKCU\Console\VirtualTerminalLevelto1and I came up with this as a fix. When dbc starts on Windows, try to enable VT processing if it's not on and, if we fail, setNO_COLORso the user doesn't get garbled output. I wasn't able to figure out how an admin could disable VT processing so that branch wasn't tested.