moo.shell.window.WindowState

class moo.shell.window.WindowState(height=1, title=None, quiet=False)

Mutable screen state shared between the driver and the Application.

The top region is a sparse grid of cells keyed by (row, col) holding Rich markup. window_write sets a cell directly; window_cursor + window_emit provide a stateful cursor for translating set_cursor + print sequences. The scroll region is a bounded list of pre-rendered ANSI lines; the visible slice is always the tail that fits.

Overlapping writes on a row are laid left-to-right by column; partial mid-segment overwrite is not modelled in v1 (writes at distinct columns, the common case, compose correctly).

__init__(height=1, title=None, quiet=False)

Methods

__init__([height, title, quiet])

append_output(ansi_text)

Append already-ANSI-rendered output, split into lines.

clear([row])

Clear the whole top region, or a single row.

emit(text)

Write text at the cursor and advance it (newlines wrap to col 0).

move_cursor(row, col)

Move the emit cursor to (row, col).

render_scroll(visible)

Return the last visible scroll lines as ANSI.

render_top()

Composite the top grid into an ANSI block of height rows.

set_height(height)

Resize the top region to height rows.

write(row, col, text)

Place text (markup) at (row, col) and park the cursor after it.