Skip to main content

Module graphics

Module graphics 

Source
Expand description

Inline kitty graphics support for the nms REPL / one-shot evaluator.

When the user evaluates a form whose value is a Value::Bytes that sniffs as an image AND stdout is connected to a kitty-graphics capable terminal, the value-printer emits a kitty APC sequence containing the image. The image renders inline at the cursor; subsequent text lines below sit beneath it.

Capability detection mirrors tui::chart::supports_kitty so an nms invocation and a TUI session inside the same terminal agree on what to emit. The --no-graphics CLI flag short-circuits the detection for CI captures and for users whose terminal the heuristics misidentify.

Enums§

ImageFormat
Image format the kitty graphics protocol can transmit directly. f=100 corresponds to PNG; f=24/f=32 would be raw RGB/RGBA. We never auto-convert SVG → PNG inline (that lives in the plotting crate’s :format png keyword path); SVG bytes fall through to the textual #u8(...) printer.

Functions§

encode_kitty
Wrap bytes of a known image format into a single kitty graphics APC sequence. The sequence is appended to out, which keeps callers in control of stdout buffering — nms prints it through the normal value-formatter, and tests can capture the bytes for comparison.
sniff
Detect the image format by magic bytes. Returns None for any payload that isn’t a known inline-renderable raster.
supports_kitty
Mirror of tui::chart::supports_kitty for the standalone nms process. Returns true when the surrounding terminal advertises kitty-graphics support via env vars set by the terminal emulator.
try_render_inline
Convenience entry that returns the kitty APC payload as a String when the bytes are a known image and the terminal supports kitty graphics, otherwise None. The caller falls back to the textual #u8(...) printer when this returns None.