From 65515ba923039b2a4c84e34822fd7c9e4911786d Mon Sep 17 00:00:00 2001 From: pg9182 <96569817+pg9182@users.noreply.github.com> Date: Wed, 22 Feb 2023 12:40:30 -0500 Subject: cmd/atlas: Disable console quick-edit on Windows This prevents selecting text from freezing the server. --- cmd/atlas/main_windows.go | 20 ++++++++++++++++++++ go.mod | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 cmd/atlas/main_windows.go diff --git a/cmd/atlas/main_windows.go b/cmd/atlas/main_windows.go new file mode 100644 index 0000000..a6a1912 --- /dev/null +++ b/cmd/atlas/main_windows.go @@ -0,0 +1,20 @@ +//go:build windows + +package main + +import ( + "os" + + "golang.org/x/sys/windows" +) + +func init() { + con := windows.Handle(os.Stdin.Fd()) + + var mode uint32 + if err := windows.GetConsoleMode(con, &mode); err == nil { + mode |= windows.ENABLE_EXTENDED_FLAGS + mode &^= windows.ENABLE_QUICK_EDIT_MODE + _ = windows.SetConsoleMode(con, mode) + } +} diff --git a/go.mod b/go.mod index ac6b659..6fe4ff1 100644 --- a/go.mod +++ b/go.mod @@ -16,6 +16,7 @@ require ( github.com/spf13/pflag v1.0.5 golang.org/x/mod v0.7.0 golang.org/x/net v0.2.0 + golang.org/x/sys v0.2.0 ) require ( @@ -25,5 +26,4 @@ require ( github.com/rs/xid v1.4.0 // indirect github.com/valyala/fastrand v1.1.0 // indirect github.com/valyala/histogram v1.2.0 // indirect - golang.org/x/sys v0.2.0 // indirect ) -- cgit v1.2.3