#! /bin/csh

#  XWIN
#  Bruce Krulwich, ILS

#  Pops up an X window and sends anything from standard-input to the window.
#  Designed for use by a LISP process or anything else needing easy output
#  to an X window.  

#  Requires that XWIN_CLIENT be in the path.
#  ~/bin/xwin

set tmpfile = xwin_$$

loop1: 
	if (-f /tmp/$tmpfile) then
		set tmpfile = $tmpfile_2
	endif

xterm -title xwin -si -sl 200 $argv -e xwin_client $tmpfile &

loop2: 
	if (!(-f /tmp/$tmpfile)) then
		goto loop2
	endif

loop3:
	set windev = `cat /tmp/$tmpfile`
	if ($windev == "") then
		goto loop3 # nothing in the file yet
	endif

# This is for debugging.  In general it will have to be cleaned out sometime.

echo "XWIN PID is $$ args are $argv"  >> /tmp/xwin_data
echo "         window DEV is $windev" >> /tmp/xwin_data

\rm /tmp/$tmpfile   # used to mv /tmp/$tmpfile /tmp/xwin_latest

cat > $windev
