mirror of
https://github.com/charmbracelet/glow
synced 2024-11-13 23:47:06 +00:00
24 lines
484 B
Go
24 lines
484 B
Go
|
// +build windows
|
||
|
|
||
|
package main
|
||
|
|
||
|
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)
|
||
|
}
|
||
|
|
||
|
func init() {
|
||
|
enableAnsiColors()
|
||
|
}
|