diff options
author | Valentin Rothberg <rothberg@redhat.com> | 2020-04-07 12:09:48 +0200 |
---|---|---|
committer | Valentin Rothberg <rothberg@redhat.com> | 2020-04-07 12:09:48 +0200 |
commit | 42fcdbf1a85c8e23ccc25a0e7e66b3a51b8f11dd (patch) | |
tree | 3344313b57b160a877044f56eec3d8e3c1c1669c /vendor/github.com/vbauerster/mpb/v5/cwriter/writer_windows.go | |
parent | 64b6a197339e0436168e254ef9caf674ee9ff932 (diff) | |
download | podman-42fcdbf1a85c8e23ccc25a0e7e66b3a51b8f11dd.tar.gz podman-42fcdbf1a85c8e23ccc25a0e7e66b3a51b8f11dd.tar.bz2 podman-42fcdbf1a85c8e23ccc25a0e7e66b3a51b8f11dd.zip |
vendor c/image v5.4.2
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
Diffstat (limited to 'vendor/github.com/vbauerster/mpb/v5/cwriter/writer_windows.go')
-rw-r--r-- | vendor/github.com/vbauerster/mpb/v5/cwriter/writer_windows.go | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/vendor/github.com/vbauerster/mpb/v5/cwriter/writer_windows.go b/vendor/github.com/vbauerster/mpb/v5/cwriter/writer_windows.go new file mode 100644 index 000000000..712528900 --- /dev/null +++ b/vendor/github.com/vbauerster/mpb/v5/cwriter/writer_windows.go @@ -0,0 +1,60 @@ +// +build windows + +package cwriter + +import ( + "fmt" + "syscall" + "unsafe" +) + +var kernel32 = syscall.NewLazyDLL("kernel32.dll") + +var ( + procGetConsoleScreenBufferInfo = kernel32.NewProc("GetConsoleScreenBufferInfo") + procSetConsoleCursorPosition = kernel32.NewProc("SetConsoleCursorPosition") + procFillConsoleOutputCharacter = kernel32.NewProc("FillConsoleOutputCharacterW") + procFillConsoleOutputAttribute = kernel32.NewProc("FillConsoleOutputAttribute") +) + +type coord struct { + x int16 + y int16 +} + +type smallRect struct { + left int16 + top int16 + right int16 + bottom int16 +} + +type consoleScreenBufferInfo struct { + size coord + cursorPosition coord + attributes uint16 + window smallRect + maximumWindowSize coord +} + +func (w *Writer) clearLines() { + if !w.isTerminal { + fmt.Fprintf(w.out, cuuAndEd, w.lineCount) + } + var info consoleScreenBufferInfo + procGetConsoleScreenBufferInfo.Call(w.fd, uintptr(unsafe.Pointer(&info))) + + info.cursorPosition.y -= int16(w.lineCount) + if info.cursorPosition.y < 0 { + info.cursorPosition.y = 0 + } + procSetConsoleCursorPosition.Call(w.fd, uintptr(uint32(uint16(info.cursorPosition.y))<<16|uint32(uint16(info.cursorPosition.x)))) + + // clear the lines + cursor := coord{ + x: info.window.left, + y: info.cursorPosition.y, + } + count := uint32(info.size.x) * uint32(w.lineCount) + procFillConsoleOutputCharacter.Call(w.fd, uintptr(' '), uintptr(count), *(*uintptr)(unsafe.Pointer(&cursor)), uintptr(unsafe.Pointer(new(uint32)))) +} |