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> owns a double-buffered Grid and the Backend lifecycle
(resize, present, events). Drawing itself goes entirely through Surface, handed out by
Terminal::draw/Terminal::surface: a game calls term.draw(|s| { s.put(...); ... })
once per frame, and present diffs the current frame against the
previous one, 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
└──────────────┬─────────────┘
│ term.draw(|s| ...): writes through Surface
▼
┌───────────────────────────┐
│ 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::App;pub use app::Flow;pub use app::Frame;pub use app::step;pub use app::RunOptions;stdpub use app::run_blocking;stdpub use app::run_blocking_with;stdpub use backend::Backend;pub use backend::Cursor;pub use backend::CursorStyle;pub use backend::DrawCell;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 dev::BuildMode;pub use dev::DEV;pub use event::Event;pub use event::KeyCode;pub use event::KeyEvent;pub use event::KeyEventKind;pub use event::KeyLocation;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;color-spacepub use grid::Grid;pub use grid::Offset;pub use grid::Pos;pub use grid::Rect;pub use grid::Size;pub use layout::HAlign;egcpub use layout::TextLayout;egcpub use layout::TextMetrics;egcpub use layout::VAlign;egcpub 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 surface::StyledSurface;pub use surface::Surface;pub use terminal::Terminal;pub use text::Line;pub use text::Span;pub use tile::Tile;pub use tint::Tint;
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.
- dev
- Which diagnostics a build compiles in. Build-mode vocabulary: which diagnostics a build compiles in.
- 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
egc - 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.
- surface
- The one grid-drawing primitive: an area-clipped, single-layer view over a
Grid.Surface: an area-clipped, single-layer view over aGrid. - terminal
- Stateful terminal lifecycle 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.
- tint
- Sprite colour modulation: how a sprite’s own pixels are recoloured at draw time.