Skip to content

Commit

Permalink
fix Ascii escape characteres on windows (#77)
Browse files Browse the repository at this point in the history
Co-authored-by: Yuri Araújo <[email protected]>
  • Loading branch information
yuridiniz and Yuri Araújo authored Jun 18, 2022
1 parent b8286ed commit 38a7eba
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
3 changes: 3 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -37,6 +38,8 @@ var (
)

func main() {
platform.EnableVirtualTerminal()

log.SetHandler(cli.Default)

fmt.Println()
Expand Down
7 changes: 7 additions & 0 deletions platform/platform_unix.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//go:build !windows
// +build !windows

package platform

func EnableVirtualTerminal() {
}
19 changes: 19 additions & 0 deletions platform/platform_windows.go
Original file line number Diff line number Diff line change
@@ -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)
}

0 comments on commit 38a7eba

Please sign in to comment.