Sun Terminal descriptor file and Editor commands. Below the default terminal descriptor and command file build into the editor V. However, by creating in your home directory files named crt.sa com.sa one can override the default. The editor searches for those files and if not found uses the default. Also files can be specified on the command line: V t=termdf c=commandf Fname where termdf is the terminal descriptor file and commandf is the command file. The format of those file is described below. Fname is the file to be edited. 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=termdf. This file must be in the format as shown below (which are the default sequences, here the Ansi sequences as used by many terminals). The file may literally be in the form as shown here, between the two -- lines. The asterisk signals the start of comments. Refer to the terminal manual for the character strings required. The strings may be given as a sequence of decimal numbers or as character strings enclosed between quotes. In the last case a backslash preceeding a character makes it a control character. Notation for strings enclosed in double quotation marks: \X = Control-X, \\ = \, \!=Control-\, "" = ". Note that escape is the same as Control-[, i.e. \[. Example: the character sequence "\[[2J" (Escape [ 2 J) can also be written as 27,91,50,74 and also in hexadecimal notation: 0x1B,0x5B,0x32,0x4A Below the string notation is used. The -1 in the second line is obligatory as a delimiter. The offsets in that line refer to the amount to be added to horizontal and vertical positions. -- "\[[\@;\@H" * Cursor positioning command. 31,31,34,80,-1 * Offsets, screen size. Add "X" after the size 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 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. Notation for strings enclosed in double quotation marks: \X = Control-X, \\ = \, \!=Control-\, "" = ". -- Cu="\[[A" * Cursor up Arrow keys Cl="\[[D" * Cursor left Cd="\[[B" * Cursor down Cr="\[[C" * Cursor right Qu="\C" * Quit Cntrl-C *There is an emergency exit command at the very lowest level. * It is Esc Cntr-C repeated twice. 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="\[[200z" * To first column. L9 Lc="\[[201z" * To last column. L10 Ln="\@" * Line number positioning. Cntrl-@ Co="\^" * Position to column Cntrl-^ Sp="\[\[[B" * Next screen Esc Cursor down Sn="\[\[[A" * Previous screen Esc Cursor 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="\[[220z" * Set mark R13 Me="\[[214z" * Erase mark R7 Mg="\[[216z" * Go to mark R9 Mx="\[[222z" * Exchange with mark R15 Df="\D" * Delete char forw, incl newl. Cntrl-D Dl="\[[209z" * Delete line R2 Db="\d" * Backward delete, incl newline Delete Dn="\[\D" * Forward delete not newline Esc Cntrl-D Nd="\[\d" * Backward delete, not newlines Esc Delete Dr="\[[208z" * Restore latest delete R1 *Cut and paste operations. To do more than one line or character use * the Hs (Highlight selection, see below) command. 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 *The following command highlights the portion of the file between * mark and cursor. A number of commands relating only to that portion * can be executed (like replace or delete for example). The available * commands are displayed in the title line. Hs="\U" * Highlight selection Cntrl-U *One may introduce control characters as part of the file. Normally * control characters are interpreted as commands. To introduce a control * character as part of the file first type the 'escape character'. * Note that control characters in a file, normally indistinguishable, * may be highlighted with the Cn (see below) command. Ec="\!" * Escape character Cntrl-\ *The following two commands are generally meant for use in macro's. 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 *For systems that need explicitly both Carriage return and Line feed in * text files. Normally, in Unix-like systems the Line feed performs the * function of the two combined, and also the Editor uses that convention. Ms="\[\M" * Strip CR from in/output Esc CR Mi="\[\[\M" * Do nothing concerning CR. 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 *When executing learned commands a continuation signal is needed every so * often. This continuation signal is \@ (Cntrl-@). This feature has been * introduced to avoid hang-up and other disasters inside macro loops. *Macro's may be made and tested while in the Editor. * Place the mark and the cursor at the beginning and end of the macro, * and issue the 'Macro reading command'. 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 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 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. * Macro's may be part of the com.sa file or they may be in some file specified on the command line with the prefix m= (Example: V m=Mfile Fname). Below follows a description of the macro language. First a very trivial example. Suppose that the sequence Esc Esc Esc (three times escape key) is to be used as equivalent to the cursor up command. A macro to achieve this is CU="\[\[\["=Cu;end If you are reading this while in the Editor then this may be tested right now: put the mark at the beginning of the macro (at the first character C), the cursor just below the macro and type the 'Macro reading' (Mr) command. Type Y in response to the question. Then type three escapes to see the effect. One of the main pitfalls in macro definition is the two character sequence in front. Make sure that it has not been used before. Furthermore, be careful that the command string (three escapes here) is not equal to any other command when stripping some characters from the end. Thus if there had been already a command sequence of two escape characters then this one would not work as intended but would be interpreted as the old command followed by one escape. 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; 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