From 667b1cf288d135d21c69502f82ea70b76ace9990 Mon Sep 17 00:00:00 2001 From: Ryan Cavicchioni Date: Sun, 10 Jan 2021 21:32:36 -0600 Subject: [PATCH] Move Windows console hack into constrained file to fix Linux build --- cmd/lume/init_windows.go | 19 +++++++++++++++++++ cmd/lume/main.go | 9 --------- 2 files changed, 19 insertions(+), 9 deletions(-) create mode 100644 cmd/lume/init_windows.go diff --git a/cmd/lume/init_windows.go b/cmd/lume/init_windows.go new file mode 100644 index 0000000..8c87266 --- /dev/null +++ b/cmd/lume/init_windows.go @@ -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) +} diff --git a/cmd/lume/main.go b/cmd/lume/main.go index 32b0d90..a653b10 100644 --- a/cmd/lume/main.go +++ b/cmd/lume/main.go @@ -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()