/** * Turns the editor buffer into the rows the prompt box draws, and back. * * The box wraps its own text rather than letting Ink do it. Ink can only wrap a * whole ``, and the caret is drawn as one inverted cell inside that text, * so wrapping performed after the caret was placed would leave the caret on a * row this module cannot name — and both the visible window, which keeps the * frame short, and the up/down keys are counted in drawn rows, not in the * buffer's own lines. * * Widths and grapheme boundaries both come from `shared/utils/grapheme`, which * measures with the same package Ink lays its frames out with. Rows are cut * between graphemes, so an emoji sequence or a combining sequence is never * split and the caret never lands inside one. */ export interface PromptLayout { /** Drawn rows, top to bottom, each already cut to fit the box. */ readonly rows: readonly string[]; /** Buffer offset each row starts at, so a row position maps back to the text. */ readonly rowStarts: readonly number[]; /** Index into `rows`; the caret is always on a row that exists. */ readonly cursorRow: number; /** Offset into that row's text, in code units, never past its end. */ readonly cursorColumn: number; } /** Columns the prompt box has left for text once its own chrome is paid for. */ export declare function resolvePromptContentWidth(terminalColumns: number | undefined): number; export declare function layoutPromptRows(text: string, cursor: number, contentWidth: number): PromptLayout; /** * The buffer offset one row up or down, keeping the display column where the * row is wide enough and clamping to its end where it is not. Returns null when * the caret is already on the first or last drawn row, which is what hands the * key over to the history. * * The column is read from the caret on every press rather than remembered * across presses, so passing through a short row shortens the column instead of * springing back — the simpler rule, and the one the buffer alone can state. */ export declare function moveCaretByRow(text: string, cursor: number, contentWidth: number, direction: 'up' | 'down'): number | null; /** * The window of rows to draw. It follows the caret and never grows, so the * frame Ink erases each tick stays the same height however long the draft is. */ export declare function selectVisibleRowRange(rowCount: number, cursorRow: number, maxRows: number): { readonly start: number; readonly end: number; }; //# sourceMappingURL=promptLayout.d.ts.map