UNPKG

@thi.ng/text-format

Version:

Customizable color text formatting with presets for ANSI & HTML

89 lines 2.9 kB
import type { StringFormat } from "./api.js"; export declare const ANSI_RESET = "\u001B[0m"; export declare const ANSI_SYNC_START = "\u001BP=1s\u001B\\"; export declare const ANSI_SYNC_END = "\u001BP=2s\u001B\\"; export declare const ANSI_HOME = "\u001B[H"; export declare const ANSI_HOME_LINE = "\u001B[0G"; export declare const ANSI_HOME_PREV_LINE = "\u001B[1F"; export declare const ANSI_CLEAR_SCREEN = "\u001B[2J"; export declare const ANSI_CLEAR_LINE = "\u001B[2K"; /** * String format preset, translating canvas format info to ANSI 4bit * control sequences. * * https://stackoverflow.com/a/33206814/294515 */ export declare const FMT_ANSI16: StringFormat; /** * String format preset, translating canvas format info to ANSI 8bit control * sequences. Only foreground/background colors are supported, no other * formatting (e.g. bold etc.). * * @remarks * https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit * * Also see {@link format256}. */ export declare const FMT_ANSI256: StringFormat; /** * String format preset, interpreting the canvas 16bit format info as text color * and translating it into ANSI 24bit control sequences. No other formatting * (e.g. bold etc.) supported in this mode. * * @remarks * This mode is intended for image displays, e.g. using thi.ng/pixel and * thi.ng/text-canvas * [`imageRaw`](https://docs.thi.ng/umbrella/text-canvas/functions/imageRaw.html). * Also see {@link format565} and {@link format565_8bit}. * * https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit */ export declare const FMT_ANSI565: StringFormat; /** * Takes 2 ANSI256 values and returns a combined 16bit format ID. * * @remarks * https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit * * @param fg - * @param bg - */ export declare const format256: (fg: number, bg?: number) => number; /** * Takes _normalized_ RGB values (`[0,1]` range) and converts them into an RGB565 * value for later use with {@link FMT_ANSI565} or {@link FMT_HTML565}. Does * NOT perform clipping! * * @param r - * @param g - * @param b - */ export declare const format565: (r: number, g: number, b: number) => number; /** * Converts RGB (8bit channels) into a 16bit RGB565 value for later use with * {@link FMT_ANSI565} or {@link FMT_HTML565}. Does NOT perform clipping! * * @param r - * @param g - * @param b - */ export declare const format565_8bit: (r: number, g: number, b: number) => number; /** * Syntax sugar for `defFormat(FMT_ANSI16, ...)` * * @param col - */ export declare const defAnsi16: (col: number) => (x: any) => string; /** * Syntax sugar for `defFormat(FMT_ANSI256, ...)` * * @param col - */ export declare const defAnsi256: (col: number) => (x: any) => string; /** * Syntax sugar for `defFormat(FMT_ANSI565, ...)` * * @param col - */ export declare const defAnsi565: (col: number) => (x: any) => string; //# sourceMappingURL=ansi.d.ts.map