beautypg.com

Crunch CRiSP File Editor 6 User Manual

Page 40

background image

Page 40

Autosaving is a feature enabled by default, whereby any modified files (buffers) within the current editing
session are saved at 60 second intervals when there is no keyboard activity. This ensures that if you walk
away from an editing session and the system crashes, that a copy of your work will be saved. The
autosaved file is given a different name to the real file name to avoid prematurely committing changes to the
file. These autosaved files are automatically deleted when the user exits from CRiSP.

CRiSP itself does not directly implement autosaving; instead, it is a macro which is supplied with CRiSP.
CRiSP supports the mechanism for implementing the autosave feature. If any user does not like the
mechanism, then he/she can modify the macro to make it do what is really wanted.

Autosaving is implemented via the idle timer. The idle timer is a timer which is maintained by CRiSP. The
idle timer goes off when the user hasn't typed anything for 60 seconds. (This is configurable via the
command line). The autosave macros looks at each non-system buffer, and writes out the buffer if it has
been modified.

Autosaved files are written to a file with a different filename from the original to avoid destroying the original
before the user is committed to keeping it. The actual filename used is operating system independent, and is
a function of the real file name. Under Unix, if the file is called foo.c, then the file is saved in a file called
@foo.c@. The use of the @'s is to make the files stand out when performing a directory listing. The prefix
'@' is useful since if for some reason CRiSP does not delete the autosaved files, then it is easier and safer
to issue an 'rm @*' command than an individual rm for each file. The trailing '@' is added on so that if the
user issues a command such as:

ls *.c

then the autosaved files don't get included in the list. The major objective here is to avoid sticking on a long
suffix (e.g. .asv) to a file name on systems such as V.3 Unix, which only have 14 character file names
anyway). Adding suffixes to a filename is a dangerous game since the original filename may already be at
the 14-character filename limit, and the suffix would get ignored. Having a prefix and suffix seems to be the
best of both worlds.

Under DOS, Windows/NT or OS/2 with the FAT file system, a .asv extension is used instead, due to
limitations on the lengths and styles of filenames.

These autosaved files are deleted when CRiSP exits.

When the autosave macro runs, it prints the message Autosaving... followed by Autosave complete when
it has finished.

Core dumping

In the case the previous two mechanisms are insufficient to save the files you are editing on, CRiSP has a
further dramatic file saving feature. If CRiSP detects an internal segmentation violation or other error which
might cause CRiSP to die, then a special emergency macro is executed. This macro is implemented via the
REG_INTERNAL registered macro. The code for this may be found in the core.cr file. It basically saves
away all modified files (after prompting the user), to files called BUFFER.1, BUFFER.2, etc.

This macro is designed to be as minimal as possible and not rely on all aspects of CRiSP being able to
work.

If CRiSP crashes it is most likely to be due to some strange combination of events which caused it to corrupt
memory, and so the core macro has a good probability of succeeding in its attempt to save files.

Regions and markers

A region, or marker, is an area of the current buffer which can be manipulated independently of the rest of
the text in the buffer. Most commonly regions are used to highlight a block of text which is to subsequently
be deleted or copied to some other buffer. A region is created by typing one of the four keys: , C>, or . Each of these different keys creates a different type of region. When the cursor is
moved, the area of text from where the marker was dropped and the current cursor position is called a
region. Certain editing commands change their functionality whilst a region is highlighted, e.g. the key
deletes the currently highlighted region, rather than the character the cursor is on.

Column regions are not implemented directly by CRiSP, but instead are manipulated by various macros.
CRiSP only supports the screen drawing necessary to draw a rectangular marker.

There are four different types of regions, each one accessible from a different function key: