import { ScreenRow } from './screenTable'; /** * less's position.c operations on the screen table. * * The table is the screen: one entry per row, holding where that row * starts. `add_forw_pos` drops the front and appends at the bottom, * `add_back_pos` prepends at the top, `pos_clear` empties it so the * next paint regenerates from the top position alone. * * The entries a backward move prepends are the whole reason the table * exists rather than a top plus a wrapping rule: back_line re-wraps * from the LINE's start and stops the moment it reaches the row that * used to be on top ("if (new_pos >= curr_pos) break", input.c), so * the row it exposes is bounded by the old screen and the rows below * keep the extents they already had. A single (row, subRow) top can * only say where the screen begins, never that. */ /** * Where the row containing `offset` begins. * * less's back_line reads back to the LINE's start and re-wraps forward * from there (input.c:358), so it lands on the greatest row start * BELOW the position it was given. A top part-way into a row therefore * steps to the boundary it sits inside, and that IS one row - the same * move as any other, needing no special case of its own. */ export declare function rowStartBelow(line: string, offset: number): number; /** The offset of a line's last display row. */ export declare function lastRowStart(line: string): number; /** * The next row's offset, or null when this row ends the line - one * forw_line step, taken from wherever the row actually starts. */ export declare function nextRowOffset(line: string, offset: number): number | null; /** The offset a given wrap sub-row begins at. */ export declare function rowOffsetOf(line: string, subRow: number): number; /** The wrap sub-row an offset falls in, for the renderer's index. */ export declare function subRowAt(line: string, offset: number): number; /** * Puts the top at a place in a line, deriving the sub-row index and * remainder the renderer still asks for. * * Movement works in offsets, like less's table entries; nothing outside * this function may set the two halves independently, or they can * disagree about where the screen starts. */ export declare function setTopOffset(line: string, row: number, at: number): void; /** * less's add_forw_pos (position.c:63), which forw() calls once per row * DRAWN: it shifts the whole table up and appends the new bottom row * in ONE operation, so the table stays sc_height long and the top * moves BECAUSE of the shift. * * We used to do only the dropping here and let buildScreen extend the * bottom separately. That was harmless while the table held just the * seam, but once it holds every row the two halves disagree about who * owns the bottom and a forward move lands on the wrong line. */ export declare function screenForward(content: string[], rows: number): number; /** The top's character offset in its line, in the layout's own space. */ export declare function topOffsetOf(content: string[]): number; /** * The entries from `top` forward until the row that reaches `bound`, * which is where the screen used to start. * * A source engine re-materializes its window on every paint, so the * indices a backward move would have recorded beforehand are gone by * the time the entries are needed. Walking forward from the new top * rebuilds exactly the same rows - back_line landed it on the absolute * grid, so the walk retraces its steps - and the last one is cut at * the bound, which is the seam. */ export declare function screenAhead(content: string[], top: { row: number; offset: number; }, bound: number): ScreenRow[]; /** The rows a backward step exposes, newest first, like back_line. */ export declare function screenBack(content: string[], rows: number, first: ScreenRow): ScreenRow[];