mirror of
https://github.com/charmbracelet/glow
synced 2024-11-10 06:04:18 +00:00
Restore ANSI support to non-TUI Glow on Windows
This commit is contained in:
parent
5f9c5b708d
commit
8ed7bb7717
1 changed files with 23 additions and 0 deletions
23
console_windows.go
Normal file
23
console_windows.go
Normal file
|
@ -0,0 +1,23 @@
|
|||
// +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()
|
||||
}
|
Loading…
Reference in a new issue