new features to markslider

This commit is contained in:
ville rantanen
2014-04-17 09:54:06 +03:00
parent e7d42d706d
commit 1ac9896403

View File

@@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
VERSION=20140416 VERSION=20140417
function display_self { function display_self {
$0 $0 $0 $0
@@ -24,12 +24,12 @@ function display_slide {
!/^# /{ !/^# /{
print $0; 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 's,^'$i'\(# .*\),'$H'\1'$Z',' | eval sed $REGEX
} }
function slide_exec { function slide_exec {
# find executables in the slide # find executables in the slide
j=$(( $2 + 1 )) j=$(( $2 + 1 ))
echo -en "$CLS" #echo -en "$CLS"
while read line while read line
do eval $line > /dev/null 2>&1 & do eval $line > /dev/null 2>&1 &
done < <( done < <(
@@ -40,6 +40,19 @@ function slide_exec {
!/^# /{ !/^# /{
print $0; print $0;
} }
' "$1" | sed -n '/^'$2'# /,/^'$j'# /p' | grep "^\&( " | sed -e 's,^\&( ,,' -e 's,)$,,' )
# restore cursor position to bottom of slide
echo -ne "${E}u"
while read line
do eval $line
done < <(
awk 'match($0,/^# /){
c++;
print c $0;
}
!/^# /{
print $0;
}
' "$1" | sed -n '/^'$2'# /,/^'$j'# /p' | grep "^\$( " | sed -e 's,^\$( ,,' -e 's,)$,,' ) ' "$1" | sed -n '/^'$2'# /,/^'$j'# /p' | grep "^\$( " | sed -e 's,^\$( ,,' -e 's,)$,,' )
} }
@@ -75,7 +88,7 @@ for (( r=0; r<${#CONF_LINE[@]}; r++ ));
replace=$( eval echo ${!value} ) replace=$( eval echo ${!value} )
REGEX="$REGEX -e 's/\(${CONF_LINE[$r]}\)/"${replace}"/g'" REGEX="$REGEX -e 's/\(${CONF_LINE[$r]}\)/"${replace}"/g'"
done done
REGEX="$REGEX -e 's/^\$([^\$]\+)/\$(*)/g'" REGEX="$REGEX -e 's/^\$(\([^)]\{20\}\).*)/\$(\1...)/g'"
#echo $REGEX #echo $REGEX
#exit #exit
@@ -86,7 +99,10 @@ do
# print slide $i # print slide $i
NO_SLIDES=$( grep -ce "^# " "$1" ) NO_SLIDES=$( grep -ce "^# " "$1" )
COLS=$(( $( tput cols ) - 3 )) COLS=$(( $( tput cols ) - 3 ))
[ "$cmd" = "e" ] && read -N 1 foo
display_slide "$1" $i display_slide "$1" $i
# save cursor location
echo -ne "${E}s"
# ask for user input # ask for user input
# 1 back, 2 forward, q exit, m menu # 1 back, 2 forward, q exit, m menu
echo -ne "${Z}${E}1;${COLS}H" echo -ne "${Z}${E}1;${COLS}H"
@@ -141,8 +157,8 @@ exit
## How to use ## ## How to use ##
* Give the markdown file as argument * Give the markdown file as argument
* Move to the next slide with key 1 * Move to the next slide with key 1, arrow right, space..
* Move to the previous slide with key 2 * Move to the previous slide with key 2, arrow left
* Exit with q or x * Exit with q or x
* Hide menu with m * Hide menu with m
* The numbers on the right show the current * The numbers on the right show the current
@@ -201,8 +217,12 @@ Object Area Perimeter
* Get creative with │Ascii!│ * Get creative with │Ascii!│
└┬────┬┘ └┬────┬┘
* Run any command with pressing "e" on a slide with * Run any command with pressing "e" on a slide with
syntax beginning a row: "$ ( command )" syntax beginning a row:
$( xeyes ) * "$ ( command )" to print the output
* "& ( command )" run process in background
&( xeyes )
$( ls )
# Hints: Other tools # Hints: Other tools