/** * Line-input state shared by the `!`, `#`, `|`, `s` (log file) and `+` * prompts. */ /** * Session shell-command history shared by `!`, `#` and `|`, like * less's ml_shell; persisted in the history file's .shell section. */ export declare let shellHistory: string[]; /** Replaces the shell history (history file load). */ export declare function setShellHistory(entries: string[]): void; /** * Records an accepted shell command, like cmd_addhist for ml_shell. */ export declare function addShellHistory(text: string): void; /** Registers the --autosave history file writer. */ export declare function onShellAutosave(fn: () => void): void; /** Registers the new-entry recorder. */ export declare function onShellHistRecord(fn: (entry: string) => void): void; /** Registers the history modified-flag raiser (less's cmd_accept). */ export declare function onShellHistTouch(fn: () => void): void; export declare const miscInput: { pending: "" | "!" | "#" | "|" | "s" | "S" | "+"; text: string; }; /** * Pending `|mark: ` request and the collected mark character. */ export declare const pipeMark: { pending: boolean; char: string; /** Second mark of the || form; empty for the single-mark form. */ char2: string; /** Which || mark is being read ('' = single-mark prompt). */ stage: "" | "first" | "second"; /** ^N toggled the prompt into line-number entry (v707). */ lineMode: boolean; /** Digits typed in line-number mode. */ num: string; /** Resolved rows: [first] or [first, second]. */ rows: number[]; /** The same marks as less POSITIONs, when the input is seekable. */ positions: (number | undefined)[]; }; /** * Pending log file overwrite query (`Warning: "x" exists; ...`). */ export declare const overwrite: { pending: boolean; file: string; reminder: boolean; }; /** The active log file name for `_o` queries, empty when unset. */ export declare const logFileName: () => string; /** * Forgets session state (log file, shell and first commands, prompts) * for a fresh pager run. */ export declare function resetMisc(): void; /** * Stores the log file named by -o/-O in $LESS, like opt_o at INIT * setting namelogfile. * * @param name - The log file name, kept unexpanded like less. * @param force - True for -O: overwrite without asking. */ export declare function setStartupLogFile(name: string, force: boolean): void; /** * Opens the $LESS-named log file once the session starts, like less's * use_logfile when the input pipe opens: regular files are not logged, * an existing file raises the overwrite query, and success is silent. * * @returns The pending log, or null when nothing should be logged. */ export declare function takeStartupLog(): { name: string; force: boolean; } | null; /** * Appends newly streamed lines to the active log, like less's ch.c * writing the log file as each buffer is read from the pipe. * * @param lines - The decoded lines just added to the content. */ export declare function appendLogLines(lines: string[]): void; /** * Opens one of the line-input prompts (`!`, `|`, `s`, `+`). * * @param kind - Which prompt to open. */ export declare function startMiscInput(kind: '!' | '#' | '|' | 's' | 'S' | '+'): void; /** The prompt label for each misc input kind, like start_mca's. */ export declare function miscPromptLabel(kind: '!' | '#' | '|' | 's' | 'S' | '+'): string; /** * Handles a key at a misc line-input prompt, examine-style. * * @param key - Raw key input. * @returns `run` to execute, `pending` or `cancel`. */ export declare function miscInputKey(key: string): 'run' | 'pending' | 'cancel'; /** * Opens the log file prompt (`s`, `-o`, `-O`), refusing up front when * the input is not piped-in content, like less checking CH_CANSEEK. * * @param force - True for `-O`: overwrite unconditionally. */ export declare function startLogFile(force: boolean): void; /** * Opens the `|mark: ` prompt for the pipe command. */ export declare function startPipe(): void; /** * Handles the mark character following `|`. * * - The mark resolves immediately, like less's get_pipe_pos: an unset * or invalid mark reports and aborts before the command prompt. * * @param content - Full content lines. * @param key - Raw key input. * @returns True when the mark was taken and the command prompt opens. */ export declare function pipeMarkKey(content: string[], key: string): boolean; /** * Resolves a `!` prompt answer into the command to run, like less: * `!!` repeats the previous command, `%` and `#` expand to filenames, * a leading `^P` suppresses the done message. * * @param text - The raw prompt answer. * @returns The command and the done message (null to suppress). */ export declare function shellCommand(text: string): { cmd: string; doneMsg: string | null; }; /** * Stores the command replayed on each newly examined file (`+cmd`). * * - Leading `+` signs and spaces are skipped; empty input clears it. * * @param text - The raw prompt answer. */ export declare function setFirstCmd(text: string): void; /** * Returns the `+cmd` command, or an empty string when unset. */ export declare function getFirstCmd(): string; /** * Stores the --cmd command, like less's opt_first_cmd_at_prompt. */ export declare function setCmdAtPrompt(text: string): void; /** * Consumes the --cmd command at the first prompt, like less's prompt() * ungetting first_cmd_at_prompt once and clearing it. */ export declare function takeCmdAtPrompt(): string; /** * Resolves an `s`/`-o` prompt answer into a log file action. * * - Only piped-in content can be logged, like less. * * @param text - The raw prompt answer. * @param force - True for `-O`: overwrite unconditionally, never ask. * @returns `write` to save, `ask` when the overwrite query opened, or * null when nothing should happen (message already set). */ export declare function logFileTarget(text: string, force?: boolean): 'write' | 'ask' | null; /** * Handles the answer to the log file overwrite query. * * @param key - Raw key input. * @returns The chosen action; unrecognized keys re-ask with less's * reminder prompt. */ export declare function overwriteKey(key: string): 'overwrite' | 'append' | 'none' | 'quit' | 'pending'; /** * Writes the paged content to the log file. * * @param content - Full content lines. * @param append - True to append instead of overwriting. * @param quiet - True to skip the success report, like less opening a * $LESS-named log file at startup. */ export declare function writeLogFile(content: string[], append: boolean, quiet?: boolean): void; /** * Reports the pager's version (`V`), like less's dispversion. */ export declare function versionMessage(): void; /** * Prints the version to stdout for -V in $LESS, like less's opt__V at * INIT printing and quitting before the pager starts. */ export declare function printVersion(): void;