rbogen%dreams@Sun.COM (Richard Bogen) (09/16/89)
%The following procedures display the contents of the operand stack or
%user dictionary for some interactive psh process. This file should
%be loaded into a psh and then the routines invoked with two parameters,
%the x & y location of the top left of a bounding rectangle for the
%display of the items. The contents of the display are updated every
%second. For example, 800 600 trackstack => process(..) object
%
% Author: Richard A. Bogen - Sun Microsystems, Inc. - 1989
%
/trackstack {% x y => process. Displays contents of parent's operand stack.
{/OperandStack get} {100 string cvs} showobj} def
/trackdict {% x y => process. Display contents of parent's userdict.
{/DictionaryStack get 1 get}
{exch 100 string cvs ( : ) append
exch 100 string cvs append}
showobj} def
/showobj {% common routine for Operand Stack or Dictionary display
10 dict begin
/makestring exch def %converts item to a sting
/getobj exch def %obtains object to be displayed
%First compute dimensions of items to be displayed
/y0 exch def
/x exch def
/wd 30 def %maximum number of chars permitted per item
(M) stringbbox wd mul %assumes (M) is the widest character
/wide exch def % in the current font
2 add /high exch def %allow 2 units between each line
pop pop
/parent currentprocess def
%Now fork off a process to do the displaying
{
{parent /State get /zombie eq {currentcolor fillcanvas exit} if
wide parent getobj length high mul dup neg y0 add /y exch def
x y moveto rect 0 setgray %display in black
parent getobj
{makestring dup length wd gt
{0 wd 1 sub getinterval} if
dup stringwidth pop
neg wide add 2 div x add y moveto
show /y y high add def } forall
gsave stroke .0333 sleep grestore
RootColor setcolor fill
} loop
} fork
end} def