* Re-enable label colors for issue list * Drop parentheses wrapping issue labels * Support ANSI escape codes in TablePrinter cells * Switch to a Truncate implementation that correctly measures ANSI escape codes * Only output RGB color if terminal has truecolor capabilities * Enable `ENABLE_VIRTUAL_TERMINAL_PROCESSING` on Windows - fixes wrapping issues with full lines and allows truecolor rendering Co-authored-by: Mislav Marohnić <mislav@github.com>
30 lines
557 B
Go
30 lines
557 B
Go
// +build windows
|
|
|
|
package iostreams
|
|
|
|
import (
|
|
"os"
|
|
|
|
"golang.org/x/sys/windows"
|
|
)
|
|
|
|
func (s *IOStreams) EnableVirtualTerminalProcessing() error {
|
|
if !s.IsStdoutTTY() {
|
|
return nil
|
|
}
|
|
|
|
f, ok := s.originalOut.(*os.File)
|
|
if !ok {
|
|
return nil
|
|
}
|
|
|
|
return enableVirtualTerminalProcessing(f)
|
|
}
|
|
|
|
func enableVirtualTerminalProcessing(f *os.File) error {
|
|
stdout := windows.Handle(f.Fd())
|
|
|
|
var originalMode uint32
|
|
windows.GetConsoleMode(stdout, &originalMode)
|
|
return windows.SetConsoleMode(stdout, originalMode|windows.ENABLE_VIRTUAL_TERMINAL_PROCESSING)
|
|
}
|