import { Block } from './block.js'; import { StyleProps } from './style.js'; /** * A representation of a virtual "terminal" where we write out the character * and style information as we parse through the ANSI encoded stream. * * Important: this is *not* a full-fledged Stream class. You can write to it * multiple times, and it will update appropriately, but it does zero buffering * or input validation, so writing a partial ANSI code sequence will result in * mochibake in the output. * * The virtual terminal is an infinitely high and wide screen, with no * scrollback buffer. So, when `scrollDown(n)` is called (either explicitly, or * with a `\x1b[S` ANSI code), `n` lines are removed from the top of the * "screen". When `scrollUp(n)` is called (explicitly or via a `\x1b[T` ANSI * code), `n` _empty_ lines are added to the top of the screen; the lines lost * to a previous `scrollDown` action are not restored when scrolling up. * * Also, actions that move the cursor down or to the right, which would on a * normal physical terminal be limited to the height/width of the terminal, are * unbounded. For example, on an actual terminal, `echo $'\x1b[1000Bhello'` * will print "hello" at the bottom of the screen (unless your screen happens * to be more than 1000 lines high); in this virtual terminal, it will create * 1000 empty lines. * * Most of the methods (other than `toString()` of course) return `this`, * allowing for things like this: * * ```js * console.log( * new Terminal() * .setStyle({ color: '#ff0000' }) * .write('hello, ') * .down(1) * .setStyle({ inverse: true }) * .write('world!').ansi * ) * ``` */ export declare class Terminal { #private; constructor(input?: string); /** * Set the style that the terminal will use for text writes. * * If a string, must be a valid `\x1b[...m` ANSI style code. * * The styles provided will be appended onto the current style in use, just * as they would be by a real terminal if the relevant ANSI code is * encountered. */ setStyle(style: string | StyleProps): Terminal; /** Move the cursor up `n` lines, stopping at the top. */ up(n: number): Terminal; /** Move the cursor down `n` lines, without limit. */ down(n: number): Terminal; /** * Prepend `n` empty lines at the start of the buffer, effectively moving the * cursor up as a result. */ scrollUp(n: number): Terminal; /** * Remove `n` lines from the start of the buffer, effectively moving the * cursor down as a result. */ scrollDown(n: number): Terminal; /** Move the cursor forward `n` columns, without limit. */ forward(n: number): Terminal; /** Move the cursor back `n` columns, stopping at the first column. */ back(n: number): Terminal; /** Move to the start of the `n`-th next line. */ nextLine(n: number): Terminal; /** * Move to the start of the `n`-th previous line, stopping at the top of the * screen. */ prevLine(n: number): Terminal; /** * Move to the `n`-th column (1-indexed), limited by the left-most column. */ horizontalPosition(n: number): Terminal; /** * Move to the 1-indexed row and column specified, limited by the top and * left sides of the screen. */ position(row: number, col: number): Terminal; /** * Delete all printed data from the screen. * * Note that this is used for both `\x1b[2J` _and_ `\x1b[3J`, because there * is no scrollback buffer in this virtual terminal. */ eraseScreen(): Terminal; /** Delete all printed data from the cursor to the end of the screen. */ eraseScreenToEnd(): Terminal; /** Delete all printed data from the top of the screen to the cursor. */ eraseScreenFromStart(): Terminal; /** Delete the contents of the current line. */ eraseLine(): Terminal; /** * Delete printed data from the cursor to the end of the current line. */ eraseLineToEnd(): Terminal; /** * Delete printed data from the start of the current line to the cursor. */ eraseLineFromStart(): Terminal; /** * Parse the ANSI encoded string provided, updating the internal character * and style buffers appropriately. */ write(input: string): Terminal; /** * Called when an OSC code of `\x1b]0;...\x1b\` is encountered. * * Sets the `title` attribute on the root `
` in html output,
     * and creates a corresponding OSC title sequence in the ansi output.
     */
    setTitle(s: string): this;
    /** the raw unstyled text of each line */
    get text(): string[];
    /**
     * Output the results of the style and character buffers as ANSI
     * styled text. This effectively normalizes all color codes to explicit
     * RGB values and resolves all cursor motions and other control codes,
     * and styling runs of identical styles with a single code.
     */
    get ansi(): string;
    /**
     * Output the results of the style and character buffers as a `
`
     * tag with `` elements setting effective styles.
     */
    toString(): string;
    /**
     * An array of `Block` objects each representing a string of text with a
     * given style.
     */
    get blocks(): Block[];
}
//# sourceMappingURL=terminal.d.ts.map