From ad9926861b25fd9494f8a70726b64ffd9ad17d84 Mon Sep 17 00:00:00 2001 From: Rootiest Date: Mon, 7 Sep 2026 20:04:44 -0400 Subject: [PATCH] refactor(config-settings): draw the sub-category page through the frame Width tier, title border, badge, cursor cell and row line now come from __config_settings_frame, and the hand-verified title dash count (iw - L - S - 22) is derived from the segment's visible width instead. Introduces the `cut` fit policy, which is this page's documented divergence from the category list: its labels and descriptions are static data from __config_settings_subcats rather than per-tier authored text, and several exceed the narrower tiers' fields. `string pad` only ever grows a string, so they are truncated before padding. That reason now lives in two places -- the frame's NOTES and each call site -- and the DESCRIPTION block stating it here is unchanged. Drops label_w and desc_w, both left assigned and never read once the frame derives the field width; the comment recording the 13-wide label field and how the description field absorbs it stays. Rendering unchanged: 377/377 render cases byte-identical, golden untouched. Code lines 85 -> 49 (-36). --- functions/__config_settings_draw_subcat.fish | 97 +++++++------------- 1 file changed, 34 insertions(+), 63 deletions(-) diff --git a/functions/__config_settings_draw_subcat.fish b/functions/__config_settings_draw_subcat.fish index c7dccd3..9c05200 100644 --- a/functions/__config_settings_draw_subcat.fish +++ b/functions/__config_settings_draw_subcat.fish @@ -41,34 +41,22 @@ function __config_settings_draw_subcat set -l cur_scope $argv[2] set -l category_var $argv[3] - set -l c_ok (set_color green) - set -l c_err (set_color red) - set -l c_dim (set_color brblack) - set -l c_sel (set_color --bold magenta) - set -l c_head (set_color --bold cyan) + set -l c_dim (set_color brblack) + set -l c_head (set_color --bold cyan) set -l c_reset (set_color normal) set -l rows (__config_settings_subcats $category_var) set -l n (count $rows) # ── Width tier: matches __config_settings_draw's 6-col-per-side steps ── - set -l iw 50 - if test "$COLUMNS" -ge 90 - set iw 76 - else if test "$COLUMNS" -ge 86 - set iw 72 - else if test "$COLUMNS" -ge 82 - set iw 68 - end + set -l iw (__config_settings_frame width) set -l HBR (string repeat -n $iw '─') set -l p (string repeat -n (math --scale=0 "max(0, ($COLUMNS - ($iw + 2)) / 2)") ' ') # Label field is 13 wide (one wider than __config_settings_draw's 12) -- - # the longest real sub-category label ("Notifications") is 13 chars. - # Description field absorbs the difference so every row still totals - # iw+2, matching the surrounding box lines exactly. - set -l label_w 13 - set -l desc_w (math $iw - 34) + # the longest real sub-category label ("Notifications") is 13 chars. The + # description field absorbs the difference inside the frame + # (field_w = iw - 21 - label_w = iw - 34), so every row still totals iw+2. set -l cat_label (string replace -r '^__fish_config_op_' '' -- $category_var) # Scope indicator: toggling a row on this page writes -U (Universal, @@ -77,32 +65,18 @@ function __config_settings_draw_subcat set -l scope_label Universal test "$cur_scope" = session; and set scope_label Session # Title layout is "┌─ Sub-categories: