xnano.core.frame
xnano.core.frame
¶
xnano.core.frame
Inspect immutable text, cursor, device, and revision data from a rendered frame.
Classes:
-
Frame–Immutable snapshot of one painted native frame.
Functions:
-
frame_from_terminal–Build a
Framesnapshot from a terminal or runtime.
Frame
dataclass
¶
Frame(
width: int,
height: int,
text: str = "",
ansi: str = "",
cursor_position: tuple[int, int] | None = None,
cursor_visible: bool = True,
cursor_style: str | None = None,
title: str | None = None,
commands: tuple[Mapping[str, Any], ...] = (),
revision: int = 0,
)
Immutable snapshot of one painted native frame.
Example
Frame(width=20, height=4, text="Ready")
Attributes:
-
width(int) –Frame width in cells.
-
height(int) –Frame height in cells.
-
text(str) –Plain-text rows joined by newlines.
-
ansi(str) –ANSI-styled serialization of the buffer.
-
cursor_position(tuple[int, int] | None) –(x, y)caret cell, when known. -
cursor_visible(bool) –Whether the caret is shown.
-
cursor_style(str | None) –Caret style name when known.
-
title(str | None) –Terminal / document title when set.
-
commands(tuple[Mapping[str, Any], ...]) –Device commands queued with this frame.
-
revision(int) –Monotonic revision for diff consumers.
Methods:
-
contains–Return whether plain text contains
needle.
cursor_position
class-attribute
instance-attribute
¶
Caret position in cells.
cursor_visible
class-attribute
instance-attribute
¶
cursor_visible: bool = True
Whether the caret is visible.
cursor_style
class-attribute
instance-attribute
¶
cursor_style: str | None = None
Caret shape and blink style.
commands
class-attribute
instance-attribute
¶
Device commands emitted with the frame.
frame_from_terminal
¶
Build a Frame snapshot from a terminal or runtime.
Parameters:
-
terminal(Any) –Object exposing size/output/cursor/device.
-
revision(int, default:0) –Monotonic revision to stamp on the frame.
Returns:
-
Frame–An immutable
Frame.