@antithesishq/bombadil/terminal #

Exports #

Action #

type Action<
  Number = number,
  String = string
> = {
  TypeText: String;
} | {
  Resize: Size<Number>;
} | {
  Click: {
    row: Range;
    column: Range;
  };
} | {
  ScrollUp: {};
} | {
  ScrollDown: {};
}

ActionTemplate #

type ActionTemplate = Action<Range, StringGenerator>

Attributes #

enum Attributes {
  Bold = 1,
  Italic = 2,
  Blink = 4,
  Inverse = 8,
  Strikethrough = 16,
  Dim = 32,
  Invisible = 64,
  Overline = 128
}
namespace Attributes {
  function has(style: Style, attribute: Attributes): boolean;
}

Color #

type Color = "None" | {
  Palette: number;
} | {
  RGB: {
    r: number;
    g: number;
    b: number;
  };
}

Cursor #

interface Cursor {
  position: CursorPosition;
  visible: boolean;
  blinking: boolean;
  visualStyle: CursorVisualStyle;
  color: Color;
}

CursorPosition #

interface CursorPosition {
  column: number;
  row: number;
}

CursorVisualStyle #

type CursorVisualStyle = "Bar" | "Block" | "Underline" | "BlockHollow" | "Unknown"

Grid #

interface Grid {
  size: Size;
  row(index: number): GridCell[];
  rowText(index: number): string;
}

GridCell #

interface GridCell {
  contents: string;
  wide: boolean;
  style: Style;
}

Size #

type Size<Number = number> = {
  columns: Number;
  rows: Number;
}

State #

interface State {
  grid: Grid;
  scrollback: Grid;
  scrollOffset: number;
  cursor: Cursor;
  exitStatus: {
    code: number;
    signal: string | null;
  } | null;
  lastAction: Action | null;
}

Style #

interface Style {
  foregroundColor: Color;
  backgroundColor: Color;
  underlineColor: Color;
  underline: Underline;
  attributes: number;
}

Underline #

type Underline = "None" | "Single" | "Double" | "Curly" | "Dotted" | "Dashed"

actions #

function actions(generate: () => Tree<ActionTemplate> | ActionTemplate[]): ActionGenerator<ActionTemplate>;

extract #

function extract<T extends JSON>(query: (state: State) => T): Cell<T>;

weighted #

function weighted(value: [number, ActionTemplate | ActionGenerator<ActionTemplate>][]): ActionGenerator<ActionTemplate>;