Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!mnetor!uunet!seismo!mcvax!ukc!dcl-cs!strath-cs!paisley!rh
From: rh@cs.paisley.ac.uk (Robert Hamilton)
Newsgroups: comp.emacs
Subject: Re: Microemacs
Message-ID: <353@paisley.ac.uk>
Date: Wed, 22-Jul-87 11:10:37 EDT
Article-I.D.: paisley.353
Posted: Wed Jul 22 11:10:37 1987
Date-Received: Sat, 25-Jul-87 14:20:47 EDT
References: <1250@ihlpm.ATT.COM> <782@cpocd2.UUCP>
Reply-To: rh@cs.paisley.ac.uk (Robert Hamilton)
Organization: Paisley College of Technology.
Lines: 127

In article <782@cpocd2.UUCP> rod@cpocd2.UUCP (Rod Rebello) writes:
>In article <1250@ihlpm.ATT.COM> aaa@ihlpm.ATT.COM (Adams) writes:
>>Does anyone know how to do key bindings for a vt100?  I have microemacs
>>3.8i and I cannot get the key bindings to work properly with a
>>vt100.  Please respond by e-mail.
>>

I hacked this for a BSD4.3 system, using tcap.c
I don't have the origonal files so no diff,
but these should give the idea... 
You get the arrow keys,Function keys and numeric keypad bound
to FN* stuff which you can use in your .emacsrc .
In tcap.c get KU,KD etc from tgetstr.
and insert these functions: (call arrowkeys fom main)
===============tcap.c====
arrowkeys()	/* bind arrow keys if string is 2 or 1 chars */
		/* added rh@paisley.cs */
{
if (KU==NULL) return;
if (strlen(KU)<3) { /* ok doit but not for the ansis which
			are set up by default we hope */
		arrowbind(forwline,KD);
		arrowbind(backchar,KL);
		arrowbind(backline,KU);
		arrowbind(forwchar,KR);
	}
}
arrowbind(func,keys)
int (*func)();
char *keys;
{
	int c=0;
	int d=0;
	register KEYTAB *ktp;
	int found;
	ktp= &keytab[0];
	found= FALSE;
	/* first translate keys into c */
	if (strlen(keys)==1) d= *keys;
	else if (keys[0]== 0x1b) 	/* escape prefix */
		{c=META; d=keys[1];}
	else if (keys[0]=='\030') { c==CTLX; d=keys[1];} /*ctlx prefix*/
	if (d>=0x00 && d<=0x1F)           
                d = CTRL | (d+'@'); /* ctl prefix on last char */
        c |= d;
	while (ktp->k_fp != NULL) {
		if (ktp->k_code == c) {
			found = TRUE;
			break;
		}
		++ktp;
	}
	if (found) ktp->k_fp = func;
	else {
			if (ktp >= &keytab[NBINDS]) {
			mlwrite("Binding table FULL!");
			return(FALSE);
		}

		ktp->k_code = c;	/* add keycode */
		ktp->k_fp = func;	/* and the function pointer */
		++ktp;			/* and make sure the next is null */
		ktp->k_code = 0;
		ktp->k_fp = NULL;
	}
	return(TRUE);

}

and in input.c change make this change to getcmd:
==============input.c=====
getcmd()

{
	int c;		/* fetched keystroke */

	/* get initial character */
	c = get1key();
#if TERMCAP
/* hack to translate ansi arrow keys esc-o-[a-d] to FN
   and function keys escop-s to spec5-8 
   added rh@paisley.cs
*/	if (c == metac) { int d=get1key();
		if (d=='[') {/*mapping arrow keys;*/
		if (islower(d)) d ^=DIFCASE;
			d=get1key();
			return(SPEC | d);
			}
		if (d=='O') {d=get1key();
			return(SPEC |d);
			}
		else  {
			if (islower(d)) d ^=DIFCASE;
			return(META | d);
		}
		}
#else
	/* process META prefix */
	if (c == metac) {
		c = get1key();
	        if (islower(c))		/* Force to upper */
        	        c ^= DIFCASE;
	        if (c>=0x00 && c<=0x1F)		/* control key */
	        	c = CTRL | (c+'@');
		return(META | c);
	}
#endif
	/* process CTLX prefix */
	if (c == ctlxc) {
		c = get1key();
	        if (c>='a' && c<='z')		/* Force to upper */
        	        c -= 0x20;
	        if (c>=0x00 && c<=0x1F)		/* control key */
	        	c = CTRL | (c+'@');
		return(CTLX | c);
	}

	/* otherwise, just return it */
	return(c);
}


-- 
JANET:  rh@uk.ac.paisley.cs		| Computing Science
EMAIL:	rh@cs.paisley.ac.uk		| Paisley College
UUCP:	...!seismo!mcvax!ukc!paisley!rh	| High St., Paisley
Phone:	+44 41 887 1241 Ext. 219	| Scotland , PA12BE