-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathzterminal_windows.go
66 lines (58 loc) · 1.8 KB
/
zterminal_windows.go
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// go.mksyscall -w -lazy=false terminal_windows.go
// MACHINE GENERATED BY go.mksyscall (github.com/kless/cutil); DO NOT EDIT
package terminal
import (
"syscall"
"unsafe"
)
var (
modkernel32 = syscall.MustLoadDLL("kernel32.dll")
procGetConsoleMode = modkernel32.MustFindProc("GetConsoleMode")
procSetConsoleMode = modkernel32.MustFindProc("SetConsoleMode")
procGetConsoleScreenBufferInfo = modkernel32.MustFindProc("GetConsoleScreenBufferInfo")
procReadConsoleInputW = modkernel32.MustFindProc("ReadConsoleInputW")
)
func getConsoleMode(handle syscall.Handle, mode *uint32) (err error) {
r1, _, e1 := syscall.Syscall(procGetConsoleMode.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(mode)), 0)
if int(r1) == 0 {
if e1 != 0 {
err = error(e1)
} else {
err = syscall.EINVAL
}
}
return
}
func setConsoleMode(handle syscall.Handle, mode uint32) (err error) {
r1, _, e1 := syscall.Syscall(procSetConsoleMode.Addr(), 2, uintptr(handle), uintptr(mode), 0)
if int(r1) == 0 {
if e1 != 0 {
err = error(e1)
} else {
err = syscall.EINVAL
}
}
return
}
func getConsoleScreenBufferInfo(handle syscall.Handle, info *_CONSOLE_SCREEN_BUFFER_INFO) (err error) {
r1, _, e1 := syscall.Syscall(procGetConsoleScreenBufferInfo.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(info)), 0)
if int(r1) == 0 {
if e1 != 0 {
err = error(e1)
} else {
err = syscall.EINVAL
}
}
return
}
func readConsoleInput(handleIn syscall.Handle, buf *_INPUT_RECORD, length uint32, numEvents *uint32) (err error) {
r1, _, e1 := syscall.Syscall6(procReadConsoleInputW.Addr(), 4, uintptr(handleIn), uintptr(unsafe.Pointer(buf)), uintptr(length), uintptr(unsafe.Pointer(numEvents)), 0, 0)
if int(r1) == 0 {
if e1 != 0 {
err = error(e1)
} else {
err = syscall.EINVAL
}
}
return
}