/** The three F flavors, like less's A_F_FOREVER/_BELL/_UNTIL_HILITE. */ type FollowKind = 'forever' | 'bell' | 'hilite'; /** What one follow poll found. */ type FollowPoll = /** No new data. */ { kind: 'idle'; } /** New complete lines; the first extends a partial last line. */ | { kind: 'data'; lines: string[]; extendTail: boolean; } /** --follow-name: the name points to a new file; reopen it. */ | { kind: 'rotate'; } /** --exit-follow-on-close: the input closed; leave the F wait. */ | { kind: 'close'; }; /** * F command state: the followed descriptor, the read offset, undisplayed * partial-line bytes, and keys typed during the wait (less ungets them; * they run as commands only when the loop ends without a signal — * READ_INTR exits run getcc_clear and discard them). */ export declare const follow: { active: FollowKind | null; fd: number; readPos: number; carry: Buffer; /** True while the displayed last line misses its newline. */ tailPartial: boolean; queued: string[]; }; interface SourceFollowHooks { /** Pins the active source to its current physical end. */ pinEnd(entering: boolean): boolean; /** Refreshes the source after pollFollow observed new bytes. */ refresh(): boolean; } /** Registers the active seekable input with the shared follow loop. */ export declare function onSourceFollow(hooks: SourceFollowHooks | null): void; /** * Opens the current file for the F command, like forw_loop entering * ignore_eoi mode. The in-memory pseudo-file has no descriptor and can * never grow, so it waits like less at the end of a closed pipe. * * @param kind - Which F flavor runs. * @returns True when following started; false with a message set. */ export declare function startFollow(kind: FollowKind): boolean; /** * Leaves the F wait, like forw_loop returning to the command prompt. * * @returns The keys typed during the wait, to run as commands. */ export declare function stopFollow(): string[]; /** * Checks the followed file for new data, like the ch.c read layer * waiting for data every 50ms. * * - Complete new lines are returned; a trailing partial line waits in * the carry until its newline arrives. * - --follow-name reopens when the name points to a different file or * the file shrank, like curr_ifile_changed. * - --exit-follow-on-close leaves the wait when a pipe's writer has * closed and its data is drained (less's POLLHUP-without-POLLIN); * like less it never fires for a regular file, which cannot HUP. */ export declare function pollFollow(): FollowPoll; /** * Starts the F command, like forw_loop: jump to the end of the file, * then wait for new data, polling every 50ms like less's read layer. * * @param kind - `forever` (F), `bell` (ESC-f) or `hilite` (ESC-F). */ export declare function beginFollow(kind: FollowKind): void; /** * Leaves the F wait, like forw_loop returning to the command loop. * * @returns Queued keys when the caller replays them itself (only a * signal-less exit does; interrupts discard them, getcc_clear). */ export declare function endFollow(): string[]; export {};