home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Fred Fish Collection 1.5
/
ffcollection-1-5-1992-11.iso
/
ff_progs
/
scrnutil
/
sct.lzh
/
SCT
/
SCT.DOC
< prev
next >
Wrap
Text File
|
1991-08-16
|
9KB
|
203 lines
SetColorTable (or SCT for short) is a CLI-based utility for displaying and/or
setting a screen's colors. It will allow you to change any or all of the
colors for any screen whose "Screen Title" you know. You can save the colors
of a screen to be restored later, or easily copy one screen's colors to another.
It works by creating an array of ColorTable entries and calling LoadRGB4.
SetColorTable is Copyright 1988 by aklevin. All rights reserved.
I copyrighted this because of all the talk of copyrighting, copy"wronging",
and such on USENET. SCT may not be sold without my express written permission.
SCT may, however, be copied and distributed in a not-for-profit manner.
First an explanation of color values as they pertain to SCT:
Color values are specified as a four digit hexadecimal number (Xrgb) using
the following convention:
Each of r, g, and b (red, green, and blue) is a hexadecimal digit ranging
from 0 (none of that color) to f (the full amount of that color).
So, as examples, black=000, medium red=800, yellow=ff0, white=fff.
The first digit (X) is an indicator flag. If this digit is 0 (or is omitted),
the rest of the number will be used as a color value to alter an entry in the
ColorTable. If this digit is a 1, it indicates that this value is to be
skipped, it is only a placeholder to keep remaining values in sync.
If this digit is a 2, it indicates that this value is to be skipped,
and that there are no more values to be changed. It is used when a less-
then-complete set of color values is being entered from stdin.
As an example, the Workbench screen has four colors,
and so has four entries in it's ColorTable:
+- Background color (blue)
| +- Text color (white)
| | +- Highlight color (near-black)
| | | +- Cursor color (orange)
| | | |
V V V V
RGB RGB RGB RGB
05a fff 002 f80 <- These are the RGB values for each ColorTable entry.
The default Workbench colors would be given to SCT with:
"SCT 005a 0fff 0002 0f80".
Other screens may have more colors than this. You can find out by typing:
"SCT 2000" which will display the RGB value for each entry the table has.
The `2' in `2000', as explained above, makes that value a flag which tells
SCT that there are no more RGB values to be read in. Since it is the only
value given, SCT won't change *any* entries.
There are two ways that SCT can get it's RGB values: from the command line,
and from stdin (standard input). You should use command line input when you
know explicitly how you want to change the ColorTable. You should use stdin
when the ColorTable values are in a file, and you want SCT to get them from
there. Each way will be discussed separately.
Input from the Command Line:
SCT Xrgb Xrgb Xrgb...
This instructs SCT to change the first N entries in the Workbench Screen's
ColorTable (where N = the number of RGB values typed). The Workbench Screen
has four colors; if you type fewer than four, only that many entries will
get modified. If you type more than four, the extra ones are ignored.
Remember that the X in each of those rgb values stands for an indicator flag.
So, a value of 0f8f (or f8f) means "use this value to change the corresponding
ColorTable entry to pink". A value of 1f8f (or 1000, or any four-digit number
beginning with a `1') means "ignore this value, but keep going". You'd use
this if you wanted to change one entry without disturbing previous ones.
For example, suppose that your Workbench Screen's colors are currently
357 fff 000 0bd, and you want to change the highlight color (third entry)
from black (000) to white (fff). You could type "SCT 0357 0fff 0fff 00bd"
and that would work. But now suppose that you didn't know what any of the
four values were to begin with (you could use "SCT 2000" to find out, but
bear with me). Then you can use "SCT 1000 1000 0fff 1000" and only the third
entry will be changed. In fact, you can leave out the last `1000' since with
command line input, SCT only changes as many entries as it has values.
SCT >colorfile Xrgb Xrgb Xrgb...
As above, but rather than printing the Workbench Screen's colors, SCT puts
them in the file called `colorfile'. Later, using the stdin form of SCT,
they can be read back in. If you don't want the current values printed out,
and also don't want them sent to a file, use "SCT >NIL: Xrgb Xrgb Xrgb... ".
SCT -t "Screen Title" Xrgb Xrgb Xrgb...
Like "SCT Xrgb Xrgb Xrgb... " above, but instead of operating on the
Workbench Screen, SCT searches for a screen whose title is "Screen Title"
and displays and/or changes the ColorTable for it. Note that you must know
the exact title of the screen to specify it to SCT. Some screens don't show
their title, some screens don't even have a title. I have included another
little utility I wrote called `Cruise', which will show you the titles of all
open screens and their windows. From that you can probably tell whether or
not your screen has a title. If it doesn't, you can either give up, or modify
SCT.c to default to the ActiveScreen (sic), rather than the Workbench Screen.
I recommend the latter approach, and I'd like to see your work if you
do it. Also note that screens other than the Workbench Screen
can have 2, 4, 8, 16 or 32 ColorTable entries.
SCT >colorfile -t "Screen Title" Xrgb Xrgb Xrgb...
As above, but rather than printing the "Screen Title" screen's colors, SCT
puts them in the file called `colorfile'. Later, using the stdin form of SCT,
they can be read back in. If you don't want the current values printed out,
and also don't want them sent to a file, use "SCT >NIL: Xrgb Xrgb Xrgb... .
Input from Stdin:
SCT <colorfile
Like "SCT Xrgb Xrgb Xrgb..." above, but instead of receiving the RGB values
from the command line, SCT gets them from the file `colorfile'.
Values can be one to a line or separated by spaces.
SCT <colorfile -t "Screen Title"
Like "SCT -t "Screen Title" Xrgb Xrgb Xrgb..." above, but instead of receiving
the RGB values from the command line, SCT gets them from the file `colorfile'.
Please note that when you use " >file", " <file" or " >NIL:" (this is known
as input and output redirection) it must come before any Xrgb values, as well
as a screen title option, so "SCT 2000 -t "A Title" >NIL:" won't work.
Now for some useful examples:
There are some programs out there that don't look too good with the Workbench
colors I choose to use. As a matter of fact, there are some programs that
don't look too good even with the default Workbench colors.
There are also some programs for which I always find myself calling up
`Preferences' to change the colors so that the text that looked good with the
programmer's Workbench colors is readable with mine. I quickly got tired of
that, and wrote SCT. Now I have a command script with:
SCT >t:colors 1000 00bd
Here I call the program.
SCT >NIL: <t:colors
The first line saves the current colors in a temporary file and then
changes the text color of the Workbench screen to a light blue.
The second line starts up the program that used to look bad. When it is done
executing, the third line restores the saved colors from t:colors.
To display the Workbench color values:
SCT 2000
The 2000 is used to indicate that no colors are to be changed.
To copy the colors from one screen to another:
SCT >NiceColors -t "Nice Screen" 2000
SCT >NIL: <NiceColors -t "Other Screen"
The first line saves the colors of the screen whose title is "Nice Screen"
in the file NiceColors. The second line "restores" the colors of the screen
whose title is "Other Screen" using the contents of NiceColors.
To swap the colors of two screens:
SCT >ColorA -t "Screen A" 2000
SCT >ColorB <ColorA -t "Screen B"
SCT >NIL: <ColorB -t "Screen A"
(You can probably figure these out on your own by now, eh?)
Keep in mind that if the two screens do not have the same number of colors,
the one with more will end up with those extra colors unchanged.
To swap the colors of two screens regardless of the number of colors:
(The ColorTable is repeated to make up the difference.)
SCT >ColorA -t "Screen A" 2000
join ColorA ColorA ColorA ColorA as temp
join temp temp temp temp as ColorA
SCT >ColorB <ColorA -t "Screen B"
join ColorB ColorB ColorB ColorB as temp
join temp temp temp temp as ColorB
SCT >NIL: <ColorB -t "Screen A"
The first line saves the colors of "Screen A" in the file `ColorA'.
There may be as few as two colors in this screen, so it must be
duplicated 16 times to be *certain* of containing at least 32 entries
(Remember, extra entries are ignored).
The second and third lines duplicate it four times each, giving 32 = 2*4*4.
The fourth line colors "Screen B" with these values, while saving
"Screen B"'s colors in `ColorB'.
The fifth and sixth lines duplicate the number of entries by 16.
The seventh line colors "Screen A" with these values.
A poor man's screen blanker:
SCT >t:SaveColors 0000 0000 0000 0000
date ?
SCT >NIL: <t:SaveColors
The first line saves the current colors and sets the screen to all black.
The second line invokes the date command, and the question mark makes it wait
for you to press return before executing. Once that is done, the third line
resets the saved colors.