refactor(config-settings): shared frame renderer + line-diff redraw #133

Merged
rootiest merged 13 commits from refactor/config-settings-renderer into main 2026-09-08 16:28:53 +00:00
Showing only changes of commit 889f8e0768 - Show all commits
+54 -87
View File
@@ -38,20 +38,21 @@ function __config_settings_draw
set -l cur_scope $argv[2] set -l cur_scope $argv[2]
set -l vars $argv[3..] set -l vars $argv[3..]
set -l c_ok (set_color green) set -l c_dim (set_color brblack)
set -l c_err (set_color red) set -l c_head (set_color --bold cyan)
set -l c_dim (set_color brblack)
set -l c_sel (set_color --bold magenta)
set -l c_hi (set_color --bold white)
set -l c_head (set_color --bold cyan)
set -l c_reset (set_color normal) set -l c_reset (set_color normal)
set -l labels Aliases Auto-exec Overrides Integrations Logging Greeting Master set -l labels Aliases Auto-exec Overrides Integrations Logging Greeting Master
# ── Width tier: 6-col buffer per side before stepping up ────────────── # ── Width tier ────────────────────────────────────────────────────────
# The tier thresholds live in __config_settings_frame; this file only
# chooses which hand-authored description set goes with the width.
# IW = inner width (chars between │ │); desc field = IW - 33. # IW = inner width (chars between │ │); desc field = IW - 33.
# All four layouts are exactly 16 lines tall — panel_h in caller stays 16. # All four layouts are exactly 16 lines tall — panel_h in caller stays 16.
set -l iw 50 # Descriptions are authored to fit their field exactly at every tier
# (43/43, 39/39, 35/35, 17/17), which is why the rows below pass `pad`
# and not `cut` -- see the NOTES in __config_settings_frame.
set -l iw (__config_settings_frame width)
set -l descs \ set -l descs \
"cmd shadows" \ "cmd shadows" \
startup \ startup \
@@ -61,36 +62,34 @@ function __config_settings_draw
fish_greeting \ fish_greeting \
"disable all" "disable all"
if test "$COLUMNS" -ge 90 switch $iw
set iw 76 case 76
set descs \ set descs \
"shadows: ls→eza, cat→bat, cd→z, rm→trash" \ "shadows: ls→eza, cat→bat, cd→z, rm→trash" \
"Fisher bootstrap, themes, py-venv activate" \ "Fisher bootstrap, themes, py-venv activate" \
"vi-mode, bang-bang, PAGER, CDPATH, starship" \ "vi-mode, bang-bang, PAGER, CDPATH, starship" \
"Kitty/WezTerm tab/split fns, notifications" \ "Kitty/WezTerm tab/split fns, notifications" \
"scrollback capture & paru/yay AUR wrappers" \ "scrollback capture & paru/yay AUR wrappers" \
"fish_greeting & first-run welcome banner" \ "fish_greeting & first-run welcome banner" \
"master off-switch: overrides all categories" "master off-switch: overrides all categories"
else if test "$COLUMNS" -ge 86 case 72
set iw 72 set descs \
set descs \ "ls→eza, cat→bat, cd→zoxide, rm→trash" \
"ls→eza, cat→bat, cd→zoxide, rm→trash" \ "Fisher bootstrap, themes, py-venv auto" \
"Fisher bootstrap, themes, py-venv auto" \ "vi-mode, bang-bang, PAGER, starship" \
"vi-mode, bang-bang, PAGER, starship" \ "Kitty/WezTerm fns, done notifications" \
"Kitty/WezTerm fns, done notifications" \ "scrollback capture & paru/yay wrappers" \
"scrollback capture & paru/yay wrappers" \ "fish_greeting: first-run welcome banner" \
"fish_greeting: first-run welcome banner" \ "master off-switch for all categories"
"master off-switch for all categories" case 68
else if test "$COLUMNS" -ge 82 set descs \
set iw 68 "ls→eza, cat→bat, cd→z, rm→trash" \
set descs \ "Fisher, themes, py-venv activate" \
"ls→eza, cat→bat, cd→z, rm→trash" \ "vi-mode, bang-bang, PAGER, starship" \
"Fisher, themes, py-venv activate" \ "Kitty/WezTerm, done notifications" \
"vi-mode, bang-bang, PAGER, starship" \ "scrollback & paru/yay log wrappers" \
"Kitty/WezTerm, done notifications" \ "fish_greeting & first-run banner" \
"scrollback & paru/yay log wrappers" \ "master disable for all categories"
"fish_greeting & first-run banner" \
"master disable for all categories"
end end
set -l HBR (string repeat -n $iw '─') set -l HBR (string repeat -n $iw '─')
@@ -101,8 +100,7 @@ function __config_settings_draw
# ── Top border ──────────────────────────────────────────────────────── # ── Top border ────────────────────────────────────────────────────────
# ┌─ Opinionated Settings (iw-23)×─ ┐ total = iw+2 # ┌─ Opinionated Settings (iw-23)×─ ┐ total = iw+2
printf '%s┌─%s Opinionated Settings %s┐\n' \ __config_settings_frame title $iw $p "$c_head Opinionated Settings $c_reset"
$p $c_head $c_reset(string repeat -n (math $iw - 23) '─')
# ── Page-tab header ─────────────────────────────────────────────────── # ── Page-tab header ───────────────────────────────────────────────────
set -l active_idx 0 set -l active_idx 0
@@ -115,36 +113,18 @@ function __config_settings_draw
printf '%s│%s│\n' $p $HBR printf '%s│%s│\n' $p $HBR
# ── Category rows 0–5 ───────────────────────────────────────────────── # ── Category rows 0–5 ─────────────────────────────────────────────────
# Label field 12 wide; the description field falls out of it inside the
# frame (field_w = iw - 21 - label_w = iw - 33). `pad`, not `cut`: these
# descriptions are authored per tier to fit exactly, so truncating them
# would be a silent no-op that discards that property.
for i in (seq 0 5) for i in (seq 0 5)
set -l idx (math $i + 1) set -l idx (math $i + 1)
set -l var $vars[$idx] set -l val (__config_settings_get_val $vars[$idx] $cur_scope)
set -l label $labels[$idx] __config_settings_frame row $iw $p \
set -l desc $descs[$idx] (__config_settings_frame cursor $i $cur_row) \
$labels[$idx] 12 \
set -l val (__config_settings_get_val $var $cur_scope) (__config_settings_frame badge $val) \
$descs[$idx] pad
# Badge: 7 visible chars, coloured
set -l badge
switch $val
case on
set badge "$c_ok"" ON$c_reset"
case off
set badge "$c_err""OFF $c_reset"
case '*'
set badge "$c_dim""DEFAULT$c_reset"
end
# Cursor: 2 visible chars
set -l curs " "
if test $i -eq $cur_row
set curs "$c_sel$c_reset "
end
# Label padded to 12, desc padded to (iw-33), right margin 3
set -l lpad (string pad -r -w 12 -- $label)
set -l dpad (string pad -r -w (math $iw - 33) -- $desc)
printf '%s│ %s%s [ %s ] %s │\n' $p $curs $lpad $badge $dpad
end end
# ── Separator before Master ─────────────────────────────────────────── # ── Separator before Master ───────────────────────────────────────────
@@ -152,24 +132,11 @@ function __config_settings_draw
# ── Master row (index 6) ────────────────────────────────────────────── # ── Master row (index 6) ──────────────────────────────────────────────
set -l val (__config_settings_get_val $vars[7] $cur_scope) set -l val (__config_settings_get_val $vars[7] $cur_scope)
set -l badge __config_settings_frame row $iw $p \
switch $val (__config_settings_frame cursor 6 $cur_row) \
case on Master 12 \
set badge "$c_ok"" ON$c_reset" (__config_settings_frame badge $val) \
case off $descs[7] pad
set badge "$c_err""OFF $c_reset"
case '*'
set badge "$c_dim""DEFAULT$c_reset"
end
set -l curs " "
if test $cur_row -eq 6
set curs "$c_sel$c_reset "
end
printf '%s│ %s%s [ %s ] %s │\n' \
$p $curs \
(string pad -r -w 12 -- Master) \
$badge \
(string pad -r -w (math $iw - 33) -- $descs[7])
# ── Filler (Dots Path moved to the Paths page) ──────────────────────── # ── Filler (Dots Path moved to the Paths page) ────────────────────────
printf '%s│ %s%s│\n' $p \ printf '%s│ %s%s│\n' $p \