Shell basic graphics demo.

I have been thinking about another shell scripting project using the Arduino Diecimila board.
I was going to make a kids level slow 8 channel Logic Analyser.

I thought about using the termiinal esc code graphics characters.

This is the test code using said terminal escape codes. I have only tested this on the
default MB Pro, OSX 10.7.5, bash terminal.
I will need to test on various terminals and Linux variants before proceeding however.

Test code to see what could be done under bash:-

#!/bin/bash --posix
clear
echo ""
echo "Graphics characters and Logic Analyser display DEMO."
# Enable _extended_ graphics characters.
echo -e "\x1B(0"
echo -e "abcdefghijklmnopqrstuvwxyz\n"
echo "lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq"
echo "j                                                               "
echo "lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk                               "
echo "j                               mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq"
echo "lqqqqqqqqqqqqqqqk               lqqqqqqqqqqqqqqqk               "
echo "j               mqqqqqqqqqqqqqqqj               mqqqqqqqqqqqqqqq"
echo "lqqqqqqqk       lqqqqqqqk       lqqqqqqqk       lqqqqqqqk       "
echo "j       mqqqqqqqj       mqqqqqqqj       mqqqqqqqj       mqqqqqqq"
echo "lqqqk   lqqqk   lqqqk   lqqqk   lqqqk   lqqqk   lqqqk   lqqqk   "
echo "j   mqqqj   mqqqj   mqqqj   mqqqj   mqqqj   mqqqj   mqqqj   mqqq"
echo "lqk lqk lqk lqk lqk lqk lqk lqk lqk lqk lqk lqk lqk lqk lqk lqk "
echo "j mqj mqj mqj mqj mqj mqj mqj mqj mqj mqj mqj mqj mqj mqj mqj mq"
echo "x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x "
echo "vqvqvqvqvqvqvqvqvqvqvqvqvqvqvqvqvqvqvqvqvqvqvqvqvqvqvqvqvqvqvqvq"
echo "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
echo "vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv"
# Disable _extended_ graphics characters.
echo -e "\x1B(B\x1B[0m"
echo "Graphics characters DEMO end."
echo ""

I am pleasantly surprised that it displays at all...
It certainly looks much better _in_the_flesh_...

Graphics characters and Logic Analyser display DEMO.

��


                                                               
                               
                               
                              
                              
                            
                            
                        
                        
                
                
                                




Graphics characters DEMO end.

AMIGA:barrywalker~> _

The culprit is not bash at all, it is the various (and eventually quite different) terminals used in Unix.

Basically it works like this: every terminal understands a set of control codes (not necessarily the same ones) to do respective things: "bold on", "bold off", "position the cursor to x,y", etc.. Which codes exactly steer what is kept in a database called "termcap" (terminal capabilities). The key to this database is your setting of the TERM variable, so when you enter, for instance,

tput smul

which starts underlined printing, tput would query current value of the TERM variable, say "myterminal" or "xterm", then search the termcap database for this key and query the control sequence for the "smul" capability of this terminal. Finally it outputs this value thereby switching the terminal into the underlined-printing-mode.

Your control sequences might work for your terminal, but they may or may not work for any other. This is not a matter of bash, but one of the terminal emulator you happen to use.

Corollary: man pages of "termcap" say it is deprecated and "terminfo" should be used. This is correct, in this respect, though, these two are not any different, so that they can be used synonymously.

I hope this helps.

bakunin

Hi bakunin...

Thanks...

I was aware it was terminal related but I am never sure about the shell(s).
That was why I quoted only the one machine tested on.
I have done lots of jiggery pokery with various terminals and some work on some and
others work on others. There are common ones that seem to work on all.

My intent here was to see if it was possible to display as accurately as is possible an
8 channel login analyser type of display using shell scripting only. And so far on the MBP
I am pleasantly surprised at the outcome. Yes it would have its limitations but as an
exercise it looks like it could be fun, plus it would enhance my shell coding abilities.

You guys have been extremely helpful in informing me of the subtleties of my exploits
since I first started scripting and I never forget.

Thanks again and your reply has been helpful...