colours-themes-glyphs

Colour schemes and characters -- navigator/styles/themes/*.nss generated by tools/palconv.py from DOS Navigator .PAL palettes, the 144-slot table from DN.DNR, LIVE/HAND_NAMED/DERIVED/DEPARTURES, palet

SKILL.md

GitHub

Colours, themes and glyphs

Themes are generated, never hand-edited

Colour is split from structure and neither half is authored by hand. navigator/styles/navigator.nss holds the rules and defines no variable; navigator/styles/themes/*.nss define every variable and no rule, and one is always loaded after it (load_scheme("norton"), --theme norton, --list-themes). navigator/lib/appearance/scheme.py holds load_scheme, default_scheme (parsed on first use, not at import) and theme_names. Each theme is a DN COLORS/*.PAL decoded by tools/palconv.py, which documents the format and which of the 228 attribute bytes means what.

  • Regenerate: ./venv/bin/python tools/palconv.py path/to/DN/COLORS --out navigator/styles/themes; --dump ONE.PAL prints one palette's decoded slots.
  • For now only default.nss is edited among the DOS themes: after palconv regenerates, revert the other ten.
  • The modern themes -- ember, nord, gruvbox, tokyo-night, one-dark, kanagawa, phosphor (dark), paper, solarized-light, gruvbox-light, everforest-light, catppuccin-latte, one-light, sepia (light); ember, paper, phosphor and sepia are originals -- are not transcriptions and have no .PAL: tools/themegen.py writes them from a role palette each (THEMES: about 45 named colours such as ground, surface, field, accent, dir, comment) and one shared table (SLOT_ROLES, DERIVED_ROLES) saying which two roles every slot draws. So they have no DEPARTURES: change a role, or a slot's roles, and rerun; --check (a test) fails on a hand edit. Every colour is a $color-<role> hex; no $dn-* registers. The no-magenta rule covers them too (Nord's, Gruvbox's and Everforest's purple, Solarized's violet and magenta, Catppuccin's mauve, pink and flamingo, Kanagawa's oniViolet and sakuraPink, and the purple One Dark/One Light and Tokyo Night colour keywords with -- those take a blue or cyan -- are left out). The schemes are MIT, credited in each header with what was changed (deepened colours on a light page, where the scheme's own fell short of the tests). The light themes' grounds are dimmed, at the user's request: the page (ground) sits near 0.68 relative luminance rather than near-white, every ground role scaled by one OKLab-lightness factor (field_focus by half as much, so the line being typed in still stands out), and an ink that then fell short was deepened to its floor (text 8:1, file types and syntax 4.5:1, comments 3.8:1, disabled and temporaries about 3:1). Keep a new light theme there.
  • Three entries a DOS theme draws exactly as DN did exist so a light theme need not: shadow (the drop shadow, Turbo Vision's ShadowAttr $08, painted through navkit's Widget::shadow part, SHADOW where a sheet names none), command-line and command-line-prompt ($07 and $0F, which TCommandLine.Draw hard-coded), and modified-title (a changed file's editor title, yellow).
  • A deliberate departure from a palette goes in palconv.py's DEPARTURES (theme -> slot -> colours and why), applied on generation and marked in the theme's comment. Current: default [117], the viewer's Normal text, is #D8D8D8 at the user's request (DEFAULT.PAL's was 2.6:1 contrast). No theme paints magenta, also at the user's request: every magenta/light magenta slot in all eleven themes is a DEPARTURES entry (mostly amber #E5B567); a custom-DAC theme defines fourteen registers, without the two magentas (UNUSED_COLORS).
  • No theme draws an unreadable pair, also at the user's request: test_no_theme_draws_an_unreadable_pair resolves every rule that sets both fg and bg, in every theme, and fails below 2:1 contrast (2.5:1 for the ordinary text of a widget made for reading -- a panel's rows, labels, static text, the editor and viewer, lists and trees -- in no state and of no file type; a button's caption keeps 2:1); when a :selected, :focused or :disabled rule sets nothing its base does not already have; when a :selected/:focused state on its base's ground fades toward that ground below 3:1 while the base reads better (a passive tree cursor is exempt, and a highlight going the other way, DN's white label on grey, does not count); or when an input line, focused or not, has the dialog's (Modal's) ground; or when a hotkey (::hotkey, ::shortcut, ::key, not disabled) looks like the text it marks -- its ::item, ::title, widget or ::label -- by colour and attributes alike, as mono's blue (its registers' light grey) did (History's sides are exempt from the contrast floor: they are the button's own colour). A rule setting only fg (a syntax token, a hotkey) is checked against the bg it inherits: the same selector without its part's classes/states, then without the part, then without the subject's states. Each pair it found in DN's palettes is a DEPARTURES entry. Most are in the grey custom-DAC themes, where two registers can be one grey. A rule that mixes two slots' fg and bg is the usual sheet-side cause (the old input-line selection, the calendar's today under the cursor), so paint a state in one slot whole.
  • No slot holds a bare #rrggbb: a departure's hex colour must be in palconv's COLOR_NAMES, and the theme defines it once at the top as $color-<name> ($color-amber, $color-pale_gray, ...) and refers to it by name; a test enforces it. Like the $dn-* registers, $color-* names are whole colours, not slots.
  • The slot table comes from RESOURCE/ENGLISH/DN.DNR (COLORITEM <name>, <index> lines; CP437, decode before grepping): all 144 entries the Colors dialog exposes, in 20 nested groups. palconv.py --names path/to/DN.DNR regenerates it. Twenty-three entries independently agree with the Turbo Vision palette-string chain, which is what makes the other 121 trustworthy. The 84 entries DN.DNR does not name are not carried.
  • Every theme carries all 144; navigator.nss reads some (LIVE marks them with >). Variables are stemmed by group path (group names repeat); a published variable name is API -- HAND_NAMED pins the ones navigator.nss uses. The editor's Highlight slots ([164] comments, [184] current-line comments, [189] symbols, [190] strings, [191] numbers) are drawn by the ::token rules (syntax highlighting, navigator-editor); LIVE does not list them yet, since adding them regenerates every theme. Keywords have no slot: DERIVED's keyword (alias of [76], yellow in default). The ten other themes were given palconv's two alias lines by hand, as palconv would write them.
  • Variables Navigator needs and DN had no slot for are the DERIVED table, each an alias of a slot, with palconv's DERIVED_DEPARTURES for a theme that wants otherwise (default's symlink and temp). With no .PAL at hand, a new alias's lines are written into the eleven DOS themes as palconv would (its SLOTS names, its column), and themegen is rerun for the rest -- as diff-* and sync-* were (navigator-compare). root-title, error-dialog (white on red), error-dialog-icons (yellow on red) and error-dialog-shadow (black on red, the buttons' shadows) are colour pairs, not aliases; bw, mono and vga-bw give the error box a #555555 ground instead, as their red is a near-black grey. The F3 viewer's highlighting has its own aliases, viewer-comments/-symbols/-strings/-numbers/-keyword/-links (of [164]/[189]/[190]/[191]/[76]/[114]), because a viewer's ground can differ from the editor's: dosshell's viewer is black where its editor is white, and departs. The quick view keeps the editor's colours, its ground being the editor's in every palette. They colour the error box (ErrorDialog), which departs from DN, whose mfError box kept the grey dialog palette. The eleven themes got their four lines by hand, spelled the way each theme spells root-title. gutter and gutter-current (of [70]/[71], the editor's passive and active frame) colour the editor's line-number gutter (LineGutter, a departure); themegen gives them faint and strong text on the ground. caret (yellow on black, (14, 0), a departure) is the text cursor's colour, Widget::caret, sent as OSC 12; only its fg counts. The eleven DOS themes got it by hand, spelled as each spells modified-title; themegen gives the accent.
  • The tables live in navigator/lib/appearance/palette.py (DOS_COLORS, ENTRIES, DERIVED), which palconv imports, because Options > Colors reads them too: its groups are ENTRIES' runs of one group name (so Tree and Menu come twice, as in DN) and a last Navigator group of DERIVED (DERIVED_ITEMS names them).

Attributes, and the user's palette

  • Every entry has seven variables: $X-fg, $X-bg and $X-bold/dim/italic/underline/reverse (palette.KEYS); every fg: $X-fg rule in navigator.nss also reads the five. Their defaults are navigator/styles/attributes.nss, loaded between the rules and the theme (scheme.ATTRIBUTES_PATH), so a theme or palette may redefine any.
  • The defaults are inherit, which navkit's parser drops (stylesheet.INHERIT), so a rule says nothing of an attribute it never named and the per-property cascade is what it was -- the cursor row stays bold over a directory. Writing false there instead breaks that (the golden snapshot catches it). Only three are set: directory-bold: true, marked-bold/marked-cursor-bold: false, which navigator.nss had written by hand.
  • Options > Colors (ColorsDialog, navigator/widgets/setup/colors_dialog/; Shell.change_colors): DN's TColorDialog -- Group, Item, the Foreground/Background grids (navml ColorSelector), a sample -- plus a line per colour taking any colour (a name, #rrggbb, default) and tri-state boxes for the five attributes ([?] is inherit). Each change re-parses the sheet from texts read once on a thread (scheme.theme_sources / scheme_from, ~50 ms) and assigns Shell.stylesheet, so the screen repaints live; Cancel puts the old sheet back.
  • The user's palettes are one per theme, palettes/<theme>.nss in the configuration directory (palette.palette_path(theme)): only what differs from that theme (palette.differences), so a theme changed under it keeps the rest, and each applies under its own theme alone -- one theme's changes laid over the next recoloured it (ember's amber keywords on paper's cream did). OK and Load palette write Shell.theme's file (none left: the file goes); main() loads the running theme's after the theme (scheme.user_scheme), and one that does not parse is left out with a stderr warning. The header names the theme ( * Theme: NAME, palette.palette_theme). The single palette.nss of before (legacy_palette_path()) is still read for the theme it was made over -- its header's, or the configured one's for a file too old to say (unmarked=) -- until that theme's own file is written, which removes a legacy file naming that theme.
  • Store palette writes every entry's seven, resolved, as a full sheet into ~/.config/navigator/themes/ (palette.user_themes(), DN's COLORS\*.PAL), asking before overwriting; a theme there is one --theme and theme_names() find, and wins over a shipped one of the same name (scheme.theme_path). Load palette opens the user's themes (or the shipped ones, with none) and keeps the file's difference from the theme as that theme's palette; one that does not parse says Not a palette. Its box is PaletteFileDialog (navigator/widgets/setup/, a departure: FileDialog 59 wide so theme names fit, plus Preview palette, off by default): ticked, the file under the Files cursor is read on a thread and painted; unticking, Esc or any close puts the screen back. .nss only -- no .PAL reading at run time; that is palconv's job.

File-type colours

navigator/lib/appearance/filetypes.py's category_of: Midnight Commander's type classes off the type mark (executable, symlink, stale-link, device, special) or else DN's categories by mask (archive, image, media, document, source, temp), one class on Panel::row beside .directory, the type winning as it does for the icon; a directory takes no category. The rules sit between .directory and the cursor/tag rules in navigator.nss, so the cursor and a tag still win. Executables [173] and Archives [174] are DN's slots; the rest are DERIVED aliases of DN's Custom 1-5 [175-181]. filetypes.matches is also what Select group reads masks with. archive takes DN's multi-volume parts too, *.[aArR][0-9][0-9] (FILESCOL.PAS's .[ar][0-9][0-9]).

Panel.type_classes gives a row's .directory and category; with Files highlight off it gives none, so directories go plain as well, as DN's HLC[1..8] := C1 made ttDirectory too. The tag sign (√) is drawn in the type's foreground over the row's colours (DN's CC and $0F), unless that foreground is the row's background.

The five custom masks (filetypes.CUSTOM, everything but archive) are DN's CustomMask1..5: Options > File Manager > Highlight groups (HighlightGroups, HighlightPage in Settings, [highlight_groups]) edits them, and Shell._use_highlight_groups (an effect) hands them to filetypes.use_masks, which re-indexes and clears the lru_caches, then re-reads every panel when they changed (DN's cmPanelReread): colour and Group order both come from them. CATEGORIES stays the defaults; the masks in force are module state, which conftest puts back.

The palette stays exact; the edge quantises

A widget asks for the colour it wants and a sheet records the colour the original asked for; render_diff(previous, current, info) quantises to what the terminal can name -- the only place the question is asked. A palette index passes through untouched unless a palette is pinned: unset (navkit's default), blue is the user's terminal theme's; with VGA_PALETTE it means the DOS register value. navigator pins by default; --palette terminal hands the question back. A child program's cells are never pinned (Style.terminal_palette, per cell, not a sheet field, and adapt_style leaves their indices alone), so ls --color in the console matches the plain terminal. Pinning is a no-op below 256 colours; --reprogram-palette (OSC 4, reset with OSC 104) reaches those. NAVKIT_PALETTE (dos/vga, terminal/none/off) overrides; --palette outranks it. The depth itself is detected from COLORTERM/TERM; [appearance] colors replaces that guess, NAVKIT_COLORS overrides it and --colors {auto,mono,8,16,256,truecolor} outranks both (depth_named()). Forcing 16 therefore also turns pinning off.

Glyphs

TerminalInfo.glyphs: GLYPHS_ASCII < GLYPHS_UNICODE < GLYPHS_NERD; NAVKIT_GLYPHS overrides and --glyphs {auto,ascii,unicode,nerd} outranks it. Options > Interface's Glyphs ([appearance] glyphs) changes it in a running session: Navigator.use_glyphs weighs the choice as main() does (so NAVKIT_GLYPHS still wins) and hands the result to navkit's Application.use_terminal_info, which swaps terminal.info, bumps the reactive info_revision and repaints whole. Widget.glyphs reads info_revision, so a binding or computed on the tier follows; anything that reads the tier once and keeps the result (a dialog built before the change) does not. A font cannot be detected, so the Nerd tier is granted only to emulators that bundle a Nerd Font fallback (kitty, WezTerm, Ghostty) or a session that says so; a multiplexer needs the override. A non-UTF-8 locale gets ASCII. navkit/glyphs.py holds the frame sets (single, double, round, ascii) and imports nothing; draw_box takes six characters, never a name; Widget.box_charset() resolves the sheet's wish against the tier. Widget.box_joins() matches tees (┬┴ single, ╤╧ double). SPINNERS (auto, the default: braille from the Unicode tier up, else dos ▌▀▐▄ from CP437's half blocks where TerminalInfo.braille is off -- TERM=linux, whose console font has no braille; ascii |/-\ below Unicode) are navml Spinner's frames, a sheet's frames: -- not chars:, which the gauge and scroll bar declare with other names.

Check and radio marks (MARKS: dos, brackets, boxes, ascii) are a departure (DN drew only [X]/(•)): each is three cells, brackets included, so nothing moves between looks. Below Unicode every look is ASCII; the Nerd tier changes only boxes, to Font Awesome 4's square_o/check_square_o/minus_square_o/circle_o/dot_circle_o centred in the slot (the blank after takes a non-Mono font's overflow). Chosen by [appearance] marks/--marks or Options > Interface's Marks; navml-library has the widget side.

The Nerd Font icon gutter in Panel is the project's one standing modern exception, taken deliberately, on only where the font is known to exist, reversible with icons: none or --glyphs unicode. Don't re-litigate it and don't read it as licence for the next flourish. Icons: icons.BY_TYPE beats the extension's; icons.HIDDEN_FILE/HIDDEN_FOLDER for unclaimed dot-names; icons.BOOKMARKED_FOLDER (nf-fa-bookmark) beats both for a directory on the bookmarks list, a link to one included. Icons stay Font Awesome 4/Octicons -- Material Design codepoints moved between Nerd Fonts 2 and 3. Without icons a bookmarked directory's type mark is Panel.BOOKMARK_MARK (♦, CP437 $04) instead of /; the ASCII tier keeps /.

The tier also picks the character table (Ctrl+B / editor Ctrl+P, pick_character in shell/unicode_chart): ASCII gets DN's CP437 ASCII Chart, Unicode the Character Table, Nerd the same with a Nerd Fonts grouping. Its Nerd names and sets are navigator/assets/unicode/nerdfont.txt, generated from nerd-fonts glyphnames.json at tools/unicode_tables.py's pinned NERD_FONTS tag (v3 codepoints); navkit.screen.char_width measures a cell holding a base plus combining marks (◌́) by its base, which is how the table shows a mark. A flag, two Regional Indicators (🇱🇻), is joined by Surface.draw_text into one cell measuring 2 (screen.is_flag), so a diff never rewrites half of it; a lone indicator stays one cell.

Read when

Reference Read when
reference/palette.md what an index in a transcribed sheet means; pinning and quantisation
reference/glyphs.md glyph tiers, why a font cannot be detected, the icon departure