Expand description
Micro assets for rs-rich (#565): emoji-sized inline images and
animations, written Deploying :micro:rocket:.
Not a port of anything upstream: an rs-rich addition, outside core. Core
is unchanged: :micro:name: is not an emoji code, so it passes through
core untouched, and every seam here goes through core’s public API (style
metadata, Renderable) or rs-rich-ext’s.
MicroAsset: a name, a kind, a size in cells (2×1 by default, up to 4×2: 1 to 4 columns, 1 or 2 rows), images, mandatory alt text, an emoji or text fallback, and where it came from.package:.richmicropackages and packs, read under hardLimits.MicroRegistry: built-in < user < trusted project < inline, with aliases, collisions andexplain.markup::micro:name:in markup and text, and in Markdown (PreparedMarkdown);MicroExtandMicroAssetRefin code.render: the placeholder representation, and theMicroRendererseam that terminal graphics plug into.rows: assets two rows high (a 2×2 icon, a 3×2 animation):MicroRowsreserves the row below the line each one sits on, in wrapped text, table cells and panels.graphics: drawing on a terminal:selectpicks Kitty, iTerm2, Sixel, half-blocks or the text fallback, andMicroGraphicsdraws with it, in printed output and through the graphics side channel ofrich-ext’s live regions and the interactive painter.cache: decoded images fitted to their cells, cached in memory and on disk.pipeline: any picture or animation to an asset’s images: fitted, adjusted, sharpened, with its transparency decided;createwrites the package.builtin: the built-in library (status, dev and fun sets), drawn for this project;MicroRegistry::builtinloads it.
use rich::Console;
use rich_micro::{render_markup, FallbackPreference, Layer, MicroAsset, MicroRegistry};
let mut registry = MicroRegistry::new();
registry.add(Layer::Inline, MicroAsset::new("ship", "rocket")?.with_emoji("🚀")?)?;
let console = Console::builder().width(40).build();
let (text, diagnostics) =
render_markup(&console, "Deploying :micro:ship: :fire:", ®istry, FallbackPreference::Emoji);
assert_eq!(text.plain(), "Deploying 🚀 🔥");
assert!(diagnostics.is_empty());Re-exports§
pub use api::MicroAssetRef;pub use api::MicroExt;pub use api::MicroPlugin;pub use cache::ImageCache;pub use cache::Prepared;pub use error::MicroError;pub use graphics::MicroGraphics;pub use graphics::MicroMode;pub use graphics::Selection;pub use graphics::select;pub use markup::Diagnostic;pub use markup::DiagnosticKind;pub use markup::MarkdownView;pub use markup::MicroTransform;pub use markup::PreparedMarkdown;pub use markup::PreparedMarkup;pub use markup::expand;pub use markup::markup_text;pub use markup::render_markup;pub use model::AssetKind;pub use model::CellSize;pub use model::Fallback;pub use model::ImageFormat;pub use model::ImageInfo;pub use model::ImageRef;pub use model::Layer;pub use model::MicroAsset;pub use model::Origin;pub use model::PackageLocation;pub use model::Variants;pub use name::is_valid_name;pub use package::Limits;pub use package::Pack;pub use registry::Collision;pub use registry::LoadReport;pub use registry::MicroRegistry;pub use registry::MicroRoots;pub use registry::Rejected;pub use render::FallbackPreference;pub use render::FallbackRenderer;pub use render::MICRO_META_KEY;pub use render::MicroMeta;pub use render::MicroRenderer;pub use render::MicroView;pub use render::PAD_CELL;pub use render::Placement;pub use render::fallback_cells;pub use render::fallback_row;pub use render::placeholder;pub use rows::MicroRows;pub use rows::reserve_rows;
Modules§
- api
- The Rust API (#570): an extension trait on core’s
Textand a renderable, so micro assets compose with everything else without a core method. - builtin
- The built-in library (#581), compiled in: the packs under
crates/rich-micro/builtin/, drawn for this project byexamples/gen_builtin.rsand read through the same package reader, under the sameLimits, as any other pack. - cache
- Decoded, fitted images for drawing, cached (#584).
- create
- Writing packages (#568): the other side of
crate::package. Whatrich micro createruns after the pipeline. - error
- Errors.
- graphics
- Drawing micro assets on a terminal (#572–#577): choosing a protocol, and the renderers and graphics source for each.
- image
- Image headers read without decoding (#580): the format, the canvas size and the frame count of a PNG, APNG, GIF or WebP, from its container structure alone. Limits are checked on these numbers before anything is ever decoded, so a decompression bomb is refused by its header.
- markup
:micro:name:markup (#569, #570).- model
- The asset model (#566, #579, #585): what a micro asset is, independent of where it was loaded from or how a terminal will draw it.
- name
- Asset names:
[a-z0-9_-]segments joined by/namespaces. - package
.richmicropackages and packs (#580), read-only.- pipeline
- The image and animation pipeline (#571, #572): from any picture to the images a package holds, fitted to its cells.
- registry
- The layered registry (#567, #583).
- render
- Placeholder cells and the renderer seam (#577, #578).
- rows
- Assets two rows high (#711): reserving their rows in any layout.
Structs§
- Cell
Pixels - The size of a terminal cell in pixels, as the cache and pipeline take it. The size of one terminal cell in pixels.