2023-03-01 09:30:32 +02:00
|
|
|
package color
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
|
|
|
|
"golang.org/x/sys/windows"
|
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
// Opt-in for ansi color support for current process.
|
|
|
|
// https://learn.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences#output-sequences
|
|
|
|
var outMode uint32
|
|
|
|
out := windows.Handle(os.Stdout.Fd())
|
2023-03-01 09:48:57 +02:00
|
|
|
if err := windows.GetConsoleMode(out, &outMode); err != nil {
|
|
|
|
return
|
2023-03-01 09:30:32 +02:00
|
|
|
}
|
2023-03-01 09:48:57 +02:00
|
|
|
outMode |= windows.ENABLE_PROCESSED_OUTPUT | windows.ENABLE_VIRTUAL_TERMINAL_PROCESSING
|
|
|
|
_ = windows.SetConsoleMode(out, outMode)
|
2023-03-01 09:30:32 +02:00
|
|
|
}
|