-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
create
ios/console.go
and ios/console_windows.go
files in ios
- Loading branch information
Showing
3 changed files
with
48 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// +build !windows | ||
|
||
package ios | ||
|
||
import ( | ||
"os" | ||
"errors" | ||
) | ||
|
||
func (s *IOStreams) EnableVirtualTerminalProcessing() error { | ||
return nil | ||
} | ||
|
||
func enableVirtualTerminalProcessing(f *os.File) error { | ||
return errors.New("not implemented") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} |