mirror of
https://github.com/tw93/Mole.git
synced 2026-02-04 15:04:42 +00:00
feat(ui): allow arrow keys and space during search filtering
- Modified FORCE_CHAR mode in read_key() to recognize arrow keys and space - Users can now navigate and select items while typing in search mode - Improves UX by eliminating need to press Enter before selecting - ESC key still works to cancel search This restores V1.19.0 behavior where navigation worked during search
This commit is contained in:
@@ -170,7 +170,43 @@ read_key() {
|
||||
case "$key" in
|
||||
$'\n' | $'\r') echo "ENTER" ;;
|
||||
$'\x7f' | $'\x08') echo "DELETE" ;;
|
||||
$'\x1b') echo "QUIT" ;;
|
||||
$'\x1b')
|
||||
# Check if this is an escape sequence (arrow keys) or ESC key
|
||||
if IFS= read -r -s -n 1 -t 0.1 rest 2> /dev/null; then
|
||||
if [[ "$rest" == "[" ]]; then
|
||||
if IFS= read -r -s -n 1 -t 0.1 rest2 2> /dev/null; then
|
||||
case "$rest2" in
|
||||
"A") echo "UP" ;;
|
||||
"B") echo "DOWN" ;;
|
||||
"C") echo "RIGHT" ;;
|
||||
"D") echo "LEFT" ;;
|
||||
"3")
|
||||
IFS= read -r -s -n 1 -t 0.1 rest3 2> /dev/null
|
||||
[[ "$rest3" == "~" ]] && echo "DELETE" || echo "OTHER"
|
||||
;;
|
||||
*) echo "OTHER" ;;
|
||||
esac
|
||||
else echo "QUIT"; fi
|
||||
elif [[ "$rest" == "O" ]]; then
|
||||
if IFS= read -r -s -n 1 -t 0.1 rest2 2> /dev/null; then
|
||||
case "$rest2" in
|
||||
"A") echo "UP" ;;
|
||||
"B") echo "DOWN" ;;
|
||||
"C") echo "RIGHT" ;;
|
||||
"D") echo "LEFT" ;;
|
||||
*) echo "OTHER" ;;
|
||||
esac
|
||||
else echo "OTHER"; fi
|
||||
else
|
||||
# Not an escape sequence, it's ESC key
|
||||
echo "QUIT"
|
||||
fi
|
||||
else
|
||||
# No following characters, it's ESC key
|
||||
echo "QUIT"
|
||||
fi
|
||||
;;
|
||||
' ') echo "SPACE" ;; # Allow space in filter mode for selection
|
||||
[[:print:]]) echo "CHAR:$key" ;;
|
||||
*) echo "OTHER" ;;
|
||||
esac
|
||||
|
||||
Reference in New Issue
Block a user