Skip to content

Commit

Permalink
feature: turn off colors in widows
Browse files Browse the repository at this point in the history
  • Loading branch information
Ak-Army committed Jul 4, 2024
1 parent 1aec438 commit ed92be5
Showing 1 changed file with 2 additions and 17 deletions.
19 changes: 2 additions & 17 deletions internal/term/term_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,16 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build windows
// +build windows

package term

import (
"io"
"syscall"
"unsafe"
)

var kernel32 = syscall.NewLazyDLL("kernel32.dll")

var (
procGetConsoleMode = kernel32.NewProc("GetConsoleMode")
)

// IsTerminal returns true if w writes to a terminal.
func IsTerminal(w io.Writer) bool {
fw, ok := w.(interface {
Fd() uintptr
})
if !ok {
return false
}
var st uint32
r, _, e := syscall.Syscall(procGetConsoleMode.Addr(), 2, fw.Fd(), uintptr(unsafe.Pointer(&st)), 0)
return r != 0 && e == 0
return false
}

0 comments on commit ed92be5

Please sign in to comment.