From 9988800431a03f1d1315f51214f21c50b8e792c0 Mon Sep 17 00:00:00 2001 From: Ryan Cavicchioni Date: Sun, 10 Jan 2021 19:24:46 -0600 Subject: [PATCH] Enable terminal colors on Windows 10 --- cmd/lume/main.go | 11 ++++++++++- go.mod | 5 ++++- go.sum | 2 ++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/cmd/lume/main.go b/cmd/lume/main.go index 2513056..bd56a0d 100644 --- a/cmd/lume/main.go +++ b/cmd/lume/main.go @@ -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) diff --git a/go.mod b/go.mod index c22719b..6084495 100644 --- a/go.mod +++ b/go.mod @@ -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 +) diff --git a/go.sum b/go.sum index 9cb2df8..f515118 100644 --- a/go.sum +++ b/go.sum @@ -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=