1
0
mirror of https://github.com/tw93/Mole.git synced 2026-02-13 01:35:15 +00:00

🎨 Loading optimization and better use of links

This commit is contained in:
Tw93
2025-10-08 18:01:46 +08:00
parent 79b1ea4091
commit 1657ff584b
9 changed files with 623 additions and 308 deletions

View File

@@ -42,11 +42,25 @@ paginated_multi_select() {
done
fi
# Preserve original TTY settings so we can restore them reliably
local original_stty=""
if [[ -t 0 ]] && command -v stty >/dev/null 2>&1; then
original_stty=$(stty -g 2>/dev/null || echo "")
fi
restore_terminal() {
show_cursor
if [[ -n "$original_stty" ]]; then
stty "$original_stty" 2>/dev/null || stty sane 2>/dev/null || stty echo icanon 2>/dev/null || true
else
stty sane 2>/dev/null || stty echo icanon 2>/dev/null || true
fi
leave_alt_screen
}
# Cleanup function
cleanup() {
show_cursor
stty echo icanon 2>/dev/null || true
leave_alt_screen
restore_terminal
}
# Interrupt handler
@@ -220,15 +234,13 @@ EOF
# Remove the trap to avoid cleanup on normal exit
trap - EXIT INT TERM
# Store result in global variable
MOLE_SELECTION_RESULT="$final_result"
# Manually cleanup terminal before returning
show_cursor
stty echo icanon 2>/dev/null || true
leave_alt_screen
restore_terminal
return 0
;;
esac