From 015563e2aef685bd0f8ba8f61b394d3259db5105 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yuri=20Ara=C3=BAjo?= Date: Thu, 10 Feb 2022 19:47:27 -0300 Subject: [PATCH] fix Ascii escape characteres on windows --- main.go | 3 +++ platform/platform_unix.go | 7 +++++++ platform/platform_windows.go | 19 +++++++++++++++++++ 3 files changed, 29 insertions(+) create mode 100644 platform/platform_unix.go create mode 100644 platform/platform_windows.go diff --git a/main.go b/main.go index df751ca..058e3da 100644 --- a/main.go +++ b/main.go @@ -12,6 +12,7 @@ import ( "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/sqs" "github.com/fatih/color" + "github.com/mercury2269/sqsmover/platform" "github.com/tj/go-progress" "github.com/tj/go/term" "gopkg.in/alecthomas/kingpin.v2" @@ -36,6 +37,8 @@ var ( ) func main() { + platform.EnableVirtualTerminal() + log.SetHandler(cli.Default) fmt.Println() diff --git a/platform/platform_unix.go b/platform/platform_unix.go new file mode 100644 index 0000000..60ae3b9 --- /dev/null +++ b/platform/platform_unix.go @@ -0,0 +1,7 @@ +//go:build !windows +// +build !windows + +package platform + +func EnableVirtualTerminal() { +} diff --git a/platform/platform_windows.go b/platform/platform_windows.go new file mode 100644 index 0000000..3639fba --- /dev/null +++ b/platform/platform_windows.go @@ -0,0 +1,19 @@ +//go:build windows +// +build windows + +package platform + +import ( + "os" + + "golang.org/x/sys/windows" +) + +func EnableVirtualTerminal() { + var flags uint32 = 0 + + var handler = windows.Handle(os.Stdout.Fd()) + + windows.GetConsoleMode(handler, &flags) + windows.SetConsoleMode(handler, flags|windows.ENABLE_VIRTUAL_TERMINAL_PROCESSING) +}