Crunch CRiSP File Editor 6 User Manual
Page 43

Page 43
An arbitrary number of macros may be registered for the same event. If more than one macro is registered
for the same event, then the macros are called in the order they were registered.
Registered macros are convenient short-hand ways of intercepting certain operations within CRiSP.
Type
Description
0
(REG_TYPED) This macro is called every time a character is inserted into a buffer via
(self_insert).
1
(REG_EDIT) This macro is called whenever (edit_file) is called.
2
(REG_ALT_H) This macro is called whenever the user presses
command prompts.
3
(REG_UNASSIGNED) This macro is called if the user presses a key which does not
have a macro bound to it.
4
(REG_IDLE) This macro is called whenever the idle timer goes off. The idle timer is set
by the CRiSP command line switch (-i). It defaults to 60 seconds.
5
(REG_EXIT) This macro is called when CRiSP is about to exit. It is designed to allow
macros to tidy up after themselves (e.g. delete temporary files).
6
(REG_NEW) This macro is called whenever a new file is read into a buffer via (edit_file).
7
(REG_CTRLC) This macro is called whenever the interrupt key is pressed. To avoid
confusion, CRiSP sets the interrupt key 'out of the way' to
mapped to the center-line-in-window macro).
This feature allows macros to be interrupted. Following the usual safe programming
style, it is only a good idea to set a flag in the interrupt handler and test its value in the
main-line macro.
8
(REG_INVALID) This macro is called if the user types an invalid key at the command
prompt. This macro allows the abbreviations and command history feature to be
implemented.
9
(REG_INTERNAL) This is called when CRiSP detects a segmentation violation. This can
be used to write all buffers away to disk in an emergency. (Refer to core.cr for an
example of this macro).
10
(REG_MOUSE) Called when a mouse button is pressed or released.
11
(REG_PROC_INPUT) Called when process input available from a process buffer.
12
(REG_KEYBOARD) Called when keyboard buffer empty. This macro MUST return an
integer value. If the value is zero, then keyboard input can be read. If it is non-zero, then
the keyboard should not be read, but the internal code will check the push-back buffer
for input.
13
(REG_SELECTION) Called when data is available from the PRIMARY selection after the
get_selection() macro has been called. This will only happen on windowing systems
supporting the ICCCM cut & paste mechanism.
14
(REG_DRAG_N_DROP) This is the drag'n'drop trigger. Currently it is only supported in
the XView version of CRISP. When this macro is registered, then the macro will be
called when the user drops a file icon into the CRiSP window. The macro is passed a
string argument corresponding to the name of the file to be edited.
15
(REG_INPUT_FILENAME) This is the input-filename trigger. It allows a macro to be
written which intercepts files being read into a buffer. The macro should return a string
value which is the mapped name of the file (or the original filename unchanged). This
trigger allows a macro to be written that allows files to be edited which are dynamically
uncompressed when read in, for example. See the crisp.cr (infile_trigger macro) for an
example of use.
16
(REG_OUTPUT_FILENAME) This is the output-filename trigger. This allows macros to
be written which intercept all files which are written to and allows them to perform some
file-name specific action. For example, an attempt to write to a symbolic-link could cause
a macro to check if the file is a symbolic link and if so remove the symlink and write a