diff options
author | P. J. McDermott <pj@pehjota.net> | 2015-10-29 00:16:50 (EDT) |
---|---|---|
committer | P. J. McDermott <pj@pehjota.net> | 2015-10-29 00:16:50 (EDT) |
commit | d19afb24c207c2324e93eb834439d468de7f0cdc (patch) | |
tree | 607d59a3fa7a221fea433d13d9ae15d3eacb1d29 | |
parent | 4337caddabfb23cee8831e2b2374e2af53a13068 (diff) | |
download | firman.sh-d19afb24c207c2324e93eb834439d468de7f0cdc.zip firman.sh-d19afb24c207c2324e93eb834439d468de7f0cdc.tar.gz firman.sh-d19afb24c207c2324e93eb834439d468de7f0cdc.tar.bz2 |
tui_show_prompt(): Enforce range on cursor position
-rw-r--r-- | src/ui/tui.sh | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/ui/tui.sh b/src/ui/tui.sh index 962e731..74211d7 100644 --- a/src/ui/tui.sh +++ b/src/ui/tui.sh @@ -252,19 +252,25 @@ tui_show_prompt() case "${key}" in KEY_ENTER) break;; KEY_BACKSPACE) - input="${input%?}" - curpos=$(($curpos - 1)) + if [ ${curpos} -gt 0 ]; then + input="${input%?}" + curpos=$(($curpos - 1)) + fi ;; KEY_DEL) ;; # TODO: Line editing KEY_SPACE) - input="${input} " - curpos=$(($curpos + 1)) + if [ ${curpos} -lt ${len} ]; then + input="${input} " + curpos=$(($curpos + 1)) + fi ;; *) - input="${input}${key}" - curpos=$(($curpos + 1)) + if [ ${curpos} -lt ${len} ]; then + input="${input}${key}" + curpos=$(($curpos + 1)) + fi ;; esac elif [ ${focus} -eq 1 ]; then |