2020-01-25 01:15:29 -05:00
|
|
|
// +build windows
|
|
|
|
|
2020-05-25 19:26:40 -04:00
|
|
|
package tea
|
2020-01-25 01:15:29 -05:00
|
|
|
|
2020-10-12 22:36:24 -04:00
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
|
|
|
|
"golang.org/x/sys/windows"
|
|
|
|
)
|
|
|
|
|
|
|
|
// enableAnsiColors enables support for ANSI color sequences in Windows
|
|
|
|
// default console. Note that this only works with Windows 10.
|
|
|
|
func enableAnsiColors() {
|
|
|
|
stdout := windows.Handle(os.Stdout.Fd())
|
|
|
|
var originalMode uint32
|
|
|
|
|
|
|
|
windows.GetConsoleMode(stdout, &originalMode)
|
|
|
|
windows.SetConsoleMode(stdout, originalMode|windows.ENABLE_VIRTUAL_TERMINAL_PROCESSING)
|
|
|
|
}
|