/ ink / termio.ts
termio.ts
 1  /**
 2   * ANSI Parser Module
 3   *
 4   * A semantic ANSI escape sequence parser inspired by ghostty, tmux, and iTerm2.
 5   *
 6   * Key features:
 7   * - Semantic output: produces structured actions, not string tokens
 8   * - Streaming: can parse input incrementally via Parser class
 9   * - Style tracking: maintains text style state across parse calls
10   * - Comprehensive: supports SGR, CSI, OSC, ESC sequences
11   *
12   * Usage:
13   *
14   * ```typescript
15   * import { Parser } from './termio.js'
16   *
17   * const parser = new Parser()
18   * const actions = parser.feed('\x1b[31mred\x1b[0m')
19   * // => [{ type: 'text', graphemes: [...], style: { fg: { type: 'named', name: 'red' }, ... } }]
20   * ```
21   */
22  
23  // Parser
24  export { Parser } from './termio/parser.js'
25  // Types
26  export type {
27    Action,
28    Color,
29    CursorAction,
30    CursorDirection,
31    EraseAction,
32    Grapheme,
33    LinkAction,
34    ModeAction,
35    NamedColor,
36    ScrollAction,
37    TextSegment,
38    TextStyle,
39    TitleAction,
40    UnderlineStyle,
41  } from './termio/types.js'
42  export { colorsEqual, defaultStyle, stylesEqual } from './termio/types.js'