add runtime-selectable icon themes (nerd/unicode/ascii)#14
Draft
roykollensvendsen wants to merge 6 commits into
Draft
add runtime-selectable icon themes (nerd/unicode/ascii)#14roykollensvendsen wants to merge 6 commits into
roykollensvendsen wants to merge 6 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 fontnerd— the original Nerd Font glyphs (opt-in; needs a patched font)ascii— pure ASCII for the most limited terminalsChosen via the
ui.iconsconfig key or theTAOLK_ICONSenv var;NERD_FONT=1is honored as a hint; non-TTY output falls back toascii. Thenerdtheme reproduces the current look exactly.How it works
An
IconSetstruct 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 anIconenum 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
Testing
cargo fmt --check,cargo clippy --all-targets -- -D warnings,cargo test(507 passing), andcargo check --no-default-features --liball pass. Also checkedui.icons/TAOLK_ICONSselection and the non-TTY fallback by hand.Companion to #13: with a safe default, a Nerd Font is now optional rather than required.