Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!munnari!mundoe!glf From: glf@mundoe.mu.oz (Giuseppe Fiusco) Newsgroups: comp.emacs Subject: Key bindings for MicroEMACS(3.8i) (3 of 3) Message-ID: <304@mundoe.mu.oz> Date: Wed, 9-Sep-87 03:06:22 EDT Article-I.D.: mundoe.304 Posted: Wed Sep 9 03:06:22 1987 Date-Received: Fri, 11-Sep-87 01:04:34 EDT Organization: Mathematics, Melbourne Uni, Australia Lines: 600 : ---------------------------------------- cut here echo x - "edef.d" 2>&1 sed "s/^X//" >"edef.d" <<'!The!End!' X25c25 X< unsigned int getckey(); X--- X> unsigned char *getckey(); X54c54 X< int discmd = TRUE; /* display command flag */ X--- X> int discmd = FALSE; /* display command flag */ X64,67c64,66 X< int metac = CTRL | '['; /* current meta character */ X< int ctlxc = CTRL | 'X'; /* current control X prefix char */ X< int reptc = CTRL | 'U'; /* current universal repeat char */ X< int abortc = CTRL | 'G'; /* current abort command char */ X--- X> int metac = CTRL & '['; /* current meta character */ X> int ctlxc = CTRL & 'X'; /* current control X prefix char */ X> int abortc = CTRL & 'G'; /* current abort command char */ X91a91,93 X> struct spec_chars *bindh=NULL; /* pointer to head of key bindings */ X> int (*command)(); /* command that must be executed */ X> int exit_def = 0 ; /* is it possible to exit */ X92a95 X> X158,159c161 X< extern KEYTAB keytab[]; /* key bind to functions table */ X< extern NBIND names[]; /* name to function table */ X--- X> extern NBIND names[]; /* name to function table */ X181d182 X< extern int reptc; /* current universal repeat char */ X186,190c187,191 X< extern KILL *kbufp; /* current kill buffer chunk pointer */ X< extern KILL *kbufh; /* kill buffer header pointer */ X< extern int kused; /* # of bytes used in KB */ X< extern WINDOW *swindow; /* saved window pointer */ X< extern int cryptflag; /* currently encrypting? */ X--- X> extern KILL *kbufp; /* current kill buffer chunk pointer */ X> extern KILL *kbufh; /* kill buffer header pointer */ X> extern int kused; /* # of bytes used in KB */ X> extern WINDOW *swindow; /* saved window pointer */ X> extern int cryptflag; /* currently encrypting? */ !The!End! echo x - "efunc.d" 2>&1 sed "s/^X//" >"efunc.d" <<'!The!End!' X11a12,16 X> extern int dummy(); /* Dummy binding routine */ X> extern int digit(); /* Dummy meta-integer handler */ X> extern int unarg(); /* Dummy universal-arg handler */ X> extern int dumpcore(); /* Leathal, causes a core dump - X> Only available in macros */ X97a103 X> extern int setspecial(); /* define special charater code */ X160,162d165 X< extern int meta(); /* meta prefix dummy function */ X< extern int cex(); /* ^X prefix dummy function */ X< extern int unarg(); /* ^U repeat arg dummy function */ X232a236 X> {"core", dumpcore}, X236d239 X< {"ctlx-prefix", cex}, X251a255,256 X> {"digit", digit}, X> {"dummy", dummy}, X339d343 X< {"meta-prefix", meta}, X391a396 X> {"special-char", setspecial}, !The!End! echo x - "epath.d" 2>&1 sed "s/^X//" >"epath.d" <<'!The!End!' X13a14 X> ".emacskb", X23a25 X> "emacs.kb", X34a37 X> "emacs.kb", X44a48 X> "emacs.kb", X56a61 X> ".emacskb", X66a72 X> "emacs.kb", !The!End! echo x - "estruct.d" 2>&1 sed "s/^X//" >"estruct.d" <<'!The!End!' X6a7,9 X> X> A few more changes relating to the key bindings X> implemented by G.Fiusco X207,210c210 X< #define CTRL 0x0100 /* Control flag, or'ed in */ X< #define META 0x0200 /* Meta flag, or'ed in */ X< #define CTLX 0x0400 /* ^X flag, or'ed in */ X< #define SPEC 0x0800 /* special key (function keys) */ X--- X> #define CTRL 037 /* Control flag, or'ed in */ X243a244,245 X> #define BSP 0x10 /* backspace character */ X> #define DEL 0x7f /* delete character */ X475,478c477,485 X< typedef struct { X< short k_code; /* Key code */ X< int (*k_fp)(); /* Routine to handle it */ X< } KEYTAB; X--- X> struct spec_chars { X> int k_code; /* Key code changed from short */ X> int research ; X> union { X> int (*command)() ; X> struct spec_chars *k_codelist ; X> } com ; X> struct spec_chars *next ; X> } ; !The!End! echo x - "eval.d" 2>&1 sed "s/^X//" >"eval.d" <<'!The!End!' X170c170,173 X< int setvar(f, n) /* set a variable */ X--- X> /* X> * returns the type of variable passed. Also retruns in paramters X> * the reference location for the varaible. X> */ X172,173c175,176 X< int f; /* default flag */ X< int n; /* numeric arg (can overide prompted value) */ X--- X> int X> checkvar(var,varref) X174a178,180 X> char *var ; X> int *varref ; X> X176,182c182,183 X< register int vnum; /* ordinal number of var refrenced */ X< register int status; /* status return */ X< register int vtype; /* type of variable to set */ X< register int c; /* translated character */ X< register char * sp; /* scratch string pointer */ X< char var[NVSIZE+1]; /* name of variable to fetch */ X< char value[NSTRING]; /* value to set variable to */ X--- X> register int vtype ; X> register int vnum ; X184,194d184 X< /* first get the variable to set.. */ X< if (clexec == FALSE) { X< status = mlreply("Variable to set: ", &var[0], NVSIZE); X< if (status != TRUE) X< return(status); X< } else { /* macro line argument */ X< /* grab token and skip it */ X< execstr = token(execstr, var); X< } X< X< /* check the legality and find the var */ X196,197c186 X< switch (var[0]) { X< X--- X> switch (*var) { X232a222,224 X> *varref = vnum ; X> return(vtype) ; X> } X234,238d225 X< /* if its not legal....bitch */ X< if (vtype == -1) { X< mlwrite("%%No such variable"); X< return(FALSE); X< } X240,247c227,228 X< /* get the value for that variable */ X< if (f == TRUE) X< strcpy(value, itoa(n)); X< else { X< status = mlreply("Value: ", &value[0], NSTRING); X< if (status != TRUE) X< return(status); X< } X--- X> int X> varset(vtype,vnum,value) X249c230,237 X< /* and set the appropriate value */ X--- X> register int vtype, vnum ; X> register char *value ; X> X> { X> register int status; /* status return */ X> register int c; /* translated character */ X> register char * sp; /* scratch string pointer */ X> X319a308,352 X> X> int setvar(f, n) /* set a variable */ X> X> int f; /* default flag */ X> int n; /* numeric arg (can overide prompted value) */ X> X> { X> int vnum; /* ordinal number of var refrenced */ X> register int status; /* status return */ X> register int vtype; /* type of variable to set */ X> char var[NVSIZE+1]; /* name of variable to fetch */ X> char value[NSTRING]; /* value to set variable to */ X> X> /* first get the variable to set.. */ X> if (clexec == FALSE) { X> status = mlreply("Variable to set: ", &var[0], NVSIZE); X> if (status != TRUE) X> return(status); X> } else { /* macro line argument */ X> /* grab token and skip it */ X> execstr = token(execstr, var); X> } X> X> /* check the legality and find the var */ X> vtype = checkvar(var,&vnum) ; X> X> /* if its not legal....bitch */ X> if (vtype == -1) { X> mlwrite("%%No such variable"); X> return(FALSE); X> } X> X> /* get the value for that variable */ X> if (f == TRUE) X> strcpy(value, itoa(n)); X> else { X> status = mlreply("Value: ", &value[0], NSTRING); X> if (status != TRUE) X> return(status); X> } X> X> /* and set the appropriate value */ X> return(varset(vtype,vnum,value)); X> } X> X448c481 X< buf, NSTRING, ctoec('\n')); X--- X> buf, NSTRING, '\n'); !The!End! echo x - "exec.d" 2>&1 sed "s/^X//" >"exec.d" <<'!The!End!' X378c378 X< status = nextarg("", tok, NSTRING, ctoec('\n')); X--- X> status = nextarg("", tok, NSTRING, '\n'); !The!End! echo x - "input.d" 2>&1 sed "s/^X//" >"input.d" <<'!The!End!' X8a9,10 X> extern struct spec_chars *bindh ; X> X32c34 X< if (c == ectoc(abortc)) /* Bail out! */ X--- X> if (c == abortc) /* Bail out! */ X55c57 X< return(nextarg(prompt, buf, nbuf, ctoec('\n'))); X--- X> return(nextarg(prompt, buf, nbuf, '\n')); X68,95d69 X< /* ectoc: expanded character to character X< colapse the CTRL and SPEC flags back into an ascii code */ X< X< ectoc(c) X< X< int c; X< X< { X< if (c & CTRL) X< c = c & ~(CTRL | 0x40); X< if (c & SPEC) X< c= c & 255; X< return(c); X< } X< X< /* ctoec: character to extended character X< pull out the CTRL and SPEC prefixes (if possible) */ X< X< ctoec(c) X< X< int c; X< X< { X< if (c>=0x00 && c<=0x1F) X< c = CTRL | (c+'@'); X< return (c); X< } X< X111c85 X< register NBIND *cffp; /* current ptr to entry in name binding table */ X--- X> register NBIND *cffp; /* ptr to entry in name binding table */ X131c105 X< if (c == 0x0d) { X--- X> if (c == '\r') { X137c111 X< } else if (c == ectoc(abortc)) { /* Bell, abort */ X--- X> } else if (c == abortc) { /* Bell, abort */ X142c116 X< } else if (c == 0x7F || c == 0x08) { /* rubout/erase */ X--- X> } else if (c == DEL || c == BSP) { /* rubout/erase */ X152c126 X< } else if (c == 0x15) { /* C-U, kill */ X--- X> } else if (c == (CTRL&'U')) { /* C-U, kill */ X282,342c256,258 X< /* GET1KEY: Get one keystroke. The only prefixs legal here X< are the SPEC and CTRL prefixes. X< */ X< X< get1key() X< X< { X< int c; X< #if AMIGA X< int d; X< #endif X< X< /* get a keystroke */ X< c = tgetc(); X< X< #if MSDOS | ST520 X< if (c == 0) { /* Apply SPEC prefix */ X< c = tgetc(); X< if (c>=0x00 && c<=0x1F) /* control key? */ X< c = CTRL | (c+'@'); X< return(SPEC | c); X< } X< #endif X< X< #if AMIGA X< /* apply SPEC prefix */ X< if ((unsigned)c == 155) { X< c = tgetc(); X< X< /* first try to see if it is a cursor key */ X< if ((c >= 'A' && c <= 'D') || c == 'S' || c == 'T') X< return(SPEC | c); X< X< /* next, a 2 char sequence */ X< d = tgetc(); X< if (d == '~') X< return(SPEC | c); X< X< /* decode a 3 char sequence */ X< c = d + 32; X< /* if a shifted function key, eat the tilde */ X< if (d >= '0' && d <= '9') X< d = tgetc(); X< return(SPEC | c); X< } X< #endif X< X< #if WANGPC X< if (c == 0x1F) { /* Apply SPEC prefix */ X< c = tgetc(); X< return(SPEC | c); X< } X< #endif X< X< if (c>=0x00 && c<=0x1F) /* C0 control -> C- */ X< c = CTRL | (c+'@'); X< return (c); X< } X< X< /* GETCMD: Get a command from the keyboard. Process all applicable X< prefix keys X--- X> /* GETCMD: Get a command from the keyboard. Process keys and return X> either the key stroke or if the key is bound to a funtion X> then load command with the function and return NULL X347a264,265 X> struct spec_chars *binding = bindh ; X> extern int (*command)() ; X349,359c267,279 X< /* get initial character */ X< c = get1key(); X< X< /* process META prefix */ X< if (c == metac) { X< c = get1key(); X< if (islower(c)) /* Force to upper */ X< c ^= DIFCASE; X< if (c>=0x00 && c<=0x1F) /* control key */ X< c = CTRL | (c+'@'); X< return(META | c); X--- X> charreq: X> c = tgetc(); X> /* check if key is bound */ X> while (binding) { X> if (binding->k_code == c) { X> if (binding->research) { X> binding = binding->com.k_codelist ; X> goto charreq ; /* wops */ X> } X> command = binding->com.command ; X> return(NULL) ; X> } X> binding = binding->next ; X361,372d280 X< X< /* process CTLX prefix */ X< if (c == ctlxc) { X< c = get1key(); X< if (c>='a' && c<='z') /* Force to upper */ X< c -= 0x20; X< if (c>=0x00 && c<=0x1F) /* control key */ X< c = CTRL | (c+'@'); X< return(CTLX | c); X< } X< X< /* otherwise, just return it */ X399c307 X< c = get1key(); X--- X> c = tgetc(); X402,403c310,311 X< if (c == (CTRL | 0x4d)) X< c = CTRL | 0x40 | '\n'; X--- X> if (c == '\r') X> c = '\n'; X420,423c328 X< /* change from command form back to character form */ X< c = ectoc(c); X< X< if (c == ectoc(abortc) && quotef == FALSE) { X--- X> if (c == abortc && quotef == FALSE) { X428c333 X< } else if ((c==0x7F || c==0x08) && quotef==FALSE) { X--- X> } else if ((c==DEL || c==BSP) && quotef==FALSE) { X446c351 X< } else if (c == 0x15 && quotef == FALSE) { X--- X> } else if (c == (CTRL&'U') && quotef == FALSE) { !The!End! echo x - "main.d" 2>&1 sed "s/^X//" >"main.d" <<'!The!End!' X681d680 X< #include "ebind.h" /* default key bindings */ X691a691 X> X703d702 X< int basec; /* c stripped of meta character */ X713a713 X> extern char *pathname[] ; /* seach paths and fnames */ X715a716,721 X> startup(pathname[2]) ; /* read in the bindings */ X> if (!exit_def) { X> fprintf(stderr,"You must make it possible to exit.\n") ; X> exit(10) ; X> } X> discmd = TRUE ; X859,862c865,868 X< loop: X< update(FALSE); /* Fix up the screen */ X< c = getcmd(); X< if (mpresf != FALSE) { X--- X> while(1) { X> update(FALSE); /* Fix up the screen */ X> c = getcmd(); X> if (mpresf != FALSE) { X867c873 X< goto loop; X--- X> continue ; X870,871c876,877 X< f = FALSE; X< n = 1; X--- X> f = FALSE; X> n = 1; X873c879 X< /* do META-# processing if needed */ X--- X> /* do META-# processing if needed */ X875,876c881 X< basec = c & ~META; /* strip meta char off if there */ X< if ((c & META) && ((basec >= '0' && basec <= '9') || basec == '-')) { X--- X> if (command == digit && !c) { X880c885 X< c = basec; /* strip the META */ X--- X> c = lastkey ; X898c903 X< } X--- X> } X900c905 X< /* do ^U repeat argument processing */ X--- X> /* do ^U repeat argument processing */ X902c907,908 X< if (c == reptc) { /* ^U, start argument */ X--- X> if (command == unarg && !c) { /* ^U, start argument */ X> command = 0 ; X907,908c913,915 X< while ((c=getcmd()) >='0' && c<='9' || c==reptc || c=='-'){ X< if (c == reptc) X--- X> while ((c=getcmd()) >='0' && c<='9' || X> command == unarg || c=='-'){ X> if (command == unarg) X945c952,955 X< } X--- X> } X> execute(c,f,n) ; X> } X> } X947,949c957,967 X< /* and execute the command */ X< execute(c, f, n); X< goto loop; X--- X> /* Causes the program to dump core */ X> X> dumpcore(f,n) X> X> { X> if (clexec) { X> clexec = FALSE ; X> abort() ; X> } X> else X> mlwrite("[Sorry, you can't do that from here]") ; X999d1016 X< register KEYTAB *ktp; X1002,1010c1019,1023 X< ktp = &keytab[0]; /* Look in key table. */ X< while (ktp->k_fp != NULL) { X< if (ktp->k_code == c) { X< thisflag = 0; X< status = (*ktp->k_fp)(f, n); X< lastflag = thisflag; X< return (status); X< } X< ++ktp; X--- X> if (c == NULL) { X> thisflag = 0; X> status = (*command)(f, n); X> lastflag = thisflag; X> return (status); X1021c1034 X< execute(META|SPEC|'W', FALSE, 1); X--- X> wrapword(FALSE, 1); X1213,1224d1225 X< } X< X< meta() /* dummy function for binding to meta prefix */ X< { X< } X< X< cex() /* dummy function for binding to control-x prefix */ X< { X< } X< X< unarg() /* dummy function for binding to universal-argument */ X< { !The!End! echo x - "random.d" 2>&1 sed "s/^X//" >"random.d" <<'!The!End!' X450c450 X< execute(META|SPEC|'W', FALSE, 1); X--- X> wrapword(FALSE, 1); !The!End! exit