1
0
mirror of https://github.com/tw93/Mole.git synced 2026-02-15 08:45:09 +00:00

Support vim's arrow keys

This commit is contained in:
Tw93
2025-11-24 11:34:40 +08:00
parent 3d14e32a5b
commit 12713dd1f9
7 changed files with 12 additions and 33 deletions

View File

@@ -64,6 +64,7 @@ mo --version # Show installed version
- Preview the cleanup by running `mo clean --dry-run` and reviewing the list. - Preview the cleanup by running `mo clean --dry-run` and reviewing the list.
- Use `mo clean --whitelist` to manage protected caches. - Use `mo clean --whitelist` to manage protected caches.
- Use `mo touchid` to approve sudo with Touch ID instead of typing your password. - Use `mo touchid` to approve sudo with Touch ID instead of typing your password.
- Prefer Vim-style navigation? All menus understand `h/j/k/l` in addition to the arrow keys.
## Features in Detail ## Features in Detail

Binary file not shown.

View File

@@ -578,17 +578,12 @@ func (m model) updateKey(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
m.offset = m.selected - viewport + 1 m.offset = m.selected - viewport + 1
} }
} }
case "enter": case "enter", "right", "l":
if m.showLargeFiles { if m.showLargeFiles {
return m, nil return m, nil
} }
return m.enterSelectedDir() return m.enterSelectedDir()
case "right": case "b", "left", "h":
if m.showLargeFiles {
return m, nil
}
return m.enterSelectedDir()
case "b", "left":
if m.showLargeFiles { if m.showLargeFiles {
m.showLargeFiles = false m.showLargeFiles = false
return m, nil return m, nil
@@ -640,7 +635,7 @@ func (m model) updateKey(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
*m.currentPath = "" *m.currentPath = ""
} }
return m, tea.Batch(m.scanCmd(m.path), tickCmd()) return m, tea.Batch(m.scanCmd(m.path), tickCmd())
case "l": case "L":
m.showLargeFiles = !m.showLargeFiles m.showLargeFiles = !m.showLargeFiles
if m.showLargeFiles { if m.showLargeFiles {
m.largeSelected = 0 m.largeSelected = 0

View File

@@ -286,7 +286,11 @@ read_key() {
$'\n' | $'\r') echo "ENTER" ;; $'\n' | $'\r') echo "ENTER" ;;
' ') echo "SPACE" ;; ' ') echo "SPACE" ;;
'q' | 'Q') echo "QUIT" ;; 'q' | 'Q') echo "QUIT" ;;
'h' | 'H') echo "HELP" ;; 'h') echo "LEFT" ;;
'j') echo "DOWN" ;;
'k') echo "UP" ;;
'l') echo "RIGHT" ;;
'm' | 'M') echo "MORE" ;;
'v' | 'V') echo "VERSION" ;; 'v' | 'V') echo "VERSION" ;;
't' | 'T') echo "TOUCHID" ;; 't' | 'T') echo "TOUCHID" ;;
'u' | 'U') echo "UPDATE" ;; 'u' | 'U') echo "UPDATE" ;;

View File

@@ -733,9 +733,6 @@ paginated_multi_select() {
restore_terminal restore_terminal
return 0 return 0
;; ;;
"HELP")
# Removed help screen, users can explore the interface
;;
esac esac
# Drain any accumulated input after processing (e.g., mouse wheel events) # Drain any accumulated input after processing (e.g., mouse wheel events)

View File

@@ -216,23 +216,6 @@ paginated_multi_select() {
printf "${clear_line}" >&2 printf "${clear_line}" >&2
} }
# Show help screen
show_help() {
printf "\033[H\033[J" >&2
cat >&2 << EOF
Help - Navigation Controls
==========================
${ICON_NAV_UP} / ${ICON_NAV_DOWN} Navigate up/down
Space Select/deselect item
Enter Confirm selection
Q / ESC Exit
Press any key to continue...
EOF
read -n 1 -s >&2
}
# Main interaction loop # Main interaction loop
while true; do while true; do
draw_menu draw_menu
@@ -294,7 +277,6 @@ EOF
selected[i]=false selected[i]=false
done done
;; ;;
"HELP") show_help ;;
"ENTER") "ENTER")
# Store result in global variable instead of returning via stdout # Store result in global variable instead of returning via stdout
local -a selected_indices=() local -a selected_indices=()

6
mole
View File

@@ -22,7 +22,7 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$SCRIPT_DIR/lib/common.sh" source "$SCRIPT_DIR/lib/common.sh"
# Version info # Version info
VERSION="1.10.8" VERSION="1.10.9"
MOLE_TAGLINE="can dig deep to clean your Mac." MOLE_TAGLINE="can dig deep to clean your Mac."
# Check if Touch ID is already configured # Check if Touch ID is already configured
@@ -534,7 +534,7 @@ show_main_menu() {
if [[ -t 0 ]]; then if [[ -t 0 ]]; then
printf '\r\033[2K\n' printf '\r\033[2K\n'
# Show TouchID if not configured, otherwise show Update # Show TouchID if not configured, otherwise show Update
local controls="${GRAY}↑↓ | Enter | H Help | " local controls="${GRAY}↑↓ | Enter | M More | "
if ! is_touchid_configured; then if ! is_touchid_configured; then
controls="${controls}T TouchID" controls="${controls}T TouchID"
else else
@@ -632,7 +632,7 @@ interactive_main_menu() {
show_cursor show_cursor
exec "$SCRIPT_DIR/bin/status.sh" exec "$SCRIPT_DIR/bin/status.sh"
;; ;;
"HELP") "MORE")
show_cursor show_cursor
clear clear
show_help show_help