@@ -24,6 +24,14 @@ def __getitem__(self, key: str, /) -> str: ...
2424
2525@dataclass (frozen = True , slots = True )
2626class RenderCell :
27+ """One terminal cell: a character, its column width, and SGR style.
28+
29+ A screen row like ``>>> def`` is a sequence of cells::
30+
31+ > > > d e f
32+ ╰──┴──╯ styled with keyword SGR escape
33+ """
34+
2735 text : str
2836 width : int
2937 style : StyleRef = field (default_factory = StyleRef )
@@ -95,6 +103,12 @@ def append_plain_text(segment: str) -> None:
95103
96104@dataclass (frozen = True , slots = True )
97105class RenderLine :
106+ """One physical screen row as a tuple of :class:`RenderCell` objects.
107+
108+ ``text`` is the pre-rendered terminal string (characters + SGR escapes);
109+ ``width`` is the total visible column count.
110+ """
111+
98112 cells : tuple [RenderCell , ...]
99113 text : str
100114 width : int
@@ -140,10 +154,15 @@ def from_rendered_text(cls, text: str) -> Self:
140154class ScreenOverlay :
141155 """An overlay that replaces or inserts lines at a screen position.
142156
143- If insert is True, lines are spliced in (shifting content down);
144- if False (default), lines replace existing content at y.
157+ If *insert* is True, lines are spliced in (shifting content down);
158+ if False (default), lines replace existing content at *y*.
159+
160+ For example, a tab-completion menu inserted below the input::
145161
146- Overlays are used to display tab completion menus and status messages.
162+ >>> os.path.j ← line 0 (base content)
163+ join ← ScreenOverlay(y=1, insert=True)
164+ junction ← (pushes remaining lines down)
165+ ... ← line 1 (shifted down by 2)
147166 """
148167 y : int
149168 lines : tuple [RenderLine , ...]
@@ -152,6 +171,19 @@ class ScreenOverlay:
152171
153172@dataclass (frozen = True , slots = True )
154173class RenderedScreen :
174+ """The complete screen state: content lines, cursor, and overlays.
175+
176+ ``lines`` holds the base content; ``composed_lines`` is the final
177+ result after overlays (completion menus, messages) are applied::
178+
179+ lines: composed_lines:
180+ ┌──────────────────┐ ┌──────────────────┐
181+ │>>> os.path.j │ │>>> os.path.j │
182+ │... │ ──► │ join │ ← overlay
183+ └──────────────────┘ │... │
184+ └──────────────────┘
185+ """
186+
155187 lines : tuple [RenderLine , ...]
156188 cursor : CursorXY
157189 overlays : tuple [ScreenOverlay , ...] = ()
@@ -220,6 +252,17 @@ def screen_lines(self) -> tuple[str, ...]:
220252
221253@dataclass (frozen = True , slots = True )
222254class LineDiff :
255+ """The changed region between an old and new version of one screen row.
256+
257+ When the user types ``e`` so the row changes from
258+ ``>>> nam`` to ``>>> name``::
259+
260+ >>> n a m old
261+ >>> n a m e new
262+ ╰─╯
263+ start_cell=7, new_cells=("m","e"), old_cells=("m",)
264+ """
265+
223266 start_cell : int
224267 start_x : int
225268 old_cells : tuple [RenderCell , ...]
0 commit comments