Skip to content

Commit 43baa50

Browse files
committed
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
1 parent 353276a commit 43baa50

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

term_windows.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,14 @@ func isTerminal(fd int) bool {
2020
return err == nil
2121
}
2222

23+
// XXX: This is intended to be used on a console input handle.
24+
// See https://learn.microsoft.com/en-us/windows/console/setconsolemode
2325
func makeRaw(fd int) (*State, error) {
2426
var st uint32
2527
if err := windows.GetConsoleMode(windows.Handle(fd), &st); err != nil {
2628
return nil, err
2729
}
28-
raw := st &^ (windows.ENABLE_ECHO_INPUT | windows.ENABLE_PROCESSED_INPUT | windows.ENABLE_LINE_INPUT | windows.ENABLE_PROCESSED_OUTPUT)
30+
raw := st &^ (windows.ENABLE_ECHO_INPUT | windows.ENABLE_PROCESSED_INPUT | windows.ENABLE_LINE_INPUT)
2931
if err := windows.SetConsoleMode(windows.Handle(fd), raw); err != nil {
3032
return nil, err
3133
}

0 commit comments

Comments
 (0)