feat(config-toggle): adaptive width, centering, and resize handling #50

Merged
rootiest merged 1 commits from feat/config-toggle-adaptive-width into main 2026-06-12 23:19:06 +00:00
Owner

Summary

  • Adaptive panel width: selects from four tiers based on $COLUMNS (52, 70, 74, or 78 chars wide), with a 6-column buffer on each side before stepping up — ensures the box never crowds the terminal edges
  • Richer descriptions: each tier carries progressively more detailed category descriptions (e.g. ls→eza, cat→bat, cd→zoxide, rm→trash at 74-wide vs cmd shadows at 52-wide)
  • Horizontal centering: left-padding prefix computed from (COLUMNS - box_width) / 2 on every draw; rerenders automatically on resize
  • Live resize detection: key reader changed from stty min 1 time 1 (blocks forever) to min 0 time 3 (0.3 s poll); event loop detects $COLUMNS change and redraws without requiring a keypress
  • Wrap-aware erase: replaces fixed \e[14A\e[J with a formula — ⌊(last_cols + 78) / 2⌋ / COLUMNS gives the wrap factor so panels drawn on a wider terminal are fully cleared after the terminal narrows, eliminating ghost lines

Files changed

File Change
functions/__config_toggle_draw.fish Width tier logic, centering prefix, adaptive descriptions
functions/__config_toggle_read_key.fish min 0 time 3 for timeout-based polling
functions/config-toggle.fish last_cols tracking, skip-on-idle-timeout, wrap-aware erase
docs/fish-config.md Documents adaptive width tiers and resize behaviour
README.md Updates config-toggle blurb with width/centering/resize info

Manual Verification

  • Run config-toggle in a terminal ≥ 90 columns wide — panel should be 78-wide and centered
  • Resize terminal to 86–89 columns — panel should reflow to 74-wide within ~0.3 s (no keypress needed)
  • Resize to 82–85 columns — panel reflows to 70-wide
  • Resize below 82 columns — panel reflows to 52-wide (original)
  • Resize from narrow back to wide — no ghost lines or duplicate panels left on screen
  • Navigate with arrow keys, h/j/k/l, Tab, and q — all behave as before
  • Toggle a value, resize, then quit — panel erases cleanly at new terminal width
## Summary - **Adaptive panel width**: selects from four tiers based on `$COLUMNS` (52, 70, 74, or 78 chars wide), with a 6-column buffer on each side before stepping up — ensures the box never crowds the terminal edges - **Richer descriptions**: each tier carries progressively more detailed category descriptions (e.g. `ls→eza, cat→bat, cd→zoxide, rm→trash` at 74-wide vs `cmd shadows` at 52-wide) - **Horizontal centering**: left-padding prefix computed from `(COLUMNS - box_width) / 2` on every draw; rerenders automatically on resize - **Live resize detection**: key reader changed from `stty min 1 time 1` (blocks forever) to `min 0 time 3` (0.3 s poll); event loop detects `$COLUMNS` change and redraws without requiring a keypress - **Wrap-aware erase**: replaces fixed `\e[14A\e[J` with a formula — `⌊(last_cols + 78) / 2⌋ / COLUMNS` gives the wrap factor so panels drawn on a wider terminal are fully cleared after the terminal narrows, eliminating ghost lines ## Files changed | File | Change | |------|--------| | `functions/__config_toggle_draw.fish` | Width tier logic, centering prefix, adaptive descriptions | | `functions/__config_toggle_read_key.fish` | `min 0 time 3` for timeout-based polling | | `functions/config-toggle.fish` | `last_cols` tracking, skip-on-idle-timeout, wrap-aware erase | | `docs/fish-config.md` | Documents adaptive width tiers and resize behaviour | | `README.md` | Updates `config-toggle` blurb with width/centering/resize info | ## Manual Verification - [x] Run `config-toggle` in a terminal ≥ 90 columns wide — panel should be 78-wide and centered - [x] Resize terminal to 86–89 columns — panel should reflow to 74-wide within ~0.3 s (no keypress needed) - [x] Resize to 82–85 columns — panel reflows to 70-wide - [x] Resize below 82 columns — panel reflows to 52-wide (original) - [x] Resize from narrow back to wide — no ghost lines or duplicate panels left on screen - [x] Navigate with arrow keys, `h`/`j`/`k`/`l`, Tab, and `q` — all behave as before - [x] Toggle a value, resize, then quit — panel erases cleanly at new terminal width
rootiest added 1 commit 2026-06-12 23:18:40 +00:00
Panel now selects from four width tiers based on $COLUMNS (with a 6-col
buffer per side before stepping up): 52-wide (default), 70, 74, or 78.
Each tier carries richer category descriptions sized to fit the layout.
The box is horizontally centered on every draw via a left-padding prefix.

Key reader switches from stty min 1 to min 0 / time 3, giving a 0.3 s
poll interval so COLUMNS changes are detected without a keypress. The
erase formula is now wrap-aware: prev_max_line_width / COLUMNS gives the
wrap factor, ensuring old wider panels are fully cleared after narrowing.
Idle timeout ticks that detect no resize are skipped entirely.
rootiest merged commit 64c559dbab into main 2026-06-12 23:19:06 +00:00
rootiest deleted branch feat/config-toggle-adaptive-width 2026-06-12 23:19:06 +00:00
Sign in to join this conversation.