Move Windows console hack into constrained file to fix Linux build

This commit is contained in:
Ryan Cavicchioni 2021-01-10 21:32:36 -06:00
parent ed02821b39
commit 667b1cf288
2 changed files with 19 additions and 9 deletions

19
cmd/lume/init_windows.go Normal file
View File

@ -0,0 +1,19 @@
// +build windows
// https://stackoverflow.com/a/52579002
package main
import (
"os"
"golang.org/x/sys/windows"
)
func init() {
stdout := windows.Handle(os.Stdout.Fd())
var originalMode uint32
windows.GetConsoleMode(stdout, &originalMode)
windows.SetConsoleMode(stdout, originalMode|windows.ENABLE_VIRTUAL_TERMINAL_PROCESSING)
}

View File

@ -9,20 +9,11 @@ import (
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
config = loadConfig()