11/11/76 Two new dispatch tables have been added to generalize dispatching from altmode and altmode question. RAMAC is a table of macros or functions just like RCMAC. The default function of altmode in RCMAC is to read the next char and use it to dispatch through the RAMAC table. Default entries are defined for the arrow keys and colored keys so they work as before. The entry corresponding to $? has as its default function a dispatch into the other new dispatch table, RBMAC. This table is empty for now, so typing alternate keypad chars just beeps and is ignored. Corresponding to these new tables are two new variables: RAMAC and RBMAC which work just like RCMAC. Note that you do not have to use these tables via $? for example. You could extract the function which dispatches to the RBMAC table and stick it in RCMAC under some char eg ^Y to use this char as another escape char in place of altmode. Other changes: esr has been fixed so that if some commands follow esr on the line, the will be executed after you exit ^R mode. This means that you can enter esr mode from a macro. ECR now works from a macro within ^R mode so that you can exit via a macro. Real Time Teco Teco has been modified to support real time interaction with display terminals (vt52's). A set of commands has been implemented within teco. User's may use these commands, or modify them to make a new set of personalized commands. To enter ^r mode type: esr$$ To leave ^r mode type: ^M (linefeed for most people) Note that there is no other way to leave ^r mode, short of break. This, without any modifications is the normal control r mode. Non- control, non-rubout chars are automatically inserted into the buffer and displayed on the screen. Control chars and rubout perform special functions when typed: char function ^D delete expt chars ^F move forward expt chars ^H move backward expt chars ^K kill expt lines ^L choose a new window ^M leave ^r mode ^N move down expt lines ^P move up expt lines ^Q insert next char typed including control chars ^U multiply expt by 4 rubout delete expt chars backwards Most of the commands take something called expt as an argument. This is a variable which is normally 1, but can be increased exponentially by typing ^U, thus ^U=4, ^U^U=16, ^U^U^U=64 etc. Each time a ^r mode command takes expt as an argument, it resets expt to 1 when it returns. Escape Mode A special mode has been implemented to take advantage of the special keys on a vt52. When esc is typed to control r mode, the next char read will be interpreted as an escape command. These translate into normal ^r mode commands, thus the following commands are defined: command vt52 char function esc A uparrow go up expt lines (^P) esc B downarrow go down expt lines (^N) esc C rightarrow go right expt chars (^F) esc D leftarrow go left expt chars (^H) esc P blue key expt := expt * 4 (^U) esc Q red key delete expt chars (^D) esc R black key kill expt lines (^K) How It Works Various mechanisms have been inserted into teco to make all this happen. For the most part, the special functions have been included in a form that the user may get his hands on from teco command level to provide his own special facilities and commands. Display hackery: the t command now has an @ option which does useful things to update the screen in ^r mode. The @ option has no effect when not in ^r mode. There are really three different commands added here depending upon whether @t has 0 1 or 2 arguments: @t This simply tries to put the cursor at the right place on the screen. You can move the cursor around via the normal c,r,l etc then set the cursor in the right place by doing @t. If you have moved the cursor outside the window currently diplayed, @t will choose a new window and redisplay it. n@t This redisplay the whole screen from char number n, to the end of the screen, leaving the cursor at the end of the screen. Thus .@t will redisplay the screen from the current cursor position. This option figures out where n is on the screen and puts the cursor there before typing anything. If n is above the screen in the real buffer then the "window?" error will result. If n is below the screen, the command is ignored. m,n@t This types the buffer between m and n inclusive at the right place on the screen, and leaves the cursor at the last char typed. m should be less than n and if m is befor the window, a "window?" error will result. Variables: a new command fv, has been added, corresponding roughly to fs on ITS teco. fv expects a variable name string argument, thus fvname$ returns the value of the name variable. In many cases, these variables are really pseudo variables which give access to obscure, internal teco routines. Variables may have one or two numeric arguments which usually means to set the variable to the argument, and will normally return one numeric result which can then be used with other commands. The name string must match exactly with the right case, no leading blanks etc. variable function %BOTTOM a simple variable, used by ^r mode. specifies the % of the screen at the bottom such that if the cursor falls in this region, a new window should be selected. %TOP simple variable analogous to %BOTTOM, which specifies the region at the top of the screen which should causes a new window to be selected. %CENTER simple variable, which tells ^r mode how far down to put the cursor when choosing a new window. Initially 40, meaning put cursor 40% down. HEIGHT simple variable, number of lines on screen. Set by teco from your tty variables. WIDTH simple variable, number of columns on screen. Equal to B.LLEN + 1. ECHOSW simple variable, tells teco whether to echo chars typed at your terminal. 0 => echo, 1 => no echo. Equal to zero while in ^r mode. GRAPHM active function, acts like simple variable to specify whether in graphics mode or not. Setting this variable to 1 cause literal output mode on your tty, setting to 0 clears literal output mode. Set to 1 by ^r mode. LINESIZE active function with no arguments. Returns the size of the line containing . in screen lines. The ^r mode function which inserts normal chars uses this function to determine when a line has overflowed, and hence the screen must be redisplayed. ^RHPOS active function, specifies horizontal position of the cursor while in graphics mode. Setting this variable will move the cursor to right column on the screen. (Note this is uparrow RHPOS, as are others.) ^RVPOS active funtion which specifies vertical position of the cursor while in graphics mode. Setting will move the cursor ^RMODE simple variable, 1 => execute commands via ^r mode 0 => normal mode. Setting this switch, causes chars typed to be executed immediately via the RCMAC dispatch table (see below). ESR sets this as well as graphm and echosw. ^RCMAC array variable. With one argument, returns the value of nth entry in RCMAC table. For the use of this table see below. With two arguments m,n; sets the nth entry to m, and returns m ^REXEC active function. nfv^REXEC$ will execute the internal rmode function n where n is a negative number like the ones returned by ^RCMAC. Doesn't return anything. ^R Mode Dispatch Hackery: Control r mode works by reading chars from your tty, then using the char as an offset into the ^RCMAC table to select a function to execute. Normal chars select the char insert funtion which inserts the char into the buffer, then updates the screen. By setting entries in the ^RCMAC table via the FV command, the user can change the function which is triggered by a particular character. The ^RCMAC table entries come in two flavors, positive and negative numbers. Negative numbers specify internal ^r mode functions to be executed. Positive numbers specify that when the char corresponding to this entry is typed, the q register whose ascii value is the number in the ^RCMAC table entry will be macroed. For example, if you don't like what ^U does and would rather that it erased the line up to this point as is normal Delphi practice, you write a macro which does the right thing and put it in some q register like U. You then do: ^^U,21FV^RCMAC$ at command level in teco. The next time you go into ^r mode and type a ^U, what ever is in q register U will be macroed. You could make ^V do what ^U used to do by setting the ^V entry to the appropriate internal ^r mode function like this: 21FV^RCMAC$u1 ;get the original ^U function, (happens to be -12) ^^U,21FV^RCMAC$ ;set ^U entry to macro q register U, your new function q1,22FV^RCMAC$ ;set ^V entry to be the old ^U function, ie -12 A note on the FV^RCMAC$ arguments: there are 128 entries in ^RCMAC, thus the arg if one arg, or the second arg if two args must be in the range 0-127 corresponding to the ascii chars. The first arg must be a number like 65-90, 97-122 for macroable q registers, or -1 to -12 for internal functions. Be careful about using explicit internal function numbers as they are subject to change.