-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathmain_windows.go
More file actions
36 lines (27 loc) · 802 Bytes
/
main_windows.go
File metadata and controls
36 lines (27 loc) · 802 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// +build windows
package main
import (
"log"
"os"
"golang.org/x/sys/windows"
)
func disableEcho() uint32 {
var st uint32
if err := windows.GetConsoleMode(windows.Handle(os.Stdout.Fd()), &st); err != nil {
log.Fatalf("failed to get the console state: %v", err)
}
newSt := st
newSt = newSt &^ windows.ENABLE_ECHO_INPUT
newSt |= windows.ENABLE_PROCESSED_INPUT
newSt |= windows.ENABLE_LINE_INPUT
newSt |= windows.ENABLE_VIRTUAL_TERMINAL_PROCESSING
if err := windows.SetConsoleMode(windows.Handle(os.Stdout.Fd()), newSt); err != nil {
log.Fatalf("failed to set the console state: %v", err)
}
return st
}
func enableEcho(st uint32) {
if err := windows.SetConsoleMode(windows.Handle(os.Stdout.Fd()), st); err != nil {
log.Fatalf("failed to set the console state: %v", err)
}
}