mirror of
https://github.com/tw93/Mole.git
synced 2026-02-08 07:59:16 +00:00
Enter to select the next step
This commit is contained in:
@@ -175,8 +175,17 @@ show_cursor() {
|
|||||||
|
|
||||||
# Keyboard input handling (simple and robust)
|
# Keyboard input handling (simple and robust)
|
||||||
read_key() {
|
read_key() {
|
||||||
local key rest
|
local key rest read_status
|
||||||
IFS= read -r -s -n 1 key || return 1
|
|
||||||
|
# Read with explicit status check
|
||||||
|
IFS= read -r -s -n 1 key
|
||||||
|
read_status=$?
|
||||||
|
|
||||||
|
# Handle read failure (Ctrl+D, EOF, etc.) - treat as quit
|
||||||
|
if [[ $read_status -ne 0 ]]; then
|
||||||
|
echo "QUIT"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
# Raw typing mode (filter): map most keys to CHAR:<key>
|
# Raw typing mode (filter): map most keys to CHAR:<key>
|
||||||
if [[ "${MOLE_READ_KEY_FORCE_CHAR:-}" == "1" ]]; then
|
if [[ "${MOLE_READ_KEY_FORCE_CHAR:-}" == "1" ]]; then
|
||||||
|
|||||||
@@ -637,7 +637,26 @@ paginated_multi_select() {
|
|||||||
draw_menu
|
draw_menu
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
# In normal mode: confirm and exit with current selections
|
# In normal mode: smart Enter behavior
|
||||||
|
# 1. Check if any items are already selected
|
||||||
|
local has_selection=false
|
||||||
|
for ((i = 0; i < total_items; i++)); do
|
||||||
|
if [[ ${selected[i]} == true ]]; then
|
||||||
|
has_selection=true
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# 2. If nothing selected, auto-select current item
|
||||||
|
if [[ $has_selection == false ]]; then
|
||||||
|
local idx=$((top_index + cursor_pos))
|
||||||
|
if [[ $idx -lt ${#view_indices[@]} ]]; then
|
||||||
|
local real="${view_indices[idx]}"
|
||||||
|
selected[real]=true
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 3. Confirm and exit with current selections
|
||||||
local -a selected_indices=()
|
local -a selected_indices=()
|
||||||
for ((i = 0; i < total_items; i++)); do
|
for ((i = 0; i < total_items; i++)); do
|
||||||
if [[ ${selected[i]} == true ]]; then
|
if [[ ${selected[i]} == true ]]; then
|
||||||
|
|||||||
Reference in New Issue
Block a user