Hacking MacTerminal As promised at the MAC-VAX Connection symposium at DECUS, but a bit tardily, I am sending you the information on the modifications to MacTerminal which I use daily. I think MacTerminal is a pretty good program, but since I spend many hours each day talking to my VAXes through it I am sensitive to even slight flaws. Where I have found such flaws I have tried to correct them. So, attached are four MacTerminal modifications which make it a nicer tool. Although I found two of these fixes independantly, all this information has been circulated in one form or another through the INFOMAC network on Arpanet. The Hacks: Remap Backspace and DELete MacTerminal maps the key labeled Backspace to be an ASCII backspace, hex 08 and the combination of the control key (cloverleaf or command key) and the Backspace key to be DELete. Since VT100 terminals have a DELete right where the Backspace key is, it's more convenient to have the two functions reversed. That way just hitting the Backspace key produces a DELete and the control-Backspace combination makes a backspace when desired (ie, in EDT). Using FEDIT, open the MacTerminal application and ask for the display to be shown in hex. Go to sector 7 hex and look at the 8 words starting at byte 0A7 hex. You should see 8 words of 087F. Change all 8 words to 7F08, and write the modified sector back to disk Remap the Arrow Keys MacTerminal puts the cursor control keys on the numeric keypad. That's a problem if you don't have a keypad; but even if you do it's not a great place. Since there aren't enough keys to give the cursor control keys their own assignment MacTerminal uses the combination of control- and the keypad keys +, *, /, and comma. Unfortunately in EDT (where the heaviest use of the cursor control keys occurs), those same keys without the command key hels down can have undesired effects, such as deleting text. To avoid this, I chose to move the cursor control keys to a place where even if I forget to press the control key nothing terrible happens. I use the combination control-9, control-0, control-- and control-= since these are closest to the placement on a VT-100 terminal. Using FEDIT open the MacTerminal application. In sector 6, near byte 100 hex you will see four words of 39FF. (There will be one word separating each of the words of 39FF) Change all four words to 3980. In a similar manner, locate 4 words of 30FF and change them to 3081; 2DFF to 2D82; and 3DFF to 3D83. Write the modified sector back to disk. Note that this just adds new cursor key equivalences. The original mappings are left intact. Change the Automatic Disk Update Timer MacTerminal updates the document in which you are working every time you leave the keyboard idle for 8.3 seconds. That happens to coincide nicely with the average amount of time I spend thinking about what to do next. I start typing just about when MacTerminal starts writing to the disk, and I have to wait a second or so before what I type appears on the screen. I've hacked this to wait approximately one minute before doing the disk update. Using FEDIT open the MacTerminal application. Search for the hex string 000001F4. Change it to 00000E00 and write the modified sector back to the disk. Change MacTerminal's Application Startup Default Settings When MacTerminal starts it comes up with certain settings, VT100 mode, 80 columns, 1200 baud, etc. You can customize these settings to be any you want. Start the MacTerminal application, and set all the options the way you want them. Save a document with these settings, and exit. Using the Resource Editor or Rmover applications, open the document you just saved. Copy the CNFG resource from the document and paste it into MacTerminal. Alternatively: MacTerminal will always look for a document named Untitled when it starts up. If you save your desired values in Untitled, starting MacTerminal will give you those settings. What the Hacks DO In this section I'll explain, to the degree I understand, what's going on with these hacks. The heart of any terminal emulation is some sort of table which converts keypresses locally to a character or string of characters to be sent to the host. The first two hacks modify that table (actually two tables). The resource KICH 256 in MacTerminal is the main table. Each key has a set of entries in the table. For each key there is a word whose left byte is the character to be sent when the key is pressed and whose right byte is the character to be sent when both the control (cloverleaf) and the key are pressed. Following that word is another specifying the action of the key when shift is held down, and when shift and control are held down. This two-word sequence is repeated three more times. I don't know why, but may have to do with the available combinations of shift, option, caps lock, etc which might also be pressed. The first hack just reverses the characters for backspace and delete for the key which is labeled backspace. The second hack goes a little bit further. To emulate a complicated terminal such as the VT the emulation program needs to be able to send more than just one character for one keypress. MacTerminal does this by treating any entry in the main table (KICH 256) which is in the range 80 to FE hex not as character to be sent, but as an index into a second table which is resource KMRC 256. Each entry in this table is a word whose right byte is the character and whose left byte controls what else is to be sent along with the character. For example, 01xx sends [xx, and 03xx sends control-xx. What the second hack does is patch the entries for the combination of keys 9, 0, -, and = and the control key to cause a lookup into the KMRC table which sends the correct escape sequences for the cursor control keys. You could easily map any other 4 keys to be cursor control keys, and you could also set up a correspondance between keypad keys and other keys to avoid having to have a keypad. There's plenty of empty space in the KMRC table, so you could set up additional function keys for any specific host applications as well. The third hack is straightforward. Most timing on Mac is counted in vertical retrace intervals, ie based on the interrupt which happens 60 times per second as the screen in redrawn. The longword 000001f4 simply counts 500 decimal retraces, and then update the disk. I changed it to 00000E00, or about 60 seconds. The fourth hack just takes advantage of the fact that MacTerminal will implement the settings stored in a CNFG resource when it starts up, if it can find one. By putting such a resource in the application's resource file you guarentee that one will be found. If you open a document with another CNFG in it, that one will be used since the search order for resources is from most recently opened resource file to oldest resource file (ie the System). Credits I have used a lot of other people's work to assemble this. These people are all disembodied electronic messages to me, and some I have only an E-mail address for. Here are the acknowledgements as I know them: Thomas@Utah-cs Info about KMRC resources J. Hardis CIS 76174,105 Disk Update info Chris Borton UCSD Pasting resources from documents into the application. Michael Peirce Livermore Labs Inspiration for arrow key movements Larry Rosenstein Apple Info about KICH resources One final Caveat... These hacks are mine. If something is wrong blame me, not Apple or the references listed above. If there is ever a MacTerminal 2.0 as rumored, these hacks may very well not work. Let the user beware. John Child Boston College