Skip to content

Commit

Permalink
refactor size check into function, then all it before ansi output. th…
Browse files Browse the repository at this point in the history
…is allows the help and version screens to work on screens smaller than 100px.
  • Loading branch information
xero committed Jun 16, 2014
1 parent 203f2c9 commit 63fd97b
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions ryu
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,19 @@
#
# ▓▓▓▓▓▓▓▓▓▓
# ░▓ author ▓ xero <x@xero.nu>
# ░▓ code ▓ http://code.xero.nu/ryu
# ░▓ mirror ▓ http://git.io/ryu
# ░▓ code ▓ http://git.io/ryu
# ░▓ mirror ▓ http://code.xero.nu/ryu
# ░▓▓▓▓▓▓▓▓▓▓
# ░░░░░░░░░░

cols=`tput cols`
if [[ $cols -lt 100 ]]; then
echo "term size must be greater than 100px wide!"
echo "call 'ryu --help' for more info"
exit
fi
checksize () {
if [[ $cols -lt 100 ]]; then
echo "term size must be greater than 100px wide!"
echo "call 'ryu --help' for more info"
exit
fi
}
pad () {
count=$1
until [[ $count -eq 1 ]]; do
Expand All @@ -40,6 +42,7 @@ let half=($cols-100)/2
half=${half/.*}

if [[ -z $1 || $1 == "--grey" || $1 == "-g" || $1 == "grey" ]]; then
checksize
pad $half; echo -en "..░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ ."; pad $half true
pad $half; echo -en ".░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ ."; pad $half true
pad $half; echo -en ".░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ ."; pad $half true
Expand Down Expand Up @@ -91,6 +94,7 @@ if [[ -z $1 || $1 == "--grey" || $1 == "-g" || $1 == "grey" ]]; then
pad $half; echo -en "......░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒▒▒░░▒░▒▒▒▒▒▒ ▒░░░░░░░▒▒▒▒▒▒ ▒ ....."; pad $half true
else
if [[ $1 == "--color" || $1 == "-c" || $1 == "color" ]]; then
checksize
pad $half; echo -en "\e[0;37m..\e[0;36m░░░░░░░░░░░░░░░░░░░░░░░░░░░░░\e[0;34m▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \e[0;37m.."; pad $half true
pad $half; echo -en "\e[0;37m.\e[0;36m░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░\e[0;34m▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \e[0;37m.."; pad $half true
pad $half; echo -en "\e[0;37m.\e[0;36m░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░\e[0;34m▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ \e[0;37m.."; pad $half true
Expand Down Expand Up @@ -141,7 +145,7 @@ else
pad $half; echo -en "\e[0;37m......\e[0;36m░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░\e[0;34m▒▒▒▒\e[0;36m░\e[0;34m▒▒▒▒▒ \e[0;36m░░░░░░░░\e[0;34m▒▒▒▒▒▒ ▒ \e[0;37m......"; pad $half true
pad $half; echo -en "\e[0;37m......\e[0;36m░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░\e[0;34m▒▒▒\e[0;36m░░\e[0;34m▒\e[0;36m░\e[0;34m▒▒▒▒▒▒ ▒\e[0;36m░░░░░░░\e[0;34m▒▒▒▒▒▒ ▒ \e[0;37m......"; pad $half true
elif [[ $1 = '--version' || $1 = '-v' || $1 == "version" ]]; then
echo "ryu version 1.0.0"
echo "ryu version 1.1.0"
echo "xero / syntax-samurai <http://git.io/ryu>"
echo " ▟▙"
echo "▟▒░░░░░░░▜▙▜████████████████████████████████▛"
Expand Down

0 comments on commit 63fd97b

Please # to comment.