diff options
Diffstat (limited to 'large.sh')
| -rwxr-xr-x | large.sh | 160 |
1 files changed, 81 insertions, 79 deletions
@@ -143,88 +143,90 @@ large_minus() { ' ' } -printf '#define LARGE_Y %i\n' $(large_0 | wc -l) -printf '#define LARGE_X %i\n' $(large_0 | head -n 1 | tr -d '\n' | wc -c) -printf '#define LARGE_XC %i\n' $(large_colon | head -n 1 | tr -d '\n' | wc -c) -printf '#define LARGE_XD %i\n' $(large_dot | head -n 1 | tr -d '\n' | wc -c) -printf '#define LARGE_XM %i\n' $(large_minus | head -n 1 | tr -d '\n' | wc -c) +what="$1" +shift 1 +if test $# = 0; then + set 0 1 2 3 4 5 6 7 8 9 colon dot minus +fi -printf '#define SMALL_Y %i\n' $(expr \( $(large_0 | wc -l) + 1 \) / 2) -printf '#define SMALL_X %i\n' $(expr \( $(large_0 | head -n 1 | tr -d '\n' | wc -c) + 1 \) / 2) -printf '#define SMALL_XC %i\n' $(expr \( $(large_colon | head -n 1 | tr -d '\n' | wc -c) + 1 \) / 2) -printf '#define SMALL_XD %i\n' $(expr \( $(large_dot | head -n 1 | tr -d '\n' | wc -c) + 1 \) / 2) -printf '#define SMALL_XM %i\n' $(expr \( $(large_minus | head -n 1 | tr -d '\n' | wc -c) + 1 \) / 2) +if test "$what" = h; then + printf '#define LARGE_Y %i\n' $(large_0 | wc -l) + printf '#define LARGE_X %i\n' $(large_0 | head -n 1 | tr -d '\n' | wc -c) + printf '#define LARGE_XC %i\n' $(large_colon | head -n 1 | tr -d '\n' | wc -c) + printf '#define LARGE_XD %i\n' $(large_dot | head -n 1 | tr -d '\n' | wc -c) + printf '#define LARGE_XM %i\n' $(large_minus | head -n 1 | tr -d '\n' | wc -c) + printf '#define SMALL_Y %i\n' $(expr \( $(large_0 | wc -l) + 1 \) / 2) + printf '#define SMALL_X %i\n' $(expr \( $(large_0 | head -n 1 | tr -d '\n' | wc -c) + 1 \) / 2) + printf '#define SMALL_XC %i\n' $(expr \( $(large_colon | head -n 1 | tr -d '\n' | wc -c) + 1 \) / 2) + printf '#define SMALL_XD %i\n' $(expr \( $(large_dot | head -n 1 | tr -d '\n' | wc -c) + 1 \) / 2) + printf '#define SMALL_XM %i\n' $(expr \( $(large_minus | head -n 1 | tr -d '\n' | wc -c) + 1 \) / 2) +fi -for c in 0 1 2 3 4 5 6 7 8 9 colon dot minus; do - if test $c = colon; then - printf '%s\n' '#ifdef INCLUDE_LARGE_COLON' - elif test $c = dot; then - printf '%s\n' '#ifdef INCLUDE_LARGE_DOT' - elif test $c = minus; then - printf '%s\n' '#ifdef INCLUDE_LARGE_MINUS' - fi - printf 'static const char *large_%s[] = {\n' $c - large_$c | \ - sed -e 's/X/ /g' -e 's/\[/\\033\[7m /g' -e 's/\]/ \\033\[27m/g' | \ - sed -e 's/^/"/' -e 's/$/",/' | \ - sed '$s/,$//' - printf '};\n' +for c; do + if test "$what" = h; then + printf 'extern const char *large_%s[];\n' $c + printf 'extern const char *small_%s[];\n' $c + else + printf 'const char *large_%s[] = {\n' $c + large_$c | \ + sed -e 's/X/ /g' -e 's/\[/\\033\[7m /g' -e 's/\]/ \\033\[27m/g' | \ + sed -e 's/^/"/' -e 's/$/",/' | \ + sed '$s/,$//' + printf '};\n' - printf 'static const char *small_%s[] = {\n' $c - ( - if expr $(large_$c | wc -l) % 2 >/dev/null; then - printf '%*.s\n' $(expr \( $(large_0 | head -n 1 | tr -d '\n' | wc -c) + 1 \) / 2 \* 2) '' - fi - if expr $(large_$c | head -n 1 | tr -d '\n' | wc -c) % 2 >/dev/null; then - large_$c | tr '][' XX | sed 's/$/ /g' - else - large_$c | tr '][' XX - fi - ) | tr ' \n' ., | sed 's/\([^,]*\),\([^,]*\),/:\1:\2:\n/g' | while read line; do - high="$(printf '%s\n' "$line" | cut -d : -f 2)" - low="$(printf '%s\n' "$line" | cut -d : -f 3)" - while test -n "$high"; do - block="$(printf '%s\n' "$high" | colrm 3)$(printf '%s\n' "$low" | colrm 3)" - high="$(printf '%s\n' "$high" | colrm 1 2)" - low="$(printf '%s\n' "$low" | colrm 1 2)" - if test "$block" = '....'; then - printf ' ' - elif test "$block" = '...X'; then - printf '▗' - elif test "$block" = '..X.'; then - printf '▖' - elif test "$block" = '..XX'; then - printf '▄' - elif test "$block" = '.X..'; then - printf '▝' - elif test "$block" = '.X.X'; then - printf '▐' - elif test "$block" = '.XX.'; then - printf '▞' - elif test "$block" = '.XXX'; then - printf '▟' - elif test "$block" = 'X...'; then - printf '▘' - elif test "$block" = 'X..X'; then - printf '▚' - elif test "$block" = 'X.X.'; then - printf '▌' - elif test "$block" = 'X.XX'; then - printf '▙' - elif test "$block" = 'XX..'; then - printf '▀' - elif test "$block" = 'XX.X'; then - printf '▜' - elif test "$block" = 'XXX.'; then - printf '▛' - elif test "$block" = 'XXXX'; then - printf '█' + printf 'const char *small_%s[] = {\n' $c + ( + if expr $(large_$c | wc -l) % 2 >/dev/null; then + printf '%*.s\n' $(expr \( $(large_0 | head -n 1 | tr -d '\n' | wc -c) + 1 \) / 2 \* 2) '' + fi + if expr $(large_$c | head -n 1 | tr -d '\n' | wc -c) % 2 >/dev/null; then + large_$c | tr '][' XX | sed 's/$/ /g' + else + large_$c | tr '][' XX fi - done - printf '\n' - done | sed -e 's/^/"/' -e 's/$/",/' | sed '$s/,$//' - printf '};\n' - if test $c = colon || test $c = dot || test $c = minus; then - printf '%s\n' '#endif' + ) | tr ' \n' ., | sed 's/\([^,]*\),\([^,]*\),/:\1:\2:\n/g' | while read line; do + high="$(printf '%s\n' "$line" | cut -d : -f 2)" + low="$(printf '%s\n' "$line" | cut -d : -f 3)" + while test -n "$high"; do + block="$(printf '%s\n' "$high" | colrm 3)$(printf '%s\n' "$low" | colrm 3)" + high="$(printf '%s\n' "$high" | colrm 1 2)" + low="$(printf '%s\n' "$low" | colrm 1 2)" + if test "$block" = '....'; then + printf ' ' + elif test "$block" = '...X'; then + printf '▗' + elif test "$block" = '..X.'; then + printf '▖' + elif test "$block" = '..XX'; then + printf '▄' + elif test "$block" = '.X..'; then + printf '▝' + elif test "$block" = '.X.X'; then + printf '▐' + elif test "$block" = '.XX.'; then + printf '▞' + elif test "$block" = '.XXX'; then + printf '▟' + elif test "$block" = 'X...'; then + printf '▘' + elif test "$block" = 'X..X'; then + printf '▚' + elif test "$block" = 'X.X.'; then + printf '▌' + elif test "$block" = 'X.XX'; then + printf '▙' + elif test "$block" = 'XX..'; then + printf '▀' + elif test "$block" = 'XX.X'; then + printf '▜' + elif test "$block" = 'XXX.'; then + printf '▛' + elif test "$block" = 'XXXX'; then + printf '█' + fi + done + printf '\n' + done | sed -e 's/^/"/' -e 's/$/",/' | sed '$s/,$//' + printf '};\n' fi done |
