mirror of
https://github.com/tw93/Mole.git
synced 2026-02-16 21:04:11 +00:00
fix: refine terminal alt screen management with IN_ALT_SCREEN flag and conditional message display
This commit is contained in:
@@ -42,6 +42,7 @@ readonly INSTALLER_SCAN_PATHS=(
|
|||||||
)
|
)
|
||||||
readonly MAX_ZIP_ENTRIES=5
|
readonly MAX_ZIP_ENTRIES=5
|
||||||
ZIP_LIST_CMD=()
|
ZIP_LIST_CMD=()
|
||||||
|
IN_ALT_SCREEN=0
|
||||||
|
|
||||||
if command -v zipinfo > /dev/null 2>&1; then
|
if command -v zipinfo > /dev/null 2>&1; then
|
||||||
ZIP_LIST_CMD=(zipinfo -1)
|
ZIP_LIST_CMD=(zipinfo -1)
|
||||||
@@ -217,7 +218,9 @@ collect_installers() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ${#all_files[@]} -eq 0 ]]; then
|
if [[ ${#all_files[@]} -eq 0 ]]; then
|
||||||
|
if [[ "${IN_ALT_SCREEN:-0}" != "1" ]]; then
|
||||||
echo -e "${GREEN}${ICON_SUCCESS}${NC} Great! No installer files to clean"
|
echo -e "${GREEN}${ICON_SUCCESS}${NC} Great! No installer files to clean"
|
||||||
|
fi
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -310,6 +313,10 @@ select_installers() {
|
|||||||
|
|
||||||
restore_terminal() {
|
restore_terminal() {
|
||||||
trap - EXIT INT TERM
|
trap - EXIT INT TERM
|
||||||
|
if [[ "${IN_ALT_SCREEN:-0}" == "1" ]]; then
|
||||||
|
leave_alt_screen
|
||||||
|
IN_ALT_SCREEN=0
|
||||||
|
fi
|
||||||
show_cursor
|
show_cursor
|
||||||
if [[ -n "${original_stty:-}" ]]; then
|
if [[ -n "${original_stty:-}" ]]; then
|
||||||
stty "${original_stty}" 2>/dev/null || stty sane 2>/dev/null || true
|
stty "${original_stty}" 2>/dev/null || stty sane 2>/dev/null || true
|
||||||
@@ -587,24 +594,35 @@ perform_installers() {
|
|||||||
# Enter alt screen for scanning and selection
|
# Enter alt screen for scanning and selection
|
||||||
if [[ -t 1 ]]; then
|
if [[ -t 1 ]]; then
|
||||||
enter_alt_screen
|
enter_alt_screen
|
||||||
|
IN_ALT_SCREEN=1
|
||||||
printf "\033[2J\033[H" >&2
|
printf "\033[2J\033[H" >&2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Collect installers
|
# Collect installers
|
||||||
if ! collect_installers; then
|
if ! collect_installers; then
|
||||||
if [[ -t 1 ]]; then leave_alt_screen; fi
|
if [[ -t 1 ]]; then
|
||||||
|
leave_alt_screen
|
||||||
|
IN_ALT_SCREEN=0
|
||||||
|
fi
|
||||||
|
printf '\n'
|
||||||
|
echo -e "${GREEN}${ICON_SUCCESS}${NC} Great! No installer files to clean"
|
||||||
|
printf '\n'
|
||||||
return 2 # Nothing to clean
|
return 2 # Nothing to clean
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Show menu
|
# Show menu
|
||||||
if ! show_installer_menu; then
|
if ! show_installer_menu; then
|
||||||
if [[ -t 1 ]]; then leave_alt_screen; fi
|
if [[ -t 1 ]]; then
|
||||||
|
leave_alt_screen
|
||||||
|
IN_ALT_SCREEN=0
|
||||||
|
fi
|
||||||
return 1 # User cancelled
|
return 1 # User cancelled
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Leave alt screen before deletion (so confirmation and results are on main screen)
|
# Leave alt screen before deletion (so confirmation and results are on main screen)
|
||||||
if [[ -t 1 ]]; then
|
if [[ -t 1 ]]; then
|
||||||
leave_alt_screen
|
leave_alt_screen
|
||||||
|
IN_ALT_SCREEN=0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Delete selected
|
# Delete selected
|
||||||
|
|||||||
Reference in New Issue
Block a user