Skip to content

add runtime-selectable icon themes (nerd/unicode/ascii)#14

Draft
roykollensvendsen wants to merge 6 commits into
mcjkula:mainfrom
roykollensvendsen:feat/icon-fallback
Draft

add runtime-selectable icon themes (nerd/unicode/ascii)#14
roykollensvendsen wants to merge 6 commits into
mcjkula:mainfrom
roykollensvendsen:feat/icon-fallback

Conversation

@roykollensvendsen

Copy link
Copy Markdown

Problem

taolk hard-coded Nerd Font glyphs with no fallback. On any terminal without a patched Nerd Font the icons show as blank boxes ("tofu"), and in GNOME Terminal/VTE the symbols-only fallback font renders them about 1.6 cells wide, which breaks the panel borders. Users had to install and set up a Nerd Font just to get a readable UI.

What this does

Makes the icon set runtime-selectable with three themes:

  • unicode (new default) — plain single-cell symbols that render on any terminal, no special font
  • nerd — the original Nerd Font glyphs (opt-in; needs a patched font)
  • ascii — pure ASCII for the most limited terminals

Chosen via the ui.icons config key or the TAOLK_ICONS env var; NERD_FONT=1 is honored as a hint; non-TTY output falls back to ascii. The nerd theme reproduces the current look exactly.

How it works

An IconSet struct with three const instances and a process-global accessor (OnceLock) resolved once at startup. The compile-time tables (command palette, help cards, hint bar) reference an Icon enum that resolves through the active theme at render time. Resolution is a pure function (resolve_with), so it's unit-tested without touching env or IO.

Keeping it terminal-agnostic

  • A test asserts every glyph in every theme is exactly one display cell and a single Unicode scalar, so a wide or ambiguous glyph can't slip in.
  • A test asserts no Nerd Font PUA glyph appears anywhere outside the icon module, so icons can't be scattered as raw literals again.
  • The unicode glyphs were picked from East-Asian-Width "narrow" ranges so they stay single-cell even under CJK locales.

Testing

cargo fmt --check, cargo clippy --all-targets -- -D warnings, cargo test (507 passing), and cargo check --no-default-features --lib all pass. Also checked ui.icons / TAOLK_ICONS selection and the non-TTY fallback by hand.

Companion to #13: with a safe default, a Nerd Font is now optional rather than required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant