QD 5 Thing Interface After the old QD2M has been used for years it became clear that it does not offer enough facilities to monitor the text kept within QD. A large number of features were missing, which I tried to define in the Level5 interface. This is, in the opposite to the QD2M, extensible. Every application should be possible with the new definition, ranging from simple thing calls invoked by the user like in the old interface up to calls which are done on any modified line. This allows implementation of line-formatters, in-line macros, instant line-parsers etc. QD will be able to handle more than one thing at a time, allowing features which had to be inbuilt into QD to be loaded and removed in a modular way. For example, you could have a QD which is connected to a BASIC parser thing, together with a Help thing (or, of course, the help could be implemented into the BASIC thing). The accesses to the text are not done directly, therefore the thing does not have to know exactly how QD organizes the lines internally. When QD is invoked, it searches for a given thing. The ID at address $0008 has to be 'QD5T'. The Thing MUST supply the following vectors, which are longword relative to itself. No zero vectors are allowed, if a vector is not supported, it should point to an RTS. The Vectors start at $0018. QT_INIT $0018 Init code, first called when QD is started. QT_TIDY $001c Tidy up code, called when QD file is removed or on a Thing change. QT_F10 $0020 F10 call code. QT_F1 $0024 Help call code. QT_NIMP $0028 reserved, must point to an MOVEQ #ERR.NIMP,D0 and RTS. QT_NIMP $002c reserved, must point to an MOVEQ #ERR.NIMP,D0 and RTS. QT_NIMP $0030 reserved, must point to an MOVEQ #ERR.NIMP,D0 and RTS. QT_NIMP $0034 reserved, must point to an MOVEQ #ERR.NIMP,D0 and RTS. On every of the above calls, A5 points to the following vector table, A6 points to QD's system variables and must not be modified: QD_INFO $0000 Inquire information about QD's system variables. The following vectors should be used to modify, insert and delete a line. The line is copied from the text into a buffer where it can be modified. D1.w holds the line number, A1 points to the buffer. Do not smash any register except D0. QD_GETLN $0004 Get a line into a buffer. QD_PUTLN $0008 Put existing line buffer into text. QD_INSLN $000c Insert new line buffer into text. QD_DELLN $0010 Delete a line within text. The following vectors may be used to scan the text quickly (e.g. for searches or parsing/compiling/assembling). Modifications within the text should not be done. D1.w holds the line number, A2 points to the line within the text. Do not smash any register except D0. QD_PTRLN $0014 Point to a given line. QD_NXTLN $0018 Point to next line. QD_PRVLN $001c Point to previous line. QD_1STLN $0020 Point to first line. QD_LSTLN $0024 Point to last line. QD_SAVE $0028 Save current file. If D1<>0, the file is overwritten if it exists. QD_LOAD $002c Load current file again into QD. QD_NWNM $0030 Signal "new filename has been introduced". QD_PRTTXT $0034 Print text. QD_CURPOS $0038 Position cursor. QD_SETWIN $003c Set window to edit-sub-window, set colours and overwrite mode. QT_INIT Entry Exit D0 0 or error to make QD remove itself D1 QD's version number should be 0 D2 should be 0 A3 address of line interface or 0 A4 QD's small Thing workspace Thing workspace A5 QD vectors QT_TIDY Entry Exit D1.b clear if simple tidy-up, set on remove A4 Thing workspace A5 QD vectors QT_F10 Entry Exit D1.b event of keystroke A4 Thing workspace A5 QD vectors QT_F1 Entry Exit D0 OK or ERR.NIMP if QD's help should be used A4 Thing workspace A5 QD vectors QT_LINE The Line Interface is called for every line which has been changed when the cursor or pointer is moved away from that line. Entry Exit D0.l bit 0 set reprint line D1.w line number preserved D2.w cursor-position -1 or new cursor position D3.w maximum line length smashed A1 ptr to line preserved A2 ptr to line buffer smashed A3 smashed A4 Thing workspace A5 QD vectors QD_INFO Returns information about the locations, where interesting values are stored. Those marked * may safely be modified. Those marked ^ should be modified if necessary. The entry is a relative pointer to A6. The table is pointed to by A1. QV_BSTLN 00 word line number of block start, 0 for no block, -1 if undefined QV_BSTCH 02 word start character of block within first line QV_BENLN 04 word line number of block end, 0 for no block, -1 if undefined QV_BENCH 06 word end character of block QV_CSCRX 08 word on-screen-cursor x-position * (if cursor is positioned) QV_CSCRY 0a word on-screen-cursor y-position * (if cursor is positioned) QV_1STVL 0c word line number of first visible line * (if text is redrawn) 0e spare QV_COLOR 10 byte colourways QV_LFMAR 12 word left margin * QV_RTMAR 14 word right margin * QV_TAB 16 word tab distance * QV_CNFRQ 18 byte set if confirmation requests required * QV_TXTCH 1a byte set if text changed ^ 1c spare 1e spare QV_SYSV 20 long pointer to machines system variables QV_WMAN 22 long window manager vector QV_PRMID 24 long primary window channel ID 26 spare QV_FILNM 28 string 28 filename * QV_HLPNM 2a string 28 help filename * QV_DIRNM 2c string 20 local directory name * QV_EXTNM 2e string 6 filename extension * QV_THGNM 30 string 12 Thing name QV_PRTNM 32 string E printer name * If changes to the text are done, the flag QV_TXTCH should be set, otherwise QD will not notice that the text has been changed and will also not react when the text is removed or overwritten. If a new filename is created, the filename is changed or the text is forgotten, then QV_FILNM should be set (or cleared, for no text) and the routine QD_NWNM should be called to inform QD about a new filename.