Clear clears the current position and moves the cursor to the left.
()
| 102 | |
| 103 | // Clear clears the current position and moves the cursor to the left. |
| 104 | func (c *Cursor) Clear() { |
| 105 | handle := syscall.Handle(c.writer.Fd()) |
| 106 | |
| 107 | var csbi consoleScreenBufferInfo |
| 108 | _, _, _ = procGetConsoleScreenBufferInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&csbi))) |
| 109 | |
| 110 | var w uint32 |
| 111 | cursor := csbi.cursorPosition |
| 112 | _, _, _ = procFillConsoleOutputCharacter.Call(uintptr(handle), uintptr(' '), uintptr(1), uintptr(*(*int32)(unsafe.Pointer(&cursor))), uintptr(unsafe.Pointer(&w))) |
| 113 | |
| 114 | if cursor.x > 0 { |
| 115 | cursor.x-- |
| 116 | } |
| 117 | _, _, _ = procSetConsoleCursorPosition.Call(uintptr(handle), uintptr(*(*int32)(unsafe.Pointer(&cursor)))) |
| 118 | } |