trim repeated code, nav with backspace
Akshay nerdypepper@tuta.io
Sun, 09 Feb 2020 11:00:51 +0530
1 files changed,
12 insertions(+),
19 deletions(-)
jump to
M
shlide
→
shlide
@@ -135,31 +135,24 @@
# Capture Ctrl+C. trap 'die' INT + # Don't go below 0. + [[ "$i" -lt 0 ]] && i=0 + # Display END reached prompt, and then exit. - [[ "$i" -eq "$total" ]] && { + if [[ "$i" -eq "$total" ]]; then display_end - read -rsn1 input - case "$input" in - "j"|"n"|"q") - die - ;; - *) - ((i=0)) - ;; - esac - } + else + display "$(<"${slides[$i]}")" "${slides[$i]}" "$i" "$total" + fi - # Don't go below 0. - [[ "$i" -lt 0 ]] && i=0 - - # Navigate on j/k/n/p and quit on q. - display "$(<"${slides[$i]}")" "${slides[$i]}" "$i" "$total" + # Navigation read -rsn1 input - case "$input" in - "j"|"n"|"") + case "$input" in + "j"|"n"|""|";") + [[ "$i" -eq "$total" ]] && die ((++i)) ;; - "k"|"p") + "k"|"p"|""|",") ((--i)) ;; "0")