Skip to main content

comb/
lib.rs

1//! `comb` — a tiny, native terminal-UI engine.
2//!
3//! No ratatui, no crossterm. Raw terminal control lives in [`terminal`] (Unix
4//! termios / Windows Console VT + ANSI), the screen is a diffed grid of [`Cell`]s
5//! in [`buffer`], and the
6//! headline feature is compositing: [`Surface`]s stacked as [`Compositor`]
7//! layers with z-order and transparency, so overlays (menus, popups, toasts)
8//! paint on top of the scene without disturbing it.
9//!
10//! The mental model is deliberately close to what a ratatui user expects
11//! (a [`Rect`], a [`Style`], [`Line`]/[`Span`] text, a `Frame` you draw into) so
12//! porting an existing UI is mechanical, while the internals are ours to shape.
13//!
14//! ```no_run
15//! use comb::{Terminal, Style, Color, Rect};
16//! let mut term = Terminal::new().unwrap();
17//! term.draw(|f| {
18//!     let area = f.area();
19//!     f.buffer().set_str(2, 1, "hello, comb", Style::new().fg(Color::rgb(0xe6,0xe6,0xe6)));
20//!     // an overlay layer, composited on top:
21//!     let pop = f.layer(Rect::new(4, 3, 20, 3), 10);
22//!     pop.fill(Rect::new(0, 0, 20, 3), ' ', Style::new().bg(Color::rgb(0x26,0x26,0x26)));
23//! }).unwrap();
24//! ```
25
26// Logic is grouped into folders; `lib.rs` just wires them and re-exports a flat,
27// stable public API so callers use `comb::Buffer`, `comb::Style`, etc.
28pub mod core;
29pub mod draw;
30pub mod term;
31pub mod widgets;
32
33// The `effects` module is re-exported by name so `comb::effects::…` keeps working.
34pub use crate::draw::effects;
35pub use crate::draw::highlight::{self, HighlightTheme, Lang};
36pub use crate::widgets::{
37    unified_diff, CodeBlock, DiffOp, DiffTheme, DiffView, List, Menu, Palette, ResizeEdge,
38    ScrollView, Scrollbar, ScrollbarStyle, Tabs, TextInput, Toasts, Window,
39};
40
41pub use crate::core::buffer::{center_pad, chip_cols, label_cols, Buffer, Cell};
42pub use crate::core::geom::{Align, Pos, Rect, Size};
43pub use crate::core::style::{Color, Modifier, Style};
44pub use crate::core::text::{Line, Span};
45pub use crate::draw::border::Border;
46pub use crate::draw::surface::{Compositor, Surface};
47pub use crate::term::event::{Event, Key, KeyCode, KeyMods, Mouse, MouseButton, MouseKind};
48pub use crate::term::terminal::{render, render_with_cursor, restore, Frame, MouseMode, Terminal};