On this page:
Character Backend (tui/  char)
9.3

Character Backend (tui/char)🔗ℹ

lu96-wow

 (require tui/char) package: racket-tui

tui/char is a drop-in mirror of the whole API whose output goes to an in-memory character grid instead of the terminal. It renders each frame as plain text (no escape codes), which makes it practical for AI agents, tests and CI to inspect UI state without a TTY. Unlike tui, tui/char does not load termios or FFI, so it runs on any platform or sandbox.

tui/char is an independent test sandbox: it implements the output / input / style / event concepts itself and reuses the same names for convenience, but it does not promise drop-in require compatibility with tui (and tui carries no char-specific code). The usual flow is to get an app working against tui/char and then port it to tui by hand. Capability probing (probe-caps, features, current-features, default-features, use-color-from-features!, current-key-protocol) is tui-only; tui/char has no terminal to probe and infers its color tier from $TERM. It additionally offers a debug-only layer that tui does not have (current-screen-size, frame history, diffs, the scripted-input DSL).

(require tui)
(require tui/char)
(require tui/char)
 
(parameterize ([current-screen-size (cons 6 30)])
 (with-tui
  (lambda ()
    (put-bytes
     (bytes-append
      format-screen-clear
      (format-cursor-move 1 1)
      (format-rgb-fg 255 255 0 "=== TUI Demo ===")
      (format-cursor-move 3 1)
      (format-256-fg 46 "count = 42")))
    (displayln (char-frame)))))

prints a plain-text layout:

=== TUI Demo ===

 

count = 42