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.
- Plot
Marks - The marks ratatui’s
Chart,CanvasandBarChartput 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§
- Slot
Override - 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). - Unicode
Mode - What the user asked for, from
[display] unicode.
Functions§
- active_
is_ unicode - Whether the active set is the Unicode one.
gethands 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
texttakes when a table cell draws it, grapheme by grapheme at ratatui’s own widths. Unlikedisplay_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
textwill 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 textas it fits inwidthcells: whole when it fits, otherwise cut at a grapheme boundary and closed withmarker, 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 evenmarkerdoes not fit, as much of it as fits.- get
- The active glyph set. Falls back to detection when
initwas 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 textwith every instructional character replaced by its ASCII twin, whatever the terminal. The twins are wider (↑isUp), 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
textthat fitswidthdisplay columns, never splitting a wide character. - take_
columns_ end - The longest suffix of
textthat fitswidthdisplay 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.