1
0
mirror of https://github.com/tw93/Mole.git synced 2026-02-04 18:34:46 +00:00

feat: add Homebrew integration and optimize UI performance

- Add Homebrew cask detection and use 'brew uninstall --cask' for proper cleanup
  - Add real-time progress feedback during uninstallation
  - Optimize scroll performance by only redrawing visible items
  - Replace Python-based Dock removal with PlistBuddy for better compatibility
  - Add comprehensive tests for Homebrew functionality

  Fixes #306
This commit is contained in:
Tw93
2026-01-13 10:44:48 +08:00
parent 4d210913d8
commit 6b594c7d69
4 changed files with 411 additions and 149 deletions

View File

@@ -632,10 +632,29 @@ paginated_multi_select() {
prev_cursor_pos=$cursor_pos
continue # Skip full redraw
elif [[ $top_index -gt 0 ]]; then
# Scroll up - redraw visible items only
((top_index--))
# Redraw all visible items (faster than full screen redraw)
local start_idx=$top_index
local end_idx=$((top_index + items_per_page - 1))
local visible_total=${#view_indices[@]}
[[ $end_idx -ge $visible_total ]] && end_idx=$((visible_total - 1))
for ((i = start_idx; i <= end_idx; i++)); do
local row=$((i - start_idx + 3)) # +3 for header
printf "\033[%d;1H" "$row" >&2
local is_current=false
[[ $((i - start_idx)) -eq $cursor_pos ]] && is_current=true
render_item $((i - start_idx)) $is_current
done
# Move cursor to footer
printf "\033[%d;1H" "$((items_per_page + 4))" >&2
prev_cursor_pos=$cursor_pos
prev_top_index=$top_index
need_full_redraw=true # Scrolling requires full redraw
continue
fi
;;
"DOWN")
@@ -670,15 +689,34 @@ paginated_multi_select() {
prev_cursor_pos=$cursor_pos
continue # Skip full redraw
elif [[ $((top_index + visible_count)) -lt ${#view_indices[@]} ]]; then
# Scroll down - redraw visible items only
((top_index++))
visible_count=$((${#view_indices[@]} - top_index))
[[ $visible_count -gt $items_per_page ]] && visible_count=$items_per_page
if [[ $cursor_pos -ge $visible_count ]]; then
cursor_pos=$((visible_count - 1))
fi
# Redraw all visible items (faster than full screen redraw)
local start_idx=$top_index
local end_idx=$((top_index + items_per_page - 1))
local visible_total=${#view_indices[@]}
[[ $end_idx -ge $visible_total ]] && end_idx=$((visible_total - 1))
for ((i = start_idx; i <= end_idx; i++)); do
local row=$((i - start_idx + 3)) # +3 for header
printf "\033[%d;1H" "$row" >&2
local is_current=false
[[ $((i - start_idx)) -eq $cursor_pos ]] && is_current=true
render_item $((i - start_idx)) $is_current
done
# Move cursor to footer
printf "\033[%d;1H" "$((items_per_page + 4))" >&2
prev_cursor_pos=$cursor_pos
prev_top_index=$top_index
need_full_redraw=true # Scrolling requires full redraw
continue
fi
fi
fi