lotsa improvements to markslider

This commit is contained in:
ville rantanen
2014-05-19 22:08:01 +03:00
parent 14d21fc2de
commit 4d6f25c631

View File

@@ -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" ] && {