Enable terminal colors on Windows 10

This commit is contained in:
Ryan Cavicchioni 2021-01-10 19:24:46 -06:00
parent 91478dd20e
commit 9988800431
Signed by: ryanc
GPG Key ID: 877EEDAF9245103D
3 changed files with 16 additions and 2 deletions

View File

@ -6,14 +6,23 @@ import (
"os"
"path"
"git.kill0.net/chill9/lume"
lifx "git.kill0.net/chill9/lume"
lumecmd "git.kill0.net/chill9/lume/cmd"
"github.com/BurntSushi/toml"
"golang.org/x/sys/windows"
)
const lumercFile = ".lumerc"
func main() {
var originalMode uint32
stdout := windows.Handle(os.Stdout.Fd())
windows.GetConsoleMode(stdout, &originalMode)
windows.SetConsoleMode(stdout, originalMode|windows.ENABLE_VIRTUAL_TERMINAL_PROCESSING)
defer windows.SetConsoleMode(stdout, originalMode)
var config lumecmd.Config
homeDir, err := os.UserHomeDir()
_, err = toml.DecodeFile(path.Join(homeDir, lumercFile), &config)

5
go.mod
View File

@ -2,4 +2,7 @@ module git.kill0.net/chill9/lume
go 1.15
require github.com/BurntSushi/toml v0.3.1
require (
github.com/BurntSushi/toml v0.3.1
golang.org/x/sys v0.0.0-20210110051926-789bb1bd4061
)

2
go.sum
View File

@ -1,2 +1,4 @@
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
golang.org/x/sys v0.0.0-20210110051926-789bb1bd4061 h1:DQmQoKxQWtyybCtX/3dIuDBcAhFszqq8YiNeS6sNu1c=
golang.org/x/sys v0.0.0-20210110051926-789bb1bd4061/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=