Pixel-align the header labels with their data columns

Previous commit's leading-space count for the header was an estimate and
visibly off in the follow-up screenshot. Rather than guess again, actually
rendered the dialog into a captured pty (whiptail installed locally,
output fed through pyte to reconstruct the real character grid) and
measured exact column offsets instead of eyeballing.

Root fix: "installed" (9 chars) and "# of installs" (13 chars) are wider
than the underlying data (an "x"-or-blank mark, a 1-2 digit count) — a
narrow data column can never align under a wide label and stay readable,
so it's the data fields that got widened to match the label widths, not
the other way around. Verified alignment holds across installed/
not-installed/double-digit-count rows and at the narrow 78-column width
floor (where the description truncates first now, not the install status —
correct priority, since status is the more critical of the two).
This commit is contained in:
Claude
2026-08-10 16:40:18 +00:00
parent 1377f20882
commit 3afd7226f2
+17 -10
View File
@@ -440,21 +440,28 @@ while true; do
# checkbox at all though (it's not a list item, just a text field), # checkbox at all though (it's not a list item, just a text field),
# so that's where the column header lives — genuinely non-selectable # so that's where the column header lives — genuinely non-selectable
# this way, not just harmless-if-selected like a fake row would be. # this way, not just harmless-if-selected like a fake row would be.
# "installed"/"# of installs" won't character-align with the #
# 1-2-char "x"/count data below (spelled-out words can't line up # The header text ("installed" / "# of installs" / "service") is
# under single-character columns and stay readable) — the leading # wider than the underlying data (an "x"-or-blank mark, a 1-2 digit
# spaces here are a best-effort approximation of where those data # count), so it's the DATA fields that were widened to match the
# columns start, not exact. # header labels' widths (9 and 13 chars) rather than the other way
# around — a narrow data column can't align under a wide label and
# stay readable, but a wide data column can absolutely align under
# a matching-width label. Verified pixel/character-exact (not
# eyeballed) by actually rendering this dialog into a captured pty
# and measuring column offsets with pyte; the leading spaces on the
# header line and the field widths below are tuned to that
# measurement, not guessed.
svc_items=() svc_items=()
for name in "${SVCS[@]}"; do for name in "${SVCS[@]}"; do
_inst_mark=" " _inst_field="$(printf '%-9s' '')"
_count_str=" " _count_field="$(printf '%-13s' '')"
_count="$(install_count "$name")" _count="$(install_count "$name")"
if [ "$_count" -gt 0 ]; then if [ "$_count" -gt 0 ]; then
_inst_mark="x" _inst_field="installed"
_count_str="$(printf "%-2d" "$_count")" _count_field="$(printf '%-13s' "$_count")"
fi fi
svc_tag="$(printf "%s %s %s" "$_inst_mark" "$_count_str" "$name")" svc_tag="$(printf "%s %s %s" "$_inst_field" "$_count_field" "$name")"
svc_items+=("$svc_tag" "${SERVICE_DESC[$name]}" "OFF") svc_items+=("$svc_tag" "${SERVICE_DESC[$name]}" "OFF")
done done
CHOICE=$(whiptail --title "${CHOSEN_CAT^^}" --checklist \ CHOICE=$(whiptail --title "${CHOSEN_CAT^^}" --checklist \