#!/usr/local/bin/wish -f #-*-tcl-*- # Choose X color by colorname. It only sets the root background, but # it could probably be adapted to do other things. # Note: if you're using CDE, you have to set your backdrop to "NoBackdrop" # to see the root window, because the backdrop covers it up. # Set up the array of colornames set color(1,1) "snow" set color(1,2) "ghostwhite" set color(1,3) "whitesmoke" set color(1,4) "gainsboro" set color(1,5) "floralwhite" set color(1,6) "oldlace" set color(1,7) "linen" set color(1,8) "antiquewhite" set color(1,9) "papayawhip" set color(1,10) "blanchedalmond" set color(1,11) "bisque" set color(1,12) "peachpuff" set color(1,13) "navajowhite" set color(2,1) "moccasin" set color(2,2) "cornsilk" set color(2,3) "ivory" set color(2,4) "lemonchiffon" set color(2,5) "seashell" set color(2,6) "honeydew" set color(2,7) "mintcream" set color(2,8) "azure" set color(2,9) "aliceblue" set color(2,10) "lavender" set color(2,11) "lavenderblush" set color(2,12) "mistyrose" set color(2,13) "white" set color(3,1) "black" set color(3,2) "darkslategray" set color(3,3) "dimgray" set color(3,4) "slategray" set color(3,5) "lightslategray" set color(3,6) "gray" set color(3,7) "lightgray" set color(3,8) "midnightblue" set color(3,9) "navy" set color(3,10) "cornflowerblue" set color(3,11) "darkslateblue" set color(3,12) "slateblue" set color(3,13) "mediumslateblue" set color(4,1) "lightslateblue" set color(4,2) "mediumblue" set color(4,3) "royalblue" set color(4,4) "blue" set color(4,5) "dodgerblue" set color(4,6) "deepskyblue" set color(4,7) "skyblue" set color(4,8) "lightskyblue" set color(4,9) "steelblue" set color(4,10) "lightsteelblue" set color(4,11) "lightblue" set color(4,12) "powderblue" set color(4,13) "paleturquoise" set color(5,1) "darkturquoise" set color(5,2) "mediumturquoise" set color(5,3) "turquoise" set color(5,4) "cyan" set color(5,5) "lightcyan" set color(5,6) "cadetblue" set color(5,7) "mediumaquamarine" set color(5,8) "aquamarine" set color(5,9) "darkgreen" set color(5,10) "darkolivegreen" set color(5,11) "darkseagreen" set color(5,12) "seagreen" set color(5,13) "mediumseagreen" set color(6,1) "lightseagreen" set color(6,2) "palegreen" set color(6,3) "springgreen" set color(6,4) "lawngreen" set color(6,5) "green" set color(6,6) "chartreuse" set color(6,7) "mediumspringgreen" set color(6,8) "greenyellow" set color(6,9) "limegreen" set color(6,10) "yellowgreen" set color(6,11) "forestgreen" set color(6,12) "olivedrab" set color(6,13) "darkkhaki" set color(7,1) "khaki" set color(7,2) "palegoldenrod" set color(7,3) "lightgoldenrodyellow" set color(7,4) "lightyellow" set color(7,5) "yellow" set color(7,6) "gold" set color(7,7) "lightgoldenrod" set color(7,8) "goldenrod" set color(7,9) "darkgoldenrod" set color(7,10) "rosybrown" set color(7,11) "indianred" set color(7,12) "saddlebrown" set color(7,13) "sienna" set color(8,1) "peru" set color(8,2) "burlywood" set color(8,3) "beige" set color(8,4) "wheat" set color(8,5) "sandybrown" set color(8,6) "tan" set color(8,7) "chocolate" set color(8,8) "firebrick" set color(8,9) "brown" set color(8,10) "darksalmon" set color(8,11) "salmon" set color(8,12) "lightsalmon" set color(8,13) "orange" set color(9,1) "darkorange" set color(9,2) "coral" set color(9,3) "lightcoral" set color(9,4) "tomato" set color(9,5) "orangered" set color(9,6) "red" set color(9,7) "hotpink" set color(9,8) "deeppink" set color(9,9) "pink" set color(9,10) "lightpink" set color(9,11) "palevioletred" set color(9,12) "maroon" set color(9,13) "mediumvioletred" set color(10,1) "violetred" set color(10,2) "magenta" set color(10,3) "violet" set color(10,4) "plum" set color(10,5) "orchid" set color(10,6) "mediumorchid" set color(10,7) "darkorchid" set color(10,8) "darkviolet" set color(10,9) "blueviolet" set color(10,10) "purple" set color(10,11) "mediumpurple" set color(10,12) "thistle" set color(10,13) "snow1" set color(11,1) "snow2" set color(11,2) "snow3" set color(11,3) "snow4" set color(11,4) "seashell1" set color(11,5) "seashell2" set color(11,6) "seashell3" set color(11,7) "seashell4" set color(11,8) "antiquewhite1" set color(11,9) "antiquewhite2" set color(11,10) "antiquewhite3" set color(11,11) "antiquewhite4" set color(11,12) "bisque1" set color(11,13) "bisque2" set color(12,1) "bisque3" set color(12,2) "bisque4" set color(12,3) "peachpuff1" set color(12,4) "peachpuff2" set color(12,5) "peachpuff3" set color(12,6) "peachpuff4" set color(12,7) "navajowhite1" set color(12,8) "navajowhite2" set color(12,9) "navajowhite3" set color(12,10) "navajowhite4" set color(12,11) "lemonchiffon1" set color(12,12) "lemonchiffon2" set color(12,13) "lemonchiffon3" set color(13,1) "lemonchiffon4" set color(13,2) "cornsilk1" set color(13,3) "cornsilk2" set color(13,4) "cornsilk3" set color(13,5) "cornsilk4" set color(13,6) "ivory1" set color(13,7) "ivory2" set color(13,8) "ivory3" set color(13,9) "ivory4" set color(13,10) "honeydew1" set color(13,11) "honeydew2" set color(13,12) "honeydew3" set color(13,13) "honeydew4" set color(14,1) "lavenderblush1" set color(14,2) "lavenderblush2" set color(14,3) "lavenderblush3" set color(14,4) "lavenderblush4" set color(14,5) "mistyrose1" set color(14,6) "mistyrose2" set color(14,7) "mistyrose3" set color(14,8) "mistyrose4" set color(14,9) "azure1" set color(14,10) "azure2" set color(14,11) "azure3" set color(14,12) "azure4" set color(14,13) "slateblue1" set color(15,1) "slateblue2" set color(15,2) "slateblue3" set color(15,3) "slateblue4" set color(15,4) "royalblue1" set color(15,5) "royalblue2" set color(15,6) "royalblue3" set color(15,7) "royalblue4" set color(15,8) "blue1" set color(15,9) "blue2" set color(15,10) "blue3" set color(15,11) "blue4" set color(15,12) "dodgerblue1" set color(15,13) "dodgerblue2" set color(16,1) "dodgerblue3" set color(16,2) "dodgerblue4" set color(16,3) "steelblue1" set color(16,4) "steelblue2" set color(16,5) "steelblue3" set color(16,6) "steelblue4" set color(16,7) "deepskyblue1" set color(16,8) "deepskyblue2" set color(16,9) "deepskyblue3" set color(16,10) "deepskyblue4" set color(16,11) "skyblue1" set color(16,12) "skyblue2" set color(16,13) "skyblue3" set color(17,1) "skyblue4" set color(17,2) "lightskyblue1" set color(17,3) "lightskyblue2" set color(17,4) "lightskyblue3" set color(17,5) "lightskyblue4" set color(17,6) "slategray1" set color(17,7) "slategray2" set color(17,8) "slategray3" set color(17,9) "slategray4" set color(17,10) "lightsteelblue1" set color(17,11) "lightsteelblue2" set color(17,12) "lightsteelblue3" set color(17,13) "lightsteelblue4" set color(18,1) "lightblue1" set color(18,2) "lightblue2" set color(18,3) "lightblue3" set color(18,4) "lightblue4" set color(18,5) "lightcyan1" set color(18,6) "lightcyan2" set color(18,7) "lightcyan3" set color(18,8) "lightcyan4" set color(18,9) "paleturquoise1" set color(18,10) "paleturquoise2" set color(18,11) "paleturquoise3" set color(18,12) "paleturquoise4" set color(18,13) "cadetblue1" set color(19,1) "cadetblue2" set color(19,2) "cadetblue3" set color(19,3) "cadetblue4" set color(19,4) "turquoise1" set color(19,5) "turquoise2" set color(19,6) "turquoise3" set color(19,7) "turquoise4" set color(19,8) "cyan1" set color(19,9) "cyan2" set color(19,10) "cyan3" set color(19,11) "cyan4" set color(19,12) "darkslategray1" set color(19,13) "darkslategray2" set color(20,1) "darkslategray3" set color(20,2) "darkslategray4" set color(20,3) "aquamarine1" set color(20,4) "aquamarine2" set color(20,5) "aquamarine3" set color(20,6) "aquamarine4" set color(20,7) "darkseagreen1" set color(20,8) "darkseagreen2" set color(20,9) "darkseagreen3" set color(20,10) "darkseagreen4" set color(20,11) "seagreen1" set color(20,12) "seagreen2" set color(20,13) "seagreen3" set color(21,1) "seagreen4" set color(21,2) "palegreen1" set color(21,3) "palegreen2" set color(21,4) "palegreen3" set color(21,5) "palegreen4" set color(21,6) "springgreen1" set color(21,7) "springgreen2" set color(21,8) "springgreen3" set color(21,9) "springgreen4" set color(21,10) "green1" set color(21,11) "green2" set color(21,12) "green3" set color(21,13) "green4" set color(22,1) "chartreuse1" set color(22,2) "chartreuse2" set color(22,3) "chartreuse3" set color(22,4) "chartreuse4" set color(22,5) "olivedrab1" set color(22,6) "olivedrab2" set color(22,7) "olivedrab3" set color(22,8) "olivedrab4" set color(22,9) "darkolivegreen1" set color(22,10) "darkolivegreen2" set color(22,11) "darkolivegreen3" set color(22,12) "darkolivegreen4" set color(22,13) "khaki1" set color(23,1) "khaki2" set color(23,2) "khaki3" set color(23,3) "khaki4" set color(23,4) "lightgoldenrod1" set color(23,5) "lightgoldenrod2" set color(23,6) "lightgoldenrod3" set color(23,7) "lightgoldenrod4" set color(23,8) "lightyellow1" set color(23,9) "lightyellow2" set color(23,10) "lightyellow3" set color(23,11) "lightyellow4" set color(23,12) "yellow1" set color(23,13) "yellow2" set color(24,1) "yellow3" set color(24,2) "yellow4" set color(24,3) "gold1" set color(24,4) "gold2" set color(24,5) "gold3" set color(24,6) "gold4" set color(24,7) "goldenrod1" set color(24,8) "goldenrod2" set color(24,9) "goldenrod3" set color(24,10) "goldenrod4" set color(24,11) "darkgoldenrod1" set color(24,12) "darkgoldenrod2" set color(24,13) "darkgoldenrod3" set color(25,1) "darkgoldenrod4" set color(25,2) "rosybrown1" set color(25,3) "rosybrown2" set color(25,4) "rosybrown3" set color(25,5) "rosybrown4" set color(25,6) "indianred1" set color(25,7) "indianred2" set color(25,8) "indianred3" set color(25,9) "indianred4" set color(25,10) "sienna1" set color(25,11) "sienna2" set color(25,12) "sienna3" set color(25,13) "sienna4" set color(26,1) "burlywood1" set color(26,2) "burlywood2" set color(26,3) "burlywood3" set color(26,4) "burlywood4" set color(26,5) "wheat1" set color(26,6) "wheat2" set color(26,7) "wheat3" set color(26,8) "wheat4" set color(26,9) "tan1" set color(26,10) "tan2" set color(26,11) "tan3" set color(26,12) "tan4" set color(26,13) "chocolate1" set color(27,1) "chocolate2" set color(27,2) "chocolate3" set color(27,3) "chocolate4" set color(27,4) "firebrick1" set color(27,5) "firebrick2" set color(27,6) "firebrick3" set color(27,7) "firebrick4" set color(27,8) "brown1" set color(27,9) "brown2" set color(27,10) "brown3" set color(27,11) "brown4" set color(27,12) "salmon1" set color(27,13) "salmon2" set color(28,1) "salmon3" set color(28,2) "salmon4" set color(28,3) "lightsalmon1" set color(28,4) "lightsalmon2" set color(28,5) "lightsalmon3" set color(28,6) "lightsalmon4" set color(28,7) "orange1" set color(28,8) "orange2" set color(28,9) "orange3" set color(28,10) "orange4" set color(28,11) "darkorange1" set color(28,12) "darkorange2" set color(28,13) "darkorange3" set color(29,1) "darkorange4" set color(29,2) "coral1" set color(29,3) "coral2" set color(29,4) "coral3" set color(29,5) "coral4" set color(29,6) "tomato1" set color(29,7) "tomato2" set color(29,8) "tomato3" set color(29,9) "tomato4" set color(29,10) "orangered1" set color(29,11) "orangered2" set color(29,12) "orangered3" set color(29,13) "orangered4" set color(30,1) "red1" set color(30,2) "red2" set color(30,3) "red3" set color(30,4) "red4" set color(30,5) "deeppink1" set color(30,6) "deeppink2" set color(30,7) "deeppink3" set color(30,8) "deeppink4" set color(30,9) "hotpink1" set color(30,10) "hotpink2" set color(30,11) "hotpink3" set color(30,12) "hotpink4" set color(30,13) "pink1" set color(31,1) "pink2" set color(31,2) "pink3" set color(31,3) "pink4" set color(31,4) "lightpink1" set color(31,5) "lightpink2" set color(31,6) "lightpink3" set color(31,7) "lightpink4" set color(31,8) "palevioletred1" set color(31,9) "palevioletred2" set color(31,10) "palevioletred3" set color(31,11) "palevioletred4" set color(31,12) "maroon1" set color(31,13) "maroon2" set color(32,1) "maroon3" set color(32,2) "maroon4" set color(32,3) "violetred1" set color(32,4) "violetred2" set color(32,5) "violetred3" set color(32,6) "violetred4" set color(32,7) "magenta1" set color(32,8) "magenta2" set color(32,9) "magenta3" set color(32,10) "magenta4" set color(32,11) "orchid1" set color(32,12) "orchid2" set color(32,13) "orchid3" set color(33,1) "orchid4" set color(33,2) "plum1" set color(33,3) "plum2" set color(33,4) "plum3" set color(33,5) "plum4" set color(33,6) "mediumorchid1" set color(33,7) "mediumorchid2" set color(33,8) "mediumorchid3" set color(33,9) "mediumorchid4" set color(33,10) "darkorchid1" set color(33,11) "darkorchid2" set color(33,12) "darkorchid3" set color(33,13) "darkorchid4" set color(34,1) "purple1" set color(34,2) "purple2" set color(34,3) "purple3" set color(34,4) "purple4" set color(34,5) "mediumpurple1" set color(34,6) "mediumpurple2" set color(34,7) "mediumpurple3" set color(34,8) "mediumpurple4" set color(34,9) "thistle1" set color(34,10) "thistle2" set color(34,11) "thistle3" set color(34,12) "thistle4" set color(34,13) "gray0" set color(35,1) "gray5" set color(35,2) "gray10" set color(35,3) "gray15" set color(35,4) "gray20" set color(35,5) "gray25" set color(35,6) "gray30" set color(35,7) "gray35" set color(35,8) "gray40" set color(35,9) "gray45" set color(35,10) "gray50" set color(35,11) "gray55" set color(35,12) "gray60" set color(35,13) "gray65" set color(36,1) "gray70" set color(36,2) "gray75" set color(36,3) "gray80" set color(36,4) "gray85" set color(36,5) "gray90" set color(36,6) "gray95" set color(36,7) "gray100" set color(36,8) "darkgray" set color(36,9) "darkblue" set color(36,10) "darkcyan" set color(36,11) "darkmagenta" set color(36,12) "darkred" set color(36,13) "lightgreen" set backg gray85 set abackg gray50 set foreg black # Define the scrollbar procedure - "bf" is -1 for backward, 1 for forward proc scrl {bf} { global color global current_col global COLS_AT_ONCE global ROWS global LASTSCREEN global leftdisp global rightdisp global backg global abackg global foreg # See if we're at the first or last screen case $bf in { -1 { if {$current_col < $COLS_AT_ONCE} then { set current_col 1 } else { incr current_col -$COLS_AT_ONCE } } 1 { if {$current_col >= $LASTSCREEN } then { set current_col $LASTSCREEN } else { incr current_col $COLS_AT_ONCE } } 0 { } } if {$current_col == 1} then { .leftarrow configure -state disabled set leftdisp 0 } else { if {!$leftdisp} { .leftarrow configure -state normal\ -foreground $foreg\ -activebackground $abackg\ -activeforeground $foreg\ -relief raised } } if {$current_col == $LASTSCREEN} then { .rightarrow configure -state disabled set rightdisp 0 } else { if {!$rightdisp} { .rightarrow configure -state normal\ -foreground $foreg\ -activebackground $abackg\ -activeforeground $foreg\ -relief raised } } for {set c 0} {$c < $COLS_AT_ONCE} {incr c} { set col [expr $current_col+$c] set ind [expr $c+1] for {set row 1} {$row <= $ROWS} {incr row 1} { if {[info exists color($col,$row)]} { destroy .button($ind,$row) button .button($ind,$row) -width 20 pack append .fm$ind .button($ind,$row) {top fillx} .button($ind,$row) configure\ -text "$color($col,$row)"\ -background $color($col,$row)\ -activebackground $abackg\ -command "exec xsetroot -solid $color($col,$row)" } } } } ###################### Starts Here ########################## set COLS_AT_ONCE 4 set SIZE [array size color] set ROWS 13 #puts $SIZE set LASTCOL [expr $SIZE/$ROWS] set LEFTOVER [expr $SIZE%$ROWS] if {$LEFTOVER > 0} {set LASTCOL [expr $LASTCOL+1]} set LASTSCREEN [expr $LASTCOL-$COLS_AT_ONCE+1] #puts "LASTCOL = $LASTCOL LASTSCREEN = $LASTSCREEN" # Make and display the main window's widgets frame .ctl .ctl configure -background $backg pack append . .ctl {bottom fillx} button .leftarrow -text "<--" -command "scrl -1" .leftarrow configure -foreground $foreg\ -background $backg\ -activebackground $abackg\ -activeforeground $foreg\ -relief raised pack append .ctl .leftarrow {left} button .b -text "done" -command "destroy ." .b configure -foreground $foreg\ -background $backg\ -activebackground $abackg\ -activeforeground $foreg\ -relief raised pack append .ctl .b {left expand} button .rightarrow -text "-->" -command "scrl 1" .rightarrow configure -foreground $foreg\ -background $backg\ -activebackground $abackg\ -activeforeground $foreg\ -relief raised pack append .ctl .rightarrow {right} set leftdisp 1 set rightdisp 1 # Set up the buttons for {set col 1} {$col <= $COLS_AT_ONCE} {incr col} { frame .fm$col pack append . .fm$col {left} for {set row 1} {$row <= $ROWS} {incr row 1} { if {[info exists color($col,$row)]} { button .button($col,$row) -width 20 pack append .fm$col .button($col,$row) {top fillx} } } } set current_col 1 scrl 0