Skip to content
Kite

Thinking in Kite

Kite brings the browser’s rendering and event model to terminal cells. Every frame moves cleanly through five isolated stages, and every user interaction flows back through the same logical tree.

1. DOM Logical tree 2. Sync Render tree 3. Style 4-layer cascade 4. Layout Immutable boxes 5. Paint UV / WASM / Mock
Dirty flags gate each phase so idle frames short-circuit and style-only updates skip layout.
  1. Logical DOM (dom, element): Holds nodes, text, focusable controls, and listeners. A button remains the same button when the terminal resizes.
  2. Sync (internal/render): Projects structural DOM changes into render objects (render.Box, render.Text) carrying granular dirty flags.
  3. Style (style, internal/styler): Resolves four cascade layers in order: inherited values → element defaults → author styles (including media queries & :hover/:focus/:active/:disabled) → UA intrinsic styles.
  4. Layout (internal/layout): Computes immutable fragment geometry in terminal cells (Block, Inline/IFC, Flexbox, CSS Grid, Tables with implicit border-collapse, Virtual-marker Lists).
  5. Paint & Commit (internal/paint, backend): Draws backgrounds, borders (resolving intersections cleanly), clipped scrolled subtrees, text selection, and hardware cursor onto the active backend.Backend.

Input events follow the standard web propagation model: Capture (Document → Target), Target, and Bubble (Target → Document).

Document Form / Container Button (Target) 1. CAPTURE ↓ 3. BUBBLE ↑
Listeners run top-down during Capture, on the hit/focused Target, then bottom-up during Bubble unless StopPropagation() is called.
  • Use element + kite.New when you want to keep direct element references and mutate them in place.
  • Use extras/kitex when UI should be derived declaratively from state via components and hooks.
  • Use extras/trail when building an inline CLI tool that writes completed items permanently into terminal scrollback above a live status bar.

Application code imports public packages (kite, dom, element, style, event, engine, backend, terminal, extras/*). Packages under internal/ are implementation details—see Architecture for internal design details.