import { LesskeyForm } from './lesskey'; /** * Opens this session's lesskey files in a pager of their own. * * NOT a less feature. less documents lesskey in a man page and leaves you * to find your own files, which works when a distribution put them * there; an npm install did not, and by the time six sources have * merged (system and user, source and compiled, and two environment * variables) "which lesskey am I actually running" is a fair question * with no way to ask it. * * So it is a VIEWER, not an editor. The pager already pages a list of * files, moves between them with :n and :p, and edits the one on * screen with `v` - which is $VISUAL or $EDITOR, the same as it has * always been. Nothing here needs to spawn an editor or quote a * command line. */ /** One form, and the file that stands in for it on screen. */ interface ViewFile { form: LesskeyForm | null; /** What the pager opens. */ path: string; /** What the prompt calls it, when the path is a temp file. */ display?: string; /** Written here, so it can be cleaned up and compiled back. */ temporary: boolean; } /** * Materializes every loaded form as something the pager can open. * * A source file is already one. A compiled file is rendered back to * source, since bytes cannot be read or edited. A content variable is * written out as the text it holds. */ export declare function lesskeyViewFiles(): { files: ViewFile[]; dir: string | null; }; /** * Reads back what `v` wrote and says what is wrong with it, touching * nothing. * * Checking and loading are separate on purpose. The check runs while * the editor's screen is still up, so its messages print where the * text they are about is - the way a broken lesskey reports before * the pager takes the terminal at startup. The load runs after, and * says nothing: everything worth saying has been said. * * The compiler is the checker for both kinds of form. It parses the * same grammar the reader does and words its errors identically * (tests/lksweep.py compares them against less's own lesskey), and it * has no side effects - so a source file can be checked without * being loaded, which the reader could not do. * * @returns One message per bad line, in less's wording. */ export declare function checkLesskeyEdits(view: ViewFile[], version: number): string[]; /** * Writes back whatever the session may have edited through `v`, and * reloads, so the new bindings are live. * * A source file was edited in place and needs nothing but the reload. * A rendered binary is compiled back over the file it came from - the * one job the compiler exists for. A content variable goes back into * the variable, its lines rejoined with the ";" separators less's own * parser splits on; that cannot outlive the process, which is all an * environment variable ever could. * * @param version - The running less version, for #version lines. * @returns Messages for anything that could not be written back. */ export declare function applyLesskeyEdits(view: ViewFile[], version: number): string[]; /** Seeds a missing default file with less's built-in bindings. */ export declare function seedDefaultKeymap(file: string): boolean; /** Removes the scratch directory a view created. */ export declare function cleanLesskeyView(dir: string | null): void; /** * Marks this session as being the view itself. * * `--view-lesskey` with no file has nothing to open over, so the * forms simply are the file list. The option scan still sees the * flag - from argv, or from $LESS where no filter can reach it - and * would open the view a SECOND time over itself, which took two q's * to leave one screen. */ export declare function markLesskeyViewSession(view: ViewFile[]): void; /** * Names the files of a session that IS the view. * * openLesskeyView does this as it builds the list; a session built by * the ordinary startup path has no such moment, so it happens once * the list exists. */ export declare function nameLesskeyViewSession(): void; /** True while a view is on screen over a stashed session. */ export declare const lesskeyViewOpen: () => boolean; /** True when opening a view again would only stack one on itself. */ export declare const isLesskeyViewSession: () => boolean; /** Clears the mark, for a test or a second session in one process. */ export declare function resetLesskeyViewSession(): void; /** True while the lesskey files are the session's file list. */ export declare const inLesskeyView: () => boolean; /** * Re-reads what `v` just edited, and makes it live. * * less does neither: its A_VISUAL is `lsystem(editproto)` and nothing * else (command.c:2137), so the screen keeps the text it had until R * flushes the buffers (clear_buffers, command.c:1846). That is right * for a file you are reading and wrong for this screen, where the * whole reason to open an editor is to change what the pager does - * and the edit taking effect only on the way out would mean quitting * to find out whether it worked. * * @returns A message when a write-back failed, else null. */ export declare function refreshLesskeyView(version: number): string[]; /** * Swaps the lesskey files in as the session's file list. * * The same move the help screen makes, one level up: help stashes the * CONTENT and puts it back, this stashes the FILE LIST. Which has to * be the file list rather than a rendered blob, because the whole * point is that :n and :p walk between the forms and `v` opens the * one on screen in an editor - both of which are things the pager * only does for real files. * * A nested pager() would have been the obvious way and is the wrong * one: two sessions sharing one screen means two painters, and the * outer one's prompt timers keep firing into the row the inner one is * drawing on - measured as a doubled ":" on the prompt line, and a * `q` that tore down the shared keyboard and took both sessions with * it. * * @returns False when there is nothing to show, or a form could not * be opened - the session is untouched either way. */ export declare function openLesskeyView(): boolean; /** * Puts the session back, like exitHelp: the stashed list returns and * the file that was open re-opens at its saved position. * * Anything edited through `v` is written back first - a rendered * binary compiled over the file it came from - and the tables are * reloaded, so a key changed in there works on the way out. * * @param version - The running less version, for #version lines. * @returns False when no lesskey view is open, so `q` can mean quit. */ export declare function exitLesskeyView(version: number): boolean; export {};