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