Use termenv to enable Windows virtual terminal processing

This commit is contained in:
Christian Muehlhaeuser 2022-01-31 23:26:17 +01:00 committed by Christian Rocha
parent 0ba6420185
commit 526700ffe4

View File

@ -1,12 +1,12 @@
//go:build windows
// +build windows
package lipgloss
import (
"os"
"sync"
"golang.org/x/sys/windows"
"github.com/muesli/termenv"
)
var enableANSI sync.Once
@ -17,10 +17,6 @@ var enableANSI sync.Once
// by default.
func enableLegacyWindowsANSI() {
enableANSI.Do(func() {
stdout := windows.Handle(os.Stdout.Fd())
var originalMode uint32
windows.GetConsoleMode(stdout, &originalMode)
windows.SetConsoleMode(stdout, originalMode|windows.ENABLE_VIRTUAL_TERMINAL_PROCESSING)
_, _ = termenv.EnableWindowsANSIConsole()
})
}