Expand description
retroglyph-core: the no_std-compatible foundation of retroglyph.
Grid, tile, style, color, text, terminal, and event types, plus the
Output/Input/Cursor backend facets (bundled together as Backend) and the
dependency-free Headless test backend, and the App/Flow/Frame game loop contract.
Platform backends (retroglyph-crossterm, retroglyph-software) and drawing helpers
(retroglyph-widgets) are separate crates that depend on this one.
§Architecture
Terminal<B> is the drawing API a game calls into (put,
print, layer, …). It owns a double-buffered Grid and diffs the
current frame against the previous one in present,
sending only changed cells to the Backend. B is the only thing that
changes between a headless test and a real window or terminal:
┌───────────────────────────┐
│ App::update(...) │ game logic, once, generic over B
└──────────────┬─────────────┘
│ put / print / present
▼
┌───────────────────────────┐
│ Terminal<B> │ double-buffered Grid, cell diff
└──────────────┬─────────────┘
│ draw / draw_layers / poll_event
▼
┌───────────────────────────┐
│ B: Output + Input + Cursor │ the only piece that swaps out
└──────────────┬─────────────┘
│
┌─────────────────────┼─────────────────────┐
▼ ▼ ▼
Headless (here) Crossterm SoftwareRenderer
in-memory grid, (retroglyph-crossterm) (retroglyph-software)
synthetic events real TTY, ANSI output winit window, pixelsHeadless stores presented content in memory and lets tests inject
synthetic Events with Headless::push_event;
nothing here talks to a real terminal or window. Swapping Headless for
Crossterm or SoftwareRenderer changes only the B type parameter –
App implementations, Terminal calls, and game logic are unchanged.
run_blocking drives Terminal<Headless> and Terminal<Crossterm>
identically; the software backend’s windowed loop drives Terminal<SoftwareRenderer>
through the same App/step contract, inverted because winit owns the
event loop instead of handing control back to a driver function.
See examples/headless.rs (cargo run -p retroglyph-core --example headless) for the smallest possible use of Headless, depending on
nothing but this crate.
Re-exports§
pub use animate::Easing;pub use animate::Tween;pub use animate::oscillate;pub use app::run_blocking;pub use app::App;pub use app::Flow;pub use app::Frame;pub use app::step;pub use backend::Backend;pub use backend::Cursor;pub use backend::Headless;pub use backend::Input;pub use backend::Output;pub use camera::Camera;pub use color::AnsiColor;pub use color::Color;pub use color::InvalidAnsiIndex;pub use event::Event;pub use event::KeyCode;pub use event::KeyEvent;pub use event::KeyEventKind;pub use event::KeyModifiers;pub use event::KeyState;pub use event::MouseButton;pub use event::MouseEvent;pub use event::MouseEventKind;pub use event::PhysicalPos;pub use event::SystemTheme;pub use frame_clock::FrameClock;pub use grid::BlendMode;pub use grid::Grid;pub use grid::Pos;pub use grid::Rect;pub use grid::Size;pub use layout::HAlign;pub use layout::TextLayout;pub use layout::TextMetrics;pub use layout::VAlign;pub use style::Style;pub use subcell::Glyph;pub use subcell::quantize_half_block;pub use subcell::quantize_quadrant;pub use subcell::quantize_sextant;pub use terminal::Terminal;pub use text::Line;pub use text::Span;pub use tile::Tile;
Modules§
- animate
- Time-driven value animation: easing curves, a stateful
Tween, and a periodic oscillator. Time-driven value animation:Easingcurves, a stateful, retargetableTween, and a periodicoscillatehelper. - app
- The
App-driven game loop. TheApp-driven game loop. - backend
- Pluggable rendering backends. Pluggable rendering backends.
- camera
- A scrolling viewport into a world larger than the screen. A scrolling viewport into a world larger than the screen.
- color
- Styling types for character cells.
- event
- Input event system.
- frame_
clock - Fixed-timestep accumulator for game loops. Fixed-timestep accumulator.
- grid
- The layered tile grid:
Grid, plus theSize,Pos, andRectcoordinate types used throughout the crate. - layout
- Text layout: measurement, word wrapping, and bounded alignment.
- style
- Text styling: foreground and background color.
- subcell
- Posterizes small blocks of raw pixels to the best-matching Unicode block-element glyph.
- terminal
- Stateful terminal management and double-buffering.
- text
- Styled text primitives:
SpanandLine. - tile
- The atomic drawable unit (glyph, style, sub-cell offsets). Fundamental unit of the grid: a single drawable tile.