ClearLine clears the current line and moves the cursor to its start position.
()
| 88 | |
| 89 | // ClearLine clears the current line and moves the cursor to its start position. |
| 90 | func (c *Cursor) ClearLine() { |
| 91 | handle := syscall.Handle(c.writer.Fd()) |
| 92 | |
| 93 | var csbi consoleScreenBufferInfo |
| 94 | _, _, _ = procGetConsoleScreenBufferInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&csbi))) |
| 95 | |
| 96 | var w uint32 |
| 97 | var x short |
| 98 | cursor := csbi.cursorPosition |
| 99 | x = csbi.size.x |
| 100 | _, _, _ = procFillConsoleOutputCharacter.Call(uintptr(handle), uintptr(' '), uintptr(x), uintptr(*(*int32)(unsafe.Pointer(&cursor))), uintptr(unsafe.Pointer(&w))) |
| 101 | } |
| 102 | |
| 103 | // Clear clears the current position and moves the cursor to the left. |
| 104 | func (c *Cursor) Clear() { |