From d973bd5b30cd1f030c128fac36c4b91963011c77 Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Thu, 29 Oct 2015 00:22:42 -0400 Subject: tui_show_prompt(): Handle arrow keys --- diff --git a/src/ui/tui.sh b/src/ui/tui.sh index 74211d7..5c88f23 100644 --- a/src/ui/tui.sh +++ b/src/ui/tui.sh @@ -251,6 +251,16 @@ tui_show_prompt() elif [ ${focus} -eq 0 ]; then case "${key}" in KEY_ENTER) break;; + KEY_LEFT) + if [ ${curpos} -gt 0 ]; then + curpos=$(($curpos - 1)) + fi + ;; + KEY_RIGHT) + if [ ${curpos} -lt ${#input} ]; then + curpos=$(($curpos + 1)) + fi + ;; KEY_BACKSPACE) if [ ${curpos} -gt 0 ]; then input="${input%?}" @@ -258,16 +268,20 @@ tui_show_prompt() fi ;; KEY_DEL) + if [ ${curpos} -lt ${#input} ]; then + : TODO + fi ;; - # TODO: Line editing KEY_SPACE) if [ ${curpos} -lt ${len} ]; then + # TODO: Handle curpos not at end input="${input} " curpos=$(($curpos + 1)) fi ;; *) if [ ${curpos} -lt ${len} ]; then + # TODO: Handle curpos not at end input="${input}${key}" curpos=$(($curpos + 1)) fi -- cgit v0.9.1