[comp.unix.sysv386] CRISP 1.9 fixkeys

rlin@cs.ubc.ca (Robert Lin) (09/14/90)

Yes, CRISP 1.9 is one great editor. If you can live with one or two
minor glitches. Here's a program to remap some keys on ISC to make it
work better with CRISP. Basically the Ctrl-num keypad needs to
generate ESC ? [0-9] instead of their num keypad (no ctrl) esc sequences.
Also, you want Alt-A,W,Q,Z,M to generate ESC n <a,w,q,z,m>.

There's more that needs to be done, but they aren't critical. I'd like
to hack it to do screen switching via Alt-Fn, instead of Alt-SysRq-Fn.
In fact, Paul Fox wrote a program that was supposed to do this, but
it doesn't quite work (src/util/kbd.c). 

I am hoping someone else will post a fix to the Alt-1 bookmark bug
that somebody mentioned.


----cut here----

#include <fcntl.h>
#include <sys/types.h>
#include <sys/at_ansi.h>
#include <sys/kd.h>

keymap_t MyKeys;
char IntMap [12] = { '7', '8', '9', '-', '4', '5', '6', '+', '1', '2', '3' };

main ()
{
	int i, n;
	char *cp, StrTable [512];
	
	ioctl (0, GIO_KEYMAP, &MyKeys);
	for (i = 0; i < 12; i++) { /* 2 is CTRL */
		MyKeys.key [i + 71].map [2] = i + 0x58;
	}

	MyKeys.key [16].map [4] = 0x7D; /* Alt-Q => esc N q */
	MyKeys.key [17].map [4] = 0x7D; /* Alt-W => esc N w */
	MyKeys.key [30].map [4] = 0x7D; /* Alt-A => esc N a */
	MyKeys.key [44].map [4] = 0x7D; /* Alt-Z => esc N z */
	MyKeys.key [50].map [4] = 0x7D; /* Alt-M => esc N m */
	MyKeys.key [11].map [4] = 0x7D; /* Alt-0 => esc N 0 */

	for (i = 2; i <= 10; i++) {
		MyKeys.key [i].map [4] = 0x7D; /* Alt-1 to 9, => esc N 1-9 */
	}

	ioctl (0, PIO_KEYMAP, &MyKeys);
	ioctl (0, GIO_STRMAP, StrTable);
	cp = StrTable + 244;	
	for (i = 0; i < 12; i++) {
		*cp++ = 0x1B;
		*cp++ = '?';
		*cp++ = IntMap [i];
		*cp++ = '\0';
	}
	*cp = '\0';	
	ioctl (0, PIO_STRMAP, StrTable);
}