Skip to content
This repository has been archived by the owner on Jul 1, 2022. It is now read-only.

Commit

Permalink
fix windows iostreams console
Browse files Browse the repository at this point in the history
  • Loading branch information
abdfnx committed Apr 23, 2022
1 parent c5b6468 commit 50f7c93
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions ios/console_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// +build windows

package ios

import (
"os"

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

func (s *IOStreams) EnableVirtualTerminalProcessing() error {
if !s.IsStdoutTTY() {
return nil
}

f, ok := s.originalOut.(*os.File)
if !ok {
return nil
}

return enableVirtualTerminalProcessing(f)
}

func enableVirtualTerminalProcessing(f *os.File) error {
stdout := windows.Handle(f.Fd())
var originalMode uint32

windows.GetConsoleMode(stdout, &originalMode)

return windows.SetConsoleMode(stdout, originalMode|windows.ENABLE_VIRTUAL_TERMINAL_PROCESSING)
}

0 comments on commit 50f7c93

Please sign in to comment.