feat(config-settings): render and toggle sub-categories in the drill-down page

Adds __config_settings_draw_subcat.fish, rendering a category's own
toggle plus its sub-category rows, sized dynamically from
__config_settings_subcats instead of the fixed 6-row category layout.
Wires the real per-category row count into config-settings.fish's
up/down handling (replacing Task 17's stub) and adds the
hyphen-to-underscore sub-category variable resolution to the
left/right toggle handlers, mirroring the translation the guard
function already applies.

Two box-drawing bugs surfaced while adapting the design doc's draft to
the real static sub-category data and were fixed rather than
transcribed: the title-dashes offset was off by 5, and several real
sub-category labels/descriptions (e.g. "Notifications", 13 chars;
several descriptions past 30 chars) exceed the narrower width tiers'
fixed field widths, so both fields are now defensively truncated
before padding to keep every row exactly iw+2 wide regardless of
content length.
This commit is contained in:
2026-08-18 03:11:17 -04:00
parent 7ad3b90503
commit 489e3cc7de
2 changed files with 162 additions and 3 deletions
+21 -3
View File
@@ -195,9 +195,8 @@ function config-settings --description 'Interactive TUI for managing fish config
end
case down j
if test $in_subcat -eq 1
# TODO(Task 18): replace the stubbed 4-row max with the real
# per-category count from __config_settings_subcats.
set subcat_row (math "min(3, $subcat_row + 1)")
set -l n (count (__config_settings_subcats $toggle_vars[(math $cur_row + 1)]))
set subcat_row (math "min($n, $subcat_row + 1)")
else
# Hoist the page index: fish cannot expand a command-substitution
# index inside a quoted math string.
@@ -215,7 +214,17 @@ function config-settings --description 'Interactive TUI for managing fish config
# Toggle page: step toward ON
set -l scope universal
test $cur_page -eq 1; and set scope session
# Default: the category variable itself -- correct both
# when not in a sub-category page at all, and when in
# one but sitting on its row 0 (the category's own
# toggle). Only row >= 1 of a sub-category page
# resolves to a different, sub-category variable.
set -l varname $toggle_vars[(math $cur_row + 1)]
if test $in_subcat -eq 1 -a $subcat_row -ne 0
set -l rows (__config_settings_subcats $toggle_vars[(math $cur_row + 1)])
set -l fields (string split -- \t $rows[$subcat_row])
set varname "$toggle_vars[(math $cur_row + 1)]"_(string replace -a -- '-' '_' $fields[1])
end
set -l cur_val (__config_settings_get_val $varname $scope)
set -l next_val on
test "$cur_val" = off; and set next_val DEFAULT
@@ -241,7 +250,16 @@ function config-settings --description 'Interactive TUI for managing fish config
if test $cur_page -le 1
set -l scope universal
test $cur_page -eq 1; and set scope session
# Same varname resolution as the right/l case above:
# row 0 (or not in a sub-category page) -> the category
# variable; row >= 1 of a sub-category page -> the
# selected sub-category variable.
set -l varname $toggle_vars[(math $cur_row + 1)]
if test $in_subcat -eq 1 -a $subcat_row -ne 0
set -l rows (__config_settings_subcats $toggle_vars[(math $cur_row + 1)])
set -l fields (string split -- \t $rows[$subcat_row])
set varname "$toggle_vars[(math $cur_row + 1)]"_(string replace -a -- '-' '_' $fields[1])
end
set -l cur_val (__config_settings_get_val $varname $scope)
set -l next_val off
test "$cur_val" = on; and set next_val DEFAULT