feat(config-settings): add __config_settings_frame shared renderer
The width tier, title-border arithmetic, ON/OFF/DEFAULT badge, cursor cell and table row are currently hand-copied across the three draw functions. This adds them once, with the two geometry identities derived rather than hand-maintained: a row's chrome is a fixed 21 columns, so field_w is iw - 21 - label_w (reproducing both iw-33 and iw-34), and a title border is dashes = iw - visible(segment) - 1 (reproducing all three of iw-23, iw-len-3 and iw-L-S-22). The frame owns no page height. Every verb prints exactly one line or fragment, so the fixed-16 category and value pages and the dynamic 7+n sub-category page keep their heights, and config-settings.fish's erase is unaffected. No caller yet, so rendering cannot move: the golden's existing page section is byte-identical (verified with cmp -n over its previous size) and the file only gains frame-verb cases appended after it.
This commit is contained in:
@@ -178,6 +178,17 @@ function _cs_render_case --argument-names label panel_h
|
||||
command rm -f $t
|
||||
end
|
||||
|
||||
# ── Frame-verb fragments ──────────────────────────────────────────────────
|
||||
# The shared computations pinned directly, not only through the pages that use
|
||||
# them. <END> marks the end of each fragment so trailing padding -- which is
|
||||
# the entire point of a 7-column badge or a 2-column cursor cell -- shows up in
|
||||
# a diff instead of being invisible whitespace.
|
||||
function _cs_frame_case --argument-names label
|
||||
printf '### frame %s\n' $label
|
||||
$argv[2..]
|
||||
printf '<END>\n'
|
||||
end
|
||||
|
||||
# ── Cases ─────────────────────────────────────────────────────────────────
|
||||
# 100 -> IW 76, 88 -> IW 72, 84 -> IW 68, 70 -> IW 50: one COLUMNS value per
|
||||
# width tier, each a few columns above its threshold.
|
||||
@@ -222,4 +233,47 @@ begin
|
||||
_cs_render_case "edit page=paths row=2 buf=empty" 16 \
|
||||
__config_settings_draw_value 2 paths edit ""
|
||||
end
|
||||
|
||||
# Emitted last on purpose: everything above is page output, so the page
|
||||
# section's byte offsets never move when this section grows.
|
||||
for cols in 100 88 84 70
|
||||
set -g COLUMNS $cols
|
||||
_cs_frame_case "width cols=$cols" __config_settings_frame width
|
||||
end
|
||||
set -g COLUMNS 100
|
||||
|
||||
set -l head (set_color --bold cyan)
|
||||
set -l rst (set_color normal)
|
||||
set -l p_test (string repeat -n 11 ' ')
|
||||
|
||||
for v in on off DEFAULT ''
|
||||
_cs_frame_case "badge onoff val=$v" __config_settings_frame badge $v
|
||||
end
|
||||
for v in true false DEFAULT
|
||||
_cs_frame_case "badge boolean val=$v" __config_settings_frame badge $v true false
|
||||
end
|
||||
|
||||
_cs_frame_case "cursor hit" __config_settings_frame cursor 3 3
|
||||
_cs_frame_case "cursor miss" __config_settings_frame cursor 3 4
|
||||
|
||||
_cs_frame_case "title toggle-page" __config_settings_frame title 76 $p_test \
|
||||
"$head Opinionated Settings $rst"
|
||||
_cs_frame_case "title subcat-page" __config_settings_frame title 76 $p_test \
|
||||
"$head Sub-categories: aliases (Universal)$rst "
|
||||
_cs_frame_case "title value-page" __config_settings_frame title 76 $p_test \
|
||||
"$head Sponge Settings$rst "
|
||||
|
||||
set -l badge_on (__config_settings_frame badge on)
|
||||
_cs_frame_case "row pad lw=12" __config_settings_frame row 76 $p_test \
|
||||
(__config_settings_frame cursor 0 0) Aliases 12 $badge_on "cmd shadows" pad
|
||||
_cs_frame_case "row cut lw=13" __config_settings_frame row 76 $p_test \
|
||||
(__config_settings_frame cursor 0 1) Notifications 13 $badge_on "done, WakaTime hook" cut
|
||||
_cs_frame_case "row cut lw=13 overlong" __config_settings_frame row 50 $p_test \
|
||||
(__config_settings_frame cursor 0 0) Notifications 13 $badge_on \
|
||||
"ls, cat, cd, du, mkdir, rm, mv, zoxide" cut
|
||||
_cs_frame_case "row shorten lw=12" __config_settings_frame row 76 $p_test \
|
||||
(__config_settings_frame cursor 0 0) "Log dir" 12 $badge_on \
|
||||
/home/tester/very/long/scrollback/history/directory shorten
|
||||
_cs_frame_case "row shorten lw=12 empty" __config_settings_frame row 50 $p_test \
|
||||
(__config_settings_frame cursor 1 0) "Log max" 12 $badge_on "" shorten
|
||||
end >$CS_RENDER_OUT
|
||||
|
||||
@@ -4938,3 +4938,57 @@
|
||||
│──────────────────────────────────────────────────│
|
||||
│[90m type value Enter save Esc cancel ⌫ delete [m│
|
||||
└──────────────────────────────────────────────────┘
|
||||
### frame width cols=100
|
||||
76
|
||||
<END>
|
||||
### frame width cols=88
|
||||
72
|
||||
<END>
|
||||
### frame width cols=84
|
||||
68
|
||||
<END>
|
||||
### frame width cols=70
|
||||
50
|
||||
<END>
|
||||
### frame badge onoff val=on
|
||||
[32m ON[m<END>
|
||||
### frame badge onoff val=off
|
||||
[31mOFF [m<END>
|
||||
### frame badge onoff val=DEFAULT
|
||||
[90mDEFAULT[m<END>
|
||||
### frame badge onoff val=
|
||||
[90mDEFAULT[m<END>
|
||||
### frame badge boolean val=true
|
||||
[32m ON[m<END>
|
||||
### frame badge boolean val=false
|
||||
[31mOFF [m<END>
|
||||
### frame badge boolean val=DEFAULT
|
||||
[90mDEFAULT[m<END>
|
||||
### frame cursor hit
|
||||
[35;1m▶[m <END>
|
||||
### frame cursor miss
|
||||
<END>
|
||||
### frame title toggle-page
|
||||
┌─[36;1m Opinionated Settings [m─────────────────────────────────────────────────────┐
|
||||
<END>
|
||||
### frame title subcat-page
|
||||
┌─[36;1m Sub-categories: aliases (Universal)[m ──────────────────────────────────────┐
|
||||
<END>
|
||||
### frame title value-page
|
||||
┌─[36;1m Sponge Settings[m ──────────────────────────────────────────────────────────┐
|
||||
<END>
|
||||
### frame row pad lw=12
|
||||
│ [35;1m▶[m Aliases [ [32m ON[m ] cmd shadows │
|
||||
<END>
|
||||
### frame row cut lw=13
|
||||
│ Notifications [ [32m ON[m ] done, WakaTime hook │
|
||||
<END>
|
||||
### frame row cut lw=13 overlong
|
||||
│ [35;1m▶[m Notifications [ [32m ON[m ] ls, cat, cd, du, │
|
||||
<END>
|
||||
### frame row shorten lw=12
|
||||
│ [35;1m▶[m Log dir [ [32m ON[m ] /home/tester/very/long/scrollback/history/… │
|
||||
<END>
|
||||
### frame row shorten lw=12 empty
|
||||
│ Log max [ [32m ON[m ] │
|
||||
<END>
|
||||
|
||||
Reference in New Issue
Block a user