From: gordon@maxwell.uwaterloo.ca (Gordon R. Strachan)
Subject: Problem with vue (and solution)
Reply-To: gordon@maxwell.uwaterloo.ca (Gordon R. Strachan)
Organization: University of Waterloo
Date: Sun, 24 Jan 1993 03:47:38 GMT

I have always had one particular problem with vue, and I am sure I am not
alone in this.  The situation has to do with the way the filemanager
handles actions for which there are no X clients.  For this, it simply
launches an hpterm in slave mode and runs the program in it.  The most
common example is when the user selects the edit action to view a file.  The
filemanager brings up a slave hpterm with vi running in the window.  While
this seems to work, it does have some problems, particularly with vi.  The
user thinks he has a normal X application in front of him and when he wants
to get rid of the window he simply closes it with the mouse.  The hpterm
then proceeds to kill its attatched process, vi in this example, and close
the window.  But, it closes vi very rudely.  If the user was making any
changes they can be lost.  At the very least, vi doesn't clean up its
temporary files and slowly my /tmp and /usr/preserve directories get
filled up with dead vi files.

Of course, this really isn't a major problem but it is an annoyance and can
be fustrating for the niave user.  The real problem is that vue is trying
to make every program look like a smart X program even when it isn't.  To do
this, they used the hpterm in a slave mode to do this when it really wasn't
cut out to do this.  The program in slave mode allows the none X programs
to display text and key press events from the X server but that's all.  In
order to solve problems like the one I mentioned above we require a much
more intelligent program than this.  What is needed is a program that performs
similar functions to the hpterm in slave mode and will also inform the program
it is controlling about other X events such as window resizing, window
closure or mapping etc.

I decided to write such a program and it has proved to be a pretty good
solution to this problem.  We have been using it around here for a few months
now and I thought I would release it on the net for other to try and get me
some feedback.  It is fairly large so I hope no one objects to me posting it
here.

The program is in two major parts.  The first, and the largest, is a terminal
emulator widget.  It is a complete standalone widget that does a very
complete (although not 100%) emulation of a term0 widget.  It can also be
configured to emulate a vt100 terminal.  Since this section is a widget, it
can be used in other programs.

The second section is the program managment program which I call XControl.  It
provides a terminal emulator for the child process it runs.  It has a series
of commands which perform actions on the child process and set list of X
events which trigger these commands.  For example, in the distribution I have
configure XControl to manage a vi process.  It loads the program and allows
the user to edit normally.  If he were to try to close the window, it puts
up a prompt dialog and asks the user if he wants to save the file before he
exits.  If the user hits the yes button, the program instructs the editor to
save its file and then exit.  If the user does not want to save then the
program will tell vi to exit cleanly.

I have also added some code to the program to provide some further interaction
with the vue environment.  It will interact with the session manager to save
and restart cleanly (and, if configured can instruct the child process to
do the same) and also to respond to drag and drops from the filemanager.  This
latter functionality was done through some terrible hacking and is not
guaranteed to work under 9.0.

Anyway, the code will follow.

Enjoy
Gordon

Newsgroups: comp.sys.hp