MCPcopy
hub / github.com/Textualize/rich / position_cursor

Method position_cursor

rich/live_render.py:51–70  ·  view source on GitHub ↗

Get control codes to move cursor to beginning of live render. Returns: Control: A control instance that may be printed.

(self)

Source from the content-addressed store, hash-verified

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.

Callers 2

test_position_cursorFunction · 0.80
process_renderablesMethod · 0.80

Calls 1

ControlClass · 0.85

Tested by 1

test_position_cursorFunction · 0.64