diff options
author | Felix Lange <fjl@twurst.com> | 2015-03-06 17:39:31 +0800 |
---|---|---|
committer | Felix Lange <fjl@twurst.com> | 2015-03-06 17:39:31 +0800 |
commit | 2393de5d6b535a850e8b5d510aa2ae4f940f3d23 (patch) | |
tree | 020fdbfeb9046f101b7e2ccab31bfc3c02caf1aa /Godeps/_workspace/src/github.com/peterh/liner/output_windows.go | |
parent | 38f6d60e6e699db24b7a850b5999823b9e36d5bb (diff) | |
download | go-tangerine-2393de5d6b535a850e8b5d510aa2ae4f940f3d23.tar go-tangerine-2393de5d6b535a850e8b5d510aa2ae4f940f3d23.tar.gz go-tangerine-2393de5d6b535a850e8b5d510aa2ae4f940f3d23.tar.bz2 go-tangerine-2393de5d6b535a850e8b5d510aa2ae4f940f3d23.tar.lz go-tangerine-2393de5d6b535a850e8b5d510aa2ae4f940f3d23.tar.xz go-tangerine-2393de5d6b535a850e8b5d510aa2ae4f940f3d23.tar.zst go-tangerine-2393de5d6b535a850e8b5d510aa2ae4f940f3d23.zip |
Godeps: add github.com/peterh/liner
Diffstat (limited to 'Godeps/_workspace/src/github.com/peterh/liner/output_windows.go')
-rw-r--r-- | Godeps/_workspace/src/github.com/peterh/liner/output_windows.go | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/Godeps/_workspace/src/github.com/peterh/liner/output_windows.go b/Godeps/_workspace/src/github.com/peterh/liner/output_windows.go new file mode 100644 index 000000000..27ae55a14 --- /dev/null +++ b/Godeps/_workspace/src/github.com/peterh/liner/output_windows.go @@ -0,0 +1,54 @@ +package liner + +import ( + "unsafe" +) + +type coord struct { + x, y int16 +} +type smallRect struct { + left, top, right, bottom int16 +} + +type consoleScreenBufferInfo struct { + dwSize coord + dwCursorPosition coord + wAttributes int16 + srWindow smallRect + dwMaximumWindowSize coord +} + +func (s *State) cursorPos(x int) { + var sbi consoleScreenBufferInfo + procGetConsoleScreenBufferInfo.Call(uintptr(s.hOut), uintptr(unsafe.Pointer(&sbi))) + procSetConsoleCursorPosition.Call(uintptr(s.hOut), + uintptr(int(x)&0xFFFF|int(sbi.dwCursorPosition.y)<<16)) +} + +func (s *State) eraseLine() { + var sbi consoleScreenBufferInfo + procGetConsoleScreenBufferInfo.Call(uintptr(s.hOut), uintptr(unsafe.Pointer(&sbi))) + var numWritten uint32 + procFillConsoleOutputCharacter.Call(uintptr(s.hOut), uintptr(' '), + uintptr(sbi.dwSize.x-sbi.dwCursorPosition.x), + uintptr(int(sbi.dwCursorPosition.x)&0xFFFF|int(sbi.dwCursorPosition.y)<<16), + uintptr(unsafe.Pointer(&numWritten))) +} + +func (s *State) eraseScreen() { + var sbi consoleScreenBufferInfo + procGetConsoleScreenBufferInfo.Call(uintptr(s.hOut), uintptr(unsafe.Pointer(&sbi))) + var numWritten uint32 + procFillConsoleOutputCharacter.Call(uintptr(s.hOut), uintptr(' '), + uintptr(sbi.dwSize.x)*uintptr(sbi.dwSize.y), + 0, + uintptr(unsafe.Pointer(&numWritten))) + procSetConsoleCursorPosition.Call(uintptr(s.hOut), 0) +} + +func (s *State) getColumns() { + var sbi consoleScreenBufferInfo + procGetConsoleScreenBufferInfo.Call(uintptr(s.hOut), uintptr(unsafe.Pointer(&sbi))) + s.columns = int(sbi.dwSize.x) +} |