home *** CD-ROM | disk | FTP | other *** search
/ RISC DISC 1 / RISC_DISC_1.iso / pd_share / utilities / zap / !Zap / Docs / E-Zapcalls < prev    next >
Encoding:
Text File  |  1994-03-23  |  36.5 KB  |  903 lines

  1. *************************************************************************
  2. * >E-ZapCalls    Documentation of Zap entry points (how to call Zap)    *
  3. *************************************************************************
  4.  
  5. Zap does NOT have a SWI interface as it uses registers R8-R10 to point to
  6. data blocks, and these cannot be passed to swi's. To call Zap you will need
  7. to know the address of the Zap module workspace (ie it's private word). If
  8. you are an extension mode then this will be passed to you in R12 whenever you
  9. are called by one of your entry points. However, for the first call you make
  10. to Zap, when you add your module to it's list via Zap_Addmode, you will not
  11. know it. Then you should use OS_Module 18 to find it. Eg,
  12.  
  13.  SYS "XOS_Module",18,"Zap" TO R0,R1,R2,R3,workspace%
  14.  
  15. Now, the first word in Zap's workspace contains the address of a table of
  16. Zap's entry points. Thus to call the entry point (documented below) at offset
  17. a% I suggest you use the basic macro given below.
  18.  
  19.     REM Call Zap at entry offset a%
  20.     REM Entry: R0-R11=args R12=zap workspace
  21.     REM Exit : R0-R11=returned values R12 preserved R14 corrupted
  22.     
  23.     DEF FNcall(a%)
  24.     [OPTpass
  25.     LDR R14,[R12]        \ get start of zap table
  26.     ADD R14,R14,#a%        \ address of the sub
  27.     STMFD R13!,{R14}        \ save address on stack
  28.     MOV R14,PC            \ return address (with flags)
  29.     LDMFD R13!,{PC}        \ call the sub 
  30.     ]:=""
  31.  
  32. The names of the routines are listed below in the order in which they appear
  33. in the table. Thus the first, Zap_AddMode, is at offset 0. The second,
  34. Zap_Claim is at offset 4, etc. These values are defined for you in the
  35. program E-Library.
  36.  
  37. In general these routines have the following entry/exit conditions:
  38.  
  39.  \E R0-R11=arguments R12=Zap's workspace R13=user stack R14=return address
  40.  \X R1-R13 preserved. R0 and Flags ALTERED. V set if error and R0=error block
  41.  
  42. Thus if I write:
  43.  
  44.  \E R8
  45.  \X R1=3
  46.  
  47. Then I mean that on entry R8 was the window block pointer, R12 zap's
  48. workspace etc. And on exit that R1=3, R2-R13 saved, R0 corrupted etc. If I
  49. omit the \E or \X then I mean the standard entry/exit conditions hold.
  50.  
  51. Errors should be passed back to Zap by the entry point through which the
  52. module was called (with V flag set and R0=error block pointer). Please note
  53. that for most calls, Zap must be paged in as the current task! This will be
  54. so if you are an extension mode.
  55.  
  56. For a table/summary of the zap call names for including in your source, see
  57. the file E-Library.
  58.  
  59. Zap_AddMode
  60. Adds a new Zap extension mode. This should be called after the module Zap is
  61. loaded, but before it starts up as a new task. Zap need not be paged in for
  62. this call.
  63.     \E R0=address of table of entry points (see file E-Entry)
  64.  
  65. Zap_Claim
  66. Claims a block of workspace in Zap's heap.
  67.     \E R0=number of bytes required
  68.     \X R0=pointer to the heap block
  69.  
  70. Zap_Ensure
  71. Ensures a zap heap block is of a given size.
  72.     \E R0=pointer to the heap block
  73.        R1=number of bytes required.
  74.     \X R0=new heap block pointer of (possibly moved) extended block.
  75.        (An error is returned if the block couldn't be enlarged).
  76.  
  77. Zap_Free
  78. Free a zap heap block after use.
  79.     \E R0=pointer to heap block to free
  80.  
  81. Zap_MoveBytes
  82. Moves a block of memory. The movement may be up or down by any amount. The
  83. data is ALWAYS preserved no matter where the destination is. This routine is
  84. highly optimised and should be used for moving any large block of data. Zap
  85. need not be paged in.
  86.     \E R1=source byte address
  87.        R2=destination byte address
  88.        R3=number of bytes to move
  89.     \X R1-R3 corrupted
  90.  
  91. Zap_SplitBuffer
  92. This splits a file held in Zap at the indicated file offset ready for
  93. insertion/deletion of data. It also ensures that file buffer has a given
  94. amount of room free. See E-File.
  95.     \E R0=file offset to split at (new value for f_splito)
  96.        R1=minimum number of bytes to have free in the split
  97.        R9=file to be split
  98.  
  99. Zap_NewTxtStatus
  100. This updates the screen after changes are made to a file. This is very low
  101. level and you should use Zap_Command when possible. Zap_SaveTxtStatus should
  102. be called first.
  103.     \E R0/R1 as for SaveTxtStatus and R2=new input caret offset.
  104.  
  105. Zap_SaveTxtStatus
  106. This is a low level call used by Zap_DoCommand when changing a file. You
  107. should use Zap_Command/Zap_DoCommand in preference. Any file changes done
  108. using this call are NOT saved in the undo buffer. Ie, don't use it. To use it
  109. you specify the area of the file to be changed (R0 to R2) and the amount of
  110. the change (in R1). After making the change you use Zap_NewTxtStatus to
  111. update the screen. Set f_docom to 0 if in doubt.
  112.     \E R0=file offset of first byte in file to be changed.
  113.        R1=proposed signed change in size of file.
  114.        R2=file offset of first character which is unchanged.
  115.        f_docom,f_dolen,f_dodata must be set up - see e_prevline.
  116.  
  117. Zap_Command
  118. This should be used for inserting/deleting/replacing data in a file. Its 
  119. action is to call the mode entry point named e_command. See E-Entry. The
  120. mode's default action is then to call Zap_DoCommand. The commands are
  121. automatically placed in the undo buffer. If you are doing a sequence of
  122. insertions/deletions then please use Zap_Start/StopOp. Note that the cursor
  123. is automatically updated to the end of the inserted/deleted region. To
  124. prevent this, set b14 of f_flags, but you MUST restore it after the command
  125. returns.
  126.     \E R0=command number: 1=insert 2=delete 3=replace (forward)
  127.         4=replace (backward). Add &10 if command is to be buffered
  128.         in one block (and thus undone in one key press).
  129.        R1=file offset for command to take place at.
  130.        R2=number of bytes being inserted/deleted/replaced.
  131.        R3=data to insert/replace with for commands 1,3,4.
  132.        R8=window on file to be altered/0 if none.
  133.        R9=file to be altered.
  134.     NB If you don't specify the window then it won't know which mode to
  135.     call, so this command will just call Zap_DoCommand.
  136.  
  137. Zap_NewWinStatus
  138. This recreates a window after some display parameters have changed. Use
  139. Zap_SaveWinStatus before changing any parameters.
  140.     \E R8/R9
  141.     
  142. Zap_SaveWinStatus
  143. This is used before changing any of the 'w_*' window parameters which would
  144. effect the display. See E-Window. The current cursor position, scroll offsets
  145. etc are saved. After changing the window parameters call Zap_NewWinStatus.
  146. Zap will do it's best to recreate the window with the new attributes,
  147. preserving the position of the cursor on screen.
  148.     \E R8/R9
  149.  
  150. Zap_ReplaceArea
  151. This command replaces one area of text with another (not necessarily of the
  152. same length) by performing the minimum number of insertions/deletions/simple
  153. replaces using Zap_Command. In BASIC mode it also retokenises the line as
  154. necessary. This is used during a search and replace. See mode entry point
  155. e_replace.
  156.     \E R1=file offset of original data
  157.        R2=length of original data
  158.        R3=address of replacement data
  159.        R4=length of replacement data R8/R9
  160.        
  161. Zap_PlotCaret
  162. This command plots a caret in its new position automatically removing it from
  163. its old position. Ie, it just calls Zap_ClearCaret then Zap_SetCaret.
  164.     \E R10=caret block
  165.  
  166. Zap_ReflectCaret
  167. This acts as Zap_PlotCaret but only uses c_off, updating the c_loff and c_col
  168. offsets from this. Ie, it just calls Zap_UpdateCaret then Zap_PlotCaret.
  169.     \E R10=caret block
  170.  
  171. Zap_SetCaret
  172. This updates the area of the window containing the the caret given on entry.
  173. Hence it's effect is usually to draw the caret at it's (new) position. See
  174. E-Cursors.
  175.     \E R10=caret block
  176.  
  177. Zap_ClearCaret
  178. As for Zap_SetCaret, but it updates the area of the window where the caret
  179. last was (stored in the c_o* variables). Hence the caret is in effect removed
  180. from its old position. See E-Cursors.
  181.     \E R10=caret block
  182.  
  183. Zap_DoCommand
  184. This acts as Zap_Command but actually performs the action rather than
  185. calling the extension mode.
  186.     \E As for Zap_Command.
  187.  
  188. Zap_ShowCursor
  189. This call makes sure that a given cursor can be seen in its window (by
  190. changing the scroll offsets if necessary). It does not redraw the cursor
  191. in general (though changing the scroll offsets may cause it to be redrawn).
  192.     \E R10=cursor block of cursor to show
  193.  
  194. Zap_ReadVar
  195. Reads one of Zaps internal variables. See the file E-Vars for the numbers.
  196.     \E R1=variable number.
  197.     \X R0=variable value.
  198.  
  199. Zap_WriteVar
  200. Writes one of zaps internal variables. See the file E-Vars for the numbers.
  201.     \E R1=variable number
  202.        R0=new value
  203.  
  204. Zap_SaveFile
  205. This saves a file to disc (using f_name as the file name). The file may not
  206. actually be saved if a dialogue box is opened. (Eg: 'file is older than
  207. version on disc box'). Please note the value of R0 on exit!
  208.     \E R8/R9 = window to save
  209.     \X R0=0  => File has been saved to disc - you can now delete it.
  210.        R0=-1 => File has not yet been saved - warning window opened /
  211.                data transfer initiated.
  212.  
  213. Zap_FillWords
  214. Fast word filling code. The block must be word aligned. Zap need not be paged
  215. in.
  216.     \E R1=word to fill with.
  217.        R2=address of memory to fill (word aligned).
  218.        R3=number of bytes to fill (a multiple of 4).
  219.     \X R0-R3 corrupted.
  220.  
  221. Zap_UpdateLns
  222. This updates the line numbers column of a given window. This is usually done
  223. automatically by Zap_Command. This is used by the BASIC mode on a renumber.
  224.     \E R0=first physical line to start from R8/R9
  225.  
  226. Zap_EachWindow
  227. This sub calls a given sub for each window on a given file. Each time it
  228. calls the sub pointed to in R10, it sets up R8 for that window.
  229.     \E R0-R7=args to pass to the sub.
  230.        R9=file (whose windows you are to call).
  231.        R10=address of sub to call for each window on this file.
  232.     The sub called has:
  233.         \E R0-R7 as set up by you
  234.            R8/R9 points to the given window
  235.         \X Must preserve R1-R11 and VS on error etc.
  236.  
  237. Zap_UpdateCaret
  238. This sub is called to update a caret position from a given file offset. Save
  239. the new offset of the caret in c_off. Call this. Then c_col, c_line, c_loff,
  240. c_width will be set up. See E-Cursors.
  241.     \E R10=caret block
  242.  
  243. Zap_GetWindState
  244. Updates the window block R8 (first few entries) by calling
  245. Wimp_GetWindowState.
  246.     \E R8
  247.  
  248. Zap_StartOp
  249. Starts a sequence of operations. This should be used when performing a
  250. sequence of calls to Zap_Command. It causes all the file changes to be made
  251. with only ONE screen refresh, thus giving a much smoother update. After this
  252. has been called, all subsequent calls to Zap_Command before a Zap_StopOp call
  253. have their actions concatenated. When you call Zap_StopOp the screen is then
  254. updated. You MUST call Zap_StopOp before returning to Wimp_Poll. StartOp/
  255. StopOp's can be nested to any depth (so only the last StopOp actually causes
  256. the screen to be updated).
  257.     \E R9=file which will be operated on.
  258.  
  259. Zap_StopOp
  260. Ends a StartOp/StopOp structure.
  261.     \E R9=file which has been operated on.
  262.     \X If VC on entry then R0 corrupted and R1-R11 preserved as usual.
  263.        If VS on entry then error pointer in R0 and V flag status are
  264.        also preserved.
  265.  
  266. Zap_CallMode
  267. Calls a mode entry point. See E-Entry for a list of entry points. The mode
  268. called is the mode of the window given in R8.
  269.     \E R0-R10=parameters R8 R11=mode entry point offset
  270.     \X As for the given mode entry point.
  271.  
  272. Zap_CallGivenMode
  273. Calls a mode entry point of a specified mode.
  274.     \E R0-R9=parameters R10=mode number R11=entry point offset
  275.     \X As for the given mode entry point.
  276.  
  277. Zap_ReadMode
  278. Read the address of the mode entry point tables. Two pointers are returned.
  279. The first (R0) is a pointer to the mode table as stored in the extension
  280. module and documented in E-Entry. The second (R1) points to a table of actual
  281. addresses to be called, with entry points which were null in the original
  282. table converted to addresses and all offsets converted to addresses. In this
  283. table, each entry consists of 8 bytes. The first 4 bytes gives the address of
  284. the entry point, and the next 4 the value to pass in R11 when the entry point
  285. is called. This will obviously vary if some mode entry points are based on
  286. other modes. Thus the linked table has the form:
  287.     e_module    #0    module address,    module workspace address
  288.     e_title        #8    title address,    undefined
  289.     e_author    #16    author address,    undefined
  290.     e_basemode    #24    basemode,    undefined
  291.     e_mode        #32    mode number,    undefined
  292.     e_init        #40    init code addr,    value to pass in R11
  293.     e_menu        #48    wimp menu data,    undefined
  294.     e_len        #56    undefined,    undefined
  295.     e_postload    #64    postload addr,    value to pass in R11
  296.      and the rest as for e_postload.
  297. I reserved the right to use the undefined words in future. You can change the
  298. table entries pointer to in R1, but I don't advise it :-)
  299.     \E R0=mode number.
  300.     \X R0=pointer to unlinked table in modes module / <=0 if invalid
  301.        R1=pointer to linked table in zaps workspace / <=0 if invalid
  302.  
  303. Zap_FindFile
  304. Given the name of a file, this call produces a window on that file (loading
  305. it if necessary). Path is canonicalised before comparing with currently
  306. loaded files.
  307.     \E R0=file name.
  308.     \X R8/R9=window on that file.
  309.  
  310. Zap_FindWindow
  311. Given a file block pointer of a file already loaded, this call produces a
  312. window block pointer of a window on that file (opening it if necessary).
  313.     \E R9
  314.     \X R8
  315.  
  316. Zap_ConvWindOff
  317. Converts a window offset to a window block pointer. See E-Windows.
  318.     \E R0=offset of a window in the window list /-ve
  319.     \X R8/R9=window and file /0
  320.  
  321. Zap_ConvFileOff
  322. Converts a file offset to a file block pointer. See E-File.
  323.     \E R0=offset of a file in the file list/-ve
  324.     \X R9=pointers to the file block/0
  325.  
  326. Zap_GetWindOff
  327. Converts a window block pointer to a window offset. See E-Windows.
  328.     \E R8=window block pointer/0
  329.     \X R0=offset in the window list/-ve
  330.  
  331. Zap_GetFileOff
  332. Converts a file block pointer to a file offset. See E-File.
  333.     \E R9=file block pointer/0
  334.     \X R0=offset in the file list/-ve
  335.  
  336. Zap_GotoOffset
  337. This call causes the given cursor to jump to a given file offset, leaving a
  338. mark behind at the previous position.
  339.     \E R0=offset to go to R8-R9=file R10=cursor
  340.  
  341. Zap_JumptoOffset
  342. As for GotoOffset but no mark left on jumping.
  343.     \E R0=offset to go to R8-R9=file R10=cursor
  344.  
  345. Zap_FindOffset
  346. Given the (x,y) position in work area characters, finds the file offset of
  347. the 'nearest' point in the file. See E-Windows.
  348.     \E R2=x column (inc margin) R3=y row (from top)
  349.     \X R0=file offset R1=file offset of physical line start R2/R3 clipped
  350.  
  351. Zap_NewFileTitle
  352. Update the titlebars of all windows on a given file.
  353.     \E R9=file
  354.  
  355. Zap_InsertString
  356. Inserts a string at the end of a buffer using Zap_Command.
  357.     \E R0=zero terminated string R8/R9
  358.  
  359. Zap_CreateFile
  360. Creates an empty file, possibly changing the opt_flags/format via BIC 'mask'
  361. EOR 'eor' when creating it. See E-Flags, E-Windows. It calls
  362. Zap_CreateWindBlock and Zap_CreateFileBlock etc.
  363.     \E R0=file type
  364.        R1=flags mask
  365.        R2=flags eor
  366.        R3=format mask
  367.        R4=format eor
  368.     \X R8/R9=newly created file (with open window).
  369.  
  370. Zap_NewLinkEntry
  371. Adds a new link entry to the f_links list. See E-File for description of the
  372. links list format. This is used by throwback. A new block is created if the
  373. file name does not match that of the previous link block, or the flags
  374. differ. The point of the links is that they are updated when changes are made
  375. to the indicated file.
  376.     \E R0=data word (Ie file offset of link / line number of link
  377.           depending on flags in R5).
  378.        R1=filename (Of the file that R0 is an offset in).
  379.        R4=file offset/-1 (Ie, offset in file list of the file named in
  380.            R1 if the file is loaded, or -1 if you don't know if the file
  381.            is loaded or not - usually safest to put as -1).
  382.        R5=flags (as documented under f_links in E-File).
  383.        R9=file to which the link should be added - ie this is the
  384.           throwback buffer file as opposed to R1 which is the file giving
  385.           the C program / file which was searched through.
  386.     \X R0=0 if link added to last list entry/1 if new entry created.
  387.  
  388. Zap_DefaultClick
  389. Calls the default mouse click handling code. See the entry point e_click.
  390.     \E R1=depth (0=drag 1=click 2=double click etc)
  391.        R2=x R3=y
  392.        R4=buttons
  393.        R8/R9 as for e_click.
  394.  
  395. Zap_PutCaret
  396. Sets standard cursor editing mode and puts the cursor caret at a given file
  397. offset in a given file.
  398.     \E R0=file offset R8/R9=file
  399.  
  400. Zap_DiscardFile
  401. Kill a file and all windows on that file without prompting user.
  402.     \E R9=file
  403.  
  404. Zap_DeleteFile
  405. As for Zap_DiscardFile but prompts user if file altered etc.
  406.     \E R9=file
  407.  
  408. Zap_DiscardWindow
  409. Kill a window, and the file if auto-delete is on and this is the last window
  410. on that file. Don't prompt user.
  411.     \E R8/R9
  412.  
  413. Zap_DeleteWindow
  414. As for Zap_DiscardWindow but prompts user if file altered etc.
  415.     \E R8/R9
  416.  
  417. Zap_BuildMenu
  418. This is zaps 'variable length menu' building sub. See E-Menu for details on
  419. Zap's menu format.
  420.     \E R0=menu name (max 12 chars)
  421.        R1=address of sub to generate the menu entries
  422.        R2=address of menu updating sub/0 if none (see E-Menu)
  423.        R3=address of menu interpret sub for all entries/0 (see E-Menu)
  424.        R4=menu width in chars
  425.        R8-R11=values to call the sub in R1 with on the first call.
  426.     \X R0=pointer to wimp menu structure
  427.     The sub passed in R1 has the following conditions:
  428.          \E R0=buffer for you to put the next menu entry in (48 bytes)
  429.         R5=address of menu structure start }
  430.         R6=address of current menu entry   } you don't need these
  431.         R7=address of current buf entry    }
  432.         R8-R11=as returned from last call
  433.          \X R0=index for this entry/-1 if no more entries (see E-Menu)
  434.              R1-R7 saved
  435.              R8-R11=updated (ie for your own use).
  436.  
  437. Zap_ClearSel
  438. Clears currently selected area.
  439.  
  440. Zap_CreateFileBlock
  441. Creates a new file block with currently configured options. f_ptr etc are set
  442. up for you. See E-File. Use Zap_Install file to load a file.
  443.     \E R0=size to make buffer
  444.        R1=filename of buffer
  445.        R2/R3=load/exec
  446.     \X R9=new file block (with file filled with rubbish).
  447.     
  448. Zap_CreateWindBlk
  449. Creates a new window block with currently configured options. Window is
  450. opened on the screen etc.
  451.     \E R9=file window is to be on.
  452.     \X R8=New window on this file.
  453.     
  454. Zap_GetSel
  455. Find out what area is selected.
  456.     \X If CS then no valid selection
  457.        If CC then R1=file offset R2=selection length R8/R9=file
  458.  
  459. Zap_InsertMark
  460. Insert a marker.
  461.     \E R0=file offset of mark R8/R9
  462.  
  463. Zap_InstallFile
  464. Load a file into zap.
  465.     \E R0=filename
  466.     \X R0=window offset of created window / -1 if not loaded.
  467.  
  468. Zap_NewMode
  469. Change the display mode of a window.
  470.     \E R0=new mode number R8/R9 (R8=0 to change options mode)
  471.  
  472. Zap_NewTitle
  473. Update the titlebar on a given window. See also Zap_NewFileTitle.
  474.     \E R8/R9
  475.  
  476. Zap_CallBaseMode
  477. DO NOT USE THIS. This call is now obsolete. Use the call Zap_BaseMode
  478. instead. If you use this call it will appear to work perfectly until someone
  479. tries to use your mode as a base mode. When this happens an infinite loop
  480. occurs which I can't fix. The docs are kept for backwards compatibility.
  481. --------------------------------------------------------------------------
  482. As for Zap_CallMode except it calls the base mode instead. The window in R8
  483. identifies the current mode. The entry point called is that of the base mode
  484. associated to this current mode. Hence, it would be used by a mode to call
  485. a base mode entry point which the current mode has redefined.
  486.     \E R0-R10=parameters R8 R11=mode entry point offset (see E-Entry)
  487.     \X As for the given mode entry point.
  488.  
  489. Zap_NewView
  490. As for Zap_CreateWindBlk but 'clones' a given window image. The cursor is not
  491. put in the window.
  492.     \E R8/R9=window to clone from (R8=0 then don't clone)
  493.  
  494. Zap_ReadSel
  495. Reads the currently selected region into a heap block. You must free the heap
  496. block when you have finished with the selection.
  497.     \X R3=heap block with data and R2=length / R3=0 if no selection
  498.  
  499. Zap_Replace
  500. Calls the zap file search and replace code using the current search string.
  501.     \E R1=0 for selective/1 for global/2 for continue selective
  502.        R3=start offset in file
  503.        R4=direction (+1/-1)
  504.        R8/R9
  505.  
  506. Zap_Search
  507. Calls the zap wildcard search code.
  508.     \E R0=search string (as typed by user)
  509.        R1=output type (0=cursor 1=tobuffer 2=none)
  510.        R3=start offset in file
  511.        R4=search direction (+1/-1)
  512.        R5=object type (0=string 2=word 4=assembler instruction)
  513.        R8/R9
  514.     \X If R1=0 or 2 on entry then R0=match offset/-ve if none.
  515.  
  516. Zap_Select
  517. Selects a given region, and puts carets back to default mode.
  518.     \E R2=start offset R3=end offset R8/R9
  519.  
  520. Zap_AlterSel
  521. As for Zap_Select but doesn't restore caret modes.
  522.     \E R2=start offset R3=end offset R8/R9
  523.  
  524. Zap_OffLineCol
  525. Converts a file offset to and x,y coordinate in the window work area. See
  526. also Zap_FindOffset. See E-Windows.
  527.     \E R0=file offset R8/R9
  528.     \X R0=start of line offset
  529.        R2=column (inc margin)
  530.        R3=row
  531.  
  532. Zap_AddCommands
  533. Adds a table of commands to zap's list. Zap can currently cope with up to 16
  534. tables of commands. This should be called when a module initialises as for
  535. Zap_AddMode. Zap need not be mapped into memory for this call. See E-Commands
  536. for the table format.
  537.     \E R0=address of command table (R12=Zaps workspace).
  538.     
  539. Zap_MiniWrite
  540. This call sends a stream of characters to the minibuffer. The minibuffer
  541. contents is changed but not updated on screen. However, if this call is used
  542. within a command, then the minibuffer will updated on screen automatically
  543. by Zap. Use Zap_MiniUpdate to force an update, but you shouldn't have to use
  544. this. The minibuffer takes the form:
  545.     <prompt string><mark><user editable field>.
  546. The user cannot move the cursor before the 'invisible' mark. The string
  547. passed to Zap_MiniWrite may contain the following control codes:
  548.     0=string terminator
  549.     1=move cursor to mark (ctrl a)
  550.     2=8=move cursor back one character (ctrl b)
  551.     4=delete character after cursor (ctrl d)
  552.     5=move to end of string (ctrl e)
  553.     6=9=move cursor forward one character (ctrl f)
  554.     11=clear buffer from cursor (ctrl k)
  555.     12=clear whole buffer (ctrl l)
  556.     21=clear buffer from mark (ctrl u)
  557.     28=set mark to current cursor offset
  558.     127=delete character before cursor
  559. When a command with string parameter is called, R0 points to the user
  560. editable part of the string.
  561.     \E R0=pointer to zero terminated string
  562.     
  563. Zap_MiniPrompt
  564. This replaces the prompt string in the minibuffer with the given string. It's
  565. main use is for reason code R2=6 when a command with string parameter is
  566. called (see E-Commands). The buffer is not updated on screen (see
  567. Zap_MiniWrite). Unlike Zap_MiniWrite, the minibuffer cursor is not affected
  568. by this call (It remains the same number of characters after the mark).
  569.     \E R0=new prompt string
  570.     
  571. Zap_MiniUpdate
  572. This call updates the minibuffer on screen (if open). This will usually be
  573. done automatically by Zap.
  574.  
  575. Zap_AddYankRegion
  576. This call adds a region to the cut/paste kill ring. The region you pass it
  577. is not copied so must be stable (eg in a heap block).
  578.     \E R0=address of region + flags:
  579.         b31 MUST BE SET (If clear then denotes an undo buffer ref).
  580.         b30 If set, then after yanking this block, it will move onto
  581.             the block before (ie, yanks many blocks at once).
  582.        R1=block length (provided b31 of R0 is set).
  583.  
  584. Zap_FindCommand
  585. This call converts a command name into a command address by looking it up in Zaps command tables.
  586.     \E R0=command name terminated by <=32 or :,&,"
  587.     \X R0=command address / 0 if not found
  588.     
  589. Zap_ProcessCommand (see also Zap_CommandString).
  590. This makes a call to a Zap command. It should be used for all calls to
  591. commands. You can find the address of a command via Zap_FindCommand. You
  592. may also call commands which may not have a name! For the entry/exit
  593. conditions of commands see the file E-Commands. If the value of R2 is
  594. undefined for a command call in the documentation in E-Command then you
  595. should set it to ZERO. Thus R2=0 always for argument types except strings.
  596. The command will be learnt if the learn flag is set and executed a number of
  597. times if the universal argument flag is set. The mode entry point
  598. e_aligncaret will be called before all commands with R2=0 on entry. A
  599. minibuffer will be opened if the command type is STRING but R0=0 (and R2=0).
  600.     \E R0-R1=command inputs - dependent on command (see E-Command).
  601.         Usually R0=pointer to command data R1=length of the data
  602.        R2=Command action code with flags in top bits.
  603.            b0-b27 =Action code to be passed on to the command. This is
  604.                    always 0 in standard command calls.
  605.            b28-b31=Flags to tell Zap_ProcessCommand things. These are
  606.                filtered out before R2 is passed to the command.
  607.                b31=Set if command should not be learnt even
  608.                    if in learn mode.
  609.             b30-b28 reserved.
  610.        R7=command address (need not point to a command registered in a
  611.                command table, but must conform to the specs in the
  612.                file E-Command. Eg, [R7,#-4] must be the flags word).
  613.        R8-R10=input cursor (or cursor you wish command to act on).
  614.     \X R1-R13 preserved.
  615.     If action code=0 on entry then R0=0 or -1 if minibuffer opened.
  616.     If action code>0 on entry then R0=value in R0 when command returned.
  617.  
  618. Zap_FindKeyEntry
  619. This finds the entry corresponding to a given key and keymap. You might use
  620. it for redefining the key for instance. The block pointed to on exit has the
  621. format:
  622.     #0 Command address (or 0 if none - key is passed on to wimp)
  623.     #4 Command parameter, this depends on the command flags b3-7. If
  624.        these bits are:
  625.        0   => #4 undefined (should be 0)
  626.        1/2 => #4 is the byte or word to be added to the list to be
  627.              passed to the command when the key is pressed.
  628.        3   => #4=address of string parameter /0 if minibuffer should be
  629.               used.
  630.        4   => #4=address of the data block.
  631.     \E R0=keymap number R1=zaps key number (0-&1FF)
  632.     \X R0=entry for this key / 0 if keymap does not exist or key is
  633.        out of range.
  634.  
  635. Zap_FindLeafName
  636. This works out which part of a filename is the leafname.
  637.     \E R0=filename pointer
  638.     \X R0=pointer to the leafname part (within the filename).
  639.  
  640. Zap_NewFileName
  641. Change the name of a given file. You may have to call Zap_NewFileTitle to
  642. update the titlebars (this will usually be done by Zap_SaveFile).
  643.     \E R0=new file name R9
  644.     
  645. Zap_CheckFileName
  646. Decides whether a filename is a full path name (eg "ADFS::$.Wibble") or just
  647. the leaf name of a file (eg "Text1"). Should be used in conjunction with
  648. Zap_SaveFile as this will not save files without full path names.
  649.     \E R0=filename
  650.     \X R0=0 if it is a full path name / 1 otherwise
  651.  
  652. Zap_GetCurrDir
  653. Returns current directory (of the temporary filing system) which should be
  654. used as default string in minibuffer file operations. On RISC OS 2, there is
  655. no way of reading the current directory so this call returns the root
  656. directory on the current disc (via OS_Args 0, OS_FSControl 33, OS_GBPB 5). On
  657. RISC OS 3, the current directory is read via OS_Args 0, OS_FSControl 33, and
  658. OS_FSControl 54. NB The block it is returned in is not stable over calls to
  659. Zap. You may call Zap_MiniWrite passing this block but should copy the
  660. string for other calls.
  661.     \X R0=pointer to 256 byte buffer containing the directory name
  662.  
  663. Zap_MiniWriteC
  664. Writes a single character to the minibuffer. See Zap_MiniWrite for the
  665. character codes.
  666.     \E R0=character to insert in minibuffer.
  667.  
  668. Zap_MiniClear
  669. Clears minibuffer contents without updating on screen. Resets marks etc. You
  670. should use this before using Zap_MiniStart.
  671.  
  672. Zap_MiniStart
  673. This starts up the minibuffer. Do not use this call when writing a Zap
  674. command. Read the file E-Command to see how the minibuffer works in this
  675. case. You never need this call, Zap_ProcessCommand can open a minibuffer at
  676. any time if you feed it a string type command and R0=R2=0.
  677.     \E R7=address of command to be called when return pressed in
  678.        minibuffer. [R7,#-4] must contain the command flags word as
  679.        documented in E-Command.
  680.        R8/R9=window minibuffer should appear at.
  681.  
  682. Zap_MiniEval
  683. This turns a string into a number via OS_EvaluateExpression. It is usually
  684. called near the start of a command which expects to find a number in the
  685. minibuffer.
  686.     \E R0=string pointer (usually minibuffer pointer passed to you)
  687.     \X R0=number stored in string/CS if not a valid number.
  688.  
  689. Zap_CommandString (see also Zap_ProcessCommand)
  690. This call takes a command (or colon separated list of commands) in string
  691. form and executes them as typed. For example if R0="MODE 0" on entry then
  692. first of all a call to Zap_FindCommand will be made to find the address of
  693. the command "MODE" and then the command will be called via
  694. Zap_ProcessCommand with R2=0.
  695.     \E R0=command string (zero terminated)
  696.           Set b31 if you don't want the commands to be learnt if in
  697.           learn mode.
  698.     \X R0=0 or -1 if the minibuffer has been opened.
  699.  
  700. Zap_ProcessKeys
  701. This entry point accesses Zap's main key handling sub so you can simulate
  702. keypresses. If you just wish to simulate one key press, then it is easier to
  703. use the next call. This call is for multiple keypresses and buffers the data
  704. as much as possible before it has to call a command. You must keep calling
  705. this command until it returns R0<0 (as it will do if you put R5=-1 on entry -
  706. it uses the R5=-1 call to execute the buffered data).
  707.     \E R0=zap key number of next key to execute (if R5>=0)
  708.        R5=-1     => there are no more keys to buffer (R0 not defined).
  709.           0-&1FF => wimp key number of key to send to Wimp_ProcessKey
  710.                if no command is attached to the key.
  711.           &200   =>    if Wimp_ProcessKey should never be called.
  712.        R6=length of current buffering (set to 0 on first call)
  713.        R7=command currently being buffered (if R6>0)
  714.        R8-R10=input cursor
  715.     \X R0>=0 if you should call this sub again with the next key (or
  716.           R5=-1 if there are no more).
  717.        R0<0 if the command has finished processing all buffered data
  718.           so you needn't call it again.
  719.        R6/R7 are updated for the next call.
  720.        
  721. Zap_ProcessAKey
  722. This command simulates a key press by calling the above command twice, once
  723. with the key and then once with R5=-1.
  724.     \E R0=zap key number
  725.        R5=wimp key number (see Zap_ProcessKeys)
  726.        R8-R10=input caret
  727.  
  728. Zap_OpenWindow
  729. The current position of a Zap window can be read easily using the code:
  730.  MOV R1,R8 : SWI "XWimp_GetWindowState". However, you should not call
  731. Wimp_OpenWindow to open a window as Zap has to keep track of the title length
  732. and position of the minibuffer etc. You should use this call instead. Use
  733. call 0 where possible as it prevents titlebar flicker.
  734.     \E R0=type of open:
  735.         0 => Just changing scroll offsets or height in window stack.
  736.              Size/position of window NOT changing.
  737.         1 => Window may move/change size. Minibuffer, title bar
  738.              and cursors dealt with accordingly.
  739.         2 => Window is a new window. Toggle size data etc reset.
  740.         3 => Bring window to front of stack (ignore R1)
  741.         4 => Put window to back of stack (ignore R1)
  742.         5 => As for 0, but cursor kept within the window if the
  743.              'constrict cursor' option is on.
  744.         (NB type 2 calls type 1 calls type 5 calls type 0)
  745.        R1=open block (as for Wimp_OpenWindow)
  746.        R8=window block (NB Usually alter this block and let R1=R8)
  747.  
  748. Zap_RestoreModeWord
  749. This call should be used by your e_start entry point. If R8<>0 on entry then
  750. it reads the reads the options for the given mode from w_datablock using the
  751. call Zap_ModeData, and sets them as the current options. If R8=0 then it does
  752. the same thing but sets the default options.
  753.     \E R0=mode number
  754.        R8=window to restore options on / 0 for the default options.
  755.        
  756. Zap_SaveModeWord
  757. This call should be used by your e_end entry point. If R8<>0 on entry then it
  758. reads the words w_flags and w_format and stores the current options in the
  759. w_modedata block by use of the call Zap_ModeData. If R8=0 on entry then it
  760. reads opt_flags and opt_format and stores them as the default option etc.
  761.     \E R0=mode number
  762.        R8=window to save options on / 0 for the default options.
  763.  
  764. Zap_GetModeWord
  765. This call reads the contents of your mode word. If R8=0 then it reads
  766. opt_moden, otherwise it reads [R8,#w_moden]. This is useful for menu
  767. options.
  768.     \E R1=mode number
  769.        R8=window to get mode word / 0 for default options mode word
  770.     \X R0=mode word contents.
  771.     
  772. Zap_PutModeWord
  773. As above, but write the value.
  774.     \E R0=new value for the word
  775.        R1=mode number
  776.            R8=window to put mode word / 0 for default options mode word
  777.  
  778. Zap_BaseMode
  779. This call replaces Zap_CallBaseMode. It differs in that you must specify
  780. which mode is calling. This information is not necessarily available from
  781. the block in R8 if another mode is based on yours. The basemode of the mode
  782. named in R9 is called via the entry point offset given in R11. Before the
  783. entry point is actually called, R9 is converted to the file block pointer
  784. of the window specified in R8. Hence any entry point requiring R8 and R9
  785. set up on entry can be called ok.
  786.     \E R0-R7=parameters for the call
  787.        R8=window block to be used by the call.
  788.        R9=mode number making this call (your mode number).
  789.        R10=parameter for the call (usually cursor block pointer).
  790.        R11=mode entry point offset (see E-Entry) to call.
  791.     \X As for the given mode entry point.
  792.  
  793. Zap_ReadWord
  794. This call can be used for reading 4 byte from a file buffer. Note that
  795. although the offset of the word in the file may be word aligned, it's offset
  796. in the buffer may not be due to the split. This call reverses the word if the
  797. Big Endian flag is set.
  798.     \E R0=File offset of the word to be read
  799.        R8=window (for big endian flag to be read)
  800.        R9=file
  801.     \X R0=the word read (padded with zeros if it went off the file end).
  802.  
  803. Zap_ReplaceWord
  804. This call replaces a word at the given file offset (inserting if the file
  805. offset+4>file length) via Zap_Command. The word is reversed if the big endian
  806. flag is set.
  807.     \E R0=word to replace
  808.        R1=file offset
  809.        R8/R9 (R8 used for the big endian flag).
  810.  
  811. Zap_ModeColour
  812. This call reads or writes the colour definition table. It will not usually
  813. have immediate effect unless you recreate the window (eg Zap_NewWinStatus).
  814. You shouldn't usually access this data as Zap handles it all for you, except
  815. to write sensible default values (using R8=0) if your mode starts up and
  816. finds its mode word is zero.
  817.     \E R0=colour to write (0-15=wimp colour) / -1 to read
  818.           (In future versions I may allow &BBGGRR10 24 bit settings
  819.            as well).
  820.        R1=mode number
  821.        R2=Zap colour number of the colour to write/read:
  822.           0/1=Background 2=Foreground 3=Selection background
  823.           4=selection foreground 5=cursor back 6=cursor for
  824.           7=line numbers 8=control chars
  825.           9-15 mode dependent extension colours.
  826.        R8=Window block to read from / 0 for default (!Config) settings.
  827.     \X R0=colour value read / old value if writing it.
  828.           NB This is currently a wimp colour (0-15) but may return
  829.              24 bit &BBGGRR10 settings in future versions.
  830.  
  831. Zap_FindInput
  832. This call works out the current position of the 'input focus' in a window. If
  833. the input caret is in this window then it returns it's offset. Otherwise it
  834. returns the 'point' position (usually marked by an empty square).
  835.     \E R8/R9
  836.     \X R0=most suitable offset to insert data.
  837.  
  838. Zap_ClipCache
  839. This call moves the cache reference point (w_cline/coff/clogl etc) to a given
  840. point (using e_clnoff).
  841.     \E R0=Offset in line to move the cache reference point to. R8/R9
  842.  
  843. Zap_ModeData
  844. This call reads or write the mode dependant options that Zap handles
  845. automatically for you. See also Zap_ModeColour. Currently there is only one
  846. word per mode storing the width and things like whether auto-indent is on or
  847. not. You should use this call with R8=0 to write sensible default values if
  848. your mode starts up and finds its mode word is zero. If you don't then the
  849. default Text mode values will be used.
  850.     \E R0=value to write / -1 to read
  851.        R1=mode number
  852.        R2=variable number to read write
  853.        R8=window concerned / 0 for the default (!Config) settings.
  854.     \X R0=variable value if read / old value if written
  855.     Variables num:    0     b0-b15  stores the "width" for this mode
  856.                 b16    auto indent bit (b16 of w_format)
  857.                 b17-b21 are reserved
  858.                 b22    hex entry mode bit (b5 of w_flags)
  859.                 b23    overwrite bit (b1 of w_flags)
  860.                 b24-b31    display bits (b8-b15 of w_format)
  861.             1+    reserved.
  862.  
  863. Zap_WhichMode
  864. This call decides which mode a given file should be displayed in.
  865.     \E R0=load address of file (containing the filetype)
  866.        R1=filename pointer / 0 if not known
  867.     \X R0=flags    b0 => Auto load flag is set, no shift test.
  868.        R10=mode file should be loaded into.
  869.  
  870. Zap_ModeNumber
  871. This calls turns a mode name (given by a string) into a mode number.
  872.     \E R0=mode name string terminated by <= space (&20)
  873.     \X R0=mode number or -1 if not found.
  874.  
  875. Zap_SendDataSave
  876. This call initiates the save protocol, saving data to another window or
  877. application via RAM transfer or WimpScrap. It sends the data_save message and
  878. all replies are handled automatically.
  879.     \E R2=path name to use for the data / 0 to use the files
  880.        R3=destination window handle (or task handle)
  881.        R4=destination icon handle
  882.        R5/R6=destination mouse coords (if applicable)
  883.        R7=0 (non zero values used internally)
  884.        R8/R9=window to save or R8=0 to save the currently selected area
  885.        R10=flags b0 => External edit flag (do not use)
  886.  
  887. Zap_Warning
  888. Warns the user without generating an error. This opens a window with the
  889. given message and pauses for the message to be seen before returning. Wimp
  890. Poll is not called.
  891.     \E R0=warning message
  892.        R1=time to leave message open in cs (0 for default delay)
  893.           + flags:
  894.            b31 => Don't beep when opening the window
  895.  
  896. Zap_AllWindow
  897. Calls a given subroutine once for each valid Zap window. See also
  898. Zap_EachWindow.
  899.     \E R0-R7=arguments to pass to the sub
  900.        R10=address of the sub to call (which must preserve all registers
  901.            except R0, and is called once for each window with R8/R9
  902.            set up to be that window).
  903.