From 4d6f25c631186861c54a20ad1cc27345facccf39 Mon Sep 17 00:00:00 2001 From: ville rantanen Date: Mon, 19 May 2014 22:08:01 +0300 Subject: [PATCH] lotsa improvements to markslider --- reporting/markslider | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/reporting/markslider b/reporting/markslider index ffd44c1..37b350c 100755 --- a/reporting/markslider +++ b/reporting/markslider @@ -24,7 +24,7 @@ function display_slide { !/^# /{ print $0; } -' "$1" | sed -n '/^'$2'# /,/^'$j'# /p' | grep -v "^$j# " | sed 's,^'$i'\(# .*\),'$H'\1'$Z',' | eval sed $REGEX +' "$1" | sed -n '/^'$2'# /,/^'$j'# /p' | grep -v "^$j# " | sed -e 's,^'$i'\(# .*\),'$H'\1'$Z',' -e ${HROW}'s/^\(.*\)/'$H$Y'\1'$Z'/' | eval sed $REGEX } function slide_exec { # find executables in the slide @@ -94,12 +94,14 @@ REGEX="$REGEX -e 's/^\$(\([^)]\{20\}\).*)/\$(\1...)/g'" i=1 MENU=1 +HROW=1 while true do # print slide $i NO_SLIDES=$( grep -ce "^# " "$1" ) SLIDE_CHARS=$(( ${#i} + ${#NO_SLIDES} +1 )) COLS=$(( $( tput cols ) - $SLIDE_CHARS )) + LINES=$( tput lines ) [ "$cmd" = "e" ] && read -N 1 foo display_slide "$1" $i # save cursor location @@ -119,13 +121,23 @@ do [ "$cmd" = "" ] && read -s -N 2 cmd case "$cmd" in - 2|"[D") + 2|"[D"|"[5") i=$(( $i - 1 )) [ $i -lt 1 ] && i=1 + HROW=1 ;; - 1|"[C"|"") + 1|"[C"|"[6"|"") i=$(( $i + 1 )) [ $i -gt $NO_SLIDES ] && i=$NO_SLIDES + HROW=1 + ;; + 4|"[A") + HROW=$(( $HROW - 1 )) + [ $HROW -lt 1 ] && HROW=1 + ;; + 3|"[B") + HROW=$(( $HROW + 1 )) + [ $HROW -gt $LINES ] && HROW=$LINES ;; m) [ -z "$MENU" ] && {