Terminal descriptor file and Editor commands. Any editor interacts with the screen and keyboard in two ways: certain sequences are emitted by the Editor to the screen to move the cursor up etc, while certain character strings emitted by the keyboard must be understood properly such that for example the Editor can move the cursor up if the keyboard arrow-up key is pressed. The strings to be sent by the Editor to the screen can be specified in an external file which file must then be specified on the command line: T=Tname. This file must be in the format as shown below (which are the default sequences, here the VT52 sequences). The file may literally be in the form as shown here, between the two -- lines. -- * CRT sequence table for VT terminals. * XY cursor positioning, base offset and screen size. * Note: an offset of 127 is interpreted as 0. * ANSI terminal characteristics and commands. "\[[\@;\@H" * ANSI standard codes (default). 31,31,24,80,-1 * Offsets, screen size. Add "X" if XY exchange. "\[[2J" * Clear screen. "\[[H" * Cursor home. "\[[G" * Cursor to column one. "\[[A" * Cursor up. "\[[B" * Cursor down. "\[[D" * Cursor left. "\[[C" * Cursor right. "\[[L" * Open line. "\[[M" * Delete line. "\[[K" * Clear line. "\[[J" * Clear from cursor to end. "\[[7m" * Reverse video. "\[[m" * Normal mode. All commands are identified by a two letter sequence (the first a Capital). The strings shown are the sequences to be generated by the keyboard, and will lead to the action described. The key sequences are in the last column. The Cntrl, Alt and Shift keys must be pressed simultaneously with the character key following. The escape key is a separate character, the same as Cntrl-[. Commands may be redefined (to adapt to another keyboard) by means of an external file to be specified on the command line: C=Name. In this file the desired command sequences can be specified by lines of the form: Xx="string" where Xx refers to the name of the command (see below) and string is the new command sequence. The first character of string must be a control character, and it must be impossible to obtain any other command by either adding or deleting characters at the end of string. Also macro definitions may be given in this file, see further on. The notation F1 etc. refers to the function keys. Notation for strings enclosed in double quotation marks: \X = Control-X, \\ = \, \!=Control-\, "" = ". Cu="\[[A" * Cursor up Cl="\[[D" * Cursor left Cd="\[[B" * Cursor down Cr="\[[C" * Cursor right Qu="\C" * Quit \C No="\S" * Do nothing 1. Np="\Q" * Do nothing 2. Bw="\A" * One word back. Cntrl-A Fw="\W" * One word forward. Cntrl-W Fc="\[[10~" * To first column. Shift cl Lc="\[[9~" * To last column. Shift cr Ln="\@" * Line number positioning. Cntrl-@ Co="\^" * Position to column Cntrl-^ Sp="\[[6~" * Next screen Page down Sn="\[[5~" * Previous screen Page up Pu="\[+" * Push position counter Esc + Po="\[-" * Pop position counter Esc - Pa="\[a" * Define pattern a Esc a Pb="\[b" * Define pattern b Esc b Px="\[x" * Exchange patterns Esc x Ps="\Z" * Pattern search Cntrl-Z Pr="\[\Z" * Reverse pattern search. Esc Cntrl-Z Pn="\[z" * Toggle search mode Esc z Rx="\R" * Replace string exclusive once Cntrl-R Ra="\[\R" * Replace string non-excl once Esc Cntrl-R An="\[R" * Replace all Esc R Ax="\[r" * Replace all exclusive Esc r Ms="\[[20~" * Set mark F9 Me="\[[21~" * Erase mark F10 Mg="\[[23~" * Go to mark F11 Mx="\[[24~" * Exchange with mark F12 Df="\D" * Delete char forw, incl newl. Cntrl-D Dl="\K" * Delete line Cntrl-K Db="\d" * Backward delete, incl newlines Delete Dn="\[\D" * Forward delete, not newline Esc Cntrl-D Nd="\[\d" * Backward delete, not newlines Esc Delete Dr="\_" * Restore latest delete Cntrl-_ Tc="\T" * Take character Cntrl-T Tl="\Y" * Take line Cntrl-Y Pt="\V" * Put buffer Cntrl-V Eb="\[\V" * Empty buffer Esc Cntrl-V Hs="\U" * Highlight selection Cntrl-U Ec="\!" * Escape character Cntrl-\ Is="\[\I" * Insert sequence (not incl \n) Esc Cntrl-I In="\[I" * Insert newlines Esc I Na="\J" * Newline 1 Linefeed Nb="\M" * Newline 2 Carriage Ret. So="\[s" * Set option Esc s Ov="\[o" * Toggle overstrike mode Esc o Pe="\[." * Period special toggle Esc . Fo="\[f" * Fold lower case to upper case Esc f Cn="\[c" * Toggle highlight control char. Esc c Td="\[t" * Tab definition Esc t Te="\[e" * Tab entry/exit Esc e Mp="\[\M" * Strip \M from in/output Esc CR Mi="\[\[\M" * Do nothing concerning \M. Esc Esc CR Gf="\G" * Get file Cntrl-G Ef="\[\G" * Exchange file Esc Cntrl-G Wf="\[W" * Write file Esc W Wb="\[w" * Write take buffer Esc w All commands between Le commands are stored. When the same command but with upper case character (thus here \[L) is received the recorded string of commands is repeated. Le="\[l" * Start/end learning. Esc l Mr="\[m" * Macro reading Esc m Buildin macro's: OL="\]R" Open line Insert BF="\]G" Begin file Home EF="\[\]G" End file Esc Home RD="\[_"=Dr;end Alernative Restore delete Esc Underscore CL="\[\]K" Cursor left through end line Esc Arrow left CR="\[\]M" Cursor right through end line Esc Arrow right RS="\L" Refresh screen Cntrl-L AE="\[\[a" Pattern A with reverse search Esc Esc a TD="\[1" Set Assembler tab format Esc 1 Follow this with command Te (Esc e) MB="\[2" Make box Esc 2 TI="\[3" Give time string Esc 3 * Summary of macro operations. * Statements are delimited by a semicolon, labels by a colon. The end of a macro definition is given by the word 'end'. The * after a semicolon is comment delimiter. Elements: labels 0-7, registers 0-7 (byte size), and an array v, elements v0-v255, of which the elements v0-v7 are directly addressable. All elements of v can be addresses through indexing by a register, whose content is then taken to be a positive number in the range 0-255. Notation: v[ri], with i=0-7. The only way to change or retrieve or test the contents of an array element is through a register. The registers and the array elements are byte size. Below, whenever reference is made to r3 or vA any one of the registers c.q. array elements in the notation shown above may be used. Special element: li. This is a word size element closely related to the line number of the cursor position. The statement r3=li brings this linenumber into the pair (r3,r4). Conversely, the statement li=r3 puts the value of the pair (r3,r4) into the linenumber, and the screen and cursor are adjusted to that. Special element: fl. fl is an error flag, reset to zero whenever it is tested. It is set to -1 if an error occurs or when reading end-of-file with an 'sc' operation. It is set to 0/-1 after a search (0 if succesful). Special function: put(). This leads to sending of one or more characters to the Editor, interpreted as if they where coming from the regular input. Legal arguments are: (i) Ascii strings. Example: put("Hello world.\J"); (ii) The registers r0-r7, and the subroutines as, a0-a7, ti, ic, sc. Subroutines are: all commands and previously defined macro's. They may be referred to by their two-character name. In addition a number of special purpose subroutines are available: Name Function ad Word operation. Performs: (r0,r1)=(r0,r1) + (r2,r3) su Word operation. Performs: (r0,r1)=(r0,r1) - (r2,r3) mu Word operation. Performs: (r0,r1)=(r0,r1) * (r2,r3) di Word operation. Performs: (r0,r1)=(r0,r1) / (r2,r3) dr Word operation. Performs: (r0,r1)=rest of (r0,r1) / (r2,r3) bp Beep. Makes the terminal beep. lo Locks the macro in. Normally, during macro operations the Editor regularly interrupts the macro operations, and will resume only if an 'approving' signal is received from the input (Control-@ = \@). This is a safeguard against macro hang-ups. Any other signal leads to abortion. For macro's guaranteed to be correct one may by invoking this subroutine (lo) avoid this interrupting. Unlocking will happen only if (i) the terminal is made to beep (either through an error or by using 'bp'), or (ii) the end of file is read by an 'sc' operation. Example: lo; no No operation. It is in fact the operation r0=r0!r0. This operation has its use in connection with message and other printing. Normally, when in a macro, the editor will not print input, for example the command Pa (pattern A) in a macro gives not rise to the usual message in the top line. If however the Pa is followed by a 'no'the message will be printed. The same holds for showing the characters typed for the pattern. Here an example of how to get a backward search following pattern input with normal printing: XX="\[\[a"=Px;Pb;no;r1="\J";r0="\M"; *Exchange patterns, then read pattern 0: r3=ic;put(r3);no;if(r0=r3)goto 1f; * B till LF or CR seen. if(r1=r3)goto 1f; goto 0b; 1: Px;Pr;end * Exchange again, reverse search. st Stop, exit from this macro. end Indicates end of the macro. Implies in addition a stop, st. Subroutines resulting in a value to be used either in a put() function or in a replacement statement. as Produce an ascii string corresponding to the word (r0,r1). Example: r0=li; put(as); This brings the line number corresponding to the cursor position on the screen, at that same position. a3 Produce an ascii string corresponding to the byte in register r3. Example: let r3 contain the character 'a' = 0x61 = decimal 97. The statement put(a3) leads to the letters 97 on the screen. ti Produce an ascii string giving date/time. Example: put(ti); leads to appearance of date/time on the screen. ic Get a character from standard input (keyboard). The character can be put in a register or passed on to the screen. Example: r3=ic; put(ic); sc Get the character from the screen at the location of the cursor. Example: r3=sc; cn Get the column number of the cursor position into a register. Example: r3=cn; Statements. r3 = # Put the given (possibly signed) byte size number into r3. r3 = r3 + # Replace r3 as specified. # byte size number. r3 = r3 - # Replace r3 as specified. # byte size number. The number # in the above statements may also be given in ascii string notation, such as r3="A"; or r3="\J"; r3 = xx Replace r3 by xx. Legal: r0-r7, vA, ic, cn, sc vA = r3 Replace the contents of vA by those of r3. r3 = r3 op x Replace r3 as specified. r3 = r3 op -x Legal operations op: + - * / & ! The last two are the logical 'and' and 'or'. Legal x: r0-r7, ic, sc, cn, and numbers in the range 0-4. Examles: r3=r3-4; r7=r7⁣ r2=r2-cn; Note that all these operations involve only two elements. Things such as r2=r3+r4 are not legal. Control statements. Labels. Defined by the occurence of a colon. Example: 7: Go to statements. Of the form 'go to #f' or 'go to #b' with # in the range 0-7. These transfer the macro pointer to the first occurrence of the label # in forward or backward direction respectively. The labels 0-7 may occur any number of times. If statements. These are simple two-way if's. Allowed forms: if(r3 ? x) statement; if(r3 ? -x)statement; if(r3 ? #) statement; if(ic ? #) statement; if(sc ? #) statement; if(cn ? #) statement; if(fl ? 0) statement; where ? may be < > or =, and x as before: 0-4, r0-r7, ic, sc, and cn. # is a positive number < 128 in ascii, hex or decimal notation. If the condition is met the statement is executed. Example: r3 = "X"; if(r3 = sc) put(a3); Note: a put() here must be byte size. In case of a put("string") only the first character is not transmitted if the condition is not met. Thus: if(r3=4)put("Ha !"); leads to transmission to the Editor of Ha ! if the condition is true, else only a ! is sent. * Runtime macro definition. * Extra Macro's may be defined at runtime. One simply types them in somewhere in the text, and when the macro seems correct delimit the appropriate area with cursor and mark. A subsequent Mr command ( \[m above) enters the macro in the macro table. If it existed already it is redefined provided it was the last one. After that it may be invoked, but it will not be saved. It may of course be saved by explicitly writing the same piece to some outside file. In fact, this is the easiest way to produce and test a macro. Step mode. When following up the column position command Co with a macro command that starts with Esc (\[) the Macro interpreter is put in step mode. This means that the request for the continuation signal (\@) is made much more frequently. Any other character aborts the macro. This can be used to debug a macro sequence. For this to work the macro command sequence must start with escape (\[). Preceeding the macro call with a column position command leads then to step mode. This can not be done when already in a macro. * Some simple macro examples. * * Rub forward till character (asked for) seen or end line or end file. * Command is Esc 4. RF="\[4"= r0=ic; r1="\J"; r2="\E"; 0: r3=sc; if(r3=r0)goto1f; if(r3=r1)goto 1f; if(r3=r2)goto 1f; Df; goto 0b; 1: st; end * Search in forward direction till character (asked) seen. * Note the use of pattern B, to avoid option resetting (done if pattern A). * Command is Esc 5. AD="\[5"= r1="\M"; r0=ic; * Allow abort by straight return. if(r1=r0)goto 3f; * Get input character. So; put("S+\M"); * Set options. Search direction r1 Pb; put(r0); put("\\J\\E\M"); * Define pattern. Px; Ps; st;3: end * Exchange patterns, search. * Macro to order lines alphabetically with respect to the first two * characters. Execution stops at the end of the file, or when meeting * an empty line. * Command is Esc O. Needs often the continuation signal \@ (Cntrl-@). OA="\[O"= r7="\J"; r6="\E"; * Remember position first by 'Push'. 0: Cd; Fc; Pu; r0=sc; * Get first two characters in r0,r1. if(r0=r7)goto 7f; if(r0=r6)goto 7f; * Stop if empty line or end file. Cr; r1=sc; Cl; r4=0; 1: Cd; Fc; r2=sc; * Inspect next line. If smaller set if(r2=r7)goto 6f; if(r2=r6)goto 6f; * mark, replace r0,r1 with r2,r3. Cr; r3=sc; Cl; if(r2