Skip to content

Commit 9093988

Browse files
authored
Merge pull request #6 from Daniel-Ric/feature/2026-02-03/fix-redeclared-identifiers-in-terminal-code-8s9qwp
Use golang.org/x/sys/windows for Windows terminal console modes
2 parents 29fe4ec + a3c7f58 commit 9093988

2 files changed

Lines changed: 12 additions & 10 deletions

File tree

go.mod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
module UWP-TCP-Con
22

33
go 1.25
4+
5+
require golang.org/x/sys v0.30.0

internal/cli/terminal_windows.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,27 @@
33
package cli
44

55
import (
6-
"syscall"
6+
"golang.org/x/sys/windows"
77
)
88

99
type terminalState struct {
1010
mode uint32
1111
}
1212

1313
func makeRaw(fd int) (*terminalState, error) {
14-
handle := syscall.Handle(fd)
14+
handle := windows.Handle(fd)
1515
var original uint32
16-
if err := syscall.GetConsoleMode(handle, &original); err != nil {
16+
if err := windows.GetConsoleMode(handle, &original); err != nil {
1717
return nil, err
1818
}
1919

2020
raw := original
21-
raw &^= syscall.ENABLE_ECHO_INPUT
22-
raw &^= syscall.ENABLE_LINE_INPUT
23-
raw &^= syscall.ENABLE_PROCESSED_INPUT
24-
raw |= syscall.ENABLE_VIRTUAL_TERMINAL_INPUT
21+
raw &^= windows.ENABLE_ECHO_INPUT
22+
raw &^= windows.ENABLE_LINE_INPUT
23+
raw &^= windows.ENABLE_PROCESSED_INPUT
24+
raw |= windows.ENABLE_VIRTUAL_TERMINAL_INPUT
2525

26-
if err := syscall.SetConsoleMode(handle, raw); err != nil {
26+
if err := windows.SetConsoleMode(handle, raw); err != nil {
2727
return nil, err
2828
}
2929

@@ -34,6 +34,6 @@ func restore(fd int, state *terminalState) {
3434
if state == nil {
3535
return
3636
}
37-
handle := syscall.Handle(fd)
38-
_ = syscall.SetConsoleMode(handle, state.mode)
37+
handle := windows.Handle(fd)
38+
_ = windows.SetConsoleMode(handle, state.mode)
3939
}

0 commit comments

Comments
 (0)