bubbletea/tty_windows.go

26 lines
501 B
Go
Raw Normal View History

// +build windows
package tea
2020-10-12 22:36:24 -04:00
import (
"io"
2020-10-12 22:36:24 -04:00
"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(w io.Writer) {
f, ok := w.(*os.File)
if !ok {
return
}
stdout := windows.Handle(f.Fd())
2020-10-12 22:36:24 -04:00
var originalMode uint32
windows.GetConsoleMode(stdout, &originalMode)
windows.SetConsoleMode(stdout, originalMode|windows.ENABLE_VIRTUAL_TERMINAL_PROCESSING)
}