burgee
Switching a terminal UI from…

Coming from blessed

Move a blessed program to controlroom, the burgee family's blessed alternative: screen, box, list, key handling and the render loop mapped onto open(), layout trees, keymaps and flagstaff panes, what does not map, and what burgee migrate reports for a blessed program.

controlroom is the burgee family's blessed alternative for keyboard-driven terminal programs, inline or full-screen. open(), layout, tabs and keymaps, the input line and plugins all ship, since 0.2.0. A screen it opens works for a person at a terminal, and prints a static projection of every pane for a pipe, CI, a screen reader or an agent.

Only drawing inline output, with no keys? You want flagstaff: Which one do I need?

Migrate from blessed: not one import

There is no controlroom/blessed, and none is planned. blessed's surface is too large to reproduce honestly, so moving is a rewrite of each screen, not of the import line. burgee migrate finds the blessed sites in your project and names the section of this page that covers each one:

npx burgee migrate --dry-run --json

It reports and never rewrites: a blessed screen and a controlroom screen are different shapes, so each one is a decision, not a substitution. For this program:

const blessed = require('blessed');

const screen = blessed.screen({ smartCSR: true });
const list = blessed.list({ items: ['build', 'test'], keys: true });
screen.append(list);
screen.key(['q', 'C-c'], () => process.exit(0));
screen.render();

the report's guided list reads, one entry per site:

[
  { "file": "src/ui.js", "line": 1, "from": "blessed", "pattern": "import", "guide": "https://burgee.interlace.tools/docs/coming-from/blessed#the-mapping" },
  { "file": "src/ui.js", "line": 3, "from": "blessed", "pattern": "screen", "guide": "https://burgee.interlace.tools/docs/coming-from/blessed#screen" },
  { "file": "src/ui.js", "line": 4, "from": "blessed", "pattern": "list", "guide": "https://burgee.interlace.tools/docs/coming-from/blessed#list" },
  { "file": "src/ui.js", "line": 6, "from": "blessed", "pattern": "key", "guide": "https://burgee.interlace.tools/docs/coming-from/blessed#key-handling" },
  { "file": "src/ui.js", "line": 7, "from": "blessed", "pattern": "render", "guide": "https://burgee.interlace.tools/docs/coming-from/blessed#render-loop" }
]

A site is reported only when the receiver came from blessed in the same file: screen.key( on a screen from blessed.screen() is a key binding, and screen.key( on anything else is not. A screen passed in from another file is not followed, but that file's own require('blessed') still is. The exit code stays 0, because nothing was refused. The Migrate page has the whole report.

The same screen on controlroom

A list of steps with a log under it, a key to rerun and a key to quit:

ui.mjs
import { open, processRuntime } from 'controlroom';
import { logTail } from 'flagstaff/log-tail';
import { tasks } from 'flagstaff/tasks';

const steps = (build, test) => ({ tasks: [{ title: 'build', status: build }, { title: 'test', status: test }] });

const screen = open(processRuntime(), {
  screen: 'alternate',
  json: process.argv.includes('--json'),
  layout: {
    direction: 'column',
    parts: [{ size: 'fit', content: 'steps' }, { content: 'log' }],
  },
  keymap: { r: 'rerun', q: 'quit', 'ctrl+c': 'quit' },
  panes: {
    steps: { component: tasks(), state: steps('running', 'pending'), label: 'Steps' },
    log: { component: logTail(), state: { lines: [] }, label: 'Log' },
  },
  onAction(action, s) {
    if (action === 'rerun') s.update('steps', steps('running', 'pending'));
  },
});

screen.update('log', { lines: ['tsc -p .'] });
screen.update('steps', steps('ok', 'running'));
screen.update('steps', steps('ok', 'ok'));
screen.close();

On a terminal this takes the alternate screen and repaints as the steps move. Piped, it prints each pane under its label, and each settled line once, with no escape byte:

node ui.mjs | cat
Steps

Log

┊ tsc -p .
✔ build
✔ test

node ui.mjs --json writes one NDJSON event per change to stderr, named after its pane ({"event":"steps","state":{…}}), and leaves stdout for the program's result.

The mapping

blessedcontrolroom
blessed.screen()open(runtime, { screen: 'alternate' })
screen.destroy()close() on what open() returned
blessed.box({ top, left, width, height })a pane in a layout tree, holding a flagstaff component
blessed.list()flagstaff's tasks in a pane, for a list you show
blessed.listbar()a pane over flagstaff's tabBar, with the screen's tab state
blessed.log()flagstaff's logTail in a pane
screen.key([...], fn)an entry in a keymap, which is data, and onAction
screen.on('keypress', fn)the same keymap
screen.render()nothing: an update() repaints
screen.program.alternateBuffer()screen: 'alternate', left on every exit path
blessed.textbox()the input line: caique's line editor in a pane
mouse: true, on('click')nothing
blessed.textarea(), formnothing: a question asked once is caique's prompt

Screen

blessed.screen() takes over the terminal when it is constructed. controlroom's open(runtime, { screen: 'alternate' }) does the same only when roundel's output policy says tty and stdin can go raw. In every other mode it opens a static screen instead, so the same program runs in a pipe, in CI and under --json. runtime is the structural runtime the family's packages take instead of reading process; processRuntime() is the real one.

screen: 'inline', the default, is a mode blessed does not have: a live region drawn under the program's own output, with commit(text) releasing text above it into the terminal's scrollback. It is ink's shape, and a chat CLI's.

screen.destroy() becomes close(), which hands the terminal back and does nothing the second time.

burgee migrate reports blessed.screen(), new blessed.Screen() and blessed.program() here. A program is blessed's lower-level handle on the terminal, and what it does for a blessed screen is what open() does for a controlroom one.

Box

A blessed box positions itself: top, left, width and height as cells, percentages or 'center'. In controlroom a pane does not position itself. One layout tree splits the screen into rows and columns of fixed, fractional ({ fr, min }) and fit-to-content sizes, and a pane is a name in that tree. layout() is the arithmetic open() runs on every paint, and you can call it yourself:

import { layout } from 'controlroom';

const tree = {
  direction: 'column',
  parts: [
    { content: { direction: 'row', parts: [{ size: { fr: 1, min: 20 }, content: 'learn' }, { size: { fr: 2 }, content: 'tasks' }] } },
    { size: 8, content: 'logs' },
  ],
};
layout(tree, { x: 0, y: 0, width: 100, height: 30 }).get('tasks');
// { x: 34, y: 0, width: 66, height: 22 }

There is no flexbox and no constraint solver: one pass hands out the fixed cells and the minimums, and a second shares the rest by fraction. A terminal too small for the minimums clips the later parts, never the first.

What a pane draws is any flagstaff component, given as { component, state, label } under panes. A border, padding and a title come from flagstaff's boxComponent.

burgee migrate reports box(), text(), element(), log() and layout() here. The last is blessed's own auto-positioning container, which the layout tree replaces outright.

List

A list you show, such as steps with a state each, is flagstaff's tasks in a pane. Outside a terminal it prints one line per task that has settled. A list the user picks from, blessed's keys: true with a select event, has no pane component. A pick is a prompt, and prompts are caique's: select, asked before or after the screen, not inside it.

listbar() maps to a tab bar: a pane over flagstaff's tabBar, kept in step with the screen's active tab from onAction. Mark it liveOnly: true, because off a terminal there are no tabs to switch and every pane prints.

burgee migrate reports list(), listtable() and listbar() here.

Key handling

blessed binds a key to a function: screen.key(['q', 'C-c'], fn). controlroom binds a key to an action name, in a keymap that is plain data. The screen's tabs, focus and collapsed panes move through a reducer, and your onAction(action, screen) sees every action after it. The hint line is generated from the same keymap, so it cannot advertise a key that is not bound.

import { hints, initial, reduce } from 'controlroom';

const keymap = { left: 'tab.prev', right: 'tab.next', s: 'toggle:status', q: 'quit', 'ctrl+c': 'quit' };
const labels = { 'tab.prev': 'switch tab', 'tab.next': 'switch tab', 'toggle:status': 'toggle status', quit: 'quit' };

let state = initial(['Status', 'Tail logs'], ['learn', 'tasks']);
state = reduce(state, keymap.right); // state.active is 1: the second tab
hints(keymap, labels); // '←→ switch tab  s toggle status  q/^C quit'

An action the reducer does not know, such as quit here, leaves the state alone and is the program's own to handle; a live screen closes on quit. Key names are spelled as caique's key decoder spells them:

blessedcontrolroom
C-cctrl+c
M-xmeta+x
S-tabshift+tab
escape, left, right, qunchanged

Raw mode is taken once for the screen's whole life and handed back on every exit. Keys are read only when stdout is a terminal and stdin can go raw. Everywhere else, screen.dispatch(action) runs an action as if its key had been pressed, so nothing waits for a key nobody can press.

burgee migrate reports key(), onceKey(), unkey() and removeKey() here, on a screen, an element or a program, and every on() or once() whose event name starts with key: keypress, and blessed's key q form.

Render loop

blessed draws nothing until you call screen.render(), so a blessed program calls it after every change. controlroom has no render call to make. update(pane, state) repaints: the layout is composed from every pane's frame and handed to flagstaff's frame writer, which writes only the rows that changed, inside one synchronized-output block, and the screen is laid out again on resize. controlroom never writes to the terminal itself. When you move a screen, delete its render() calls rather than translating them. burgee migrate reports each one, including box.screen.render().

Alternate screen

blessed's screen switches to the alternate buffer itself, through its program's alternateBuffer(), and normalBuffer() switches back. controlroom's is the screen: 'alternate' option. The alternate screen, the hidden cursor, raw mode and bracketed paste are each entered through closeout with their undo registered in the same call, so close(), Ctrl+C, a signal and a throw all hand the terminal back. There is no normalBuffer() to remember.

The alternate screen has no scrollback, so text given to commit() there is kept and handed to the main screen when the screen closes.

burgee migrate reports alternateBuffer() and normalBuffer() here, on a program or on screen.program.

What does not map

These are out of scope, so a program that depends on them should stay on blessed.

Mouse

Clicks, the wheel and drags (mouse: true, screen.enableMouse(), on('click')) have no controlroom equivalent, and none is planned. burgee migrate reports each mouse site it can see, so you know how many there are: enableMouse(), and on() with mouse, click, mousedown, mouseup, mousemove, mouseover, mouseout, wheeldown or wheelup.

Text editing in a pane

textbox() maps to the input line: caique's line editor hosted in one pane, with history, completion and pasted text arriving whole. Keys go to it while it has focus and fall through to the keymap when it does not use them, and in a pipe each line of stdin is one entry. It is the input: { editor, pane, onSubmit, onEnd } option of open().

textarea() and form, a multi-line editor or several fields inside the layout, do not map. A question asked once is a prompt, and prompts are caique's. burgee migrate reports textbox() and textarea() here.

Legacy Windows consoles

controlroom handles no Windows legacy console quirks beyond what Node's own terminal handling does. If your blessed program relies on behaviour specific to an old Windows console, check that before you move it.

The rest of blessed's widget catalogue, including images and embedded terminals, has no controlroom counterpart either. A pane draws any flagstaff component, and you can register your own as a plugin.

Is controlroom compatible with blessed?

No, by design. There is no drop-in and nothing is graded: no blessed suite runs against controlroom, and none will, because the API is not being reproduced. The Compatibility page grades controlroom's drop-in for ink, controlroom/ink, by ink 8.0.0's own suite. It has no blessed row.

What you gain over blessed

  • Every caller gets an answer, not just a terminal. Off a terminal a screen prints each pane's static projection under its label, with no escape byte, no carriage return and no cursor movement, and only the lines that changed on each update. Tabs hide nothing, and a liveOnly pane such as the hint line is not printed.
  • --json is an event stream. One NDJSON event per change on stderr, named after the pane, so an agent reads the same program a person watches, with stdout left for the result.
  • It never waits for a key nobody can press. Behind a pipe, in CI or with < file, a screen reads no keys, and dispatch() is what the program has instead.
  • Inline or full screen. blessed always takes the whole terminal; controlroom can also draw under the program's output and keep a transcript in the scrollback.
  • One render engine. The spinner in a pane is the same flagstaff component, drawn by the same frame loop, as the spinner in an ordinary CLI.
  • Nothing installed from outside the family. That is a rule every published package in this repository is held to by a lock, controlroom included.

This page does not say what blessed writes to a pipe or under CI, and makes no size or speed comparison against blessed: none has been measured here. controlroom's own bytes, per export, are on the weight page.

When to switch from blessed

Switch a screen if its output has to work for a pipe, CI, a screen reader or an agent as well as for a person at a terminal, or if you want it inline under the program's output. Stay on blessed if you depend on the mouse, on multi-line editing or forms inside the screen, or on widgets outside the mapping above. The package page has the whole API.

On this page