$ show FedeClaudi/Term.jl
Term.jl is a Julia library for producing styled, beautiful terminal output. Inspired by Python's Rich library, it provides a markup language for inline color and style formatting (e.g., `{red}text{/red}`), a hierarchy of renderable objects (Panel, Table, Tree, Dendogram, ProgressBar), and interactive widgets (App, Menus, Pager, Buttons). The library also includes enhanced logging, stack trace rendering, progress bars, custom REPL display, and markdown rendering. Its architecture is modular: core types like `AbstractRenderable`, `Segment`, and `Measure` form the foundation, with composition via overloaded `*` (horizontal stack) and `/` (vertical stack) operators. A theme system centralizes styling. The codebase is well-tested with golden-file snapshots, but includes some platform-specific assumptions and absolute file paths in test fixtures that limit portability. Overall, it is a mature, feature-rich terminal UI toolkit with high craftsmanship.
The LLM identified 4 files worth highlighting for reuse:
Defines the `Box` struct and the `BoxLine` enum for drawing terminal borders. Provides multiple named box styles (ROUNDED, HEAVY, DOUBLE, ASCII, etc.) with corresponding box-drawing characters. This component is isolated, depends only on basic Julia types, and can be reused in any terminal UI project that needs consistent border rendering.
Implements the `Compositor` pattern: a declarative layout DSL using Julia expressions (`Expr`). The `Compositor` constructor accepts expressions like `:(A(10,0.5) * B(10,0.5) / C(10,1.0))` to define a grid of placeholders that can be filled with renderables. This is a novel, self-contained pattern for specifying two-dimensional terminal layouts without external configuration files.
Provides the core layout primitives: `hstack` (horizontal stacking via `*`), `vstack` (vertical stacking via `/`), `Spacer`, `vLine`, `hLine`, `pad`, `leftalign`, `center`, `rightalign`. These operate on `AbstractRenderable` objects by automatically padding and aligning segments. The file is relatively self-contained and demonstrates a clean functional approach to terminal layout composition.
Defines the `Theme` struct with fields for every visual attribute (panel borders, table highlights, progress bar colors, etc.) and provides default `DarkTheme` and `LightTheme` instances. A global `TERM_THEME` reference is set via `set_theme()`. This pattern centralizes all style decisions and is easily reusable in other terminal applications requiring themable output.