Expand description
comb — a tiny, native terminal-UI engine.
No ratatui, no crossterm. Raw terminal control lives in [terminal] (Unix
termios / Windows Console VT + ANSI), the screen is a diffed grid of Cells
in [buffer], and the
headline feature is compositing: Surfaces stacked as Compositor
layers with z-order and transparency, so overlays (menus, popups, toasts)
paint on top of the scene without disturbing it.
The mental model is deliberately close to what a ratatui user expects
(a Rect, a Style, Line/Span text, a Frame you draw into) so
porting an existing UI is mechanical, while the internals are ours to shape.
use comb::{Terminal, Style, Color, Rect};
let mut term = Terminal::new().unwrap();
term.draw(|f| {
let area = f.area();
f.buffer().set_str(2, 1, "hello, comb", Style::new().fg(Color::rgb(0xe6,0xe6,0xe6)));
// an overlay layer, composited on top:
let pop = f.layer(Rect::new(4, 3, 20, 3), 10);
pop.fill(Rect::new(0, 0, 20, 3), ' ', Style::new().bg(Color::rgb(0x26,0x26,0x26)));
}).unwrap();Re-exports§
pub use crate::draw::effects;pub use crate::draw::highlight;pub use crate::draw::highlight::HighlightTheme;pub use crate::draw::highlight::Lang;pub use crate::widgets::unified_diff;pub use crate::widgets::CodeBlock;pub use crate::widgets::DiffOp;pub use crate::widgets::DiffTheme;pub use crate::widgets::DiffView;pub use crate::widgets::List;pub use crate::widgets::Menu;pub use crate::widgets::Palette;pub use crate::widgets::ResizeEdge;pub use crate::widgets::ScrollView;pub use crate::widgets::Scrollbar;pub use crate::widgets::ScrollbarStyle;pub use crate::widgets::Tabs;pub use crate::widgets::TextInput;pub use crate::widgets::Toasts;pub use crate::widgets::Window;pub use crate::core::buffer::center_pad;pub use crate::core::buffer::chip_cols;pub use crate::core::buffer::label_cols;pub use crate::core::buffer::Buffer;pub use crate::core::buffer::Cell;pub use crate::core::geom::Align;pub use crate::core::geom::Pos;pub use crate::core::geom::Rect;pub use crate::core::geom::Size;pub use crate::core::style::Color;pub use crate::core::style::Modifier;pub use crate::core::style::Style;pub use crate::core::text::Line;pub use crate::core::text::Span;pub use crate::draw::border::Border;pub use crate::draw::surface::Compositor;pub use crate::draw::surface::Surface;pub use crate::term::event::Event;pub use crate::term::event::Key;pub use crate::term::event::KeyCode;pub use crate::term::event::KeyMods;pub use crate::term::event::Mouse;pub use crate::term::event::MouseButton;pub use crate::term::event::MouseKind;pub use crate::term::terminal::render;pub use crate::term::terminal::render_with_cursor;pub use crate::term::terminal::restore;pub use crate::term::terminal::Frame;pub use crate::term::terminal::MouseMode;pub use crate::term::terminal::Terminal;
Modules§
- core
- Core value types — the data model everything else draws on: geometry, colour and text style, styled text runs, and the cell buffer that backs the screen.
- draw
- Drawing and compositing on top of the
coremodel: layered surfaces (the compositor), box-drawing borders, and visual effects. - term
- The terminal layer: the native raw-mode ANSI backend (with the draw loop and compositing) and the input-event parser.
- widgets
- Ready-made, composable widgets built on top of
coreanddraw: a selectableList, aScrollViewwith a scrollbar, and a dropdown/contextMenuoverlay.