[net.micro.mac] How to remap MacTerminal keys

chuqui@nsc.UUCP (Chuq Von Rospach) (06/23/85)

Thanks to everyone who responed to my request for the information on remapping
MacTerminal keys. I've got things set up the way I want them. For the
others out there who are interested, here is a summary of the information 
I got. I hope it helps.

chuq
---
From seismo!harvard!gcc-bill!timp Thu Jun 20 14:44:52 1985
Chuq,
	The keyboard map, as you may know, is set at boot time
by an INIT resource in your system file.  I do not know which ID (0, 1 or 2)
INIT resource is responsible.  However, if you use FEDIT on the resource
fork of your system file, you will find the map in sector 7 (and possibly
the start of 8).
	Editing the resource and then re-booting causes the new keyboard
map to be initialized.  The structure of an INIT resource should be:
	1)  A branch to the code.
	2)  A table used by the code. (In this case the map.)
	3)  The actual code.

	Finally, there has been talk on the net of applications which set
the keyboard map.  These must change the map after it has been initialized.
If you can't find them, a look at the init resource will probably tell you
how to do it yourself.  Hope this helps.

Tim Peacock (timp@gcc-bill)

From seismo!ut-sally!mcc-db!paver Fri Jun 21 17:40:59 1985

>From hitchens@ut-sally.UUCP (Ron Hitchens) Tue Dec  4 08:53:06 1984
Relay-Version: version B 2.10.1 6/24/83; site ut-ngp.UUCP
Posting-Version: version B 2.10.2 9/18/84; site ut-sally.UUCP
Path: ut-ngp!ut-sally!hitchens
From: hitchens@ut-sally.UUCP (Ron Hitchens)
Newsgroups: net.micro.mac
Subject: MacTerm keymap layout
Message-ID: <371@ut-sally.UUCP>
Date: Tue, 4-Dec-84 08:53:06 CST
Date-Received: Thu, 6-Dec-84 15:31:17 CST
Distribution: net
Organization: WizCo Enterprises, Dept of Departmental Affairs
Lines: 69

[MacBug line]

   Recently someone posted instructions for patching the tilde key in
MacTerminal, Here's the info you need to patch any key to anything.
Following is a copy of the notes I made up after spending a few hours 
poking around inside of MacTerm with FEdit (which you'll need to patch
MacTerm, it's available via anonymous ftp from ut-sally or sumex-aim):
-------

	Layout of the Macterminal keymap table for vt100 mode

  There is a lookup table in Macterminal which specifies the character 
to be transmitted for each key-down event on the keyboard.  When using
FEdit (in hex mode) to examine the resource fork of the MacTerminal
application, the table begins in block #5 (A is the first entry),
occupies all of #6, and ends in #7.  The tilde key is the last
printable key in the table, followed by the backspace key, then the
Enter key.  Entries for the optional keypad follow that, these entries
are encode in some way, supposedly to show they're inactive, but I
couldn't see an obvious relationship to their ascii counterparts.
  Each key on the keyboard has sixteen bytes in the table which define
the codes to be sent for each of the possible combinations of that key
plus the four modifier keys.  The four modifiers are: cmd, shift,
option and caps lock.
  Numbered from 0-15, left to right, the byte positions represent:

	 0 - Unshifted (no modifiers)
	 1 - Command
	 2 - Shift
	 3 - Shift/Command
	 4 - Caps Lock
	 5 - Caps Lock/Command
	 6 - Caps Lock/Shift
	 7 - Caps Lock/Shift/Command
	 8 - Option
	 9 - Option/Command
	10 - Option/Shift
	11 - Option/Shift/Command
	12 - Option/Caps Lock
	13 - Option/Caps Lcok/Command
	14 - Option/Caps Lock/Shift
	15 - Option/Caps Lock/Shift/Command

   Apparently unused codes should contain FF, but pressing one of these
combinations seems to produce a del (FF minus parity bit -> 7F)
   The code FC, seems to cause a break signal to be sent.
   The code FB, seems to be the effective 'do-nothing' code, nothing is sent.
   There are other codes used in this range, I didn't research them all.
----

   The changes I've made, which make MacTerm much easier to use with Unix,
are:
	tilde key:  unshifted=esc, cmd=`, shift=~  (same in second half, +opt)
	backspace:  unshifted=del, cmd=^H, shift=^H
	enter key:  unshifted=^J (new line), cmd=send break
	2 key: cmd=^@
	- key: cmd=^_  (these two to get control forms of the uppercase char)

  If you would prefer using option as the control key, you can change
byte number 8 (option modifier only) to the control value (in byte 1)
for each of the 26 alpha keys.  This would yield perhaps the first keyboard
in history with a control key on both sides.

  There is another table for tty mode, maybe a third for 3278 mode, I don't
know where it (they) are, I never use those modes so I didn't bother looking.
--------

Ron Hitchens		hitchens@ut-sally
  "So far, everything has happened prior to now"


= = == = = = = = = = = = = = = = = = = = = = = = = = = == = == = = = = = = =

>From lsr@apple.UUCP (Larry Rosenstein) Mon Dec  3 19:35:37 1984
Relay-Version: version B 2.10.1 6/24/83; site ut-ngp.UUCP
Posting-Version: version B 2.10.1.chuqui 4/7/84; site apple.UUCP
Path: ut-ngp!ut-sally!seismo!hao!hplabs!oliveb!ios!apple!lsr
From: lsr@apple.UUCP (Larry Rosenstein)
Newsgroups: net.micro.mac
Subject: Customizing MacTerminal
Message-ID: <7114@apple.UUCP>
Date: Mon, 3-Dec-84 19:35:37 CST
Date-Received: Thu, 6-Dec-84 19:51:47 CST
Organization: Apple Computer, Inc.
Lines: 44

After all the complaints about the MacTerminal keyboard, I feel compelled
to post this message.

The mapping between keycaps and Ascii characters is totally defined in
resource files (of course)!  Because of the way resources are found, it is
possible to setup the keyboard mapping on a document-by-document basis,
which is much better than have multiple copies of MacTerminal around.

There are 3 resource types to consider.  (In the following, I describe the
contents of the resource in terms of a Pascal declaration.)

(1) Type KCKI: PACKED ARRAY[KeyCode] OF KeyIndex,
               where KeyCode = 0..95 and KeyIndex = 1..71.
This maps the standard keycode numbers into the range 1..71.

(2) Type KICH: ARRAY[KeyIndex] OF Entry,
               where Entry = PACKED ARRAY[0..15] OF CHAR.
This maps the KeyIndex and the state of the modifier keys into an Ascii
character.  (The modifier bits are in the same order as in the
EventRecord.)

(3) Type CHRT: PACKED ARRAY[Boolean, Char] OF Boolean.
This maps the state of the command key and the Ascii character (from (2))
into TRUE if repeating is allowed for that key if the Repeat Ctrls options
if off.  (I am not 100% sure about this, however.)

There are 2 resources of each type; ID = 256 is for VT100/TTY mode and ID =
257 if for IBM mode.

I was able to customize one of my documents by using RMover to copy the
appropriate resources into the document, and using FEdit to modify them.

NOTE: I believe this information is accurate, but I have not verified this
with the MacTerminal authors.  (So don't blame them or Apple if something
goes wrong, blame me.)

Good Luck, and Enjoy!

Larry Rosenstein

CSNET: lsr%Apple@CSNET-RELAY
UUCP: {nsc, dual, idi, voder}!apple!lsr

P.S. I was deeply hurt to see that some people did not trust Apple to do
the RIGHT thing, at least once. :-)



-- 
:From the misfiring synapses of:                  Chuq Von Rospach
{cbosgd,fortune,hplabs,ihnp4,seismo}!nsc!chuqui   nsc!chuqui@decwrl.ARPA

The offices were very nice, and the clients were only raping the land, and
then, of course, there was the money...