mirror of
https://github.com/tw93/Mole.git
synced 2026-02-14 17:02:26 +00:00
feat(ui): add Ctrl+U support and optimize paginated menu performance
This commit is contained in:
@@ -170,6 +170,7 @@ read_key() {
|
|||||||
case "$key" in
|
case "$key" in
|
||||||
$'\n' | $'\r') echo "ENTER" ;;
|
$'\n' | $'\r') echo "ENTER" ;;
|
||||||
$'\x7f' | $'\x08') echo "DELETE" ;;
|
$'\x7f' | $'\x08') echo "DELETE" ;;
|
||||||
|
$'\x15') echo "CLEAR_LINE" ;; # Ctrl+U (often mapped from Cmd+Delete in terminals)
|
||||||
$'\x1b')
|
$'\x1b')
|
||||||
if IFS= read -r -s -n 1 -t 1 rest 2> /dev/null; then
|
if IFS= read -r -s -n 1 -t 1 rest 2> /dev/null; then
|
||||||
if [[ "$rest" == "[" ]]; then
|
if [[ "$rest" == "[" ]]; then
|
||||||
@@ -230,6 +231,7 @@ read_key() {
|
|||||||
'l' | 'L') echo "RIGHT" ;;
|
'l' | 'L') echo "RIGHT" ;;
|
||||||
$'\x03') echo "QUIT" ;;
|
$'\x03') echo "QUIT" ;;
|
||||||
$'\x7f' | $'\x08') echo "DELETE" ;;
|
$'\x7f' | $'\x08') echo "DELETE" ;;
|
||||||
|
$'\x15') echo "CLEAR_LINE" ;; # Ctrl+U
|
||||||
$'\x1b')
|
$'\x1b')
|
||||||
if IFS= read -r -s -n 1 -t 1 rest 2> /dev/null; then
|
if IFS= read -r -s -n 1 -t 1 rest 2> /dev/null; then
|
||||||
if [[ "$rest" == "[" ]]; then
|
if [[ "$rest" == "[" ]]; then
|
||||||
|
|||||||
@@ -12,9 +12,12 @@ format_app_display() {
|
|||||||
# Use common function from ui.sh to format last used time
|
# Use common function from ui.sh to format last used time
|
||||||
local compact_last_used
|
local compact_last_used
|
||||||
compact_last_used=$(format_last_used_summary "$last_used")
|
compact_last_used=$(format_last_used_summary "$last_used")
|
||||||
|
if [[ -z "$compact_last_used" || "$compact_last_used" == "Unknown" || "$compact_last_used" == "Never" ]]; then
|
||||||
|
compact_last_used="..."
|
||||||
|
fi
|
||||||
|
|
||||||
# Format size
|
# Format size
|
||||||
local size_str="Unknown"
|
local size_str="..."
|
||||||
[[ "$size" != "0" && "$size" != "" && "$size" != "Unknown" ]] && size_str="$size"
|
[[ "$size" != "0" && "$size" != "" && "$size" != "Unknown" ]] && size_str="$size"
|
||||||
|
|
||||||
# Calculate available width for app name based on terminal width
|
# Calculate available width for app name based on terminal width
|
||||||
@@ -114,10 +117,14 @@ select_apps_for_uninstall() {
|
|||||||
local epochs_csv=""
|
local epochs_csv=""
|
||||||
local sizekb_csv=""
|
local sizekb_csv=""
|
||||||
local -a names_arr=()
|
local -a names_arr=()
|
||||||
|
local has_epoch_metadata=false
|
||||||
|
local has_size_metadata=false
|
||||||
local idx=0
|
local idx=0
|
||||||
for app_data in "${apps_data[@]}"; do
|
for app_data in "${apps_data[@]}"; do
|
||||||
IFS='|' read -r epoch _ display_name _ size last_used size_kb <<< "$app_data"
|
IFS='|' read -r epoch _ display_name _ size last_used size_kb <<< "$app_data"
|
||||||
menu_options+=("$(format_app_display "$display_name" "$size" "$last_used" "$terminal_width" "$max_name_width")")
|
menu_options+=("$(format_app_display "$display_name" "$size" "$last_used" "$terminal_width" "$max_name_width")")
|
||||||
|
[[ "${epoch:-0}" =~ ^[0-9]+$ && "${epoch:-0}" -gt 0 ]] && has_epoch_metadata=true
|
||||||
|
[[ "${size_kb:-0}" =~ ^[0-9]+$ && "${size_kb:-0}" -gt 0 ]] && has_size_metadata=true
|
||||||
if [[ $idx -eq 0 ]]; then
|
if [[ $idx -eq 0 ]]; then
|
||||||
epochs_csv="${epoch:-0}"
|
epochs_csv="${epoch:-0}"
|
||||||
sizekb_csv="${size_kb:-0}"
|
sizekb_csv="${size_kb:-0}"
|
||||||
@@ -143,8 +150,16 @@ select_apps_for_uninstall() {
|
|||||||
# - MOLE_MENU_META_EPOCHS: numeric last_used_epoch per item
|
# - MOLE_MENU_META_EPOCHS: numeric last_used_epoch per item
|
||||||
# - MOLE_MENU_META_SIZEKB: numeric size in KB per item
|
# - MOLE_MENU_META_SIZEKB: numeric size in KB per item
|
||||||
# The menu will gracefully fallback if these are unset or malformed.
|
# The menu will gracefully fallback if these are unset or malformed.
|
||||||
|
if [[ $has_epoch_metadata == true ]]; then
|
||||||
export MOLE_MENU_META_EPOCHS="$epochs_csv"
|
export MOLE_MENU_META_EPOCHS="$epochs_csv"
|
||||||
|
else
|
||||||
|
unset MOLE_MENU_META_EPOCHS
|
||||||
|
fi
|
||||||
|
if [[ $has_size_metadata == true ]]; then
|
||||||
export MOLE_MENU_META_SIZEKB="$sizekb_csv"
|
export MOLE_MENU_META_SIZEKB="$sizekb_csv"
|
||||||
|
else
|
||||||
|
unset MOLE_MENU_META_SIZEKB
|
||||||
|
fi
|
||||||
export MOLE_MENU_FILTER_NAMES="$names_newline"
|
export MOLE_MENU_FILTER_NAMES="$names_newline"
|
||||||
|
|
||||||
# Use paginated menu - result will be stored in MOLE_SELECTION_RESULT
|
# Use paginated menu - result will be stored in MOLE_SELECTION_RESULT
|
||||||
@@ -157,11 +172,6 @@ select_apps_for_uninstall() {
|
|||||||
unset MOLE_MENU_META_EPOCHS MOLE_MENU_META_SIZEKB
|
unset MOLE_MENU_META_EPOCHS MOLE_MENU_META_SIZEKB
|
||||||
# leave MOLE_MENU_SORT_DEFAULT untouched if user set it globally
|
# leave MOLE_MENU_SORT_DEFAULT untouched if user set it globally
|
||||||
|
|
||||||
# Refresh signal handling
|
|
||||||
if [[ $exit_code -eq 10 ]]; then
|
|
||||||
return 10
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ $exit_code -ne 0 ]]; then
|
if [[ $exit_code -ne 0 ]]; then
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -90,6 +90,7 @@ paginated_multi_select() {
|
|||||||
local sort_mode="${MOLE_MENU_SORT_MODE:-${MOLE_MENU_SORT_DEFAULT:-date}}" # date|name|size
|
local sort_mode="${MOLE_MENU_SORT_MODE:-${MOLE_MENU_SORT_DEFAULT:-date}}" # date|name|size
|
||||||
local sort_reverse="${MOLE_MENU_SORT_REVERSE:-false}"
|
local sort_reverse="${MOLE_MENU_SORT_REVERSE:-false}"
|
||||||
local filter_text="" # Filter keyword
|
local filter_text="" # Filter keyword
|
||||||
|
local filter_text_lower=""
|
||||||
|
|
||||||
# Metadata (optional)
|
# Metadata (optional)
|
||||||
# epochs[i] -> last_used_epoch (numeric) for item i
|
# epochs[i] -> last_used_epoch (numeric) for item i
|
||||||
@@ -121,10 +122,20 @@ paginated_multi_select() {
|
|||||||
# Index mappings
|
# Index mappings
|
||||||
local -a orig_indices=()
|
local -a orig_indices=()
|
||||||
local -a view_indices=()
|
local -a view_indices=()
|
||||||
|
local -a filter_targets_lower=()
|
||||||
local i
|
local i
|
||||||
for ((i = 0; i < total_items; i++)); do
|
for ((i = 0; i < total_items; i++)); do
|
||||||
orig_indices[i]=$i
|
orig_indices[i]=$i
|
||||||
view_indices[i]=$i
|
view_indices[i]=$i
|
||||||
|
local filter_target
|
||||||
|
if [[ $has_filter_names == true && -n "${filter_names[i]:-}" ]]; then
|
||||||
|
filter_target="${filter_names[i]}"
|
||||||
|
else
|
||||||
|
filter_target="${items[i]}"
|
||||||
|
fi
|
||||||
|
local filter_target_lower
|
||||||
|
filter_target_lower=$(printf "%s" "$filter_target" | LC_ALL=C tr '[:upper:]' '[:lower:]')
|
||||||
|
filter_targets_lower[i]="$filter_target_lower"
|
||||||
done
|
done
|
||||||
|
|
||||||
local -a selected=()
|
local -a selected=()
|
||||||
@@ -171,8 +182,8 @@ paginated_multi_select() {
|
|||||||
# Cleanup function
|
# Cleanup function
|
||||||
cleanup() {
|
cleanup() {
|
||||||
trap - EXIT INT TERM
|
trap - EXIT INT TERM
|
||||||
export MOLE_MENU_SORT_MODE="$sort_mode"
|
export MOLE_MENU_SORT_MODE="${sort_mode:-name}"
|
||||||
export MOLE_MENU_SORT_REVERSE="$sort_reverse"
|
export MOLE_MENU_SORT_REVERSE="${sort_reverse:-false}"
|
||||||
restore_terminal
|
restore_terminal
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -240,36 +251,25 @@ paginated_multi_select() {
|
|||||||
printf "%s%s\n" "$clear_line" "$line" >&2
|
printf "%s%s\n" "$clear_line" "$line" >&2
|
||||||
}
|
}
|
||||||
|
|
||||||
# Rebuild the view_indices applying filter and sort
|
local sort_cache_key=""
|
||||||
rebuild_view() {
|
local -a sorted_indices_cache=()
|
||||||
local -a active_indices=()
|
local filter_cache_key=""
|
||||||
if [[ -n "$filter_text" ]]; then
|
local filter_cache_text_lower=""
|
||||||
local filter_lower
|
local -a filter_cache_indices=()
|
||||||
filter_lower=$(printf "%s" "$filter_text" | LC_ALL=C tr '[:upper:]' '[:lower:]')
|
|
||||||
for id in "${orig_indices[@]}"; do
|
ensure_sorted_indices() {
|
||||||
local filter_target
|
local requested_key="${sort_mode}:${sort_reverse}:${has_metadata}"
|
||||||
if [[ $has_filter_names == true && -n "${filter_names[id]:-}" ]]; then
|
if [[ "$requested_key" == "$sort_cache_key" && ${#sorted_indices_cache[@]} -gt 0 ]]; then
|
||||||
filter_target="${filter_names[id]}"
|
return
|
||||||
else
|
|
||||||
filter_target="${items[id]}"
|
|
||||||
fi
|
|
||||||
local target_lower
|
|
||||||
target_lower=$(printf "%s" "$filter_target" | LC_ALL=C tr '[:upper:]' '[:lower:]')
|
|
||||||
if [[ "$target_lower" == *"$filter_lower"* ]]; then
|
|
||||||
active_indices+=("$id")
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
else
|
|
||||||
active_indices=("${orig_indices[@]}")
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Sort filtered results
|
|
||||||
if [[ "$has_metadata" == "false" ]]; then
|
if [[ "$has_metadata" == "false" ]]; then
|
||||||
view_indices=("${active_indices[@]}")
|
sorted_indices_cache=("${orig_indices[@]}")
|
||||||
elif [[ ${#active_indices[@]} -eq 0 ]]; then
|
sort_cache_key="$requested_key"
|
||||||
view_indices=()
|
return
|
||||||
else
|
fi
|
||||||
# Build sort key
|
|
||||||
|
# Build sort key once; filtering should reuse this cached order.
|
||||||
local sort_key
|
local sort_key
|
||||||
if [[ "$sort_mode" == "date" ]]; then
|
if [[ "$sort_mode" == "date" ]]; then
|
||||||
# Date: ascending by default (oldest first)
|
# Date: ascending by default (oldest first)
|
||||||
@@ -285,12 +285,11 @@ paginated_multi_select() {
|
|||||||
[[ "$sort_reverse" == "true" ]] && sort_key="-k1,1fr"
|
[[ "$sort_reverse" == "true" ]] && sort_key="-k1,1fr"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Create temporary file for sorting
|
|
||||||
local tmpfile
|
local tmpfile
|
||||||
tmpfile=$(mktemp 2>/dev/null) || tmpfile=""
|
tmpfile=$(mktemp 2>/dev/null) || tmpfile=""
|
||||||
if [[ -n "$tmpfile" ]]; then
|
if [[ -n "$tmpfile" ]]; then
|
||||||
local k id
|
local k id
|
||||||
for id in "${active_indices[@]}"; do
|
for id in "${orig_indices[@]}"; do
|
||||||
case "$sort_mode" in
|
case "$sort_mode" in
|
||||||
date) k="${epochs[id]:-0}" ;;
|
date) k="${epochs[id]:-0}" ;;
|
||||||
size) k="${sizekb[id]:-0}" ;;
|
size) k="${sizekb[id]:-0}" ;;
|
||||||
@@ -299,16 +298,64 @@ paginated_multi_select() {
|
|||||||
printf "%s\t%s\n" "$k" "$id" >>"$tmpfile"
|
printf "%s\t%s\n" "$k" "$id" >>"$tmpfile"
|
||||||
done
|
done
|
||||||
|
|
||||||
view_indices=()
|
sorted_indices_cache=()
|
||||||
while IFS=$'\t' read -r _key _id; do
|
while IFS=$'\t' read -r _key _id; do
|
||||||
[[ -z "$_id" ]] && continue
|
[[ -z "$_id" ]] && continue
|
||||||
view_indices+=("$_id")
|
sorted_indices_cache+=("$_id")
|
||||||
done < <(LC_ALL=C sort -t $'\t' $sort_key -- "$tmpfile" 2>/dev/null)
|
done < <(LC_ALL=C sort -t $'\t' $sort_key -- "$tmpfile" 2>/dev/null)
|
||||||
|
|
||||||
rm -f "$tmpfile"
|
rm -f "$tmpfile"
|
||||||
else
|
else
|
||||||
# Fallback: no sorting
|
sorted_indices_cache=("${orig_indices[@]}")
|
||||||
view_indices=("${active_indices[@]}")
|
fi
|
||||||
|
sort_cache_key="$requested_key"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Rebuild the view_indices applying filter over cached sort order
|
||||||
|
rebuild_view() {
|
||||||
|
ensure_sorted_indices
|
||||||
|
|
||||||
|
if [[ -n "$filter_text_lower" ]]; then
|
||||||
|
local -a source_indices=()
|
||||||
|
if [[ "$filter_cache_key" == "$sort_cache_key" &&
|
||||||
|
"$filter_text_lower" == "$filter_cache_text_lower"* &&
|
||||||
|
${#filter_cache_indices[@]} -gt 0 ]]; then
|
||||||
|
source_indices=("${filter_cache_indices[@]}")
|
||||||
|
else
|
||||||
|
if [[ ${#sorted_indices_cache[@]} -gt 0 ]]; then
|
||||||
|
source_indices=("${sorted_indices_cache[@]}")
|
||||||
|
else
|
||||||
|
source_indices=()
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
view_indices=()
|
||||||
|
local id
|
||||||
|
for id in "${source_indices[@]}"; do
|
||||||
|
if [[ "${filter_targets_lower[id]:-}" == *"$filter_text_lower"* ]]; then
|
||||||
|
view_indices+=("$id")
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
filter_cache_key="$sort_cache_key"
|
||||||
|
filter_cache_text_lower="$filter_text_lower"
|
||||||
|
if [[ ${#view_indices[@]} -gt 0 ]]; then
|
||||||
|
filter_cache_indices=("${view_indices[@]}")
|
||||||
|
else
|
||||||
|
filter_cache_indices=()
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
if [[ ${#sorted_indices_cache[@]} -gt 0 ]]; then
|
||||||
|
view_indices=("${sorted_indices_cache[@]}")
|
||||||
|
else
|
||||||
|
view_indices=()
|
||||||
|
fi
|
||||||
|
filter_cache_key="$sort_cache_key"
|
||||||
|
filter_cache_text_lower=""
|
||||||
|
if [[ ${#view_indices[@]} -gt 0 ]]; then
|
||||||
|
filter_cache_indices=("${view_indices[@]}")
|
||||||
|
else
|
||||||
|
filter_cache_indices=()
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -368,7 +415,10 @@ paginated_multi_select() {
|
|||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
if [[ "$char" =~ ^[[:print:]]$ ]]; then
|
if [[ "$char" =~ ^[[:print:]]$ ]]; then
|
||||||
|
local char_lower
|
||||||
|
char_lower=$(printf "%s" "$char" | LC_ALL=C tr '[:upper:]' '[:lower:]')
|
||||||
filter_text+="$char"
|
filter_text+="$char"
|
||||||
|
filter_text_lower+="$char_lower"
|
||||||
rebuild_view
|
rebuild_view
|
||||||
cursor_pos=0
|
cursor_pos=0
|
||||||
top_index=0
|
top_index=0
|
||||||
@@ -458,13 +508,12 @@ paginated_multi_select() {
|
|||||||
local reverse_arrow="↑"
|
local reverse_arrow="↑"
|
||||||
[[ "$sort_reverse" == "true" ]] && reverse_arrow="↓"
|
[[ "$sort_reverse" == "true" ]] && reverse_arrow="↓"
|
||||||
|
|
||||||
local refresh="${GRAY}R Refresh${NC}"
|
|
||||||
local sort_ctrl="${GRAY}S ${sort_status}${NC}"
|
local sort_ctrl="${GRAY}S ${sort_status}${NC}"
|
||||||
local order_ctrl="${GRAY}O ${reverse_arrow}${NC}"
|
local order_ctrl="${GRAY}O ${reverse_arrow}${NC}"
|
||||||
local filter_ctrl="${GRAY}/ Filter${NC}"
|
local filter_ctrl="${GRAY}/ Filter${NC}"
|
||||||
|
|
||||||
if [[ -n "$filter_text" ]]; then
|
if [[ -n "$filter_text" ]]; then
|
||||||
local -a _segs_filter=("${GRAY}Backspace${NC}" "${GRAY}ESC Clear${NC}")
|
local -a _segs_filter=("${GRAY}Backspace${NC}" "${GRAY}Ctrl+U Clear${NC}" "${GRAY}ESC Clear${NC}")
|
||||||
_print_wrapped_controls "$sep" "${_segs_filter[@]}"
|
_print_wrapped_controls "$sep" "${_segs_filter[@]}"
|
||||||
elif [[ "$has_metadata" == "true" ]]; then
|
elif [[ "$has_metadata" == "true" ]]; then
|
||||||
# With metadata: show sort controls
|
# With metadata: show sort controls
|
||||||
@@ -473,7 +522,7 @@ paginated_multi_select() {
|
|||||||
[[ "$term_width" =~ ^[0-9]+$ ]] || term_width=80
|
[[ "$term_width" =~ ^[0-9]+$ ]] || term_width=80
|
||||||
|
|
||||||
# Full controls
|
# Full controls
|
||||||
local -a _segs=("$nav" "$space_select" "$enter" "$refresh" "$sort_ctrl" "$order_ctrl" "$filter_ctrl" "$exit")
|
local -a _segs=("$nav" "$space_select" "$enter" "$sort_ctrl" "$order_ctrl" "$filter_ctrl" "$exit")
|
||||||
|
|
||||||
# Calculate width
|
# Calculate width
|
||||||
local total_len=0 seg_count=${#_segs[@]}
|
local total_len=0 seg_count=${#_segs[@]}
|
||||||
@@ -484,7 +533,7 @@ paginated_multi_select() {
|
|||||||
|
|
||||||
# Level 1: Remove "Space Select" if too wide
|
# Level 1: Remove "Space Select" if too wide
|
||||||
if [[ $total_len -gt $term_width ]]; then
|
if [[ $total_len -gt $term_width ]]; then
|
||||||
_segs=("$nav" "$enter" "$refresh" "$sort_ctrl" "$order_ctrl" "$filter_ctrl" "$exit")
|
_segs=("$nav" "$enter" "$sort_ctrl" "$order_ctrl" "$filter_ctrl" "$exit")
|
||||||
|
|
||||||
total_len=0
|
total_len=0
|
||||||
seg_count=${#_segs[@]}
|
seg_count=${#_segs[@]}
|
||||||
@@ -495,14 +544,14 @@ paginated_multi_select() {
|
|||||||
|
|
||||||
# Level 2: Remove sort label if still too wide
|
# Level 2: Remove sort label if still too wide
|
||||||
if [[ $total_len -gt $term_width ]]; then
|
if [[ $total_len -gt $term_width ]]; then
|
||||||
_segs=("$nav" "$enter" "$refresh" "$order_ctrl" "$filter_ctrl" "$exit")
|
_segs=("$nav" "$enter" "$order_ctrl" "$filter_ctrl" "$exit")
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
_print_wrapped_controls "$sep" "${_segs[@]}"
|
_print_wrapped_controls "$sep" "${_segs[@]}"
|
||||||
else
|
else
|
||||||
# Without metadata: basic controls
|
# Without metadata: basic controls
|
||||||
local -a _segs_simple=("$nav" "$space_select" "$enter" "$refresh" "$filter_ctrl" "$exit")
|
local -a _segs_simple=("$nav" "$space_select" "$enter" "$filter_ctrl" "$exit")
|
||||||
_print_wrapped_controls "$sep" "${_segs_simple[@]}"
|
_print_wrapped_controls "$sep" "${_segs_simple[@]}"
|
||||||
fi
|
fi
|
||||||
printf "${clear_line}" >&2
|
printf "${clear_line}" >&2
|
||||||
@@ -530,6 +579,7 @@ paginated_multi_select() {
|
|||||||
"QUIT")
|
"QUIT")
|
||||||
if [[ -n "$filter_text" || -n "${MOLE_READ_KEY_FORCE_CHAR:-}" ]]; then
|
if [[ -n "$filter_text" || -n "${MOLE_READ_KEY_FORCE_CHAR:-}" ]]; then
|
||||||
filter_text=""
|
filter_text=""
|
||||||
|
filter_text_lower=""
|
||||||
unset MOLE_READ_KEY_FORCE_CHAR
|
unset MOLE_READ_KEY_FORCE_CHAR
|
||||||
rebuild_view
|
rebuild_view
|
||||||
cursor_pos=0
|
cursor_pos=0
|
||||||
@@ -683,18 +733,6 @@ paginated_multi_select() {
|
|||||||
continue # Skip full redraw
|
continue # Skip full redraw
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
"RETRY")
|
|
||||||
# 'R' toggles reverse order (only if metadata available)
|
|
||||||
if [[ "$has_metadata" == "true" ]]; then
|
|
||||||
if [[ "$sort_reverse" == "true" ]]; then
|
|
||||||
sort_reverse="false"
|
|
||||||
else
|
|
||||||
sort_reverse="true"
|
|
||||||
fi
|
|
||||||
rebuild_view
|
|
||||||
need_full_redraw=true
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
"CHAR:s" | "CHAR:S")
|
"CHAR:s" | "CHAR:S")
|
||||||
if handle_filter_char "${key#CHAR:}"; then
|
if handle_filter_char "${key#CHAR:}"; then
|
||||||
: # Handled as filter input
|
: # Handled as filter input
|
||||||
@@ -739,14 +777,6 @@ paginated_multi_select() {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
"CHAR:r" | "CHAR:R")
|
|
||||||
if handle_filter_char "${key#CHAR:}"; then
|
|
||||||
: # Handled as filter input
|
|
||||||
else
|
|
||||||
cleanup
|
|
||||||
return 10
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
"CHAR:o" | "CHAR:O")
|
"CHAR:o" | "CHAR:O")
|
||||||
if handle_filter_char "${key#CHAR:}"; then
|
if handle_filter_char "${key#CHAR:}"; then
|
||||||
: # Handled as filter input
|
: # Handled as filter input
|
||||||
@@ -761,13 +791,19 @@ paginated_multi_select() {
|
|||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
"CHAR:/" | "CHAR:?")
|
"CHAR:/" | "CHAR:?")
|
||||||
|
if [[ -n "${MOLE_READ_KEY_FORCE_CHAR:-}" ]]; then
|
||||||
|
unset MOLE_READ_KEY_FORCE_CHAR
|
||||||
|
else
|
||||||
export MOLE_READ_KEY_FORCE_CHAR=1
|
export MOLE_READ_KEY_FORCE_CHAR=1
|
||||||
|
fi
|
||||||
need_full_redraw=true
|
need_full_redraw=true
|
||||||
;;
|
;;
|
||||||
"DELETE")
|
"DELETE")
|
||||||
if [[ -n "$filter_text" ]]; then
|
if [[ -n "$filter_text" ]]; then
|
||||||
filter_text="${filter_text%?}"
|
filter_text="${filter_text%?}"
|
||||||
|
filter_text_lower="${filter_text_lower%?}"
|
||||||
if [[ -z "$filter_text" ]]; then
|
if [[ -z "$filter_text" ]]; then
|
||||||
|
filter_text_lower=""
|
||||||
unset MOLE_READ_KEY_FORCE_CHAR
|
unset MOLE_READ_KEY_FORCE_CHAR
|
||||||
fi
|
fi
|
||||||
rebuild_view
|
rebuild_view
|
||||||
@@ -776,6 +812,16 @@ paginated_multi_select() {
|
|||||||
need_full_redraw=true
|
need_full_redraw=true
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
"CLEAR_LINE")
|
||||||
|
if [[ -n "$filter_text" ]]; then
|
||||||
|
filter_text=""
|
||||||
|
filter_text_lower=""
|
||||||
|
rebuild_view
|
||||||
|
cursor_pos=0
|
||||||
|
top_index=0
|
||||||
|
need_full_redraw=true
|
||||||
|
fi
|
||||||
|
;;
|
||||||
"CHAR:"*)
|
"CHAR:"*)
|
||||||
handle_filter_char "${key#CHAR:}" || true
|
handle_filter_char "${key#CHAR:}" || true
|
||||||
;;
|
;;
|
||||||
@@ -816,8 +862,8 @@ paginated_multi_select() {
|
|||||||
|
|
||||||
trap - EXIT INT TERM
|
trap - EXIT INT TERM
|
||||||
MOLE_SELECTION_RESULT="$final_result"
|
MOLE_SELECTION_RESULT="$final_result"
|
||||||
export MOLE_MENU_SORT_MODE="$sort_mode"
|
export MOLE_MENU_SORT_MODE="${sort_mode:-name}"
|
||||||
export MOLE_MENU_SORT_REVERSE="$sort_reverse"
|
export MOLE_MENU_SORT_REVERSE="${sort_reverse:-false}"
|
||||||
restore_terminal
|
restore_terminal
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
|
|||||||
Reference in New Issue
Block a user