UNPKG

@eagleoutice/flowr-dev

Version:

Static Dataflow Analyzer and Program Slicer for the R Programming Language

38 lines (37 loc) 1.61 kB
import type readline from 'readline'; import type { EventEmitter } from 'events'; import type { FlowrConfig } from '../../config'; export declare const defaultReplHint = ":help \u00B7 Tab completes \u00B7 :query @config +repl.hints=false to hide"; /** ANSI that draws the dimmed `hint` and restores the cursor to where it was. */ export declare function ghostHintShowSequence(hint: string): string; export declare const ghostHintClearSequence = "\u001B[0K"; export interface GhostHintIO { stdin: EventEmitter & { isTTY?: boolean; }; stdout: { isTTY?: boolean; columns?: number; write(s: string): unknown; }; } export interface GhostHintOptions { hint?: string; suggest?: (line: string) => string; } export interface GhostHintController { show(): void; clear(): void; } /** Whether hints may be shown: enabled in the config and on an interactive TTY (honoring `NO_COLOR`/`TERM=dumb`). */ export declare function ghostHintEnabled(config: FlowrConfig, env?: NodeJS.ProcessEnv, stdout?: { isTTY?: boolean; }, stdin?: { isTTY?: boolean; }): boolean; /** * Installs an opt-out ghost hint on the REPL prompt: a dim placeholder on the empty prompt and, as the user * types, a dim preview of the best Tab-completion. A no-op on non-interactive terminals (see * {@link ghostHintEnabled}) and whenever the text would not fit the line, so it can never wrap or corrupt output. */ export declare function installGhostHint(rl: readline.Interface, config: FlowrConfig, { hint, suggest }?: GhostHintOptions, io?: GhostHintIO): GhostHintController;