[Date Prev] [Date Next] [Thread Prev] [Thread Next] Date Index Thread Index Search archive:
Date:Mon May 23 17:11:46 1994 
Subject:Saving VED state 
From: Robin Popplestone  
Volume-ID:940526.01 

My own solution to  the problem I  posed about saving the  state of VED  is
below. Being very simple it merely writes the names of the currently open
VED files to a file ~/.vedsave When  POPLOG is restarted all these files
are opened in VED.  Robin.

===========================================================================

HELP ved_save                                Robin Popplestone May 1994

This file may be freely copied, preserving or updating the above
attribution.

ved_save and ved_restore provide a way of recording the state of VED during
one POPLOG session so that it can be restored in another session.

<enter> save         Write the current VED buffers to disk and record which
                     buffers were open in the file $HOME/.vedsave



<enter> restore      Read in the files that were open in VED at the last
                     save (with null argument).


It is worth putting

    uses ved_save

in your vedinit.p  file. This  will cause  a ved_save()  procedure call  to
happen on normal system exit. Note that the unix command

  kill -1 <pid>

can be used to kill a POPLOG process in such a way that this is done.  Thus
if you log in remotely to your workstation and remember that you have  left
a POPLOG running, you can kill it in this way, and then proceed to start up
another POPLOG, thus being able to access the files that were open  without
danger of confusion.

This is a rudely functional rather  than elegant facility. For example  the
files are restored as VED widgets rather  than icons, even if they were  in
iconic form when  saved. And when  iconified, the icons  will not have  the
same position they had when the save was done. No doubt if I pored  through
the documentation of XVED I could do better. Life (sigh!) is too short.

In XVED the call -ved_restore()- can be given as a POP-11 statement. In
ordinary ved, it should always be given as a the VED command:

    <enter> restore


[This file may be freely copied, preserving or updating the above
attribution.]

=========================================================================

;;; ved_save.p                               Robin Popplestone, May 1994

;;; This file may be freely copied, preserving or updating the above
;;; attribution.


/*
-ved_save()- first writes the files currently open in VED, and then
records their names.  -ved_restore()-, typically done
in a new invocation of POPLOG, re-opens those files (by name).

ved_save() will be done during a normal exit from POPLOG
*/

lconstant popexit_old = popexit;

define ved_save();
  lvars b;
  npr('Saving VED state');
  dlocal cucharout = discout('$HOME/.vedsave');
  ved_w();
  for b in vedbufferlist do
    printf('\'%p%p\'\n',[%b(2),b(1)%]);
  endfor;
  cucharout(termin);
enddefine;

define popexit();
  ved_save();
  popexit_old();
enddefine;

===============================================================================

;;; ved_restore.p                    Robin Popplestone, May 1994

;;; This file may be freely copied, preserving or updating the above
;;; attribution

;;; Reads in VED files whose names were saved by ved_save.

define ved_restore();
  lvars rep = incharitem(discin('$HOME/.vedsave'));
  lvars filename;
  until (rep()->>filename) == termin do
    ved_ved(filename->vedargument);
  enduntil;
enddefine;