Skip to main content

Module glyphs

Module glyphs 

Source
Expand description

Terminal glyphs, with an ASCII fallback.

datui runs on a modern desktop terminal and over SSH on a plain server with a bitmap font and a C locale. Neither should be the one that suffers: on a capable terminal the box-drawing and arrow characters carry real meaning, and on a limited one they turn into replacement boxes that make the UI harder to read rather than prettier.

Nothing here is a Nerd Font glyph. Every Unicode character has passed the font-coverage audit (scripts/code/audit_glyphs.py): present in JetBrainsMono Nerd Font, and never an Emoji=Yes, Emoji_Presentation=No codepoint that Liberation Mono and Noto Sans Mono don’t also carry, because a terminal whose font lacks one of those falls back to the color emoji font and renders a blank cell or a clipped blob (#325). Nerd Font icons appear only in the Omarchy menu definition, where the font is guaranteed — and in a user’s own [glyphs] overrides, where the risk is theirs. The ASCII fallback exists for terminals that are not doing UTF-8 at all.

Structs§

Glyphs
Symbols used by the UI, in whichever alphabet the terminal can render.
PlotMarks
The marks ratatui’s Chart, Canvas and BarChart put on a plot, and the lines of its axes and legend frame. ratatui picks none of these from the locale, so each set names its own.

Enums§

SlotOverride
One [glyphs] override from the config: a single glyph, or a list for the slots that hold one (spinner, score_marks, mini_bars, bar_eighths).
UnicodeMode
What the user asked for, from [display] unicode.

Functions§

active_is_unicode
Whether the active set is the Unicode one. get hands out a copy of a const, so no address — the set’s nor a field’s — can identify it; the flag on the set can.
ascii
The ASCII set.
asciify_instructions
Instructional text with its Unicode characters mapped to ASCII, for the help overlay on a terminal that is not doing UTF-8. Applied at the render boundary only — user data is never transliterated. The pairs cover what the help files actually contain; the audit that counts them is every_help_screen_is_ascii_clean.
cell_width
Cells text takes when a table cell draws it, grapheme by grapheme at ratatui’s own widths. Unlike display_width, an emoji sequence joined into one grapheme counts once, and control characters count nothing, because ratatui draws nothing for them.
display_width
Display columns text will occupy, as the terminal draws it. Scalar counts undercount CJK and overcount combining marks; layout math that budgets cells must use this.
environment_is_utf8
Whether the terminal can be trusted with UTF-8.
fit_cells
text as it fits in width cells: whole when it fits, otherwise cut at a grapheme boundary and closed with marker, so a clipped value never passes for a whole one. A wide character that would straddle the edge goes, never half of it. Control characters are dropped, as ratatui would drop them, so the result is exactly what is drawn. When even marker does not fit, as much of it as fits.
get
The active glyph set. Falls back to detection when init was never called, so library users and tests get sensible symbols without ceremony.
init
Choose the glyph set for this run. Later calls are ignored, so this is safe to call once from startup and never think about again.
init_with_overrides
init, with the config’s [glyphs] overrides laid over the Unicode set. The ASCII set is never touched: it is the tested floor a C locale falls back to, and an override written for a rich font would garble exactly there.
instructions_in_ascii
text with every instructional character replaced by its ASCII twin, whatever the terminal. The twins are wider (↑ is Up), so help rows laid out as key, two or more spaces, description are re-padded one section (a run of non-blank lines) at a time: descriptions stay at the columns they were authored at, and when an ASCII key no longer fits, the whole section moves right together rather than that one row.
take_columns
The longest prefix of text that fits width display columns, never splitting a wide character.
take_columns_end
The longest suffix of text that fits width display columns, never splitting a wide character.
unicode
The Unicode set, for tests and for callers that know their output is UTF-8.
validate_overrides
Check a [glyphs] override map without touching the active set, so a bad config fails at load time with the slot named, not mid-draw.