-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: escape sequences on windows powershell (#234)
* fix: escape sequences on windows powershell * cleanup binaries * Update init_windows.go * Update internal/cli/root.go Co-authored-by: Rita Zerrizuela <[email protected]> Co-authored-by: Rita Zerrizuela <[email protected]>
- Loading branch information
Showing
5 changed files
with
37 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,7 @@ | ||
// +build !windows | ||
|
||
package ansi | ||
|
||
// InitConsole initializes any platform-specific aspect of the terminal. | ||
// This method will run for all except Windows. | ||
func InitConsole() {} |
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,21 @@ | ||
package ansi | ||
|
||
import ( | ||
"golang.org/x/sys/windows" | ||
) | ||
|
||
// InitConsole configures the standard output and error streams | ||
// on Windows systems. This is necessary to enable colored and ANSI output. | ||
// This is the Windows implementation of ansi/init.go. | ||
func InitConsole() { | ||
setWindowsConsoleMode(windows.Stdout, windows.ENABLE_VIRTUAL_TERMINAL_PROCESSING) | ||
setWindowsConsoleMode(windows.Stderr, windows.ENABLE_VIRTUAL_TERMINAL_PROCESSING) | ||
} | ||
|
||
func setWindowsConsoleMode(handle windows.Handle, flags uint32) { | ||
var mode uint32 | ||
// set the console mode if not already there: | ||
if err := windows.GetConsoleMode(handle, &mode); err == nil { | ||
_ = windows.SetConsoleMode(handle, mode|flags) | ||
} | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.