@eagleoutice/flowr-dev
Version:
Static Dataflow Analyzer and Program Slicer for the R Programming Language
81 lines (80 loc) • 3.19 kB
TypeScript
export declare const enum FontStyles {
Bold = 1,
Faint = 2,
Italic = 3,
Underline = 4
}
export declare const enum Colors {
Black = 0,
Red = 1,
Green = 2,
Yellow = 3,
Blue = 4,
Magenta = 5,
Cyan = 6,
White = 7
}
export declare enum ColorEffect {
Foreground = 30,
Background = 40
}
export type FormatOptions = ColorFormatOptions | WeightFormatOptions | ColorFormatOptions & WeightFormatOptions;
export interface ColorFormatOptions {
color: Colors;
effect: ColorEffect;
/** use the high-intensity variant */
bright?: boolean;
}
export interface WeightFormatOptions {
style: FontStyles | readonly FontStyles[];
}
export interface OutputFormatter {
format(input: string, options?: FormatOptions): string;
getFormatString(options?: FormatOptions): string;
reset(): string;
/**
* Render `text` as a link to `url` in whatever form this output supports (OSC 8, markdown, or plain text).
* When a live hyperlink cannot be rendered, the raw `url` is shown so the target is not lost; pass
* `force` to always emit just the short `text` label instead.
*/
hyperlink(text: string, url: string, force?: boolean): string;
}
export declare const voidFormatter: OutputFormatter;
export declare const markdownFormatter: OutputFormatter;
/**
* This does not work if the {@link setFormatter|formatter} is void. Tries to format the text with a bold font weight.
*/
export declare function italic(s: string, f?: OutputFormatter, options?: FormatOptions): string;
/**
* This does not work if the {@link setFormatter|formatter} is void. Tries to format the text with an italic font shape.
*/
export declare function bold(s: string, f?: OutputFormatter, options?: FormatOptions): string;
/**
* Color the text in the given foreground color.
*/
export declare function color(s: string, c: Colors, f?: OutputFormatter, opts?: {
bright?: boolean;
style?: FontStyles | readonly FontStyles[];
}): string;
/** Faint/dim ("grayed out") text. */
export declare function faint(s: string, f?: OutputFormatter, options?: FormatOptions): string;
/**
* This does not work if the {@link setFormatter|formatter} is void. Tries to format the text as informational message.
*/
export declare function ansiInfo(s: string, f?: OutputFormatter): string;
export declare const escape = "\u001B[";
/** The text without any colouring, for wherever an escape sequence would only show up as `[0m`. */
export declare function stripAnsi(text: string): string;
/** best-effort, env-based OSC 8 hyperlink support (`FORCE_HYPERLINK`/`NO_HYPERLINK` override; unknown terminals are treated as unsupported) */
export declare function supportsHyperlinks(): boolean;
export declare const ansiFormatter: {
reset(): string;
hyperlink(text: string, url: string, force?: boolean): string;
format(input: string, options?: FormatOptions): string;
getFormatString(options?: FormatOptions): string;
};
export declare let formatter: OutputFormatter;
/**
* (Globally) sets the output formatter used by the utility functions in this module.
*/
export declare function setFormatter(setFormatter: OutputFormatter): void;