@@ -29,11 +29,11 @@ _pm_parse_csv_to_array() {
2929
3030# Non-blocking input drain (bash 3.2)
3131drain_pending_input () {
32- local _k
33- # -t 0 is non-blocking; -n 1 consumes one byte at a time
34- while IFS= read -r -s -n 1 -t 0 _k; do
35- IFS= read -r -s -n 1 _k || break
36- done
32+ local _k
33+ # -t 0 is non-blocking; -n 1 consumes one byte at a time
34+ while IFS= read -r -s -n 1 -t 0 _k; do
35+ IFS= read -r -s -n 1 _k || break
36+ done
3737}
3838
3939# Main paginated multi-select menu function
@@ -57,8 +57,8 @@ paginated_multi_select() {
5757 local cursor_pos=0
5858 local top_index=0
5959 local filter_query=" "
60- local filter_mode=" false" # filter mode toggle
61- local sort_mode=" ${MOLE_MENU_SORT_DEFAULT:- date} " # date|name|size
60+ local filter_mode=" false" # filter mode toggle
61+ local sort_mode=" ${MOLE_MENU_SORT_DEFAULT:- date} " # date|name|size
6262 local sort_reverse=" false"
6363 # Live query vs applied query
6464 local applied_query=" "
@@ -97,11 +97,11 @@ paginated_multi_select() {
9797 _pm_escape_glob () {
9898 local s=" ${1-} " out=" " c
9999 local i len=${# s}
100- for (( i= 0 ; i< len; i++ )) ; do
100+ for (( i = 0 ; i < len; i++ )) ; do
101101 c=" ${s: i: 1} "
102102 case " $c " in
103- ' \' | ' *' | ' ?' | ' [' | ' ]' ) out+=" \\ $c " ;;
104- * ) out+=" $c " ;;
103+ ' \' | ' *' | ' ?' | ' [' | ' ]' ) out+=" \\ $c " ;;
104+ * ) out+=" $c " ;;
105105 esac
106106 done
107107 printf ' %s' " $out "
@@ -191,11 +191,12 @@ paginated_multi_select() {
191191
192192 # Print footer lines wrapping only at separators
193193 _print_wrapped_controls () {
194- local sep=" $1 " ; shift
194+ local sep=" $1 "
195+ shift
195196 local -a segs=(" $@ " )
196197
197198 local cols=" ${COLUMNS:- } "
198- [[ -z " $cols " ]] && cols=$( tput cols 2> /dev/null || echo 80)
199+ [[ -z " $cols " ]] && cols=$( tput cols 2> /dev/null || echo 80)
199200
200201 _strip_ansi_len () {
201202 local text=" $1 "
@@ -212,7 +213,7 @@ paginated_multi_select() {
212213 else
213214 candidate=" $line ${sep}${s} "
214215 fi
215- if (( $(_strip_ansi_len "$candidate ") > cols )) ; then
216+ if (( $(_strip_ansi_len "$candidate ") > cols)) ; then
216217 printf " %s%s\n" " $clear_line " " $line " >&2
217218 line=" $s "
218219 else
@@ -280,14 +281,14 @@ paginated_multi_select() {
280281
281282 # Create temporary file for sorting
282283 local tmpfile
283- tmpfile=$( mktemp 2> /dev/null) || tmpfile=" "
284+ tmpfile=$( mktemp 2> /dev/null) || tmpfile=" "
284285 if [[ -n " $tmpfile " ]]; then
285286 local k id
286287 for id in " ${filtered[@]} " ; do
287288 case " $sort_mode " in
288289 date) k=" ${epochs[id]:- 0} " ;;
289290 size) k=" ${sizekb[id]:- 0} " ;;
290- name| * ) k=" ${items[id]} |${id} " ;;
291+ name | * ) k=" ${items[id]} |${id} " ;;
291292 esac
292293 printf " %s\t%s\n" " $k " " $id " >> " $tmpfile "
293294 done
@@ -296,7 +297,7 @@ paginated_multi_select() {
296297 while IFS=$' \t ' read -r _key _id; do
297298 [[ -z " $_id " ]] && continue
298299 view_indices+=(" $_id " )
299- done < <( LC_ALL=C sort -t $' \t ' $sort_key -- " $tmpfile " 2> /dev/null)
300+ done < <( LC_ALL=C sort -t $' \t ' $sort_key -- " $tmpfile " 2> /dev/null)
300301
301302 rm -f " $tmpfile "
302303 else
@@ -485,7 +486,6 @@ paginated_multi_select() {
485486 printf " ${clear_line} " >&2
486487 }
487488
488-
489489 # Main interaction loop
490490 while true ; do
491491 draw_menu
@@ -494,18 +494,19 @@ paginated_multi_select() {
494494
495495 case " $key " in
496496 " QUIT" )
497- if [[ " $filter_mode " == " true" ]]; then
498- filter_mode=" false"
499- unset MOLE_READ_KEY_FORCE_CHAR
500- filter_query=" "
501- applied_query=" "
502- top_index=0; cursor_pos=0
503- rebuild_view
504- continue
505- fi
506- cleanup
507- return 1
508- ;;
497+ if [[ " $filter_mode " == " true" ]]; then
498+ filter_mode=" false"
499+ unset MOLE_READ_KEY_FORCE_CHAR
500+ filter_query=" "
501+ applied_query=" "
502+ top_index=0
503+ cursor_pos=0
504+ rebuild_view
505+ continue
506+ fi
507+ cleanup
508+ return 1
509+ ;;
509510 " UP" )
510511 if [[ ${# view_indices[@]} -eq 0 ]]; then
511512 :
@@ -560,7 +561,7 @@ paginated_multi_select() {
560561 rebuild_view
561562 fi
562563 ;;
563- " CHAR:s" | " CHAR:S" )
564+ " CHAR:s" | " CHAR:S" )
564565 if [[ " $filter_mode " == " true" ]]; then
565566 local ch=" ${key# CHAR: } "
566567 filter_query+=" $ch "
@@ -583,7 +584,7 @@ paginated_multi_select() {
583584 cursor_pos=0
584585 rebuild_view
585586 ;;
586- " CHAR:f" | " CHAR:F" )
587+ " CHAR:f" | " CHAR:F" )
587588 if [[ " $filter_mode " == " true" ]]; then
588589 filter_query+=" ${key# CHAR: } "
589590 fi
@@ -625,11 +626,12 @@ paginated_multi_select() {
625626 applied_query=" $filter_query "
626627 filter_mode=" false"
627628 unset MOLE_READ_KEY_FORCE_CHAR
628- top_index=0; cursor_pos=0
629+ top_index=0
630+ cursor_pos=0
629631
630632 searching=" true"
631- draw_menu # paint "searching..."
632- drain_pending_input # drop any extra keypresses (e.g., double-Enter)
633+ draw_menu # paint "searching..."
634+ drain_pending_input # drop any extra keypresses (e.g., double-Enter)
633635 rebuild_view
634636 searching=" false"
635637 draw_menu
0 commit comments