[comp.windows.news] getcolors: saves the current screen colors

sjs@jcricket.ctt.bellcore.com (Stan Switzer) (10/21/88)

Ok, fine.  Now I have pretty colors on my screen.  Do I have to set
them up every time I log in?  What a hassle!

No problem.  This little ditty produces a postscript program that when
run sets your colors back to what they are right now.

If you have all been good little hackers, you will have already
installed my window patches in your user.ps file.  One of the last
things that file does is to check to see if a file called "color.ps"
or "mono.ps" exists (in the current directory, presumably $HOME) and
if so runs it.

Suggested use:
  1) Get the colors just the way you like them.  (Use good judgement.
     Other people may have to look at your screen someday!)
  2) On a color workstation: getcolors >~/color.ps
  3) On a mono workstation: getcolors >~/mono.ps

Again, as always, enjoy!

Stan Switzer sjs@ctt.bellcore.com

P.S.:  Ignore article's reply address since my poster mungs it; use
signature address instead.
-------------------------------------------------------------
#!/usr/NeWS/bin/psh
%
% getcolors: output postscript program to restore current colors.
%
% Copyright (C) 1988 by Stan Switzer. All rights reserved.
% This program is provided for unrestricted use, provided that this 
% copyright message is preserved. There is no warranty, and no author 
% or distributer accepts responsibility for any damage caused by this 
% program.
%

/OrigColor currentcolor def

/Ip { 100 mul dup 99 gt
  { pop (1) print } { (0.)print .501 add cvi
    dup 10 lt { (0) print } if (xxxxx) cvs print } ifelse } def

/P {
  dup type /Z type eq { dup 50 string cvs (/) print print } if
  dup type 11 type eq { dup Ip } if
  dup type .1 type eq { dup Ip } if
  dup type () type eq { dup print } if
  pop
} def
/X { (  ) print
  [ exch dup load setshade currentrgbcolor  ] { P ( ) print } forall
  ( rgbcolor store\n) print } def
/X? { currentdict 1 index known { X } { pop } ifelse } def 

/DefaultRootGrayOrColor X
/backgroundcolor X
/textcolor X

LiteWindow begin (LiteWindow begin\n) print
  (  /ClientFillColor backgroundcolor store\n) print
  /FrameFillColor X
  /KeyFocusColor X
  /IconFillColor X
  /IconBorderColor X
  /IconTextColor X
(end\n) print end

UserProfile begin (UserProfile begin\n) print
  /NtermTextColor X?
  /NtermFillColor X?
  /NtermCaretColor X?
(end\n) print end

({ framebuffer setcanvas PaintRoot\n) print
( { /setfgcolor where { pop % Hack Warning (find nterm windows)\n) print
(  /NtermTextColor UserProfile 1 index known { UserProfile exch get\n)print
(    dup /setfgcolor Text send /setfgcolor Win send } { pop } ifelse\n) print
(  /NtermFillColor UserProfile 1 index known { UserProfile exch get\n) print
(    dup /setbgcolor Text send /setbgcolor Win send } { pop } ifelse\n) print
(  /NtermCaretColor UserProfile 1 index known { UserProfile exch get\n) print
(    /setcaretcolor Text send } { pop } ifelse \n) print
( } if /paint self send} AllWin } fork pop\n) print

10 { pause } repeat

OrigColor setcolor

% ---- anything below this line is NOT part of the program ----