fix page down, page up and del key, added del key to delete function
This commit is contained in:
@@ -675,15 +675,21 @@ draw() {
|
|||||||
read_key() {
|
read_key() {
|
||||||
IFS= read -r -n1 key 2>/dev/null || IFS= read -r key
|
IFS= read -r -n1 key 2>/dev/null || IFS= read -r key
|
||||||
if [ "$key" = "$(printf '\033')" ]; then
|
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=""
|
IFS= read -r -n1 -t 0.1 _k2 2>/dev/null || _k2=""
|
||||||
if [ -z "$_k2" ]; then
|
if [ -z "$_k2" ]; then
|
||||||
# nothing followed — bare esc
|
|
||||||
printf '\033'; return
|
printf '\033'; return
|
||||||
fi
|
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=""
|
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
|
fi
|
||||||
printf '%s' "$key"
|
printf '%s' "$key"
|
||||||
}
|
}
|
||||||
@@ -1665,6 +1671,7 @@ while true; do
|
|||||||
G) SEL=$((COUNT - 1)) ;;
|
G) SEL=$((COUNT - 1)) ;;
|
||||||
"$(printf '\033[6~')") SEL=$((SEL + $(term_rows) / 2)) ;;
|
"$(printf '\033[6~')") SEL=$((SEL + $(term_rows) / 2)) ;;
|
||||||
"$(printf '\033[5~')") SEL=$((SEL - $(term_rows) / 2)) ;;
|
"$(printf '\033[5~')") SEL=$((SEL - $(term_rows) / 2)) ;;
|
||||||
|
"$(printf '\033[3~')") do_delete ;;
|
||||||
"$(printf '\n')"|\
|
"$(printf '\n')"|\
|
||||||
"$(printf '\r')"|\
|
"$(printf '\r')"|\
|
||||||
"$(printf '\033[C')"|\
|
"$(printf '\033[C')"|\
|
||||||
|
|||||||
Reference in New Issue
Block a user