Get control codes to move cursor to beginning of live render. Returns: Control: A control instance that may be printed.
(self)
| 49 | self.renderable = renderable |
| 50 | |
| 51 | def position_cursor(self) -> Control: |
| 52 | """Get control codes to move cursor to beginning of live render. |
| 53 | |
| 54 | Returns: |
| 55 | Control: A control instance that may be printed. |
| 56 | """ |
| 57 | if self._shape is not None: |
| 58 | _, height = self._shape |
| 59 | return Control( |
| 60 | ControlType.CARRIAGE_RETURN, |
| 61 | (ControlType.ERASE_IN_LINE, 2), |
| 62 | *( |
| 63 | ( |
| 64 | (ControlType.CURSOR_UP, 1), |
| 65 | (ControlType.ERASE_IN_LINE, 2), |
| 66 | ) |
| 67 | * (height - 1) |
| 68 | ) |
| 69 | ) |
| 70 | return Control() |
| 71 | |
| 72 | def restore_cursor(self) -> Control: |
| 73 | """Get control codes to clear the render and restore the cursor to its previous position. |