Skip to content

Commit

Permalink
FIX: windows import
Browse files Browse the repository at this point in the history
  • Loading branch information
whoisnian committed Oct 28, 2023
1 parent 80735dc commit 25121c1
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions ansi/ansi_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@

package ansi

import "golang.org/x/sys/windows"

// from https://github.com/golang/term/blob/f413282cd8dbb55102093d9f16ab3ba90f7b9b31/term_windows.go#L17
// from https://github.com/fatih/color/blob/d5c210ca2a0ed2ce7d8e46320ef777d64f38c83a/color_windows.go#L9
// from https://learn.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences
func isSupported(fd uintptr) bool {
var mode uint32
var mode, flag uint32
if err := windows.GetConsoleMode(windows.Handle(fd), &mode); err != nil {
return false
}

flag := windows.ENABLE_VIRTUAL_TERMINAL_PROCESSING | windows.ENABLE_PROCESSED_OUTPUT
flag = windows.ENABLE_VIRTUAL_TERMINAL_PROCESSING | windows.ENABLE_PROCESSED_OUTPUT
if mode&flag == flag {
return true
}
Expand Down

0 comments on commit 25121c1

Please sign in to comment.