Skip to content

Commit

Permalink
Merge pull request #28 from JanDeDobbeleer/master
Browse files Browse the repository at this point in the history
fix: use console handle correctly on windows
  • Loading branch information
inhere committed Sep 21, 2020
2 parents 5e36db0 + c52faac commit 909b6a3
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions color_windows.go
Expand Up @@ -48,7 +48,12 @@ func init() {
procGetConsoleMode = kernel32.NewProc("GetConsoleMode")
procSetConsoleMode = kernel32.NewProc("SetConsoleMode")

err := EnableVirtualTerminalProcessing(syscall.Stdout, true)
outHandle, err := syscall.Open("CONOUT$", syscall.O_RDWR, 0)
if err != nil {
fmt.Println(53, err)
return
}
err = EnableVirtualTerminalProcessing(outHandle, true)
saveInternalError(err)
if err != nil {
fmt.Println(err)
Expand Down Expand Up @@ -84,7 +89,7 @@ func EnableVirtualTerminalProcessing(stream syscall.Handle, enable bool) error {
// err := syscall.GetConsoleMode(syscall.Stdout, &mode)
err := syscall.GetConsoleMode(stream, &mode)
if err != nil {
fmt.Println(88, err)
fmt.Println(92, err)
return err
}

Expand Down

0 comments on commit 909b6a3

Please sign in to comment.