Skip to content

Playbooks for g

Story-style workflows—solo, team, and on-call. Jump into the full Use cases page anytime.

ui

Terminal UI — all output, styling, spinners, tables, and git formatting.

auto-generated This page is built from //! comments in the Rust source. Edit the source and run npm run docs:extract to update it.

Terminal UI — all output, styling, spinners, tables, and git formatting.

Module layout

ui/
  mod.rs        ← this file: public facade, re-exports everything
  theme.rs      ← Theme, Palette, Icons + global OnceLock accessor
  render.rs     ← ct_color, paint_*, Spinner, ProgressBar, terminal_width
  print.rs      ← Mode 1: print_info, print_success, semantic styling helpers
  widgets.rs    ← Mode 2: Fieldset, Table, CommitEntry, git color helpers
  interactive/  ← Mode 3: full-screen ratatui TUI kit (alternate screen)
    mod.rs        · the prompts: select, multi_select, input, confirm, fuzzy
    runtime.rs    · reusable enter/draw/key/restore event loop + TTY guards
    layout.rs     · shared vertical zone splits
    widgets.rs    · themed header, help, list, input line, paginator, scroll_list
  inline/       ← Mode 4: inline prompt kit (stays in scrollback)
    mod.rs        · the inline_* prompts
    runtime.rs    · raw-mode key loop + static header + TTY guard
    widgets.rs    · option/checkbox rows + in-place redraw

Building a new screen

A full-screen prompt is just state + a draw call + a key match:

interactive::runtime::run(
    0usize,                                   // state
    |f, &cursor| widgets::scroll_list(/* … */),   // draw each frame
    |cursor, key| match key { /* … */ Flow::Done(result) },
)

An inline prompt prints its header + body, then hands keys to run_raw.

Command files import only crate::ui and call ui::print_info(…) etc. They never reference the sub-modules directly, so the split is an implementation detail that can evolve without touching call sites.

Design principles

  • Single source of styling — every color comes from theme::current().
  • No raw colored / indicatif — all output is crossterm-backed and theme-aware.
  • Commands own layout; ui owns style — a command decides what to print; this module decides how it looks.

Source: src/ui/mod.rs