Skip to content

Commit

Permalink
Use termenv to enable Windows virtual terminal processing
Browse files Browse the repository at this point in the history
  • Loading branch information
muesli authored and meowgorithm committed Feb 8, 2022
1 parent 0ba6420 commit 526700f
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions ansi_windows.go
@@ -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
Expand All @@ -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()
})
}

0 comments on commit 526700f

Please sign in to comment.