blessed
Terminal capabilities library for Python — wraps curses to provide a clean API for terminal control, colors, keyboard input, and cursor positioning. blessed features: Terminal() class for terminal detection, t.bold/t.red/t.on_blue for ANSI styling, t.move_xy() for cursor positioning, t.width/t.height for terminal dimensions, t.inkey() for keyboard input with key detection, t.cbreak() for raw key mode, t.hidden_cursor() for cursor management, t.fullscreen() for fullscreen mode, 256-color and true color support, and context managers for terminal state management. Successor to blessings library.
Score Breakdown
⚙ Agent Friendliness
🔒 Security
Terminal library with no network calls. t.cbreak() puts terminal in raw mode — ensure proper cleanup via context manager to restore terminal on exit. Don't display sensitive values with cursor positioning in shared terminal sessions. Always use context managers to guarantee terminal restoration.
⚡ Reliability
Best When
Building custom terminal UIs with full control over cursor positioning, colors, and keyboard input — blessed provides the right level of abstraction over curses for agent dashboards and interactive CLI tools.
Avoid When
Widget-based TUI (use textual), web terminal (use xterm.js), or Windows-first (use prompt_toolkit).
Use Cases
- • Agent terminal colors — from blessed import Terminal; t = Terminal(); print(t.bold_red('ERROR: ') + t.bold('Connection failed')); print(t.green('SUCCESS: ') + 'Operation complete') — composable styling; agent CLI output uses rich color combinations; t.bold_red combines bold + red in one call; styles compose naturally
- • Agent terminal dimensions — t = Terminal(); cols = t.width; rows = t.height; print(f'Terminal: {cols}x{rows}'); bar_width = cols - 10; bar = '█' * int(bar_width * progress) — responsive layout; agent CLI adapts to terminal size; t.width/t.height auto-detect and update on resize
- • Agent keyboard input — t = Terminal(); with t.cbreak(): key = t.inkey(timeout=5) — non-blocking key read; agent CLI waits for key input with timeout; key.name gives 'KEY_UP', 'KEY_ENTER' etc.; key.code for numeric code; inkey() is non-blocking alternative to input()
- • Agent cursor control — with t.hidden_cursor(): for i, item in enumerate(items): print(t.move_xy(0, i) + t.clear_eol + f'{item.name}: {item.status}') — cursor-controlled output; agent status dashboard updates lines in place without scrolling; clear_eol clears to end of line
- • Agent fullscreen TUI — with t.fullscreen(): with t.hidden_cursor(): with t.cbreak(): header = t.bold(t.center('Agent Dashboard')); print(t.move_xy(0, 0) + header); while True: key = t.inkey(timeout=0.1); if key.name == 'q': break — full-screen app; agent dashboard occupies entire terminal
Not For
- • Complex widget-based TUI — blessed provides primitives; for full widgets (buttons, tables, dialogs) use textual or urwid
- • Web terminal emulation — blessed is local terminal only; for web terminal use xterm.js
- • Windows compatibility — blessed has limited Windows support; for Windows use prompt_toolkit
Interface
Authentication
No auth — local terminal library.
Pricing
blessed is MIT licensed. Free for all use.
Agent Metadata
Known Gotchas
- ⚠ Context managers must be nested correctly — with t.fullscreen(): with t.hidden_cursor(): with t.cbreak(): order matters; fullscreen must be outermost; reversing order causes terminal restoration issues; exiting contexts restores terminal state — do not catch SystemExit inside these contexts or terminal won't restore
- ⚠ t.inkey() timeout=0 returns immediately — t.inkey(timeout=0) checks for pending key without blocking; returns Keystroke with empty string if no key; agent game loop: key = t.inkey(timeout=0.05) for responsive without CPU burning; None timeout blocks forever
- ⚠ Style callable vs format string — t.bold is callable: t.bold('text') or format string: f'{t.bold}text{t.normal}'; mixing: t.bold + 'text' + t.normal (string concatenation); agent code must pick one pattern and be consistent; callable is cleaner but format strings enable composition
- ⚠ Keyboard key names differ by terminal — KEY_UP may be 'KEY_UP' in most terminals but different in some; t.KEY_UP is the constant for comparison: if key.code == t.KEY_UP:; do not hardcode escape sequences; agent code using key.name for navigation must test on target terminal type
- ⚠ t.move_xy(x, y) is column-then-row — move_xy(x=0, y=5) moves to column 0, row 5; many cursor APIs are row,col but blessed is x (col), y (row); agent code mixing blessed with curses.move() (row, col) gets coordinates swapped
- ⚠ Dumb terminal degrades gracefully — Terminal() on non-color terminal: style calls return empty strings silently; agent code t.bold('text') on dumb terminal returns 'text' without bold; no errors; agent tools are usable on minimal terminals but without decoration
Alternatives
Full Evaluation Report
Detailed scoring breakdown, competitive positioning, security analysis, and improvement recommendations for blessed.
Scores are editorial opinions as of 2026-03-06.