/** * Option value types, like opttbl.c: BOOL toggles, TRIPLE has lower and * upper states, NUMBER and STRING prompt for a parameter, NOVAR runs an * action. */ import { OptionSpec } from './spec'; export * from './state'; export * from './shared'; export * from './spec'; /** * Runtime option command state (`-`, `--`, `_`, `__`): pending command, * long name collection, parameter collection and the -+/-! modifier. */ export declare const option: { pending: "" | "-" | "_"; name: string | null; spec: OptionSpec | null; upper: boolean; param: string; flag: "" | "+" | "!"; /** True once the long name auto-completed to a unique option. */ match: boolean; /** The long-name match and the typed first-char case. */ matchSpec: OptionSpec | null; matchUpper: boolean; /** Suppresses the setting message, toggled by ^P (OPT_NO_PROMPT). */ noPrompt: boolean; /** TAB completion candidates over long option names. */ tabList: string[] | null; tabIdx: number; }; /** * Opens the option prompt. * * @param command - `-` to toggle an option, `_` to query its state. */ export declare function startOption(command: '-' | '_'): void; /** * Handles input following a `-` or `_` command. * * - A doubled `-`/`_` collects a long option name (`--chop-long-lines`), * terminated by RETURN or `=` before an inline parameter. * - An uppercase long name selects a triple's second state, like less * (`--QUIT-AT-EOF`). * - `-+` resets an option to its default, `-!` sets it, like less. * - Number and string options prompt for their parameter. * * @param content - Full content lines. * @param key - Raw key input following the option command. */ export declare function optionKey(content: string[], key: string): void; /** What the $LESS scan tells the pager to do at startup. */ interface StartupCmds { /** `+`/`-p` commands replayed at the first file, in order. */ firstCmds: string[]; /** True when `-?`/`--help` pages the help file first (less's dohelp). */ dohelp: boolean; /** The same, for --lesskey-help and the lesskey syntax page. */ lesskeyHelp: boolean; viewLesskey: boolean; /** True when -V printed the version: the pager must not start. */ version: boolean; } /** * Marks the $LESS_UNSUPPORT options as ignored by the $LESS scan, * like option.c's init_unsupport: entries are option letters or long * names, each optionally preceded by dashes. */ export declare function initUnsupport(env: string): void; /** * Reports a still-dangling option after all startup scans, like less's * main calling nopendopt() when isoptpending() survives the argv loop. */ export declare function flushPendopt(): void; /** Prints an option's name for messages (option.c's opt_desc). */ export declare const optionDesc: (spec: OptionSpec) => string; /** The full option table, for the API type generator and its guard. */ export declare const optionSpecs: () => OptionSpec[]; /** * Walks one command line argument the way scan_option consumes it and * returns the option left waiting for a value, like less's isoptpending * classifying the next argv string as a parameter rather than a file. * Nothing is applied and no messages print. * * @param arg - The command line argument. * @param pending - The option dangling from the previous argument. * @param seen - Called with each option the argument names. */ export declare function optionArgPending(arg: string, pending: OptionSpec | null, seen?: (spec: OptionSpec) => void): OptionSpec | null; /** Stores the CLI option strings for the next session's scan. */ export declare function setCliOptions(args: string[]): void; /** Takes (and clears) the pending CLI option strings. */ export declare function takeCliOptions(): string[]; /** * Applies the $LESS environment options at startup, like option.c's * scan_option with INIT semantics: no-toggle options may be set, string * and number parameters follow their option (`$` terminates a string), * `-+x` resets to the default, `+cmd` queues commands for the first * file (`++cmd` for every file), and `-r` acts as `-R` only in the * environment (less's is_env), not in a command line argument. * * @param env - The $LESS string (or one command line argument). * @param content - Full content lines for display-affecting setters. * @param isEnv - False for a command line argument. * @returns Commands and flags the pager applies at startup. */ /** * Does this option string ASK for --no-shell? * * A read-only walk over the same name matching scan_option uses, for * deciding whether an environment demands the safety flag. It must * not be the real scan: running that twice would re-apply handlers * with side effects of their own (a --lesskey-content would load its * bindings again), and this string may never be scanned at all. * * A `+` reset (`--+no-shell`) is not a request, it is the opposite. * * @param text - An option string, like a $LESS value. */ export declare function requestsNoShell(text: string): boolean; export declare function scanOptions(env: string, content: string[], isEnv?: boolean): StartupCmds;