diff --git a/windows/console.go b/windows/console.go index 4bad32e..5c97bcc 100644 --- a/windows/console.go +++ b/windows/console.go @@ -4,8 +4,7 @@ package windowsconsole import ( "os" - - "github.com/Azure/go-ansiterm/winterm" + "syscall" ) // GetHandleInfo returns file descriptor and bool indicating whether the file is a console. @@ -22,14 +21,18 @@ func GetHandleInfo(in interface{}) (uintptr, bool) { if file, ok := in.(*os.File); ok { inFd = file.Fd() - isTerminal = IsConsole(inFd) + isTerminal = isConsole(inFd) } return inFd, isTerminal } // IsConsole returns true if the given file descriptor is a Windows Console. // The code assumes that GetConsoleMode will return an error for file descriptors that are not a console. -func IsConsole(fd uintptr) bool { - _, e := winterm.GetConsoleMode(fd) - return e == nil +// Deprecated: use syscall.GetConsoleMode(), golang.org/x/sys/windows.GetConsoleMode(), or golang.org/x/crypto/ssh/terminal.IsTerminal() +var IsConsole = isConsole + +func isConsole(fd uintptr) bool { + var mode uint32 + err := syscall.GetConsoleMode(syscall.Handle(fd), &mode) + return err == nil }