From 161ff27e3de7580dcbdd934142e29ca146fa47bb Mon Sep 17 00:00:00 2001 From: Tw93 Date: Sun, 5 Oct 2025 22:25:05 +0800 Subject: [PATCH] fix: adjust header underline rendering in paginated menu --- lib/paginated_menu.sh | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/paginated_menu.sh b/lib/paginated_menu.sh index a1ed078..08ae4f0 100755 --- a/lib/paginated_menu.sh +++ b/lib/paginated_menu.sh @@ -82,12 +82,14 @@ paginated_multi_select() { draw_menu() { printf "\033[H\033[J" >&2 # Clear screen and move to top - # Header - strip emoji for length calculation + # Header - compute underline length without external seq dependency local title_clean="${title//[^[:print:]]/}" - local title_len_approx=$(( ${#title_clean} - 4 )) # Rough adjustment for emoji - [[ $title_len_approx -lt 10 ]] && title_len_approx=10 - - printf "${PURPLE}%s${NC}\n%s\n" "$title" "$(printf '=%.0s' $(seq 1 $title_len_approx))" >&2 + local underline_len=${#title_clean} + [[ $underline_len -lt 10 ]] && underline_len=10 + # Build underline robustly (no seq); printf width then translate spaces to '=' + local underline + underline=$(printf '%*s' "$underline_len" '' | tr ' ' '=') + printf "${PURPLE}%s${NC}\n%s\n" "$title" "$underline" >&2 # Status local selected_count=0