tty-strings
Version:
Tools for working with strings displayed in the terminal
21 lines • 957 B
TypeScript
/**
* A generator function that matches all ansi escape sequences within a string, yielding sequential
* chunks that are either a matched escape sequence or a run of plain text between matches.
*
* @param string - input string
* @returns - A generator that yields `[chunk, isEscape]` pairs
*/
export declare function parseAnsi(string: string): Generator<[string, boolean], void>;
/**
* Additional information about the escape sequence
* - 0 = no additional info
* - 1 = is link
* - 2 = is incomplete sgr sequence that will consume subsequent parameters
*/
type EscapeAttr = 0 | 1 | 2;
export type AnsiEscape<T> = [string, EscapeAttr, string, T];
export declare function parseEscape<T>(stack: AnsiEscape<T>[], seq: string, idx: T): AnsiEscape<T>[] | null;
export declare function openEscapes<T>(stack: AnsiEscape<T>[]): string;
export declare function closeEscapes<T>(stack: AnsiEscape<T>[]): string;
export {};
//# sourceMappingURL=utils.d.ts.map