/** * Converts a buffer string to a number. * * - Parses the string as a base-10 integer. * - Returns 0 if the input is not a valid number or equals 0. * * @param buffer - The string array to convert. * @returns Parsed numeric value, or 0 if invalid. */ export declare function bufferToNum(buffer: string[]): number; /** * Normalizes unknown input into an array of valid file paths. * * - Accepts a string, an array, or nested arrays containing strings. * - Filters out non-string values and paths that do not exist on the * filesystem. * * @param input - A potential file path, array of paths, or nested arrays. * @returns An array of existing file paths. */ /** * Flattens input into file paths WITHOUT dropping missing ones: less's * main passes every name to edit, which errors per file ("b: No such * file or directory") and quits with an error when none opened. */ export declare function inputToRawPaths(input: unknown): string[]; export declare function inputToFilePaths(input: unknown): string[]; /** * Converts any input to a string array. * * - Strings and primitives are split by newline. * - Objects are stringified with optional formatting. * * @param input - Value to convert. * @param tabObject - Whether objects indent, one tab per level. * @returns - Array of strings representing the input. */ export declare function inputToString(input: unknown, tabObject: boolean): string[]; /** * Builds the left gutter for a display row: the -J status column and * the -N line number field, identical on a wrapped line's every row * (less's per-row plinestart from the line's base_pos). Empty when * neither option is on. * * @param content - Display lines. * @param row - The content row of this display row. * @param from - Cluster index where this screen row starts in the line. * @param to - Where it ends. less's status column asks whether a match * falls in THIS row's range, so a wrapped line's rows differ. */ export declare function gutterFor(content: string[], row: number, from?: number, to?: number): string; /** * Columns a line's -N number overflows the nominal field by: less pads * only to linenum_width and the wider digits eat into the LINE's * text area — the line buffer holds the actual prefix and fills the * rest to sc_width (line.c:446, the ragged field its :457 comment * admits). The line's layout width shrinks by this much. */ export declare function gutterOverflow(row: number): number; /** True when display rows carry a gutter or the -w attn highlight. */ export declare const decoratedRows: () => boolean; /** * Applies the row highlight for -w attn, --hilite-target and * --status-line marks: with --status-line the standout spans the * entire screen width, like less. * * @param text - The formatted row text. * @param row - The content row. * @param sindex - The 0-based screen line the row is displayed on. * @returns The row, highlighted when it is the attn, target or a * marked line. */ export declare function highlightRow(text: string, row: number, sindex?: number): string; /** Forgets the eof bell rate limit, like a fresh less process. */ export declare function resetBellTimer(): void; /** * Rings the terminal bell. * * - Like less's lbell/eof_bell: `-q` replaces eof/bof bells with the * visual bell, `-Q` replaces every bell, and --no-vbell suppresses * the flash. Eof/bof bells ring at most once per second. * * @param kind - `eof` for end/beginning-of-file bells, `error` otherwise. */ export declare function ringBell(kind?: 'error' | 'eof'): void; export declare function formatContent(content: string[]): string[]; /** * Adds a character to the input buffer. * * - Increments buffer offset if visible width limit is reached. * * @param buffer - Current input buffer array. * @param key - Character to append. */ export declare function addBufferChar(buffer: string[], key: string): void; /** * Removes the last character from the input buffer. * * - Decrements buffer offset if no visible characters remain. * * @param buffer - Current input buffer array. */ export declare function delBufferChar(buffer: string[]): void; /** * Forgets the previously rendered frame, forcing the next render to redraw * the whole screen. Call when entering a fresh screen (session start). * * @param keepPainted - keep the "something has been drawn" flag, less's * !first_time. less clears the position table on every content swap * (pos_clear) but sets first_time only at STARTUP and for * redraw_on_quit (main.c:592) — swapping in the help file is an * ordinary edit(), so the "...skipping..." marker still prints * (forwback.c:272). Clearing it here suppressed that marker. */ export declare function resetRender(keepPainted?: boolean): void; /** Forgets an owed --end-prompt marker: a NEW session only — less's * prompting flag survives edits (help entry included) and clears * solely by firing. */ export declare function resetPrompting(): void; /** The most recently rendered screen rows, for --redraw-on-quit. */ export declare function lastScreen(): string[] | null; /** Arms less's post-toggle repaint(), run at the next true prompt. */ export declare function markFullRepaint(): void; /** * less's O_HL_REPAINT: toggle_option calls chg_hilite BEFORE it prints * the option's message (option.c:463), and chg_hilite re-highlights * the screen through repaint_hilite, which redraws every row * (search.c:1119). So the new rendering is on screen UNDER the * message, not after it - unlike plain O_REPAINT, whose screen_trashed * waits for the next make_display. */ export declare function markHiliteRepaint(): void; /** * The same, for the O_HL_REPAINT options whose message the ofunc * prints ITSELF - the three --no-search-header* ones, the only * O_HL_REPAINT entries with a NULL ovar (opttbl.c:697, :703, :709). * * toggle_option erases the highlights first (repaint_hilite(FALSE), * option.c:365) and calls chg_hilite only at :464, AFTER the ofunc. * For these three the ofunc's own error() blocks in get_return before * that, so the message lands over the erased screen and the * highlights come back on the next command, recomputed under the new * setting. Every other O_HL_REPAINT option has toggle_option print * the message at :480 - after chg_hilite - so its frame keeps them. * * Measured on the live binary: --no-search-headers emits one SGR 7, * the message's own; --proc-backspace emits the highlights too. */ export declare function markHiliteErase(): void; /** True while such a repaint is still owed. */ export declare const hiliteRepaintPending: () => boolean; /** Whether a repaint is armed and waiting for a true prompt. */ export declare const fullRepaintArmed: () => boolean; export declare function freezeFrame(homeOnUnfreeze?: boolean): void; export declare function unfreezeFrame(): void; /** * Seeds the previous frame as a blank screen, so frozen frames show * less's unpainted display while startup ungot commands (the errmsgs * gate key, +cmds) collect input before the first make_display. */ export declare function seedBlankFrame(): void; /** * Seeds the previous frame with rows painted OUTSIDE the renderer * (a raw squish repaint at a blocking gate), so a following frozen * render preserves exactly what is on screen. */ export declare function seedFrameRows(rows: string[]): void; /** * Marks the bottom line as clobbered by a raw writeSync (a mid-scan * ierror like "Calculating line numbers..."): the next render must * repaint the prompt row instead of deduping it, less's prompt() * rewriting the cleared bottom line at every command loop. */ export declare function dirtyBottomRow(): void; /** * less's squish_check (forwback.c:88), which error() calls before it * writes anything: a squished first paint - a short file stuck to the * bottom of the screen with nothing above it - is un-squished and * repainted, so the message lands over a normal screen with the text * at the top and tildes below it. * * render() does this itself for a message it is about to draw; this is * for the gated messages, which write straight to the terminal and * would otherwise leave the squished frame underneath. */ export declare function squishCheck(): void; /** Arms less's first_time for a new session. */ export declare function resetFirstPaint(): void; /** * How long the keyboard must stay quiet before the ":" comes back. * * Without it the ":" blinks through a burst's tail: macOS auto-repeat * spaces its last keys further and further apart, so each one finds an * empty queue and looks like the end of the scroll. */ export declare const PROMPT_SETTLE_MS = 150; /** * Tells the paint we are BEHIND the keyboard - another key was already * waiting when this one started. * * That is the state less is in whenever it polls mid-read and ungets, * and it is the honest signal for "the user is scrolling faster than * the screen can follow", which is when the ":" must stay out of the * way. The help file declines it: less's ch never polls CH_HELPFILE, so * no help command ever finds its prompt suppressed. */ export declare function markBurst(burst: boolean): void; /** * A command that took long enough to stall the key loop - our own * version of less going to disk. */ export declare function markCommandTime(took: number): void; /** * The key queue reporting that it has not drained for a while - the * listener is stalled, which is the thing the user actually sees. */ export declare function markBehind(): void; /** * less's `nlines == 0` (forwback.c:335, :372): THIS command broke out * before moving a line, so it read nothing and ungot nothing. * * Raised by eof_bell, which less calls at exactly those points, and * cleared at the start of the next command (armStall) - so it always * describes the command that just ran and nothing older. */ export declare function markStalled(): void; /** * Assumes the command about to run WILL move, until its eof_bell says * otherwise. * * This used to be a latch cleared by comparing painted rows, on the * theory that changed content is less's `nlines > 0`. It is - but only * where a comparable frame exists: a frozen frame, an mca holding the * screen, or any path that does not repaint leaves the flag standing, * and a stale flag means the collapse below starts eating keys while * the screen is genuinely moving. Asking each command afresh cannot * go stale. */ export declare function armStall(): void; /** Whether the command just run moved nothing - so an identical key * behind it will do nothing either (core.ts collapses those). */ export declare const isStalled: () => boolean; /** * Whether the ":" is being held off - so cmd_exec flushes its clear * like less, and the frame leaves the row alone. */ export declare const promptHolding: () => boolean; /** Ends the hold once the keyboard has settled and the ":" can return. */ export declare function endPromptHold(): void; /** Paints the content with no prompt row, like less mid-command. */ export declare function renderBare(rawContent: string[], buffer: string[]): void; /** * less's repaint_hilite (search.c:276): every row redrawn IN PLACE - * goto_line, clear_eol, put_line - and then lower_left. It addresses * each row rather than homing once, which matters when a row is wider * than the screen: the terminal wraps it and the following addressed * rows land INSIDE the wrapped text, which is exactly the interleaving * less produces under -r. */ export declare function renderHiliteRepaint(rawContent: string[], buffer: string[]): void; export declare function render(rawContent: string[], buffer: string[]): void; /** * less's get_back_scroll (forwback.c:535): zero when the terminal can * neither add a line nor reverse-index (no_back_scroll, so every * backward movement repaints), -h when it is set, a whole screen * minus two under -c, where every repaint starts a new screen anyway, * and no limit at all otherwise. */ export declare const backScrollCap: () => number; /** * less's clear_bot: erase from the left of the current (prompt) line, * or jump to the physical bottom row first with --old-bot * (screen.c's lower_left vs line_left). */ export declare function clearBot(): string; /** The block engine reporting how far its last move scrolled. */ export declare function noteScrollRows(n: number): void; /** Marks the next scroll-mode paint as a fresh screen entry. */ export declare function screenEntered(): void; /** * less's jump_loc far-backward branch clearing before back(): * cmd_exec's clear_bot for the command, then `if (!top_scroll) * lclear(); else home();` (jump.c:353). back() repaints from there * when a whole screen exceeds get_back_scroll, and the repaint brings * no clear_bot of its own. */ export declare function markFarBackClear(): void; /** * less's DO_SEARCH (command.c:1973): a repeated search runs * `mca_search(); cmd_exec();` first, so the search prompt is written * over the command line and then cleared away again before anything * is painted - a visible "/" flash on every n and N. */ export declare function markSearchFlash(label: string): void; /** Marks the next scroll-mode paint as a bare re-edit repaint. */ export declare function markBareRepaint(prefix?: string): void; /** Forces the next full paint to clear and home, like less's forw * with top_scroll (also jump_loc's !full_screen lclear). */ export declare function markClearHome(): void; /** * The --end-prompt string owed to the next output, like less's putchr * checking `prompting` (output.c:496): consumed once per prompt, * suppressed for prompts painted on the help file. */ export declare function eprPrefix(): string; /** * Whether anything has been painted yet. * * less's position table is empty until the first make_display, and a * forward move asks position(BOTTOM_PLUS_ONE) before anything else -- * with no table there is no row past the bottom, so it bells rather * than moving. That only happens before the FIRST paint: a key ungot * at the startup gate runs while prompt() is still skipping. */ export declare const screenPainted: () => boolean; /** * Marks the next paint as less's jump_loc far-BACKWARD branch: lclear() * then back(sc_height-1) from the target (jump.c:353), a cleared * screen painted upward through home + reverse index. */ export declare function markBackPaint(): void; /** Marks the next paint as less's pos_clear'd jump (G). */ export declare function markPosClear(): void; export declare function resetDumbPaint(): void; /** * Counts the dumb screen as painted, so the next full frame carries * less's "...skipping..." marker: a search executing before any paint * compresses less's paint-repaint sequence, whose final repaint is * always past first_time. */ export declare function markDumbPaint(): void; /** * Composes the full screen: the formatted content rows plus the bottom * prompt line (expanded prototype, input prompt or message). * * @param rawContent - The string content to display. * @param buffer - Array of buffer characters. * @returns The screen rows, top to bottom. */ export declare function screenRows(rawContent: string[], buffer: string[], open?: boolean): string[]; /** * Calculates the last content row and sub-row that fits in the current window. * * - Works backwards from the end of content. * - Accounts for wrapped lines that span multiple screen rows. * * @param content - The full array of content lines. * @returns Object containing the last visible row index and sub-row offset. */ export declare function getLastRow(content: string[]): { lastRow: number; lastSubRow: number; }; /** * Recalculates the EOF anchor position for the current window size. * * - Stores the last window-fitting row and sub-row in `config`. * - Sets `mode.EOF` when the whole content already fits the window. * * @param content - The full array of content lines. */ export declare function calculateEOF(content: string[]): void; /** * Returns the prompt string to be shown at the bottom of the screen. * * - Input prompts and messages take precedence; otherwise the -P * prototype for the current -m/-M style expands like less, falling * back to `:` when it comes out empty. * * @param content - Display lines, for prompt expansion. * @returns The prompt string. */ export declare function getPrompt(content: string[]): string;