home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Datafile PD-CD 3
/
PDCD_3.iso
/
utilities
/
utilst
/
zap
/
!Zap
/
Docs
/
E-Command
< prev
next >
Wrap
Text File
|
1995-06-19
|
22KB
|
552 lines
*************************************************************************
* >E-Command Documents how to add commands to Zap *
*************************************************************************
As mentioned in the ReadMe file, commands are added to Zap by registering a
table of commands when the module providing the extra commands initialises.
You should use the call Zap_AddCommands to register the table. The table has
the format below. All offsets are from your module start unless otherwise
indicated.
#0 Offset of table from start of module (so Zap can convert the
offsets below into addresses).
#4 Offset from module start of 'Zap service call code' or 0
if none. Zap calls this entry point to tell you about
various things - see the section below.
#8 List of commands, terminated by a zero word. Each element
of the list has the format:
<command name>+<0 byte terminator>+
<ZERO bytes padding until word aligned>+
<word giving command offset from module start>
The command name must be in UPPER CASE in this table. In general, command
names are not case sensitive, but they are converted to upper case in order
to search for them in the command tables. The characters padding to the next
word alignment MUST be ZEROs as the table is searched through in words not
in bytes.
When a command is found in the table, its address is calculated, and
henceforth the command is referred to by its address. This unfortunately
means that I cannot pass the command your module workspace when the command
is called as I do not know which module the command lies in. This is not
usually a problem however as you may claim workspace from Zap's heap. If this
is not sufficient, then you will just have to store the address of your
workspace in the module itself and read it when you are called (until I work
out a better method).
The address of the command is of course the address called when the command
is executed. However, at offset -4, the word before the first instruction of
the command, some flags are stored. These flags determine what type of
parameter the command takes and how the command interacts with the
minibuffer and menus. This word must be filled in. It's meaning is summarised
below. Greater detail is given further down the file.
b0 Set if the command doesn't need R10 on entry (eg called from
b1 Set if the command doesn't need R8 on entry a menu).
b2 Set if the command doesn't need R9 on entry
b3-b5 Argument type for the command:
0 = Command takes no parameters
1 = Command takes a list of bytes as parameter
2 = Command takes a list of words as parameter
3 = Command takes a string as parameter
4 = Command takes a block of data as parameter
5-7 reserved
b6 Set if you wished to be called before minibuffer opened
b7 Set if you wish to be called after every minibuffer update
b8 Set if you wish to be called before a key is inserted into
the minibuffer (and possibly alter it).
b9 Set if you want TAB to complete file names in the minibuffer
b10 Set if you may want to kill the minibuffer when it starts up.
b11 Set if you may want minibuffer to remain open when command finished.
b12 Set if Universal arg should multiply R1 by the number of times to do.
b13 Set if command should be called repeatedly with R1 smaller.
b14 Set if the command should not be executed when loading a file.
b15 Set if the command is 'tickable' when on a menu entry.
b16 Set if the command can create a submenu or leaf window.
b17 Set if the command can provide a default string for a menu entry.
b18 Set if the command wishes to provide the menu entry text.
b19 Set if the command wishes to specify the submenu.
b20 Set if the command may wish to remove the menu entry.
b21-b31 Reserved - set to 0
The entry/exit conditions of your command depend on your flags word as I will
detail below. When the command is called the registers have the meaning:
R0 = input data for the command (dependent on R2 & command type - see below)
R1 = length of input data (dependent on R2 & command type - see below)
R2 = action code (details below)
R8 = window of the input caret (see E-Windows) (unless flags b1 set)
R9 = file block associated with R8 (see E-File) (unless flags b2 set)
R10 = cursor block pointer of input cursor (see E-Cursors)
(unless flags b3 set) (This is car_cursor if the cursors are combined
and car_input if they are split - see E-Vars).
R11 = undefined
R12 = Zap's workspace
R13 = small FD stack
ALL calls to your command have these registers set up. The descriptions of R0
and R1 given above are for action code R2=0 (execute the command). In general
their meaning will be dependent on R2 and are undefined otherwise. Note that
you are only called with the action codes you request via your flags word so
do not need to test for all possible action codes.
On exit from a command you may corrupt the registers R0-R11 and the flags.
You should return V flag set and R0=error block on error. Some of the calls
with R2<>0 require you to return a result in R0. To detail the actual meaning
of R0-R2 I have partitioned into cases below. Registers not mentioned are
undefined.
If you want to call a command yourself, then please use the call
Zap_ProcessCommand or Zap_CommandString. All calls from Zap are made by this
method. See the file 'Commands' for the syntax used when typing a command
into the keys file, or sending it to Zap_CommandString.
NB Only command calls with R2=0 or R2=1 are learnt. All other calls are
regarded as 'setup' calls and are not learnt.
************************
* Details of flag bits *
************************
Bit 0
-----
If this bit is set then R10 is undefined on entry. If it is clear then the
current position of the input cursor will be read if R10 is not specified (ie
is 0) when Zap_ProcessCommand is called. Note that reading the current
input cursor position may change R8 and R9 as well.
This is useful when the command is called from a menu. The menu may not be on
the window with the input focus. If this bit is set then the command can act
on the menu the window is on, where as if it is clear then it will always act
on the window with the input focus. Thus it should be set for any command
which only affects the window state and doesn't need to know the cursor
position.
Bit 1
-----
If this bit is set then R8 either points to a window or is 0 on entry. If 0
then the command is being called from the options menu to change the default
state. If the bit is clear and Zap_ProcessCommand is called with R8=0 then an
error is given.
Thus this bit should be set for commands which don't need to know where the
cursor is and can change the default options as well as the current window
state. If this bit is set then you should also set Bit 0.
Bit 2
-----
As for Bit 1 except that the file pointer R9 is checked instead of R8. If the
command is called from the options menu then both R8 and R9 will be 0.
Bits 3-5
--------
These determine what type of data the command takes. When the command is
executed it is called with R2=0. In general the meaning of R2>0 is documented
under the Bit with value R2. Note that Bits 12 and 13 are used in deciding
which value is passed in R1. When the command is called with R2=0 additional
information is passed in R3:
R3 = b0 Set => This command was executed as the last command as well.
(eg to spot cumulative ctrl K's/Yanks).
b1-b27 => Reserved
b28-b31=> Top bits of R2 when command called via Zap_ProcessCommand.
Data type None (0) is called with:
R0=undefined
R1=number of times the key has been pressed (depends on flags bits):
Suppose the key has been buffered a total of m times. Suppose also that
Universal argument (^U) is active and that the user has requested a
repetition of n times. (n=1 if universal argument not active).
Ie, Zap_ProcessCommand has been called with R1=m. Then:
b12=0 & b13=0 => Command is called n times with R1=m
b12=1 & b13=0 => Command is called once with R1=m*n
b12=0 & b13=1 => Command is called m*n times with R1=1
b12=1 & b13=1 => Command is called m times with R1=n
ie b12=1 => R1 is multiplied by n (the universal argument)
b13