1
0
mirror of https://github.com/tw93/Mole.git synced 2026-02-16 21:39:11 +00:00

Uninstall supported continue to uninstall

This commit is contained in:
Tw93
2025-12-12 09:50:14 +08:00
parent f990c444a6
commit 4955e02523

View File

@@ -426,6 +426,8 @@ main() {
# Hide cursor during operation
hide_cursor
# Main interaction loop
while true; do
# Simplified: always check if we need alt screen for scanning
# (scan_applications handles cache internally)
local needs_scanning=true
@@ -438,13 +440,24 @@ main() {
# Only enter alt screen if we need scanning (shows progress)
if [[ $needs_scanning == true && $use_inline_loading == true ]]; then
# Only enter if not already active
if [[ "${MOLE_ALT_SCREEN_ACTIVE:-}" != "1" ]]; then
enter_alt_screen
export MOLE_ALT_SCREEN_ACTIVE=1
export MOLE_INLINE_LOADING=1
export MOLE_MANAGED_ALT_SCREEN=1
fi
printf "\033[2J\033[H" >&2
else
# If we don't need scanning but have alt screen from previous iteration, keep it?
# Actually, scan_applications might output to stderr.
# Let's just unset the flags if we don't need scanning, but keep alt screen if it was active?
# No, select_apps_for_uninstall will handle its own screen management.
unset MOLE_INLINE_LOADING MOLE_MANAGED_ALT_SCREEN MOLE_ALT_SCREEN_ACTIVE
if [[ "${MOLE_ALT_SCREEN_ACTIVE:-}" == "1" ]]; then
leave_alt_screen
unset MOLE_ALT_SCREEN_ACTIVE
fi
fi
# Scan applications
@@ -495,6 +508,7 @@ main() {
clear_screen
printf '\033[2J\033[H' >&2 # Also clear stderr
rm -f "$apps_file"
# User cancelled selection, exit the loop
return 0
fi
@@ -513,7 +527,9 @@ main() {
if [[ $selection_count -eq 0 ]]; then
echo "No apps selected"
rm -f "$apps_file"
return 0
# Loop back or exit? If select_apps_for_uninstall returns 0 but empty selection,
# it technically shouldn't happen based on that function's logic.
continue
fi
# Show selected apps with clean alignment
echo -e "${BLUE}${ICON_CONFIRM}${NC} Selected ${selection_count} app(s):"
@@ -556,8 +572,28 @@ main() {
# Execute batch uninstallation (handles confirmation)
batch_uninstall_applications
# Cleanup
# Cleanup current apps file
rm -f "$apps_file"
# Pause before looping back
echo -e "${GRAY}Press Enter to return to application list, ESC to exit...${NC}"
local key
IFS= read -r -s -n1 key || key=""
drain_pending_input # Clean up any escape sequence remnants
case "$key" in
$'\e' | q | Q)
show_cursor
return 0
;;
*)
# Continue loop
;;
esac
# Reset force_rescan to false for subsequent loops,
# but relying on batch_uninstall's cache deletion for actual update
force_rescan=false
done
}
# Run main function