mirror of
https://github.com/tw93/Mole.git
synced 2026-02-07 03:35:40 +00:00
feat(menu): add sort (date/name/size), live filter, reverse; visible-only A/N; responsive footer (#34)
Paginated menu: - Sorting: press S/s to cycle Date → Name → Size; press R/r to reverse. - Live filter: press F/f to enter; case-insensitive substring; prefix with ' to anchor at start; DELETE to backspace; ENTER to apply; ESC to cancel. Shows “searching…” while rebuilding. - Selection scope: A (All) and N (None) now work on the currently visible items only (after filter/sort), not the entire list. - Footer: adds A/N to the help line and wraps only at ' | ' separators so labels are never broken; adapts to terminal width. - Internals: view_indices mapping for filtered/sorted view; glob-safe matching via _pm_escape_glob; drain_pending_input; robust stty restore; optional MOLE_MANAGED_ALT_SCREEN; cleanup unsets MOLE_READ_KEY_FORCE_CHAR; shellcheck clean. common.sh: - read_key supports a raw typing mode (MOLE_READ_KEY_FORCE_CHAR=1) emitting CHAR:<k>; ENTER/DELETE/ESC handled. - Uppercase A/N/R mappings (ALL/NONE/RETRY), printable-key detection, better ESC sequence handling. app_selector.sh: - Builds and exports per-item metadata CSV for epochs and size_kb via MOLE_MENU_META_EPOCHS and MOLE_MENU_META_SIZEKB; unsets them after the menu. - Menu options keep display text; sorting/filtering use metadata. uninstall.sh: - Computes app_size_kb using du -sk for numeric sorting while keeping human-readable size; writes it as the final field. - load_applications reads the new size_kb field. Notes: - Footer grew due to new commands; responsive wrapping prevents mid-word breaks. - ./tests/run.sh: only the two upstream failures remain (unchanged by this patch). Co-authored-by: Jonas Bertossa <jonas.bertossa@eoc.ch>
This commit is contained in:
@@ -245,7 +245,10 @@ scan_applications() {
|
||||
|
||||
# Parallel size calculation
|
||||
local app_size="N/A"
|
||||
local app_size_kb="0"
|
||||
if [[ -d "$app_path" ]]; then
|
||||
# numeric size (KB) for sorting + human-readable for display
|
||||
app_size_kb=$(du -sk "$app_path" 2> /dev/null | awk '{print $1}' || echo "0")
|
||||
app_size=$(du -sh "$app_path" 2> /dev/null | cut -f1 || echo "N/A")
|
||||
fi
|
||||
|
||||
@@ -297,7 +300,8 @@ scan_applications() {
|
||||
fi
|
||||
|
||||
# Write to output file atomically
|
||||
echo "${last_used_epoch}|${app_path}|${display_name}|${bundle_id}|${app_size}|${last_used}" >> "$output_file"
|
||||
# Fields: epoch|app_path|display_name|bundle_id|size_human|last_used|size_kb
|
||||
echo "${last_used_epoch}|${app_path}|${display_name}|${bundle_id}|${app_size}|${last_used}|${app_size_kb}" >> "$output_file"
|
||||
}
|
||||
|
||||
export -f process_app_metadata
|
||||
@@ -380,8 +384,8 @@ load_applications() {
|
||||
selection_state=()
|
||||
|
||||
# Read apps into array
|
||||
while IFS='|' read -r epoch app_path app_name bundle_id size last_used; do
|
||||
apps_data+=("$epoch|$app_path|$app_name|$bundle_id|$size|$last_used")
|
||||
while IFS='|' read -r epoch app_path app_name bundle_id size last_used size_kb; do
|
||||
apps_data+=("$epoch|$app_path|$app_name|$bundle_id|$size|$last_used|${size_kb:-0}")
|
||||
selection_state+=(false)
|
||||
done < "$apps_file"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user