import { FileEntry } from "./files"; /** * Jumps to line `lineNum` in the content, placing it at the top of the * screen (`g`, `<`, `ESC-<`). * * - Reports an error like less when the line does not exist. * * @param content - Full content lines. * @param lineNum - 1-based target line number, or 0 when none was given. */ export declare function firstLine(content: string[], lineNum: number): void; /** * Jumps to the end of the content, placing the last line at the bottom of * the screen (`G`, `>`, `ESC->`). * * - With a number, behaves exactly like `firstLine` (as in less). * - Rings the bell when already at the end. * * @param content - Full content lines. * @param lineNum - 1-based target line number, or 0 to jump to the end. * @returns True when jump_forw's end jump ran (past its eof_bell) — * the caller decides whether it was less's pos_clearing G or the * buffered F entry. */ export declare function lastLine(content: string[], lineNum: number): boolean; /** * Null rows above BOF for an end jump on short content, like jump_loc's * back-walk from the last line hitting BOF and handing the remainder to * forw as blank lines at the top of the screen (jump.c:316): G and F * bottom-anchor a file shorter than the window under a run of tildes. */ export declare function endPad(content: string[]): number; /** * Jumps `percent` percent into the content, placing the target line at the * top of the screen (`p`, `%`). * * - Percentages above 100 are clamped to 100, like less. * - 100 percent lands on the last line, not past it. * * @param content - Full content lines. * @param percent - Percentage into the content, 0 for the beginning. */ export declare function percentLine(content: string[], percent: number): void; /** * Jumps to a byte offset in the content (`P`), like less's jump_pos: * the line containing the offset lands on the -j target line. * * @param content - Full content lines. * @param offset - Byte offset, 0 for the beginning. */ export declare function goPos(content: string[], offset: number): void; /** * Custom bracket command state (`ESC-^F` / `ESC-^B`): collects the two * characters naming the open and close bracket, like less's `Brackets: ` * prompt. */ export declare const brackets: { pending: "" | "f" | "b"; chars: string; n: number; }; /** * Opens the `Brackets: ` prompt for a custom bracket pair. * * @param forward - True for `ESC-^F` (find close), false for `ESC-^B`. * @param n - N-th reference bracket to match. */ export declare function startBrackets(forward: boolean, n: number): void; /** * Collects the two custom bracket characters, then runs the match. * * - `^C` or any ESC sequence cancels the prompt. * * @param content - Full content lines. * @param key - Raw key input following `ESC-^F` / `ESC-^B`. */ type BracketFinder = (open: string, close: string, forward: boolean, n: number) => boolean; export declare function bracketsKey(content: string[], key: string, finder?: BracketFinder | null): void; /** * Bracket matching, ported from less's match_brac (brac.c). * * - Forward: finds the n-th `open` in the top displayed line, scans forward * counting nesting, and places the line holding the matching `close` on * the bottom line of the screen. * - Backward: finds the n-th `close` in the bottom displayed line, scans * backward, and places the line holding the matching `open` on top. * - Reference scans start at the first displayed character (mid-line when * the top/bottom row shows a wrapped chunk) and run to the line's end. * * @param content - Full content lines. * @param open - Open bracket character. * @param close - Close bracket character. * @param forward - Scan direction. * @param n - N-th reference bracket in the reference line. */ export declare function matchBracket(content: string[], open: string, close: string, forward: boolean, n: number): void; /** * Returns the raw string index where a wrapped sub-row starts. * * @param line - The raw content line. * @param subRow - Wrapped sub-row index. */ /** * Advances the top over the rows a backward move uncovered, treating * the anchor as a row boundary. * * less's forw() generates each row from the current bottom and * add_forw_pos drops table[0] (position.c:63), so moving forward * walks the entries the backward moves prepended - the last of which * ends AT the anchor - before the grid below resumes. Returns the * rows it consumed. */ /** * less's pos_rehead (position.c): every horizontal shift command moves * table[TOP] back to the BEGINNING of its line first - LSHIFT, * RSHIFT, LLSHIFT, RRSHIFT and the horizontal wheel all call it * (command.c:1740, :1754, :2459, :2473, :2483, :2493) - and trashes * the screen, so the repaint regenerates from there. A top already on * a line start is left alone ("if (linepos == tpos) return"). * * The move is permanent: shifting right and back left again leaves * the screen at the line's start, not where it was. */ export declare function posRehead(): void; export declare function subRowStart(line: string, subRow: number): number; /** * Returns the sub-row whose range contains a raw string index; an * index exactly on a wrap boundary belongs to the sub-row it starts. */ export declare function subRowOfIndex(line: string, index: number): number; /** * A marked position: a content position plus the 1-based screen line it * occupied, like less's scrpos, and the file it belongs to (m_ifile). */ export interface Mark { /** * The file itself, not its place in the list. * * less's mark holds an IFILE pointer, which stays valid however the * list is reordered, spliced or swapped out. A list index does not: * every change to the list silently re-points every mark, which is * why this used to need a renumbering pass on :d and a snapshot * around --view-lesskey. The entry object is our ifile. */ file: FileEntry; row: number; subRow: number; sline: number; /** Seekable inputs retain less's byte POSITION across window changes. */ pos?: number; } /** * Shifts user marks after the front of a streaming pipe is recycled, * like less's positions inside discarded buffers becoming unreadable: * marks above the cut are lost. * * @param drop - Display rows removed from the front. */ export declare function shiftMarkRows(drop: number): void; /** * A mark restored from the history file (less's file_marks): the mark * letter, its screen line, byte position and file name. */ export interface FileMark { char: string; sline: number; pos: number; path: string; } /** Stores marks parsed from the history file's `.mark` section. */ export declare function setFileMarks(restored: FileMark[]): void; /** The history-file marks, re-saved and merged by saveHistory. */ export declare function getFileMarks(): FileMark[]; /** Canonical file name, like less's lrealpath (falls back unchanged). */ export declare function realPath(path: string): string; interface SourceMarkHooks { position(row: number, subRow: number): number | null; linePosition(line: number): number | null | undefined; jump(mark: Mark, sline: number): boolean; } /** Registers the active seekable input's byte-position mark operations. */ export declare function onSourceMarks(hooks: SourceMarkHooks | null): void; /** Registers gomark's edit_ifile paths: switching to an open entry's * mark, and opening a restored mark's file by name. */ export declare function onMarkSwitch(switchFn: (mark: Mark, sline: number) => void, editFn: (path: string, char: string, sline: number) => void): void; /** Lists the active user marks, for --save-marks persistence. */ export declare function allMarks(): { char: string; mark: Mark; }[]; /** * Applies history-file marks to a freshly examined file, converting * byte positions back to rows, like less resolving file_marks. * * @param index - The examined entry's index in the file list. * @param lines - The file's content lines. */ export declare function adoptFileMarks(index: number, lines: string[]): void; /** * Mark command state: which prompt is open (`set mark: `, `goto mark: `, * `clear mark: `) and the captured N prefix. */ export declare const marks: { pending: "" | "m" | "M" | "'" | "c"; n: number; }; /** * Opens the `set mark: ` prompt (`m`, `M`). * * - Silently ignored on the help screen, like less. * * @param bottom - True to mark the bottom displayed line (`M`). * @param n - Line number to mark instead of the screen position. */ export declare function startSetMark(bottom: boolean, n: number): void; /** * Opens the `goto mark: ` prompt (`'`, `^X^X`). * * @param n - Screen line to place the mark on, overriding the stored one. */ export declare function startGoMark(n: number): void; /** * Opens the `clear mark: ` prompt (`ESC-m`). */ export declare function startClearMark(): void; /** * Returns the letter of a user mark on a content row of the current * file, for the -J status column, or an empty string. * * @param row - Content row to look up. */ export declare function markAtRow(row: number): string; /** Every mark, for a caller about to swap the file list underneath. */ export interface MarkSnapshot { user: [string, Mark][]; quote: Mark | null; } /** * Copies the marks aside. * * A mark names its file by INDEX (less's ifile pointer, which we cannot * hold), so anything recorded while a different file list is in place * points somewhere else entirely once the old list returns - the * automatic ' mark included, since edit_ifile records one on every * switch. Whoever swaps the list puts the marks back with it. */ export declare function markSnapshot(): MarkSnapshot; /** Puts a snapshot back, dropping anything marked in the meantime. */ export declare function restoreMarkSnapshot(snapshot: MarkSnapshot): void; /** * Forgets all marks and closes any mark prompt. */ export declare function resetMarks(): void; /** * Handles the character following a mark command. * * - Erase and newline characters cancel silently, like less; `^C` and ESC * sequences cancel by this pager's prompt convention. * * @param content - Full content lines. * @param key - Raw key input following the mark command. */ export declare function marksKey(content: string[], key: string): void; /** * Lands a resolved mark on its screen line, gomark's jump_loc tail. */ export declare function jumpToMark(content: string[], mark: Mark, sline: number, fresh?: boolean): void; /** * Finishes a cross-file gomark once its file is open: the mark should * have been adopted by the open (mark_check_ifile). */ export declare function jumpToUserMark(content: string[], char: string, sline: number): void; /** * Places a target on a screen row with less's jump_loc semantics. * * - A target already sitting on its destination screen row rings the bell * and moves nothing (back(0) hitting eof_bell in less). * - The previous position is recorded only on the full-repaint paths; * the on-screen scroll and both "Surprise!" close-enough branches of * jump_loc skip lastmark, so short jumps are not remembered by `''`. * * @param content - Full content lines. * @param row - Target row. * @param subRow - Target sub-row. * @param sindex - 0-based screen row to place the target on. */ export declare function jumpLoc(content: string[], row: number, subRow: number, sindex: number, fresh?: boolean): void; /** * Resolves a mark character to its content row for the `|` command, * like less's markpos. * * @param content - Full content lines. * @param char - Mark letter or predefined mark. * @returns The row, or null with a message set. */ export declare function markRow(content: string[], char: string): number | null; /** * A line number as a byte POSITION, like less's find_pos -- which is * what get_pipe_pos returns for its `|line number: ` entry. * * @param lineNum - 1-based line number. * @returns The position, or undefined when this input has none. */ export declare function linePos(lineNum: number): number | null | undefined; /** * Resolves a mark character to its byte POSITION, like less's markpos. * * less's marks ARE positions: a mark holds an scrpos, and markpos hands * pipe_pos the raw m_scrpos.pos. Ours hold a local row as well, and a * row is only meaningful while the window that produced it is still * mapped -- once it slides, the same row names different bytes. Every * caller that compares one mark against another (the pipe) has to work * in positions for that reason. * * @param content - Full content lines. * @param char - Mark letter or predefined mark. * @returns The byte position, or undefined when this input has none. */ export declare function markPos(content: string[], char: string): number | undefined; /** * Saves the current top position as the previous position (`''`). * * - Refused on the help screen, like less's lastmark. * - Also called when entering the help screen: less's edit_ifile records * the last position whenever it leaves the current file (edit.c). */ export declare function recordLastPosition(): void; /** * Resolves the last non-empty displayed position and its screen line, * like less's get_scrpos(BOTTOM) scanning up past rows beyond EOF. * * @param content - Full content lines. */ /** * Sets the mouse mark `#` at a clicked screen line (0-based), like * less's mouse_button_left calling setmark('#', y, 0). */ export declare function setMouseMark(content: string[], y: number): void; /** * Jumps to the mouse mark, like mouse_button_right's gomark('#', 0). */ export declare function goMouseMark(content: string[]): void; export {};