HorizontalAbsolute moves the cursor to n horizontally. The position n is absolute to the start of the line.
(n int)
| 44 | // HorizontalAbsolute moves the cursor to n horizontally. |
| 45 | // The position n is absolute to the start of the line. |
| 46 | func (c *Cursor) HorizontalAbsolute(n int) { |
| 47 | handle := syscall.Handle(c.writer.Fd()) |
| 48 | |
| 49 | var csbi consoleScreenBufferInfo |
| 50 | _, _, _ = procGetConsoleScreenBufferInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&csbi))) |
| 51 | |
| 52 | var cursor coord |
| 53 | cursor.x = short(n) |
| 54 | cursor.y = csbi.cursorPosition.y |
| 55 | |
| 56 | if csbi.size.x < cursor.x { |
| 57 | cursor.x = csbi.size.x |
| 58 | } |
| 59 | |
| 60 | _, _, _ = procSetConsoleCursorPosition.Call(uintptr(handle), uintptr(*(*int32)(unsafe.Pointer(&cursor)))) |
| 61 | } |
| 62 | |
| 63 | // Show the cursor if it was hidden previously. |
| 64 | // Don't forget to show the cursor at least at the end of your application. |