summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Faure <billiob@gmail.com>2013-10-16 23:06:49 +0200
committerBoris Faure <billiob@gmail.com>2013-10-16 23:06:49 +0200
commit882777c6f2635aa5074e4fd323d165ac1450ea29 (patch)
treec14a71f5dfe8985df89c7748ed21595dedbc7d84
early typres
-rwxr-xr-xtypres.sh120
1 files changed, 120 insertions, 0 deletions
diff --git a/typres.sh b/typres.sh
new file mode 100755
index 0000000..ff8d9ed
--- /dev/null
+++ b/typres.sh
@@ -0,0 +1,120 @@
1#!/usr/bin/env bash
2
3set -e
4#set -x
5
6WL=0
7
8r() {
9 echo -ne '\033}qs\0' && read -s s
10 COLUMNS=${s/;*}
11 LINES=${s#*;}
12 LINES=${LINES/;*}
13 WL=0
14}
15
16t() {
17 #TODO
18 echo "$@"
19}
20
21function b {
22 #TODO
23 echo "$@"
24}
25
26vc() {
27 local str=$@
28 local spaces=$(( ($COLUMNS - ${#str}) / 2 ))
29 for I in $(seq 1 $spaces); do
30 echo -n " "
31 done
32 echo $str
33 WL=$(( $WL + 1 ))
34}
35
36c() {
37 local str=$@
38 local lines=()
39 local len=$COLUMNS
40 local line=""
41 for w in $str; do
42 local l=${#w}
43 if [[ l -lt $len ]] ; then
44 len=$(( $len - $l ))
45 line="$line $w"
46 else
47 len=$COLUMNS
48 lines+=("$line")
49 line=""
50 fi
51 done;
52 if [[ -n $line ]]; then
53 lines+=("$line")
54 fi
55
56 local l=$(( ($LINES - ${#lines[@]}) / 2 ))
57 for I in $(seq 1 $l); do
58 echo ""
59 WL=$(( $WL + 1 ))
60 done
61
62
63 for l in "${lines[@]}"; do
64 vc $l
65 done
66}
67
68f() {
69 WL=$(( $WL + 1 ))
70
71 while [[ $WL -lt $LINES ]]; do
72 echo ""
73 WL=$(( $WL + 1 ))
74 done
75 echo $@
76}
77
78function s01 {
79 c "Terminology - Oct 2013 - Where are we?"
80
81 f $@
82}
83function s02 {
84 t "whoami"
85
86 b "Boris Faure aka billiob"
87 b "developer on Enlightement and the EFL for 4 years"
88
89 f $@
90}
91
92
93
94
95slides=(s01 s02)
96
97clear
98
99S=0
100while true; do
101 r
102 if [[ $S -ge ${#slides[@]} ]]; then
103 S=0
104 fi
105 if [[ $S -lt 0 ]]; then
106 S=$(( ${#slides[@]} - 1))
107 fi
108
109 eval ${slides[$S]} "$S/${#slides[@]}"
110 read answer
111 case $answer in
112 q*) exit;;
113 n*) S=$(( $S + 1));;
114 p*) S=$(( $S - 1));;
115 r*) ;;
116 *) S=$answer;;
117 esac
118
119done
120