Skip to content

Layout

Category: Terminal & Rendering

Source: layout.dart

Classes

Layout

Divides the terminal into vertical zones that cooperate using ANSI scroll regions.

┌──────────────────────────────┐
│  Output Zone (scrollable)    │ ← uses terminal's native scroll
│  ...                         │
├──────────────────────────────┤
│  Overlay Zone (0-N lines)    │ ← autocomplete popup, etc.
├──────────────────────────────┤
│  Status Bar (1 line, fixed)  │ ← painted at fixed row
├──────────────────────────────┤
│  Input Zone (1-N lines)      │ ← painted at bottom
└──────────────────────────────┘

The scroll region trick keeps output scrolling naturally while the overlay, status bar, and input area stay pinned.

Constructor

dart
Layout(this.terminal)

Properties

PropertyTypeDescription
terminalTerminal
outputTopint getFirst row of the scrollable output zone.
outputBottomint getLast row of the scrollable output zone.
outputLeftint getLeft column of the scrollable output zone.
outputRightint getRight column of the scrollable output zone.
outputWidthint getWidth of the output zone.
outputHeightint getHeight of the output zone.
overlayTopint getFirst row of the overlay zone (between output and status bar).
overlayBottomint getLast row of the overlay zone.
statusRowint getRow where the status bar is painted.
inputTopint getFirst row of the input area.
inputBottomint getLast row of the input area.
outputTopint getFirst row of the scrollable output zone.
outputBottomint getLast row of the scrollable output zone.
outputLeftint getLeft column of the scrollable output zone.
outputRightint getRight column of the scrollable output zone.
outputWidthint getWidth of the output zone.
outputHeightint getHeight of the output zone.
overlayTopint getFirst row of the overlay zone (between output and status bar).
overlayBottomint getLast row of the overlay zone.
statusRowint getRow where the status bar is painted.
inputTopint getFirst row of the input area.
inputBottomint getLast row of the input area.

Methods

void apply()

Apply (or re-apply) the hardware scroll region so that text printed inside the output zone scrolls without disturbing the status bar or input area.

void setInputHeight(int lines)

Update the input zone height (e.g. for multi-line editing).

`void applyDockGutters({
int left = 0,
int top = 0,
int right = 0,
int bottom = 0,

})`

Update dock gutters for pinned panels.

void setOverlayHeight(int lines)

Update the overlay zone height. Call before rendering.

Only calls [apply] if the height actually changed to avoid flicker.

void paintOutputViewport(List<String> lines)

Paint the output zone with pre-computed lines for scrollback.

void writeOutput(String text)

Append [text] to the output zone (scrolls naturally within the scroll region).

void paintOverlay(List<String> lines)

Paint the overlay zone with pre-rendered lines.

`void paintRect({
required int row,
required int col,
required int width,
required int height,
required List<String> lines,

})`

Paint a rectangular block without disturbing other cells.

void paintStatus(String left, String right)

Paint the status bar at its fixed row.

[left] is shown left-aligned and [right] is shown right-aligned.

`void paintInput(
String prompt,
List<String> lines,
int cursorRow,
int cursorCol, {
bool showCursor = true,
AnsiStyle promptStyle = AnsiStyle.yellow,

})`

Paint the multiline input area.

[prompt] is shown on the first line (e.g. '❯ '), continuation lines are indented with a dimmed '· ' indicator to the same width. [lines] are the logical lines of text, [cursorRow] and [cursorCol] are the cursor position within the logical lines.

Handles visual line wrapping and scrolls the viewport when content exceeds [AppConstants.maxInputVisibleLines].

Released under the MIT License.