xnano.cursor
xnano.cursor
¶
xnano.cursor
Show, hide, style, and move the cursor in live or offscreen sessions.
Position, visibility, and style are always tracked locally, so the caret
state a Frame snapshot reports is correct for a live or an offscreen
runtime (tests, and every web visitor's session). Only a live runtime
issues the real terminal escape codes; an offscreen runtime must not, or
it would write control sequences to whatever process owns stdout.
Classes:
-
Cursor–Show, hide, style, and move the caret for a
Runtimesession.
Attributes:
-
CursorStyle(TypeAlias) –The caret rendering style.
CursorStyle
module-attribute
¶
CursorStyle: TypeAlias = Literal[
"default",
"blinking_block",
"steady_block",
"blinking_underline",
"steady_underline",
"blinking_bar",
"steady_bar",
]
The caret rendering style.
Values
"default": The terminal's default caret style.
"blinking_block": A blinking block. (█)
"steady_block": A steady (non-blinking) block. (█)
"blinking_underline": A blinking underline. (_)
"steady_underline": A steady (non-blinking) underline. (_)
"blinking_bar": A blinking vertical bar. (|)
"steady_bar": A steady (non-blinking) vertical bar. (|)
Cursor
¶
Show, hide, style, and move the caret for a Runtime session.
Obtained from runtime.cursor — do not construct this class
yourself.
Attributes:
-
visible(bool) –Whether the caret is shown.
-
style(CursorStyle) –Caret rendering style.
-
position(Coordinate) –Current
(x, y)position in cells.
Example
from xnano.core.runtime import Runtime runtime = Runtime.offscreen(20, 4) runtime.cursor.position = (3, 1) runtime.cursor.position (3, 1) runtime.close()
Methods:
-
get_position–The locally tracked
(x, y)caret position. -
move–Move the caret to
(x, y). -
move_up–Move the caret up by
countrows. -
move_down–Move the caret down by
countrows. -
move_left–Move the caret left by
countcolumns. -
move_right–Move the caret right by
countcolumns. -
save–Save the current caret position.
-
restore–Restore the previously saved caret position.
-
enable_blinking–Enable caret blinking.
-
disable_blinking–Disable caret blinking.
Source code in xnano/cursor.py
get_position
¶
get_position() -> Coordinate
move
¶
save
¶
restore
¶
Restore the previously saved caret position.
enable_blinking
¶
Enable caret blinking.
Source code in xnano/cursor.py
disable_blinking
¶
Disable caret blinking.