/** * A bounded window over physical rendered rows. * * Rendering owns what a row means; this module owns only which contiguous rows * are visible. Keeping those concerns apart lets modal documents, lists, and * future views share the same resize-safe position rules. * @module dshline/scroll */ /** One cursor-following window over rendered rows. */ export interface RowWindow { /** The visible rows, at most the effective capacity. */ readonly rows: readonly string[]; /** How many rendered rows were scrolled past above the window. */ readonly offset: number; /** How many rendered rows remain below the window. */ readonly below: number; } /** * Window rendered rows so the cursor's row stays visible. * * This is ONE policy shared by the primary composer and the bounded subagent * message overlay. It keeps the cursor's row in view and prefers to show what * follows it, because a person typing or pasting works at the end: the window * is pinned to the bottom until the cursor rises into it, then follows the * cursor upward. Keeping it here is what makes the two editors agree without * the renderer learning what a cursor is. * * `maximum` is the budget the current geometry grants and `cap` is the caller's * own absolute ceiling; the effective window is the smaller of the two. A * caller with only a geometry budget passes no `cap`. A capacity of zero still * yields one row when there are rows to show, so a short terminal degrades to a * single line rather than an empty body; callers that must draw nothing at a * zero budget slice the result themselves. * @param rows - every rendered row, in draw order. * @param cursorRow - the cursor's row index within `rows`. * @param maximum - most rows the current geometry can draw. * @param cap - the caller's own absolute limit, or unlimited when omitted. * @returns the visible slice and the counts scrolled past above and below it. */ export declare function cursorWindow(rows: readonly string[], cursorRow: number, maximum: number, cap?: number): RowWindow; /** A scroll position over a sequence of rendered rows. */ export declare class RowViewport { private offset; private total; private visible; /** * Update the document and window sizes, retaining the current position where * it remains valid. * @param total - rendered rows in the complete document. * @param visible - rows the current layout can show, possibly zero. * @returns whether a smaller document or wider window moved the viewport. */ update(total: number, visible: number): boolean; /** * Move by physical rendered rows, clamped to the document's bounds. * @param amount - positive moves down; negative moves up. * @returns whether the position changed. */ move(amount: number): boolean; /** * Page through the document by about one visible window. * * A line-by-line hop would need dozens of presses on a long document, so this * advances by the whole visible window minus one row: the overlap keeps the * last row of the previous page in view, which anchors the reader's eye as * the document shifts. A window of one still pages by one. * @param direction - +1 pages down, -1 pages up. * @returns whether the position changed. */ page(direction: 1 | -1): boolean; /** * Jump to the document's first row. * @returns whether the position changed. */ first(): boolean; /** * Jump to the last valid top row. * @returns whether the position changed. */ last(): boolean; /** The first visible row, zero-based. */ get start(): number; /** The exclusive end of the visible window. */ get end(): number; /** The greatest valid first visible row. */ get maxOffset(): number; } //# sourceMappingURL=scroll.d.ts.map