initial commit
[profile/ivi/xterm.git] / vttests / 16colors.sh
1 #!/bin/sh
2 # $XTermId: 16colors.sh,v 1.13 2003/05/19 00:52:30 tom Exp $
3 # -----------------------------------------------------------------------------
4 # this file is part of xterm
5 #
6 # Copyright 1999-2002,2003 by Thomas E. Dickey
7
8 #                         All Rights Reserved
9
10 # Permission is hereby granted, free of charge, to any person obtaining a
11 # copy of this software and associated documentation files (the
12 # "Software"), to deal in the Software without restriction, including
13 # without limitation the rights to use, copy, modify, merge, publish,
14 # distribute, sublicense, and/or sell copies of the Software, and to
15 # permit persons to whom the Software is furnished to do so, subject to
16 # the following conditions:
17
18 # The above copyright notice and this permission notice shall be included
19 # in all copies or substantial portions of the Software.
20
21 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
22 # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
24 # IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
25 # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
26 # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
27 # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28
29 # Except as contained in this notice, the name(s) of the above copyright
30 # holders shall not be used in advertising or otherwise to promote the
31 # sale, use or other dealings in this Software without prior written
32 # authorization.
33 # -----------------------------------------------------------------------------
34 # Show a simple 16-color test pattern.  It is a little more confusing than
35 # 8colors.sh, since everything is abbreviated to fit on an 80-column line.
36 # The high (8-15) combinations for foreground or background are marked with
37 # a '+' sign.
38
39 ESC="\e"
40 CMD='echo'
41 OPT='-n'
42 SUF=''
43 TMP=/tmp/xterm$$
44 eval '$CMD $OPT >$TMP || echo fail >$TMP' 2>/dev/null
45 ( test ! -f $TMP || test -s $TMP ) &&
46 for verb in printf print ; do
47     rm -f $TMP
48     eval '$verb "\c" >$TMP || echo fail >$TMP' 2>/dev/null
49     if test -f $TMP ; then
50         if test ! -s $TMP ; then
51             CMD="$verb"
52             OPT=
53             SUF='\c'
54             break
55         fi
56     fi
57 done
58 rm -f $TMP
59
60 if ( trap "echo exit" EXIT 2>/dev/null ) >/dev/null
61 then
62     trap '$CMD "\e[0m"; exit' EXIT HUP INT TRAP TERM
63 else
64     trap '$CMD "\e[0m"; exit' 0    1   2   5    15
65 fi
66
67 echo "\e[0m"
68 while true
69 do
70     for AT in 0 1 4 7
71     do
72         case $AT in
73         0) attr="   ";;
74         1) attr="BO ";;
75         4) attr="UN ";;
76         7) attr="RV ";;
77         esac
78         for FG in 0 1 2 3 4 5 6 7
79         do
80             case $FG in
81             0) fcolor="BLK ";;
82             1) fcolor="RED ";;
83             2) fcolor="GRN ";;
84             3) fcolor="YEL ";;
85             4) fcolor="BLU ";;
86             5) fcolor="MAG ";;
87             6) fcolor="CYN ";;
88             7) fcolor="WHT ";;
89             esac
90             for HI in 3 9
91             do
92                 if test $HI = 3 ; then
93                     color=" $fcolor"
94                 else
95                     color="+$fcolor"
96                 fi
97                 $CMD $OPT "\e[0;${AT}m$attr$SUF"
98                 $CMD $OPT "\e[${HI}${FG}m$color$SUF"
99                 for BG in 1 2 3 4 5 6 7
100                 do
101                     case $BG in
102                     0) bcolor="BLK ";;
103                     1) bcolor="RED ";;
104                     2) bcolor="GRN ";;
105                     3) bcolor="YEL ";;
106                     4) bcolor="BLU ";;
107                     5) bcolor="MAG ";;
108                     6) bcolor="CYN ";;
109                     7) bcolor="WHT ";;
110                     esac
111                     $CMD $OPT "\e[4${BG}m$bcolor$SUF"
112                     $CMD $OPT "\e[10${BG}m+$bcolor$SUF"
113                 done
114                 echo "\e[0m"
115             done
116         done
117         sleep 1
118     done
119 done