Skip to content

createLiveRegion

createLiveRegion(terminal): LiveRegion

Defined in: live-region.ts:67

A live region bound to one terminal.

Closes over the height of the last frame, which is the only thing that makes the next erase correct — so one region owns one cursor position, and two regions must never share a stream.

Entries are split on newlines first: a caller renders one item per entry — an event, a whole table — and an entry holding two lines occupies two rows, which the erase has to count and the clamp has to measure separately.

Lines are clamped to the terminal’s width, because a wrapped line occupies two rows and leaves the erase one short; and the region is clamped to rows - 1, because cursorUp cannot reach above the viewport and anything that scrolled off would be stranded in scrollback. A region that overflows keeps its last lines: those are the newest, and the ones it drops were never written, so there is nothing left behind.

Committing a finished region is the same operation with the finished text as scrollback and an empty region.

Terminal

LiveRegion