-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutil_win.go
More file actions
37 lines (28 loc) · 844 Bytes
/
util_win.go
File metadata and controls
37 lines (28 loc) · 844 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
37
//go:build windows
// +build windows
package log
import "golang.org/x/sys/windows"
func eraseLine() {
// get info about our console window
var info windows.ConsoleScreenBufferInfo
hConsole, err := windows.GetStdHandle(windows.STD_OUTPUT_HANDLE)
if err != nil {
panic(err)
}
windows.GetConsoleScreenBufferInfo(hConsole, &info)
goBack(hConsole, &info)
// write empty line to "clear" it of characters
width := int(info.Window.Right - info.Window.Left + 1)
buf := make([]uint16, width)
for i := range buf {
buf[i] = uint16(' ')
}
windows.WriteConsole(hConsole, &buf[0], uint32(width), nil, nil)
goBack(hConsole, &info)
}
func goBack(hConsole windows.Handle, info *windows.ConsoleScreenBufferInfo) {
position := info.CursorPosition
position.Y -= 1
position.X = 0
windows.SetConsoleCursorPosition(hConsole, position)
}