mirror of
https://github.com/johnkerl/miller.git
synced 2026-01-23 02:14:13 +00:00
Enable ANSI escape sequence processing on Windows (#1045)
Windows added support for ANSI escape sequences processing, and showing colors, and such. However, this needs to be enabled explicitly, for that to work. This enables that on startup.
This commit is contained in:
parent
418f6d80aa
commit
485beb126b
5 changed files with 31 additions and 0 deletions
1
go.mod
1
go.mod
|
|
@ -22,6 +22,7 @@ require (
|
|||
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51
|
||||
github.com/lestrrat-go/strftime v1.0.6
|
||||
github.com/mattn/go-isatty v0.0.14
|
||||
github.com/nine-lives-later/go-windows-terminal-sequences v1.0.4 // indirect
|
||||
github.com/pkg/profile v1.6.0
|
||||
github.com/stretchr/testify v1.8.0
|
||||
golang.org/x/sys v0.0.0-20211019181941-9d821ace8654
|
||||
|
|
|
|||
2
go.sum
2
go.sum
|
|
@ -13,6 +13,8 @@ github.com/lestrrat-go/strftime v1.0.6 h1:CFGsDEt1pOpFNU+TJB0nhz9jl+K0hZSLE205Ah
|
|||
github.com/lestrrat-go/strftime v1.0.6/go.mod h1:f7jQKgV5nnJpYgdEasS+/y7EsTb8ykN2z68n3TtcTaw=
|
||||
github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
|
||||
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
|
||||
github.com/nine-lives-later/go-windows-terminal-sequences v1.0.4 h1:NC4H8hewgaktBqMI5yzy6L/Vln5/H7BEziyxaE2fX3Y=
|
||||
github.com/nine-lives-later/go-windows-terminal-sequences v1.0.4/go.mod h1:eUQxpEiJy001RoaLXrNa5+QQLYiEgmEafwWuA3ppJSo=
|
||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/profile v1.6.0 h1:hUDfIISABYI59DyeB3OTay/HxSRwTQ8rB/H83k6r5dM=
|
||||
|
|
|
|||
|
|
@ -33,6 +33,10 @@ func Main() MainReturn {
|
|||
// as-is.)
|
||||
os.Args = platform.GetArgs()
|
||||
|
||||
// Enable ANSI escape sequence processing on the Windows pseudo terminal,
|
||||
// otherwise, we only raw ANSI escape sequences like ←[0;30m 0←[0m ←[0;31m 1
|
||||
platform.EnableAnsiEscapeSequences()
|
||||
|
||||
// Expand "-xyz" into "-x -y -z" while leaving "--xyz" intact. This is a
|
||||
// keystroke-saver for the user.
|
||||
//
|
||||
|
|
|
|||
8
internal/pkg/platform/terminal_notwindows.go
Normal file
8
internal/pkg/platform/terminal_notwindows.go
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
|
||||
//go:build !windows
|
||||
// +build !windows
|
||||
|
||||
package platform
|
||||
|
||||
func EnableAnsiEscapeSequences() {
|
||||
}
|
||||
16
internal/pkg/platform/terminal_windows.go
Normal file
16
internal/pkg/platform/terminal_windows.go
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
|
||||
//go:build windows
|
||||
// +build windows
|
||||
|
||||
package platform
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
|
||||
sequences "github.com/nine-lives-later/go-windows-terminal-sequences"
|
||||
)
|
||||
|
||||
func EnableAnsiEscapeSequences() {
|
||||
sequences.EnableVirtualTerminalProcessing(syscall.Stdout, true)
|
||||
sequences.EnableVirtualTerminalProcessing(syscall.Stderr, true)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue