diff options
| -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')"|\ |