mirror of
https://github.com/tw93/Mole.git
synced 2026-02-17 03:24:12 +00:00
Uninstall supported continue to uninstall
This commit is contained in:
@@ -426,6 +426,8 @@ main() {
|
|||||||
# Hide cursor during operation
|
# Hide cursor during operation
|
||||||
hide_cursor
|
hide_cursor
|
||||||
|
|
||||||
|
# Main interaction loop
|
||||||
|
while true; do
|
||||||
# Simplified: always check if we need alt screen for scanning
|
# Simplified: always check if we need alt screen for scanning
|
||||||
# (scan_applications handles cache internally)
|
# (scan_applications handles cache internally)
|
||||||
local needs_scanning=true
|
local needs_scanning=true
|
||||||
@@ -438,13 +440,24 @@ main() {
|
|||||||
|
|
||||||
# Only enter alt screen if we need scanning (shows progress)
|
# Only enter alt screen if we need scanning (shows progress)
|
||||||
if [[ $needs_scanning == true && $use_inline_loading == true ]]; then
|
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
|
enter_alt_screen
|
||||||
export MOLE_ALT_SCREEN_ACTIVE=1
|
export MOLE_ALT_SCREEN_ACTIVE=1
|
||||||
export MOLE_INLINE_LOADING=1
|
export MOLE_INLINE_LOADING=1
|
||||||
export MOLE_MANAGED_ALT_SCREEN=1
|
export MOLE_MANAGED_ALT_SCREEN=1
|
||||||
|
fi
|
||||||
printf "\033[2J\033[H" >&2
|
printf "\033[2J\033[H" >&2
|
||||||
else
|
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
|
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
|
fi
|
||||||
|
|
||||||
# Scan applications
|
# Scan applications
|
||||||
@@ -495,6 +508,7 @@ main() {
|
|||||||
clear_screen
|
clear_screen
|
||||||
printf '\033[2J\033[H' >&2 # Also clear stderr
|
printf '\033[2J\033[H' >&2 # Also clear stderr
|
||||||
rm -f "$apps_file"
|
rm -f "$apps_file"
|
||||||
|
# User cancelled selection, exit the loop
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -513,7 +527,9 @@ main() {
|
|||||||
if [[ $selection_count -eq 0 ]]; then
|
if [[ $selection_count -eq 0 ]]; then
|
||||||
echo "No apps selected"
|
echo "No apps selected"
|
||||||
rm -f "$apps_file"
|
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
|
fi
|
||||||
# Show selected apps with clean alignment
|
# Show selected apps with clean alignment
|
||||||
echo -e "${BLUE}${ICON_CONFIRM}${NC} Selected ${selection_count} app(s):"
|
echo -e "${BLUE}${ICON_CONFIRM}${NC} Selected ${selection_count} app(s):"
|
||||||
@@ -556,8 +572,28 @@ main() {
|
|||||||
# Execute batch uninstallation (handles confirmation)
|
# Execute batch uninstallation (handles confirmation)
|
||||||
batch_uninstall_applications
|
batch_uninstall_applications
|
||||||
|
|
||||||
# Cleanup
|
# Cleanup current apps file
|
||||||
rm -f "$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
|
# Run main function
|
||||||
|
|||||||
Reference in New Issue
Block a user