Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

EPM restart feature (long)

0 views
Skip to first unread message

Joerg Schwieder

unread,
Mar 16, 1993, 10:57:08 AM3/16/93
to
Hi there!

Some people asked for my EPM macros for auto-reload and syntax coloring.
So here s some of it. What it does is saving the program state upon
shutdown and then trying to restart where you left it. That means if you
start EPM without parameters, the files that were active upon shutdown are
loaded and the cursor is positioned at its former position in the file.

1) The cursor thing is quite easy. All the macro does is storing the
current cursor and screen coordinates (.line, .col, .cursorx, .cursory) in
an extended attribute (EA) called EPM.POS whenever the file is saved or
quit. Currently, changes to savefile() and quitfile() commands are
necessary to do this cause there s no such thing as a defsave or
defquit statement, but these are announced for the next release.

2) Generally the restart thing should be even more easy, you just store a
list of active files before exiting and replace it for arg(1) in MAIN.E s
defmain proc whenever arg(1) is empty.
Unfortunately, defexit which sounds as being exactly the right thing for
this is only called when you close the last open file in EPM pressing F3
or QUIT ting. This doesn t help of course, cause quitting files is
exactly what we do NOT want to do. If you end EPM using either the frame
control, the task list or ALT-F4 defexit is not called.
My solution for this problem is to intercept all savefile(), loadfile()
(via defload), namefile() and quitfile() commands and keep track of all
the files in the ring. Everytime a file is loaded or created it is added
to the file list in a STARTUP_FILES entry in the .INI-file and everytime
a file is quit it is removed from that list.
My macros do NOT store temp files (files with names starting with a . ).
You may want to change this.

Because I had to change all these standard EPM-files, it would be too much
code to post it completely so I just document the changes made. Also, this
may help you keep your own changes.

If there s to be a new release of EPM 5.51 soon (Larry Margolis wrote
something like that on Mar. 12) that supports hooks in save, load, quit
and main, this becomes much more easy and you don t have to change your
standard macro fielset so you might want to wait for this release to come.

I don t post the color support here because it does not yet work as I want
it to. I ll post it as soon as it s done but I ve some other work to do
besides from configuring my editor. Maybe I ll have it ready next week.

Joerg


Thats it:

/*** This has to be included at the beginning of MYSELECT.E, MAIN.E and
SAVELOAD.E ***/

define
compile if EVERSION >= '5.20' -- 5.20 adds a HINI to the *Profile calls.
HINI_PARM = 'app_hini,'
compile else
HINI_PARM = ' '
compile endif

/*** Add the following line to the universal statement in your defmain and
to the universal ***/
/*** statements in the procs savefile(), namefile() and quitfile() in
SAVELOAD.E ***/
/*** These are needed for the applications .INI-file handle ***

universal appname, app_hini /* .INI-file handles */

/*** The first line is from the standard MAIN.E. The rest has to be
inserted after it ***/
doscmdline = 'e 'arg(1) /* Can do special processing of DOS command
line.*/

if doscmdline='e' then /* if no parameters specified ...
*/
doscmdline ='e 'queryprofile( $HINI_PARM appname, 'STARTUP_FILES' )
/* ...add the ones from 'STARTUP_FILES' */
endif

/*** These are the changes to savefile(). Statements in comments show the
position in the original ***/
/*** file where the changes have to be added ***/

/*** universal ... statements ***/

delete_ea('EPM.POS') /* delete old 'EPM.POS' entry in
the EAs */
psave_pos(screenpos) /* get cursor and screen
position,... */
'addea EPM.POS' screenpos /* and store it in the EA */
oldfile = .filename /* needed for STARTUP_FILES */

/*** 'deleteautosavefile' ***/

else /* if not rc... */
filelist = queryprofile( $HINI_PARM appname, 'STARTUP_FILES') /*
get the old file list */
if wordpos(oldfile, filelist) then /* if old filename
is in list */
filelist = delword(filelist, wordpos(oldfile, filelist), 1) /*
delete it */
endif
if (not wordpos(.filename, filelist)) and (substr(.filename,
lastpos('\', .filename) + 1, 1) <> '.') then
filelist = .filename' 'filelist /* Add actual filename if
its not a tempfile ('.---') */

/* remove the 'and (substr...' section if you want to restart temp
files */
endif
setprofile( $HINI_PARM appname, 'STARTUP_FILES', filelist ) /*
store the new list */

/*** endif ***/

/*** Now for namefile() ***/

/*** universal... */
oldfile = .filename

/*** Add this at the end of namefile() ***/

filelist = queryprofile( $HINI_PARM appname, 'STARTUP_FILES') /*
same as for savefile() */
if wordpos(oldfile, filelist) then
filelist = delword(filelist, wordpos(oldfile, filelist), 1)
endif
if (not wordpos(.filename, filelist)) and (substr(.filename,
lastpos('\', .filename) + 1, 1) <> '.') then
filelist = .filename' 'filelist
endif
setprofile( $HINI_PARM appname, 'STARTUP_FILES', filelist )

/*** ... and for quitfile() ***/

/*** 'deleteautosavefile' ***/

filelist = queryprofile( $HINI_PARM appname, 'STARTUP_FILES') /*
just delete entry */
if wordpos(.filename, filelist) then
filelist = delword(filelist, wordpos(.filename, filelist), 1)
endif
setprofile( $HINI_PARM appname, 'STARTUP_FILES', filelist )


/*** The following are additions to MYSELECT.E ***/

defload /* sme as for namefile and savefile, just
that there are no old names to delete */
universal appname, app_hini
filelist = queryprofile( $HINI_PARM appname, 'STARTUP_FILES')
if (not wordpos(.filename, filelist)) and (substr(.filename,
lastpos('\', .filename) + 1, 1) <> '.') then
filelist = .filename' 'filelist
endif
setprofile( $HINI_PARM appname, 'STARTUP_FILES', filelist )

defload /* This one's for setting the Cursor and
window position for the loaded file */
if find_ea('EPM.POS', ea_seg, ea_ofs, ea_ptr1, ea_ptr2, ea_len,
ea_entrylen, ea_valuelen) then
/* if there's ab EPM.POS EA...*/
getfileid myid /* that's the actual file */
'postme restore_ORG_pos 'myid get_EAT_ASCII_value('EPM.POS')
/* have to post it 'cause the screen may not yet be painted. Also
I had to make this */
/* the last of my defloads to make it work correctly */
endif

defselect /* This one makes shure that the file that was on to on
shutdown will reappear there on startup */
universal appname, app_hini
filelist = queryprofile( $HINI_PARM appname, 'STARTUP_FILES')
if wordpos(.filename, filelist) then
filelist = delword(filelist, wordpos(.filename, filelist), 1)
endif
if (not wordpos(.filename, filelist)) and (substr(.filename,
lastpos('\', .filename) + 1, 1) <> '.') then
filelist = .filename' 'filelist
endif
setprofile( $HINI_PARM appname, 'STARTUP_FILES', filelist )


defc restore_ORG_pos /* This sets the cursor and screen-positions. It
does the same as */
/* prestore_pos except for
being passed the fileid as first parameter */
parse value arg(1) with myid fline fcol cx cy
myid.cursorx = cx
myid.cursory = cy
myid.line = fline
myid.col = fcol

--
-------
Joerg Schwieder
qwer...@w271zrz.zrz.tu-berlin.de
ki...@cs.tu-berlin.de

0 new messages