Skip to main content

A simple TUI in Python, inspired by pi-tui

Project description

saber-tui

A simple TUI in Python, inspired by pi-tui.

saber-tui provides low-level building blocks for terminal UIs: a render tree, raw terminal integration, focus and overlays, editable text controls, list selection, animated loaders, and ANSI/Unicode-aware layout helpers.

Features

  • TUI and Container render trees with differential rendering, resize handling, overlays, focus management, and optional hardware cursor placement.
  • ProcessTerminal for raw terminal lifecycle, bracketed paste, resize callbacks, title/progress control, and native scrollback-friendly rendering.
  • Key parsing and customizable keybindings, including kitty keyboard protocol, modifyOtherKeys sequences, printable key decoding, and key repeat/release detection.
  • Text layout components: Text, TruncatedText, Box, and Spacer.
  • Interactive controls: single-line Input, multiline Editor, SelectList, Loader, and CancellableLoader.
  • Editor behavior for command-style input: history, undo, kill/yank, word movement, paste markers, submit/change callbacks, and configurable padding.
  • Autocomplete primitives and providers: AutocompleteItem, SlashCommand, AutocompleteSuggestions, CompletionResult, and CombinedAutocompleteProvider with command and path suggestions.
  • ANSI-aware wrapping, slicing, truncation, background application, grapheme handling, fuzzy matching, and terminal-output normalization utilities.

Usage

from saber_tui import ProcessTerminal, TUI, matches_key
from saber_tui.components import Editor, Text

terminal = ProcessTerminal()
tui = TUI(terminal)
tui.add_child(Text("Welcome"))

editor = Editor(tui)
editor.on_submit = lambda value: tui.add_child(Text(f"You said: {value}"))
tui.add_child(editor)
tui.set_focus(editor)

def exit_on_ctrl_c(data: str):
    if matches_key(data, "ctrl+c"):
        tui.stop()
        raise SystemExit(0)
    return None

tui.add_input_listener(exit_on_ctrl_c)
tui.start()

Run the examples:

uv run python examples/chat.py
uv run python examples/showcase.py

Development

uv run pytest
uv run ruff check
uv run ruff format --check
uvx ty check

Current Scope

Available in this slice:

  • Core TUI, Container, overlays, focus, and differential rendering.
  • ProcessTerminal
  • ANSI and Unicode width utilities.
  • StdinBuffer with bracketed paste handling.
  • Key parsing and keybindings.
  • Text, TruncatedText, Box, Spacer, Input, Editor, SelectList, Loader, and CancellableLoader.
  • Slash-command and file/path autocomplete support.

Outside this slice:

  • Markdown rendering.
  • Terminal image protocols.
  • Full Windows-specific VT input support.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

saber_tui-0.1.0.tar.gz (135.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

saber_tui-0.1.0-py3-none-any.whl (51.8 kB view details)

Uploaded Python 3

File details

Details for the file saber_tui-0.1.0.tar.gz.

File metadata

  • Download URL: saber_tui-0.1.0.tar.gz
  • Upload date:
  • Size: 135.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for saber_tui-0.1.0.tar.gz
Algorithm Hash digest
SHA256 72ca0545783f8d40ba08a8b52f3085ab23113163ee98320f9dec2a192b9fc31e
MD5 5ae8705f0d55f0f7d4588926461aaeb8
BLAKE2b-256 aba2a2a96b738cfea834087a7f015b68d2d92b20b5e93c2d135d535bf78f100f

See more details on using hashes here.

File details

Details for the file saber_tui-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: saber_tui-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 51.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for saber_tui-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dc3b549081557a5d1878c647b348ff8e38661f4451e46e9f1c3d39dcb207674d
MD5 181255fbef616effd9b223910604003c
BLAKE2b-256 4b84a3418912454ba634cca17e80e1e3d51571e8a98d6eacef5c29dd4f42feec

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page