diff options
| author | emmett1 <me@emmett1.my> | 2026-04-11 08:57:44 +0800 |
|---|---|---|
| committer | emmett1 <me@emmett1.my> | 2026-04-11 08:57:44 +0800 |
| commit | 938955120b391e353f7761e5b6f06910dc15efc8 (patch) | |
| tree | 98d8ec41f487ed53c4de5ee9e201d0ddf78e8766 | |
| parent | f374506215371cd375b43f54135cbf46dc202ea0 (diff) | |
| download | sfm-938955120b391e353f7761e5b6f06910dc15efc8.tar.gz sfm-938955120b391e353f7761e5b6f06910dc15efc8.zip | |
fix page down, page up and del key, added del key to delete function
| -rwxr-xr-x | sfm | 15 |
1 files changed, 11 insertions, 4 deletions
@@ -675,15 +675,21 @@ draw() { read_key() { IFS= read -r -n1 key 2>/dev/null || IFS= read -r key if [ "$key" = "$(printf '\033')" ]; then - # peek at next char with a very short timeout IFS= read -r -n1 -t 0.1 _k2 2>/dev/null || _k2="" if [ -z "$_k2" ]; then - # nothing followed — bare esc printf '\033'; return fi - # got a second char — read one more for full sequence (e.g. [A [B [C [D) IFS= read -r -n1 -t 0.1 _k3 2>/dev/null || _k3="" - key="${key}${_k2}${_k3}" + # if sequence ends with ~, it may have more chars — read one more + case "${_k2}${_k3}" in + '['[0-9]) + IFS= read -r -n1 -t 0.1 _k4 2>/dev/null || _k4="" + key="${key}${_k2}${_k3}${_k4}" + ;; + *) + key="${key}${_k2}${_k3}" + ;; + esac fi printf '%s' "$key" } @@ -1665,6 +1671,7 @@ while true; do G) SEL=$((COUNT - 1)) ;; "$(printf '\033[6~')") SEL=$((SEL + $(term_rows) / 2)) ;; "$(printf '\033[5~')") SEL=$((SEL - $(term_rows) / 2)) ;; + "$(printf '\033[3~')") do_delete ;; "$(printf '\n')"|\ "$(printf '\r')"|\ "$(printf '\033[C')"|\ |