/** * Returns how many extra sub-rows a line will take if it overflows screen * width. * * - Returns 0 if line-chopping is enabled. * - Styled or Unicode lines use the cached layout, so the count always * matches what the renderer actually emits. * * @param line - The string to measure. * @returns Number of sub-rows needed to display the line. */ export declare function maxSubRow(line: string): number; /** Registers the selected link's row/offset for display styling. */ export declare function setOsc8Display(at: { row: number; start: number; } | null): void; /** The raw line a display line was derived from, if it still differs. */ export declare const sourceLine: (display: string) => string | undefined; /** * How many DISPLAYED characters the first `count` raw characters * produce, style codes excluded. * * less needs no such function: it stores one display char at a time and * tags each with its source position - a tab's spaces all carry the * tab's (store_tab, line.c:1056), a caret pair the control char's * (store_prchar, line.c:1069). Transforming the prefix answers the * same question, and only match boundaries ever ask. */ export declare function displayPrefixLength(raw: string, count: number): number; /** * The raw index whose displayed prefix is `shown` characters long - * the inverse of displayPrefixLength, for turning a display position * back into the source position less would have used. */ export declare function sourceIndexAt(raw: string, shown: number): number; /** * The style codes still in force at a character index, so a line can * be resumed part-way and still look right - less carries the same * state forward in shifted_ansi (line.c:282) when it shifts a line. */ export declare function openStyleAt(line: string, index: number): string; /** * The display text of a single line, the transform memoized. * * transformContent still runs unmemoized over a screen's worth of * lines: it is called once per frame there, and the -s squeeze it * applies depends on the lines around each one, which a per-line memo * cannot see. */ export declare function displayLine(raw: string): string; export declare function transformContent(lines: string[]): string[]; /** * The end of the escape run starting at `start`, like cvt_text * consuming an ansi_start sequence (cvt.c:79): characters go while * ansi_step answers ANSI_MID, and the one that ends the run is taken * too - whether it ended it properly (ANSI_END) or aborted it * (ANSI_ERR). That is why ESC[K and ESC(B vanish entirely and not * just their valid prefix. * * @param line - The raw line. * @param start - Index of the ESC. * @returns The index after the run, or `start` when none begins here. */ export declare function ansiRunEnd(line: string, start: number): number; /** * The prompt line through the same char machinery as content, like * less's prompt() handing pr_string's result to load_line (command.c), * which pappends it character by character exactly as forw_line does * a file line: tabs expand to their stops and control characters take * caret notation instead of reaching the terminal. * * The prototype's literal bytes are NOT converted while the prompt is * being built - less's ap_char stores them raw (5a369ed, whose whole * point was that routing them through ap_str corrupts multibyte * chars). The conversion belongs here, at the draw. */ export declare function transformPrompt(line: string): string; /** * less's do_append recognizes an ANSI sequence when ctldisp is ONPLUS * *or* the char has no file position (line.c:1302) - and a prompt is * appended with NULL_POSITION, so its escapes are always live. When one * is there, load_line then leaves the line's own attributes alone * instead of colouring the whole prompt standout (line.c:1950). */ export declare function promptHasAnsi(line: string): boolean; /** * Calculates the total visual width of a string based on terminal character * widths. * * @param line - The input string to measure. * @returns The total visual width of the string in terminal columns. */ export declare function visualWidth(line: string): number; /** * Closes a display line, like less's add_attr_normal from pdone * (line.c:1426, called at line.c:1482 and :1499). * * Under -R less appends a literal "\033[m" to EVERY line, open attribute * or not - it writes those three bytes itself rather than asking * terminfo, and stores them zero-width, so they neither cost a column * nor depend on the terminal. That is what keeps an unclosed colour in * the file from bleeding down the screen. Its companion "\033]8;;\e\\" * goes out only inside an OSC 8 link, which we do not track across the * line end and so never emit. * * Every other ctldisp leaves the line alone in less, because no file * escape survives to that point: only ours can be open, and the reset * below closes it. * * @param line - The line to terminate. * @returns The line with styles guaranteed closed. */ export declare function withReset(line: string): string; /** * Splits a line into grapheme clusters. * * - Keeps multi-code-point sequences (ZWJ emoji, variation selectors, * combining marks) together as single units. * * @param line - The string to split. * @returns Array of grapheme clusters. */ export declare const splitChars: (line: string) => string[]; /** * Checks whether a given segment consists entirely of ASCII characters. * * - Matches characters in the range 0x00 to 0x7F. * - Used to determine whether fast-path rendering can be applied. * * @param segment - A string segment to check. * @returns Whether the segment is pure ASCII. */ export declare const isAscii: (segment: string) => boolean; /** * Checks whether a given string contains ANSI style codes. * * @param line The input string to test. * @returns `true` if ANSI style codes are present, otherwise `false`. */ export declare const isStyled: (line: string) => boolean;