From 43baa50e61560e00b7d6000149a3027ee2afbe8e Mon Sep 17 00:00:00 2001 From: Ayman Bagabas Date: Fri, 9 Feb 2024 12:20:09 -0500 Subject: [PATCH 1/2] term: remove duplicate flag and add comment on windows Both `windows.ENABLE_PROCESSED_INPUT` and `windows.ENABLE_PROCESSED_OUTPUT` have the same value of `0x1`. Using `makeRaw` on a console output screen buffer handle wouldn't make sense since on Windows the input handle and the output screen buffer handle are two separate things. See https://learn.microsoft.com/en-us/windows/console/setconsolemode --- term_windows.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/term_windows.go b/term_windows.go index 465f560..ba40349 100644 --- a/term_windows.go +++ b/term_windows.go @@ -20,12 +20,14 @@ func isTerminal(fd int) bool { return err == nil } +// XXX: This is intended to be used on a console input handle. +// See https://learn.microsoft.com/en-us/windows/console/setconsolemode func makeRaw(fd int) (*State, error) { var st uint32 if err := windows.GetConsoleMode(windows.Handle(fd), &st); err != nil { return nil, err } - raw := st &^ (windows.ENABLE_ECHO_INPUT | windows.ENABLE_PROCESSED_INPUT | windows.ENABLE_LINE_INPUT | windows.ENABLE_PROCESSED_OUTPUT) + raw := st &^ (windows.ENABLE_ECHO_INPUT | windows.ENABLE_PROCESSED_INPUT | windows.ENABLE_LINE_INPUT) if err := windows.SetConsoleMode(windows.Handle(fd), raw); err != nil { return nil, err } From 832fc7e8af65b1377f2e46653aed8011d51fd3b9 Mon Sep 17 00:00:00 2001 From: Ayman Bagabas Date: Wed, 18 Jun 2025 13:32:26 -0400 Subject: [PATCH 2/2] docs: update comment --- term_windows.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/term_windows.go b/term_windows.go index 7bfa922..0ddd81c 100644 --- a/term_windows.go +++ b/term_windows.go @@ -20,7 +20,7 @@ func isTerminal(fd int) bool { return err == nil } -// XXX: This is intended to be used on a console input handle. +// This is intended to be used on a console input handle. // See https://learn.microsoft.com/en-us/windows/console/setconsolemode func makeRaw(fd int) (*State, error) { var st uint32