adding exec feature
This commit is contained in:
@@ -14,6 +14,37 @@ function display_self {
|
|||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function display_slide {
|
||||||
|
j=$(( $2 + 1 ))
|
||||||
|
echo -en "$CLS"
|
||||||
|
awk 'match($0,/^# /){
|
||||||
|
c++;
|
||||||
|
print c $0;
|
||||||
|
}
|
||||||
|
!/^# /{
|
||||||
|
print $0;
|
||||||
|
}
|
||||||
|
' "$1" | sed -n '/^'$2'# /,/^'$j'# /p' | grep -v "^$j# " | sed 's,^'$i'\(# .*\),'$H'\1'$Z',' | eval sed $REGEX
|
||||||
|
}
|
||||||
|
function slide_exec {
|
||||||
|
# find executables in the slide
|
||||||
|
j=$(( $2 + 1 ))
|
||||||
|
echo -en "$CLS"
|
||||||
|
while read line
|
||||||
|
do eval $line > /dev/null 2>&1 &
|
||||||
|
done < <(
|
||||||
|
awk 'match($0,/^# /){
|
||||||
|
c++;
|
||||||
|
print c $0;
|
||||||
|
}
|
||||||
|
!/^# /{
|
||||||
|
print $0;
|
||||||
|
}
|
||||||
|
' "$1" | sed -n '/^'$2'# /,/^'$j'# /p' | grep "^\$( " | sed -e 's,^\$( ,,' -e 's,)$,,' )
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
E='\x1b['
|
E='\x1b['
|
||||||
H="${E}1m"
|
H="${E}1m"
|
||||||
Z="${E}0m"
|
Z="${E}0m"
|
||||||
@@ -44,6 +75,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'"
|
||||||
#echo $REGEX
|
#echo $REGEX
|
||||||
#exit
|
#exit
|
||||||
|
|
||||||
@@ -54,38 +86,31 @@ 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 ))
|
||||||
j=$(( $i + 1 ))
|
display_slide "$1" $i
|
||||||
echo -en "$CLS"
|
|
||||||
awk 'match($0,/^# /){
|
|
||||||
c++;
|
|
||||||
print c $0;
|
|
||||||
}
|
|
||||||
!/^# /{
|
|
||||||
print $0;
|
|
||||||
}
|
|
||||||
' "$1" | sed -n '/^'$i'# /,/^'$j'# /p' | grep -v "^$j# " | sed 's,^'$i'\(# .*\),'$H'\1'$Z',' | eval sed $REGEX
|
|
||||||
# ask for user input
|
# ask for user input
|
||||||
# 1 back, 2 forward, q exit, h help
|
# 1 back, 2 forward, q exit, m menu
|
||||||
echo -ne "${Z}${E}1;${COLS}H"
|
echo -ne "${Z}${E}1;${COLS}H"
|
||||||
[ -z "$MENU" ] || {
|
[ -z "$MENU" ] || {
|
||||||
echo -ne "${i}/${NO_SLIDES}"
|
echo -ne "${i}/${NO_SLIDES}"
|
||||||
echo -ne "${E}1B${E}3D1:▶"
|
echo -ne "${E}1B${E}3D1:▶"
|
||||||
echo -ne "${E}1B${E}3D2:◀"
|
echo -ne "${E}1B${E}3D2:◀"
|
||||||
echo -ne "${E}1B${E}3Dq:x"
|
echo -ne "${E}1B${E}3Dq:x"
|
||||||
echo -ne "${E}1B${E}3Dh:▲${E}4A"
|
echo -ne "${E}1B${E}3Dm:▲${E}4A"
|
||||||
}
|
}
|
||||||
read -s -N 1 cmd
|
read -s -N 1 cmd
|
||||||
|
# Escape inputed if arrow keys used
|
||||||
|
[ "$cmd" = "" ] && read -s -N 2 cmd
|
||||||
|
|
||||||
case "$cmd" in
|
case "$cmd" in
|
||||||
2)
|
2|"[D")
|
||||||
i=$(( $i - 1 ))
|
i=$(( $i - 1 ))
|
||||||
[ $i -lt 1 ] && i=1
|
[ $i -lt 1 ] && i=1
|
||||||
;;
|
;;
|
||||||
1)
|
1|"[C"|"")
|
||||||
i=$(( $i + 1 ))
|
i=$(( $i + 1 ))
|
||||||
[ $i -gt $NO_SLIDES ] && i=$NO_SLIDES
|
[ $i -gt $NO_SLIDES ] && i=$NO_SLIDES
|
||||||
;;
|
;;
|
||||||
h)
|
m)
|
||||||
[ -z "$MENU" ] && {
|
[ -z "$MENU" ] && {
|
||||||
MENU=1
|
MENU=1
|
||||||
} || {
|
} || {
|
||||||
@@ -96,6 +121,9 @@ do
|
|||||||
echo -ne "${E}1E"
|
echo -ne "${E}1E"
|
||||||
exit
|
exit
|
||||||
;;
|
;;
|
||||||
|
e)
|
||||||
|
slide_exec "$1" $i
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
@@ -116,7 +144,7 @@ exit
|
|||||||
* Move to the next slide with key 1
|
* Move to the next slide with key 1
|
||||||
* Move to the previous slide with key 2
|
* Move to the previous slide with key 2
|
||||||
* Exit with q or x
|
* Exit with q or x
|
||||||
* Hide menu with h
|
* Hide menu with m
|
||||||
* The numbers on the right show the current
|
* The numbers on the right show the current
|
||||||
and number of slides in this presentation
|
and number of slides in this presentation
|
||||||
|
|
||||||
@@ -165,7 +193,6 @@ Object Area Perimeter
|
|||||||
Background colors: BGR BGG BGB BGC BGM BGY BGW
|
Background colors: BGR BGG BGB BGC BGM BGY BGW
|
||||||
Reset colors with ${ [1DZ}
|
Reset colors with ${ [1DZ}
|
||||||
|
|
||||||
|
|
||||||
# Hints: Presenting
|
# Hints: Presenting
|
||||||
|
|
||||||
* Use a terminal with large font, perhaps 80 columns on screen
|
* Use a terminal with large font, perhaps 80 columns on screen
|
||||||
@@ -173,6 +200,9 @@ Object Area Perimeter
|
|||||||
┌──────┐
|
┌──────┐
|
||||||
* Get creative with │Ascii!│
|
* Get creative with │Ascii!│
|
||||||
└┬────┬┘
|
└┬────┬┘
|
||||||
|
* Run any command with pressing "e" on a slide with
|
||||||
|
syntax beginning a row: "$ [1D( command )"
|
||||||
|
$( xeyes )
|
||||||
|
|
||||||
# Hints: Other tools
|
# Hints: Other tools
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user