From 0b4539170b88d8e87eba410785d6ab6e08de30d2 Mon Sep 17 00:00:00 2001 From: Christian Rocha Date: Sat, 2 Oct 2021 15:46:31 -0400 Subject: [PATCH] Set ENABLE_VIRTUAL_TERMINAL_INPUT on Windows --- cancelreader_windows.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cancelreader_windows.go b/cancelreader_windows.go index 0d449a7..0bd75d6 100644 --- a/cancelreader_windows.go +++ b/cancelreader_windows.go @@ -206,7 +206,13 @@ func prepareConsole(input windows.Handle) (reset func() error, err error) { newMode |= windows.ENABLE_INSERT_MODE newMode |= windows.ENABLE_QUICK_EDIT_MODE - newMode &^= windows.ENABLE_VIRTUAL_TERMINAL_INPUT + // Enabling virutal terminal input is necessary for processing certain + // types of input like X10 mouse events and arrows keys with the current + // bytes-based input reader. It does, however, prevent cancelReader from + // being able to cancel input. The planned solution for this is to read + // Windows events in a more native fashion, rather than the current simple + // bytes-based input reader which works well on unix systems. + newMode |= windows.ENABLE_VIRTUAL_TERMINAL_INPUT err = windows.SetConsoleMode(input, newMode) if err != nil {