22 lines
543 B
Go
22 lines
543 B
Go
|
package term
|
||
|
|
||
|
import (
|
||
|
"os"
|
||
|
|
||
|
"golang.org/x/sys/windows"
|
||
|
)
|
||
|
|
||
|
// from https://github.com/fatih/color
|
||
|
|
||
|
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())
|
||
|
if err := windows.GetConsoleMode(out, &outMode); err != nil {
|
||
|
return
|
||
|
}
|
||
|
outMode |= windows.ENABLE_PROCESSED_OUTPUT | windows.ENABLE_VIRTUAL_TERMINAL_PROCESSING
|
||
|
_ = windows.SetConsoleMode(out, outMode)
|
||
|
}
|