add 0 and G motions
Akshay nerdypepper@tuta.io
Sun, 09 Feb 2020 10:44:48 +0530
1 files changed,
11 insertions(+),
4 deletions(-)
jump to
M
shlide
→
shlide
@@ -126,8 +126,9 @@ main() {
slides_dir="${1:-./}" slides=("$slides_dir"/[0-9]*.txt) + total="${#slides[@]}" i=0 - while true; do + while :; do # Clear the screen. printf '\e[2J'@@ -135,7 +136,7 @@ # Capture Ctrl+C.
trap 'die' INT # Display END reached prompt, and then exit. - [[ "$i" -eq "${#slides[@]}" ]] && { + [[ "$i" -eq "$total" ]] && { display_end read -rsn1 input case "$input" in@@ -143,7 +144,7 @@ "j"|"n"|"q")
die ;; *) - ((--i)) + ((i=0)) ;; esac }@@ -152,7 +153,7 @@ # 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" "${#slides[@]}" + display "$(<"${slides[$i]}")" "${slides[$i]}" "$i" "$total" read -rsn1 input case "$input" in "j"|"n"|"")@@ -160,6 +161,12 @@ ((++i))
;; "k"|"p") ((--i)) + ;; + "0") + ((i=0)) + ;; + "G") + ((i=total-1)) ;; "q") # Return the cursor on exit.