all repos — shlide @ f4d066d2cb9a52eb279e91c69a7a5214829d8288

slide deck presentation tool written in pure bash

Better comments, trap Ctrl+C

Signed-off-by: Anirudh Oppiliappan <x@icyphox.sh>
Anirudh Oppiliappan x@icyphox.sh
Mon, 03 Feb 2020 00:05:22 +0530
commit

f4d066d2cb9a52eb279e91c69a7a5214829d8288

parent

ccc315bc69282c88dcb29fb3a187eacd53caf5b3

1 files changed, 16 insertions(+), 7 deletions(-)

jump to
M shlideshlide

@@ -28,15 +28,17 @@ printf '%s\n' "$max"

} colorify() { + # 'eval' hack to achieve substitution for colors. eval "declare dummy=\"$1\"" printf '%b' "$dummy" } +# Filter out color sequences. shopt -s extglob ansi_filter() { - local IFS= - echo "${1//$'\e'[\[(]*([0-9;])[@-n]/}" - #/" a little fix to keep my vim syntax hl sane + local IFS= + echo "${1//$'\e'[\[(]*([0-9;])[@-n]/}" + #" A little fix to prevent vim syntax highlighting from breaking. }

@@ -88,6 +90,11 @@ done <<< "$slide_contents"

} +die() { + printf '\e[?25h' + exit 0 +} + display_end() { read -r LINES COLUMNS < <(stty -F /dev/tty size) ((l=$LINES/2))

@@ -105,6 +112,10 @@ i=0

while true; do # Clear the screen. printf '\e[2J' + + # Capture Ctrl+C. + trap 'die' INT + # Display END reached prompt, and then exit [[ "$i" -eq "${#slides[@]}" ]] && { display_end

@@ -112,8 +123,7 @@ read -rsn1 input

case "$input" in "j"|"n"|"q") printf '\e[2J' - printf '\e[?25h' - exit + die ;; *) ((--i))

@@ -136,8 +146,7 @@ ((--i))

;; "q") # Return the cursor on exit. - printf '\e[?25h' - exit + die ;; esac done