mirror of
https://github.com/rfivet/uemacs.git
synced 2024-12-18 15:26:23 -05:00
Merge name to function and key code to function table initialization.
This commit is contained in:
parent
521d96fbda
commit
f30ef38bc8
5
bind.c
5
bind.c
@ -19,7 +19,6 @@
|
|||||||
#include "bindable.h"
|
#include "bindable.h"
|
||||||
#include "buffer.h"
|
#include "buffer.h"
|
||||||
#include "display.h"
|
#include "display.h"
|
||||||
#include "ebind.h"
|
|
||||||
#include "exec.h"
|
#include "exec.h"
|
||||||
#include "file.h"
|
#include "file.h"
|
||||||
#include "flook.h"
|
#include "flook.h"
|
||||||
@ -308,7 +307,7 @@ int apro( int f, int n) {
|
|||||||
static int buildlist( char *mstring) {
|
static int buildlist( char *mstring) {
|
||||||
#endif
|
#endif
|
||||||
struct window *wp; /* scanning pointer to windows */
|
struct window *wp; /* scanning pointer to windows */
|
||||||
struct key_tab *ktp; /* pointer into the command table */
|
key_tab *ktp; /* pointer into the command table */
|
||||||
const name_bind *nptr;/* pointer into the name binding table */
|
const name_bind *nptr;/* pointer into the name binding table */
|
||||||
struct buffer *bp; /* buffer to put binding list into */
|
struct buffer *bp; /* buffer to put binding list into */
|
||||||
char outseq[80]; /* output buffer for keystroke sequence */
|
char outseq[80]; /* output buffer for keystroke sequence */
|
||||||
@ -493,7 +492,7 @@ static void cmdstr( int c, char *seq) {
|
|||||||
* int c; key to find what is bound to it
|
* int c; key to find what is bound to it
|
||||||
*/
|
*/
|
||||||
key_tab *getkeybind( unsigned c) {
|
key_tab *getkeybind( unsigned c) {
|
||||||
struct key_tab *ktp ;
|
key_tab *ktp ;
|
||||||
|
|
||||||
for( ktp = keytab ; ktp->k_fp != NULL ; ktp++)
|
for( ktp = keytab ; ktp->k_fp != NULL ; ktp++)
|
||||||
if (ktp->k_code == c)
|
if (ktp->k_code == c)
|
||||||
|
4
bind.h
4
bind.h
@ -1,15 +1,15 @@
|
|||||||
#ifndef _BIND_H_
|
#ifndef _BIND_H_
|
||||||
#define _BIND_H_
|
#define _BIND_H_
|
||||||
|
|
||||||
#include "ebind.h"
|
#include "names.h"
|
||||||
|
|
||||||
#define APROP 1 /* Add code for Apropos command */
|
#define APROP 1 /* Add code for Apropos command */
|
||||||
|
|
||||||
|
/* uEMACS functions */
|
||||||
#if APROP
|
#if APROP
|
||||||
int apro( int f, int n) ;
|
int apro( int f, int n) ;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* uEMACS functions */
|
|
||||||
int help( int f, int n) ;
|
int help( int f, int n) ;
|
||||||
int deskey( int f, int n) ;
|
int deskey( int f, int n) ;
|
||||||
int bindtokey( int f, int n) ;
|
int bindtokey( int f, int n) ;
|
||||||
|
363
ebind.c
363
ebind.c
@ -1,363 +0,0 @@
|
|||||||
/* ebind.c -- implements ebind.h */
|
|
||||||
#include "ebind.h"
|
|
||||||
|
|
||||||
/* ebind.c
|
|
||||||
*
|
|
||||||
* Initial default key to function bindings
|
|
||||||
*
|
|
||||||
* Modified by Petri Kutvonen
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
|
|
||||||
#include "basic.h"
|
|
||||||
#include "bind.h"
|
|
||||||
#include "estruct.h"
|
|
||||||
#include "bindable.h"
|
|
||||||
#include "buffer.h"
|
|
||||||
#include "eval.h"
|
|
||||||
#include "exec.h"
|
|
||||||
#include "file.h"
|
|
||||||
#include "isearch.h"
|
|
||||||
#include "line.h"
|
|
||||||
#include "random.h"
|
|
||||||
#include "region.h"
|
|
||||||
#include "search.h"
|
|
||||||
#include "spawn.h"
|
|
||||||
#include "window.h"
|
|
||||||
#include "word.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Command table.
|
|
||||||
* This table is *roughly* in ASCII order, left to right across the
|
|
||||||
* characters of the command. This explains the funny location of the
|
|
||||||
* control-X commands.
|
|
||||||
*/
|
|
||||||
key_tab keytab[ NBINDS] = {
|
|
||||||
{CONTROL | '?', backdel, NULL},
|
|
||||||
{CONTROL | 'A', (fnp_t) gotobol, NULL}
|
|
||||||
,
|
|
||||||
{CONTROL | 'B', (fnp_t) backchar, NULL}
|
|
||||||
,
|
|
||||||
{CONTROL | 'C', insspace, NULL}
|
|
||||||
,
|
|
||||||
{CONTROL | 'D', forwdel, NULL}
|
|
||||||
,
|
|
||||||
{CONTROL | 'E', (fnp_t) gotoeol, NULL}
|
|
||||||
,
|
|
||||||
{CONTROL | 'F', (fnp_t) forwchar, NULL}
|
|
||||||
,
|
|
||||||
{CONTROL | 'G', ctrlg, NULL}
|
|
||||||
,
|
|
||||||
{CONTROL | 'H', backdel, NULL}
|
|
||||||
,
|
|
||||||
{CONTROL | 'I', insert_tab, NULL}
|
|
||||||
,
|
|
||||||
{CONTROL | 'J', indent, NULL}
|
|
||||||
,
|
|
||||||
{CONTROL | 'K', killtext, NULL}
|
|
||||||
,
|
|
||||||
{CONTROL | 'L', redraw, NULL}
|
|
||||||
,
|
|
||||||
{CONTROL | 'M', insert_newline, NULL}
|
|
||||||
,
|
|
||||||
{CONTROL | 'N', (fnp_t) forwline, NULL}
|
|
||||||
,
|
|
||||||
{CONTROL | 'O', openline, NULL}
|
|
||||||
,
|
|
||||||
{CONTROL | 'P', (fnp_t) backline, NULL}
|
|
||||||
,
|
|
||||||
{CONTROL | 'Q', quote, NULL}
|
|
||||||
,
|
|
||||||
{CONTROL | 'R', backsearch, NULL}
|
|
||||||
,
|
|
||||||
{CONTROL | 'S', forwsearch, NULL}
|
|
||||||
,
|
|
||||||
{CONTROL | 'T', (fnp_t) twiddle, NULL}
|
|
||||||
,
|
|
||||||
{CONTROL | 'U', unarg, NULL}
|
|
||||||
,
|
|
||||||
{CONTROL | 'V', (fnp_t) forwpage, NULL}
|
|
||||||
,
|
|
||||||
{CONTROL | 'W', killregion, NULL}
|
|
||||||
,
|
|
||||||
{CONTROL | 'X', cex, NULL}
|
|
||||||
,
|
|
||||||
{CONTROL | 'Y', yank, NULL}
|
|
||||||
,
|
|
||||||
{CONTROL | 'Z', (fnp_t) backpage, NULL}
|
|
||||||
,
|
|
||||||
{CONTROL | ']', metafn, NULL}
|
|
||||||
,
|
|
||||||
{CTLX | CONTROL | 'B', listbuffers, NULL}
|
|
||||||
,
|
|
||||||
{CTLX | CONTROL | 'C', quit, NULL}
|
|
||||||
, /* Hard quit. */
|
|
||||||
#if PKCODE & AEDIT
|
|
||||||
{CTLX | CONTROL | 'A', detab, NULL}
|
|
||||||
,
|
|
||||||
#endif
|
|
||||||
#if PKCODE
|
|
||||||
{CTLX | CONTROL | 'D', filesave, NULL}
|
|
||||||
, /* alternative */
|
|
||||||
#else
|
|
||||||
#if AEDIT
|
|
||||||
{CTLX | CONTROL | 'D', detab, NULL}
|
|
||||||
,
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#if AEDIT
|
|
||||||
{CTLX | CONTROL | 'E', entab, NULL}
|
|
||||||
,
|
|
||||||
#endif
|
|
||||||
{CTLX | CONTROL | 'F', filefind, NULL}
|
|
||||||
,
|
|
||||||
{CTLX | CONTROL | 'I', insfile, NULL}
|
|
||||||
,
|
|
||||||
{CTLX | CONTROL | 'L', lowerregion, NULL}
|
|
||||||
,
|
|
||||||
{CTLX | CONTROL | 'M', delmode, NULL}
|
|
||||||
,
|
|
||||||
{CTLX | CONTROL | 'N', mvdnwind, NULL}
|
|
||||||
,
|
|
||||||
{CTLX | CONTROL | 'O', deblank, NULL}
|
|
||||||
,
|
|
||||||
{CTLX | CONTROL | 'P', mvupwind, NULL}
|
|
||||||
,
|
|
||||||
{CTLX | CONTROL | 'R', fileread, NULL}
|
|
||||||
,
|
|
||||||
{CTLX | CONTROL | 'S', filesave, NULL}
|
|
||||||
,
|
|
||||||
#if AEDIT
|
|
||||||
{CTLX | CONTROL | 'T', trim, NULL}
|
|
||||||
,
|
|
||||||
#endif
|
|
||||||
{CTLX | CONTROL | 'U', upperregion, NULL}
|
|
||||||
,
|
|
||||||
{CTLX | CONTROL | 'V', viewfile, NULL}
|
|
||||||
,
|
|
||||||
{CTLX | CONTROL | 'W', filewrite, NULL}
|
|
||||||
,
|
|
||||||
{CTLX | CONTROL | 'X', (fnp_t) swapmark, NULL}
|
|
||||||
,
|
|
||||||
{CTLX | CONTROL | 'Z', shrinkwind, NULL}
|
|
||||||
,
|
|
||||||
{CTLX | '?', deskey, NULL}
|
|
||||||
,
|
|
||||||
{CTLX | '!', spawn, NULL}
|
|
||||||
,
|
|
||||||
{CTLX | '@', pipecmd, NULL}
|
|
||||||
,
|
|
||||||
{CTLX | '#', filter_buffer, NULL}
|
|
||||||
,
|
|
||||||
{CTLX | '$', execprg, NULL}
|
|
||||||
,
|
|
||||||
{CTLX | '=', showcpos, NULL}
|
|
||||||
,
|
|
||||||
{CTLX | '(', ctlxlp, NULL}
|
|
||||||
,
|
|
||||||
{CTLX | ')', ctlxrp, NULL}
|
|
||||||
,
|
|
||||||
{CTLX | '^', enlargewind, NULL}
|
|
||||||
,
|
|
||||||
{CTLX | '0', delwind, NULL}
|
|
||||||
,
|
|
||||||
{CTLX | '1', onlywind, NULL}
|
|
||||||
,
|
|
||||||
{CTLX | '2', splitwind, NULL}
|
|
||||||
,
|
|
||||||
{CTLX | 'A', setvar, NULL}
|
|
||||||
,
|
|
||||||
{CTLX | 'B', usebuffer, NULL}
|
|
||||||
,
|
|
||||||
{CTLX | 'C', spawncli, NULL}
|
|
||||||
,
|
|
||||||
#if BSD | SVR4
|
|
||||||
{CTLX | 'D', bktoshell, NULL}
|
|
||||||
,
|
|
||||||
#endif
|
|
||||||
{CTLX | 'E', ctlxe, NULL}
|
|
||||||
,
|
|
||||||
{CTLX | 'F', setfillcol, NULL}
|
|
||||||
,
|
|
||||||
{CTLX | 'K', killbuffer, NULL}
|
|
||||||
,
|
|
||||||
{CTLX | 'M', setemode, NULL}
|
|
||||||
,
|
|
||||||
{CTLX | 'N', filename, NULL}
|
|
||||||
,
|
|
||||||
{CTLX | 'O', nextwind, NULL}
|
|
||||||
,
|
|
||||||
{CTLX | 'P', prevwind, NULL}
|
|
||||||
,
|
|
||||||
#if PKCODE
|
|
||||||
{CTLX | 'Q', quote, NULL}
|
|
||||||
, /* alternative */
|
|
||||||
#endif
|
|
||||||
#if ISRCH
|
|
||||||
{CTLX | 'R', risearch, NULL}
|
|
||||||
,
|
|
||||||
{CTLX | 'S', fisearch, NULL}
|
|
||||||
,
|
|
||||||
#endif
|
|
||||||
{CTLX | 'W', resize, NULL}
|
|
||||||
,
|
|
||||||
{CTLX | 'X', nextbuffer, NULL}
|
|
||||||
,
|
|
||||||
{CTLX | 'Z', enlargewind, NULL}
|
|
||||||
,
|
|
||||||
{META | CONTROL | '?', delbword, NULL},
|
|
||||||
#if WORDPRO
|
|
||||||
{META | CONTROL | 'C', wordcount, NULL}
|
|
||||||
,
|
|
||||||
#endif
|
|
||||||
#if PKCODE
|
|
||||||
{META | CONTROL | 'D', newsize, NULL}
|
|
||||||
,
|
|
||||||
#endif
|
|
||||||
#if PROC
|
|
||||||
{META | CONTROL | 'E', execproc, NULL}
|
|
||||||
,
|
|
||||||
#endif
|
|
||||||
#if CFENCE
|
|
||||||
{META | CONTROL | 'F', getfence, NULL}
|
|
||||||
,
|
|
||||||
#endif
|
|
||||||
{META | CONTROL | 'H', delbword, NULL}
|
|
||||||
,
|
|
||||||
{META | CONTROL | 'K', unbindkey, NULL}
|
|
||||||
,
|
|
||||||
{META | CONTROL | 'L', reposition, NULL}
|
|
||||||
,
|
|
||||||
{META | CONTROL | 'M', delgmode, NULL}
|
|
||||||
,
|
|
||||||
{META | CONTROL | 'N', namebuffer, NULL}
|
|
||||||
,
|
|
||||||
{META | CONTROL | 'R', qreplace, NULL}
|
|
||||||
,
|
|
||||||
{META | CONTROL | 'S', newsize, NULL}
|
|
||||||
,
|
|
||||||
{META | CONTROL | 'T', newwidth, NULL}
|
|
||||||
,
|
|
||||||
{META | CONTROL | 'V', scrnextdw, NULL}
|
|
||||||
,
|
|
||||||
#if WORDPRO
|
|
||||||
{META | CONTROL | 'W', killpara, NULL}
|
|
||||||
,
|
|
||||||
#endif
|
|
||||||
{META | CONTROL | 'Z', scrnextup, NULL}
|
|
||||||
,
|
|
||||||
{META | ' ', (fnp_t) setmark, NULL}
|
|
||||||
,
|
|
||||||
{META | '?', help, NULL}
|
|
||||||
,
|
|
||||||
{META | '!', reposition, NULL}
|
|
||||||
,
|
|
||||||
{META | '.', (fnp_t) setmark, NULL}
|
|
||||||
,
|
|
||||||
{META | '>', (fnp_t) gotoeob, NULL}
|
|
||||||
,
|
|
||||||
{META | '<', (fnp_t) gotobob, NULL}
|
|
||||||
,
|
|
||||||
{META | '~', unmark, NULL}
|
|
||||||
,
|
|
||||||
#if APROP
|
|
||||||
{META | 'A', apro, NULL}
|
|
||||||
,
|
|
||||||
#endif
|
|
||||||
{META | 'B', backword, NULL}
|
|
||||||
,
|
|
||||||
{META | 'C', capword, NULL}
|
|
||||||
,
|
|
||||||
{META | 'D', delfword, NULL}
|
|
||||||
,
|
|
||||||
{META | 'F', forwword, NULL}
|
|
||||||
,
|
|
||||||
{META | 'G', gotoline, NULL}
|
|
||||||
,
|
|
||||||
#if PKCODE
|
|
||||||
#if WORDPRO
|
|
||||||
{META | 'J', justpara, NULL}
|
|
||||||
,
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
{META | 'K', bindtokey, NULL}
|
|
||||||
,
|
|
||||||
{META | 'L', lowerword, NULL}
|
|
||||||
,
|
|
||||||
{META | 'M', setgmode, NULL}
|
|
||||||
,
|
|
||||||
#if WORDPRO
|
|
||||||
{META | 'N', gotoeop, NULL}
|
|
||||||
,
|
|
||||||
{META | 'P', gotobop, NULL}
|
|
||||||
,
|
|
||||||
{META | 'Q', fillpara, NULL}
|
|
||||||
,
|
|
||||||
#endif
|
|
||||||
{META | 'R', sreplace, NULL}
|
|
||||||
,
|
|
||||||
#if PKCODE
|
|
||||||
{META | 'S', forwhunt, NULL}
|
|
||||||
,
|
|
||||||
#else
|
|
||||||
#if BSD
|
|
||||||
{META | 'S', bktoshell, NULL}
|
|
||||||
,
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
{META | 'U', upperword, NULL}
|
|
||||||
,
|
|
||||||
{META | 'V', (fnp_t) backpage, NULL}
|
|
||||||
,
|
|
||||||
{META | 'W', copyregion, NULL}
|
|
||||||
,
|
|
||||||
{META | 'X', namedcmd, NULL}
|
|
||||||
,
|
|
||||||
{META | 'Z', quickexit, NULL}
|
|
||||||
,
|
|
||||||
|
|
||||||
#if VT220
|
|
||||||
{SPEC | '1', (fnp_t) gotobob /* fisearch */, NULL}
|
|
||||||
, /* VT220 keys */
|
|
||||||
{SPEC | '2', yank, NULL}
|
|
||||||
,
|
|
||||||
{SPEC | '3', forwdel /* killregion */, NULL}
|
|
||||||
,
|
|
||||||
{SPEC | '4', (fnp_t) gotoeob /* setmark */, NULL}
|
|
||||||
,
|
|
||||||
{SPEC | '5', (fnp_t) backpage, NULL}
|
|
||||||
,
|
|
||||||
{SPEC | '6', (fnp_t) forwpage, NULL}
|
|
||||||
,
|
|
||||||
{SPEC | 'A', (fnp_t) backline, NULL}
|
|
||||||
,
|
|
||||||
{SPEC | 'B', (fnp_t) forwline, NULL}
|
|
||||||
,
|
|
||||||
{SPEC | 'C', (fnp_t) forwchar, NULL}
|
|
||||||
,
|
|
||||||
{SPEC | 'D', (fnp_t) backchar, NULL}
|
|
||||||
,
|
|
||||||
{SPEC | 'c', metafn, NULL}
|
|
||||||
,
|
|
||||||
{SPEC | 'd', (fnp_t) backchar, NULL}
|
|
||||||
,
|
|
||||||
{SPEC | 'e', (fnp_t) forwline, NULL}
|
|
||||||
,
|
|
||||||
{SPEC | 'f', (fnp_t) gotobob, NULL}
|
|
||||||
,
|
|
||||||
{SPEC | 'h', help, NULL}
|
|
||||||
,
|
|
||||||
{SPEC | 'i', cex, NULL}
|
|
||||||
,
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* special internal bindings */
|
|
||||||
{ SPEC | META | 'W', wrapword , NULL}, /* called on word wrap */
|
|
||||||
{ SPEC | META | 'C', nullproc , NULL}, /* every command input */
|
|
||||||
{ SPEC | META | 'R', nullproc , NULL}, /* on file read */
|
|
||||||
{ SPEC | META | 'X', nullproc , NULL}, /* on window change P.K. */
|
|
||||||
|
|
||||||
{0, NULL, NULL}
|
|
||||||
};
|
|
17
ebind.h
17
ebind.h
@ -1,17 +0,0 @@
|
|||||||
#ifndef _EBIND_H_
|
|
||||||
#define _EBIND_H_
|
|
||||||
|
|
||||||
#include "names.h"
|
|
||||||
|
|
||||||
/* Structure for the key bindings table. */
|
|
||||||
typedef struct key_tab {
|
|
||||||
unsigned k_code ; /* Key code */
|
|
||||||
fnp_t k_fp ; /* Routine to handle it */
|
|
||||||
const name_bind *k_nbp ; /* entry in name to function map table */
|
|
||||||
} key_tab ;
|
|
||||||
|
|
||||||
/* keycode to function mapping table */
|
|
||||||
#define NBINDS 256 /* max # of bound keys */
|
|
||||||
extern key_tab keytab[ NBINDS] ; /* key bind to functions table */
|
|
||||||
|
|
||||||
#endif
|
|
4
exec.c
4
exec.c
@ -87,7 +87,7 @@ static int macarg( char *tok, int toksz) ;
|
|||||||
*/
|
*/
|
||||||
int namedcmd( int f, int n) {
|
int namedcmd( int f, int n) {
|
||||||
/* prompt the user to type a named command */
|
/* prompt the user to type a named command */
|
||||||
mlwrite(": execute-named-cmd ");
|
mlwrite("execute-named-cmd: ");
|
||||||
|
|
||||||
/* and now get the function name to execute */
|
/* and now get the function name to execute */
|
||||||
const name_bind *nbp = getname() ;
|
const name_bind *nbp = getname() ;
|
||||||
@ -121,7 +121,7 @@ int execcmd( int f, int n) {
|
|||||||
char *cmdstr ; /* string holding command to execute */
|
char *cmdstr ; /* string holding command to execute */
|
||||||
|
|
||||||
/* get the line wanted */
|
/* get the line wanted */
|
||||||
status = newmlarg( &cmdstr, ": execute-command-line ", 0) ;
|
status = newmlarg( &cmdstr, "execute-command-line: ", 0) ;
|
||||||
if( status != TRUE)
|
if( status != TRUE)
|
||||||
return status ;
|
return status ;
|
||||||
|
|
||||||
|
1
main.c
1
main.c
@ -165,6 +165,7 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize the editor. */
|
/* Initialize the editor. */
|
||||||
|
init_bindings() ; /* initialize mapping of function to name and key */
|
||||||
vtinit(); /* Display */
|
vtinit(); /* Display */
|
||||||
mloutfmt = mlwrite ;
|
mloutfmt = mlwrite ;
|
||||||
edinit("main"); /* Buffers, windows */
|
edinit("main"); /* Buffers, windows */
|
||||||
|
465
names.c
465
names.c
@ -1,13 +1,18 @@
|
|||||||
/* names.c -- implements names.h */
|
/* names.c -- implements names.h */
|
||||||
#include "names.h"
|
#include "names.h"
|
||||||
|
|
||||||
|
#define PARANOID 1
|
||||||
|
|
||||||
/* Name to function binding table.
|
/* Name to function binding table.
|
||||||
*
|
*
|
||||||
* This table gives the names of all the bindable functions and their C
|
* This table gives the names of all the bindable functions and their C
|
||||||
* function address. These are used for the bind-to-key function and macro
|
* function address. These are used for the bind-to-key function and
|
||||||
* processing.
|
* command line parsing.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifdef PARANOID
|
||||||
|
#include <assert.h>
|
||||||
|
#endif
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "basic.h"
|
#include "basic.h"
|
||||||
@ -28,216 +33,322 @@
|
|||||||
#include "window.h"
|
#include "window.h"
|
||||||
#include "word.h"
|
#include "word.h"
|
||||||
|
|
||||||
|
|
||||||
|
#define CTL_ CONTROL
|
||||||
|
|
||||||
const name_bind names[] = {
|
const name_bind names[] = {
|
||||||
{" abort-command", ctrlg} ,
|
{" abort-command", ctrlg, CTL_ | 'G'} ,
|
||||||
{" add-global-mode", setgmode} ,
|
{" add-global-mode", setgmode, META | 'M'} ,
|
||||||
{" add-mode", setemode} ,
|
{" add-mode", setemode, CTLX | 'M'} ,
|
||||||
#if APROP
|
#if APROP
|
||||||
{" apropos", apro} ,
|
{" apropos", apro, META | 'A'} ,
|
||||||
#endif
|
#endif
|
||||||
{" backward-character", (fnp_t) backchar} ,
|
{" backward-character", (fnp_t) backchar, CTL_ | 'B'} ,
|
||||||
{" begin-macro", ctlxlp} ,
|
{" begin-macro", ctlxlp, CTLX | '('} ,
|
||||||
{" beginning-of-file", (fnp_t) gotobob} ,
|
{" beginning-of-file", (fnp_t) gotobob, META | '<'} ,
|
||||||
{" beginning-of-line", (fnp_t) gotobol} ,
|
{" beginning-of-line", (fnp_t) gotobol, CTL_ | 'A'} ,
|
||||||
{" bind-to-key", bindtokey} ,
|
{" bind-to-key", bindtokey, META | 'K'} ,
|
||||||
{" buffer-position", showcpos} ,
|
{" buffer-position", showcpos, CTLX | '='} ,
|
||||||
{"!case-region-lower", lowerregion} ,
|
{"!case-region-lower", lowerregion, CTLX | CTL_ | 'L'} ,
|
||||||
{"!case-region-upper", upperregion} ,
|
{"!case-region-upper", upperregion, CTLX | CTL_ | 'U'} ,
|
||||||
{"!case-word-capitalize", capword} ,
|
{"!case-word-capitalize", capword, META | 'C'} ,
|
||||||
{"!case-word-lower", lowerword} ,
|
{"!case-word-lower", lowerword, META | 'L'} ,
|
||||||
{"!case-word-upper", upperword} ,
|
{"!case-word-upper", upperword, META | 'U'} ,
|
||||||
{" change-file-name", filename} ,
|
{" change-file-name", filename, CTLX | 'N'} ,
|
||||||
{" change-screen-size", newsize} ,
|
{" change-screen-size", newsize, META | CTL_ | 'D'} , /* M^S */
|
||||||
{" change-screen-width", newwidth} ,
|
{" change-screen-width", newwidth, META | CTL_ | 'T'} ,
|
||||||
{" clear-and-redraw", redraw} ,
|
{" clear-and-redraw", redraw, CTL_ | 'L'} ,
|
||||||
{" clear-message-line", clrmes} ,
|
{" clear-message-line", clrmes, 0} ,
|
||||||
{" copy-region", copyregion} ,
|
{" copy-region", copyregion, META | 'W'} ,
|
||||||
#if WORDPRO
|
#if WORDPRO
|
||||||
{" count-words", wordcount} ,
|
{" count-words", wordcount, META | CTL_ | 'C'} ,
|
||||||
#endif
|
#endif
|
||||||
{" ctlx-prefix", cex} ,
|
{" ctlx-prefix", cex, CTL_ | 'X'} ,
|
||||||
{"!delete-blank-lines", deblank} ,
|
{"!delete-blank-lines", deblank, CTLX | CTL_ | 'O'} ,
|
||||||
{" delete-buffer", killbuffer} ,
|
{" delete-buffer", killbuffer, CTLX | 'K'} ,
|
||||||
{" delete-global-mode", delgmode} ,
|
{" delete-global-mode", delgmode, META | CTL_ | 'M'} ,
|
||||||
{" delete-mode", delmode} ,
|
{" delete-mode", delmode, CTLX | CTL_ | 'M'} ,
|
||||||
{"!delete-next-character", forwdel} ,
|
{"!delete-next-character", forwdel, CTL_ | 'D'} ,
|
||||||
{"!delete-next-word", delfword} ,
|
{"!delete-next-word", delfword, META | 'D'} ,
|
||||||
{" delete-other-windows", onlywind} ,
|
{" delete-other-windows", onlywind, CTLX | '1'} ,
|
||||||
{"!delete-previous-character", backdel} ,
|
{"!delete-previous-character", backdel, CTL_ | 'H'} , /* ^? */
|
||||||
{"!delete-previous-word", delbword} ,
|
{"!delete-previous-word", delbword, META | CTL_ | 'H'} , /* M^? */
|
||||||
{" delete-window", delwind} ,
|
{" delete-window", delwind, CTLX | '0'} ,
|
||||||
{" describe-bindings", desbind} ,
|
{" describe-bindings", desbind, 0} ,
|
||||||
{" describe-key", deskey} ,
|
{" describe-key", deskey, CTLX | '?'} ,
|
||||||
#if AEDIT
|
#if AEDIT
|
||||||
{"!detab-line", detab} ,
|
{"!detab-line", detab, CTLX | CTL_ | 'D'} , /* X^A */
|
||||||
#endif
|
#endif
|
||||||
{" end-macro", ctlxrp} ,
|
{" end-macro", ctlxrp, CTLX | ')'} ,
|
||||||
{" end-of-file", (fnp_t) gotoeob} ,
|
{" end-of-file", (fnp_t) gotoeob, META | '>'} ,
|
||||||
{" end-of-line", (fnp_t) gotoeol} ,
|
{" end-of-line", (fnp_t) gotoeol, CTL_ | 'E'} ,
|
||||||
#if AEDIT
|
#if AEDIT
|
||||||
{"!entab-line", entab} ,
|
{"!entab-line", entab, CTLX | CTL_ | 'E'} ,
|
||||||
#endif
|
#endif
|
||||||
{" exchange-point-and-mark", (fnp_t) swapmark} ,
|
{" exchange-point-and-mark", (fnp_t) swapmark, CTLX | CTL_ | 'X'} ,
|
||||||
{" execute-buffer", execbuf} ,
|
{" execute-buffer", execbuf, 0} ,
|
||||||
{" execute-command-line", execcmd} ,
|
{" execute-command-line", execcmd, 0} ,
|
||||||
{" execute-file", execfile} ,
|
{" execute-file", execfile, 0} ,
|
||||||
{" execute-macro", ctlxe} ,
|
{" execute-macro", ctlxe, CTLX | 'E'} ,
|
||||||
{" execute-macro-1", cbuf1} ,
|
{" execute-macro-1", cbuf1, 0} ,
|
||||||
{" execute-macro-10", cbuf10} ,
|
{" execute-macro-10", cbuf10, 0} ,
|
||||||
{" execute-macro-11", cbuf11} ,
|
{" execute-macro-11", cbuf11, 0} ,
|
||||||
{" execute-macro-12", cbuf12} ,
|
{" execute-macro-12", cbuf12, 0} ,
|
||||||
{" execute-macro-13", cbuf13} ,
|
{" execute-macro-13", cbuf13, 0} ,
|
||||||
{" execute-macro-14", cbuf14} ,
|
{" execute-macro-14", cbuf14, 0} ,
|
||||||
{" execute-macro-15", cbuf15} ,
|
{" execute-macro-15", cbuf15, 0} ,
|
||||||
{" execute-macro-16", cbuf16} ,
|
{" execute-macro-16", cbuf16, 0} ,
|
||||||
{" execute-macro-17", cbuf17} ,
|
{" execute-macro-17", cbuf17, 0} ,
|
||||||
{" execute-macro-18", cbuf18} ,
|
{" execute-macro-18", cbuf18, 0} ,
|
||||||
{" execute-macro-19", cbuf19} ,
|
{" execute-macro-19", cbuf19, 0} ,
|
||||||
{" execute-macro-2", cbuf2} ,
|
{" execute-macro-2", cbuf2, 0} ,
|
||||||
{" execute-macro-20", cbuf20} ,
|
{" execute-macro-20", cbuf20, 0} ,
|
||||||
{" execute-macro-21", cbuf21} ,
|
{" execute-macro-21", cbuf21, 0} ,
|
||||||
{" execute-macro-22", cbuf22} ,
|
{" execute-macro-22", cbuf22, 0} ,
|
||||||
{" execute-macro-23", cbuf23} ,
|
{" execute-macro-23", cbuf23, 0} ,
|
||||||
{" execute-macro-24", cbuf24} ,
|
{" execute-macro-24", cbuf24, 0} ,
|
||||||
{" execute-macro-25", cbuf25} ,
|
{" execute-macro-25", cbuf25, 0} ,
|
||||||
{" execute-macro-26", cbuf26} ,
|
{" execute-macro-26", cbuf26, 0} ,
|
||||||
{" execute-macro-27", cbuf27} ,
|
{" execute-macro-27", cbuf27, 0} ,
|
||||||
{" execute-macro-28", cbuf28} ,
|
{" execute-macro-28", cbuf28, 0} ,
|
||||||
{" execute-macro-29", cbuf29} ,
|
{" execute-macro-29", cbuf29, 0} ,
|
||||||
{" execute-macro-3", cbuf3} ,
|
{" execute-macro-3", cbuf3, 0} ,
|
||||||
{" execute-macro-30", cbuf30} ,
|
{" execute-macro-30", cbuf30, 0} ,
|
||||||
{" execute-macro-31", cbuf31} ,
|
{" execute-macro-31", cbuf31, 0} ,
|
||||||
{" execute-macro-32", cbuf32} ,
|
{" execute-macro-32", cbuf32, 0} ,
|
||||||
{" execute-macro-33", cbuf33} ,
|
{" execute-macro-33", cbuf33, 0} ,
|
||||||
{" execute-macro-34", cbuf34} ,
|
{" execute-macro-34", cbuf34, 0} ,
|
||||||
{" execute-macro-35", cbuf35} ,
|
{" execute-macro-35", cbuf35, 0} ,
|
||||||
{" execute-macro-36", cbuf36} ,
|
{" execute-macro-36", cbuf36, 0} ,
|
||||||
{" execute-macro-37", cbuf37} ,
|
{" execute-macro-37", cbuf37, 0} ,
|
||||||
{" execute-macro-38", cbuf38} ,
|
{" execute-macro-38", cbuf38, 0} ,
|
||||||
{" execute-macro-39", cbuf39} ,
|
{" execute-macro-39", cbuf39, 0} ,
|
||||||
{" execute-macro-4", cbuf4} ,
|
{" execute-macro-4", cbuf4, 0} ,
|
||||||
{" execute-macro-40", cbuf40} ,
|
{" execute-macro-40", cbuf40, 0} ,
|
||||||
{" execute-macro-5", cbuf5} ,
|
{" execute-macro-5", cbuf5, 0} ,
|
||||||
{" execute-macro-6", cbuf6} ,
|
{" execute-macro-6", cbuf6, 0} ,
|
||||||
{" execute-macro-7", cbuf7} ,
|
{" execute-macro-7", cbuf7, 0} ,
|
||||||
{" execute-macro-8", cbuf8} ,
|
{" execute-macro-8", cbuf8, 0} ,
|
||||||
{" execute-macro-9", cbuf9} ,
|
{" execute-macro-9", cbuf9, 0} ,
|
||||||
{" execute-named-command", namedcmd} ,
|
{" execute-named-command", namedcmd, META | 'X'} ,
|
||||||
#if PROC
|
#if PROC
|
||||||
{" execute-procedure", execproc} ,
|
{" execute-procedure", execproc, META | CTL_ | 'E'} ,
|
||||||
#endif
|
#endif
|
||||||
{" execute-program", execprg} ,
|
{" execute-program", execprg, CTLX | '$'} ,
|
||||||
{" exit-emacs", quit} ,
|
{" exit-emacs", quit, CTLX | CTL_ | 'C'} ,
|
||||||
#if WORDPRO
|
#if WORDPRO
|
||||||
{"!fill-paragraph", fillpara} ,
|
{"!fill-paragraph", fillpara, META | 'Q'} ,
|
||||||
#endif
|
#endif
|
||||||
{"!filter-buffer", filter_buffer} ,
|
{"!filter-buffer", filter_buffer, CTLX | '#'} ,
|
||||||
{" find-file", filefind} ,
|
{" find-file", filefind, CTLX | CTL_ | 'F'} ,
|
||||||
{" forward-character", (fnp_t) forwchar} ,
|
{" forward-character", (fnp_t) forwchar, CTL_ | 'F'} ,
|
||||||
{" goto-line", gotoline} ,
|
{" goto-line", gotoline, META | 'G'} ,
|
||||||
#if CFENCE
|
#if CFENCE
|
||||||
{" goto-matching-fence", getfence} ,
|
{" goto-matching-fence", getfence, META | CTL_ | 'F'} ,
|
||||||
#endif
|
#endif
|
||||||
{" grow-window", enlargewind} ,
|
{" grow-window", enlargewind, CTLX | 'Z'} , /* X^ */
|
||||||
{"!handle-tab", insert_tab} ,
|
{"!handle-tab", insert_tab, CTL_ | 'I'} ,
|
||||||
{" help", help} ,
|
{" help", help, META | '?'} ,
|
||||||
{" hunt-backward", backhunt} ,
|
{" hunt-backward", backhunt, 0} ,
|
||||||
{" hunt-forward", forwhunt} ,
|
{" hunt-forward", forwhunt, META | 'S'} ,
|
||||||
{" i-shell", spawncli} ,
|
{" i-shell", spawncli, CTLX | 'C'} ,
|
||||||
#if ISRCH
|
#if ISRCH
|
||||||
{" incremental-search", fisearch} ,
|
{" incremental-search", fisearch, CTLX | 'S'} ,
|
||||||
#endif
|
#endif
|
||||||
{"!insert-file", insfile} ,
|
{"!insert-file", insfile, CTLX | CTL_ | 'I'} ,
|
||||||
{"!insert-space", insspace} ,
|
{"!insert-space", insspace, CTL_ | 'C'} ,
|
||||||
{"!insert-string", istring} ,
|
{"!insert-string", istring, 0} ,
|
||||||
#if WORDPRO
|
#if WORDPRO
|
||||||
#if PKCODE
|
#if PKCODE
|
||||||
{"!justify-paragraph", justpara} ,
|
{"!justify-paragraph", justpara, META | 'J'} ,
|
||||||
#endif
|
#endif
|
||||||
{"!kill-paragraph", killpara} ,
|
{"!kill-paragraph", killpara, META | CTL_ | 'W'} ,
|
||||||
#endif
|
#endif
|
||||||
{"!kill-region", killregion} ,
|
{"!kill-region", killregion, CTL_ | 'W'} ,
|
||||||
{"!kill-to-end-of-line", killtext} ,
|
{"!kill-to-end-of-line", killtext, CTL_ | 'K'} ,
|
||||||
{" list-buffers", listbuffers} ,
|
{" list-buffers", listbuffers, CTLX | CTL_ | 'B'} ,
|
||||||
{" meta-prefix", metafn} ,
|
{" meta-prefix", metafn, CTL_ | '['} ,
|
||||||
{" move-window-down", mvdnwind} ,
|
{" move-window-down", mvdnwind, CTLX | CTL_ | 'N'} ,
|
||||||
{" move-window-up", mvupwind} ,
|
{" move-window-up", mvupwind, CTLX | CTL_ | 'P'} ,
|
||||||
{" name-buffer", namebuffer} ,
|
{" name-buffer", namebuffer, META | CTL_ | 'N'} ,
|
||||||
{"!newline", insert_newline} ,
|
{"!newline", insert_newline, CTL_ | 'M'} ,
|
||||||
{"!newline-and-indent", indent} ,
|
{"!newline-and-indent", indent, CTL_ | 'J'} ,
|
||||||
{" next-buffer", nextbuffer} ,
|
{" next-buffer", nextbuffer, CTLX | 'X'} ,
|
||||||
{" next-line", (fnp_t) forwline} ,
|
{" next-line", (fnp_t) forwline, CTL_ | 'N'} ,
|
||||||
{" next-page", (fnp_t) forwpage} ,
|
{" next-page", (fnp_t) forwpage, CTL_ | 'V'} ,
|
||||||
#if WORDPRO
|
#if WORDPRO
|
||||||
{" next-paragraph", gotoeop} ,
|
{" next-paragraph", gotoeop, META | 'N'} ,
|
||||||
#endif
|
#endif
|
||||||
{" next-window", nextwind} ,
|
{" next-window", nextwind, CTLX | 'O'} ,
|
||||||
{" next-word", forwword} ,
|
{" next-word", forwword, META | 'F'} ,
|
||||||
{" nop", nullproc} ,
|
{" nop", nullproc, SPEC | META | 'C'}, /* hook */
|
||||||
{"!open-line", openline} ,
|
{"!open-line", openline, CTL_ | 'O'} ,
|
||||||
{" overwrite-string", ovstring} ,
|
{" overwrite-string", ovstring, 0} ,
|
||||||
{" pipe-command", pipecmd} ,
|
{" pipe-command", pipecmd, CTLX | '@'} ,
|
||||||
{" previous-line", (fnp_t) backline} ,
|
{" previous-line", (fnp_t) backline, CTL_ | 'P'} ,
|
||||||
{" previous-page", (fnp_t) backpage} ,
|
{" previous-page", (fnp_t) backpage, CTL_ | 'Z'} , /* MV */
|
||||||
#if WORDPRO
|
#if WORDPRO
|
||||||
{" previous-paragraph", gotobop} ,
|
{" previous-paragraph", gotobop, META | 'P'} ,
|
||||||
#endif
|
#endif
|
||||||
{" previous-window", prevwind} ,
|
{" previous-window", prevwind, CTLX | 'P'} ,
|
||||||
{" previous-word", backword} ,
|
{" previous-word", backword, META | 'B'} ,
|
||||||
{"!query-replace-string", qreplace} ,
|
{"!query-replace-string", qreplace, META | CTL_ | 'R'} ,
|
||||||
{" quick-exit", quickexit} ,
|
{" quick-exit", quickexit, META | 'Z'} ,
|
||||||
{"!quote-character", quote} ,
|
{"!quote-character", quote, CTL_ | 'Q'} , /* also XQ */
|
||||||
{"!read-file", fileread} ,
|
{"!read-file", fileread, CTLX | CTL_ | 'R'} ,
|
||||||
{" redraw-display", reposition} ,
|
{" redraw-display", reposition, META | CTL_ | 'L'} , /* M! */
|
||||||
{"!replace-string", sreplace} ,
|
{"!replace-string", sreplace, META | 'R'} ,
|
||||||
{" resize-window", resize} ,
|
{" resize-window", resize, CTLX | 'W'} ,
|
||||||
{" restore-window", restwnd} ,
|
{" restore-window", restwnd, 0} ,
|
||||||
#if ISRCH
|
#if ISRCH
|
||||||
{" reverse-incremental-search", risearch} ,
|
{" reverse-incremental-search", risearch, CTLX | 'R'} ,
|
||||||
#endif
|
#endif
|
||||||
#if PROC
|
#if PROC
|
||||||
{" run", execproc} ,
|
{" run", execproc, 0} ,
|
||||||
#endif
|
#endif
|
||||||
{"!save-file", filesave} ,
|
{"!save-file", filesave, CTLX | CTL_ | 'S'} , /* also X^D */
|
||||||
{" save-window", savewnd} ,
|
{" save-window", savewnd, 0} ,
|
||||||
{" scroll-next-down", scrnextdw} ,
|
{" scroll-next-down", scrnextdw, META | CTL_ | 'V'} ,
|
||||||
{" scroll-next-up", scrnextup} ,
|
{" scroll-next-up", scrnextup, META | CTL_ | 'Z'} ,
|
||||||
{" search-forward", forwsearch} ,
|
{" search-forward", forwsearch, CTL_ | 'S'} ,
|
||||||
{" search-reverse", backsearch} ,
|
{" search-reverse", backsearch, CTL_ | 'R'} ,
|
||||||
{" select-buffer", usebuffer} ,
|
{" select-buffer", usebuffer, CTLX | 'B'} ,
|
||||||
{" set", setvar} ,
|
{" set", setvar, CTLX | 'A'} ,
|
||||||
{" set-fill-column", setfillcol} ,
|
{" set-fill-column", setfillcol, CTLX | 'F'} ,
|
||||||
{" set-mark", (fnp_t) setmark} ,
|
{" set-mark", (fnp_t) setmark, META | ' '} , /* M. */
|
||||||
{" shell-command", spawn} ,
|
{" shell-command", spawn, CTLX | '?'} ,
|
||||||
{" shrink-window", shrinkwind} ,
|
{" shrink-window", shrinkwind, CTLX | CTL_ | 'Z'} ,
|
||||||
{" split-current-window", splitwind} ,
|
{" split-current-window", splitwind, CTLX | '2'} ,
|
||||||
{" store-macro", storemac} ,
|
{" store-macro", storemac, 0} ,
|
||||||
#if PROC
|
#if PROC
|
||||||
{" store-procedure", storeproc} ,
|
{" store-procedure", storeproc, 0} ,
|
||||||
#endif
|
#endif
|
||||||
#if BSD | SVR4
|
#if BSD | SVR4
|
||||||
{" suspend-emacs", bktoshell} ,
|
{" suspend-emacs", bktoshell, CTLX | 'D'} , /* BSD MS */
|
||||||
#endif
|
#endif
|
||||||
{"!transpose-characters", (fnp_t) twiddle} ,
|
{"!transpose-characters", (fnp_t) twiddle, CTL_ | 'T'} ,
|
||||||
#if AEDIT
|
#if AEDIT
|
||||||
{"!trim-line", trim} ,
|
{"!trim-line", trim, CTLX | CTL_ | 'T'} ,
|
||||||
#endif
|
#endif
|
||||||
{" unbind-key", unbindkey} ,
|
{" unbind-key", unbindkey, META | CTL_ | 'K'} ,
|
||||||
{" universal-argument", unarg} ,
|
{" universal-argument", unarg, CTL_ | 'U'} ,
|
||||||
{" unmark-buffer", unmark} ,
|
{" unmark-buffer", unmark, META | '~'} ,
|
||||||
{" update-screen", upscreen} ,
|
{" update-screen", upscreen, 0} ,
|
||||||
{" view-file", viewfile} ,
|
{" view-file", viewfile, CTLX | CTL_ | 'V'} ,
|
||||||
{" wrap-word", wrapword} ,
|
{"!wrap-word", wrapword, SPEC | META | 'W'} , /* hook */
|
||||||
{" write-file", filewrite} ,
|
{" write-file", filewrite, CTLX | CTL_ | 'W'} ,
|
||||||
{" write-message", writemsg} ,
|
{" write-message", writemsg, 0} ,
|
||||||
{"!yank", yank} ,
|
{"!yank", yank, CTL_ | 'Y'} ,
|
||||||
|
|
||||||
{" ", NULL}
|
{" ", NULL, 0},
|
||||||
};
|
/* extra key mapping */
|
||||||
|
// { NULL, newsize, META | CTL_ | 'S'},
|
||||||
|
{ NULL, backdel, CTL_ | '?'},
|
||||||
|
{ NULL, delbword, META | CTL_ | '?'},
|
||||||
|
{ NULL, detab, CTLX | CTL_ | 'A'},
|
||||||
|
{ NULL, enlargewind, CTLX | '^'},
|
||||||
|
{ NULL, (fnp_t) backpage, META | 'V'},
|
||||||
|
{ NULL, quote, CTLX | 'Q'},
|
||||||
|
{ NULL, reposition, META | '!'},
|
||||||
|
//detab { NULL, filesave, CTLX | CTL_ | 'D'},
|
||||||
|
{ NULL, (fnp_t) setmark, META | '.'},
|
||||||
|
// { NULL, bktoshell, META | 'S'},
|
||||||
|
|
||||||
|
#if VT220
|
||||||
|
{ NULL, yank, SPEC | '2'}, /* Insert */
|
||||||
|
{ NULL, forwdel /* killregion */, SPEC | '3'}, /* Delete */
|
||||||
|
{ NULL, (fnp_t) backpage, SPEC | '5'}, /* Page Up */
|
||||||
|
{ NULL, (fnp_t) forwpage, SPEC | '6'}, /* Page Down */
|
||||||
|
{ NULL, (fnp_t) backline, SPEC | 'A'}, /* Up */
|
||||||
|
{ NULL, (fnp_t) forwline, SPEC | 'B'}, /* Down */
|
||||||
|
{ NULL, (fnp_t) forwchar, SPEC | 'C'}, /* Right */
|
||||||
|
{ NULL, (fnp_t) backchar, SPEC | 'D'}, /* Left */
|
||||||
|
{ NULL, (fnp_t) gotoeob, SPEC | 'F'}, /* End */
|
||||||
|
{ NULL, (fnp_t) gotobob, SPEC | 'H'}, /* Home */
|
||||||
|
{ NULL, help, SPEC | 'P'}, /* F1 */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* hooks */
|
||||||
|
{ NULL, nullproc, SPEC | META | 'R'}, /* hook */
|
||||||
|
{ NULL, nullproc, SPEC | META | 'X'}, /* hook */
|
||||||
|
|
||||||
|
{ NULL, NULL, 0}
|
||||||
|
} ;
|
||||||
|
|
||||||
|
static int lastidx = 0 ;
|
||||||
|
|
||||||
|
key_tab keytab[ NBINDS] = {
|
||||||
|
{0, NULL, NULL}
|
||||||
|
} ;
|
||||||
|
|
||||||
|
|
||||||
|
void init_bindings( void) {
|
||||||
|
/* Add default key bindings */
|
||||||
|
key_tab *ktp = keytab ;
|
||||||
|
const name_bind *nbp ;
|
||||||
|
for( nbp = names ; nbp->n_func != NULL ; nbp++) {
|
||||||
|
#ifdef PARANOID
|
||||||
|
/* Check entries and strict order */
|
||||||
|
assert( (nbp->n_name != NULL) &&
|
||||||
|
((nbp == names) ||
|
||||||
|
(0 > strcmp( bind_name( nbp - 1), bind_name( nbp)))
|
||||||
|
)
|
||||||
|
) ;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Add key definition */
|
||||||
|
if( nbp->n_keycode) {
|
||||||
|
ktp->k_code = nbp->n_keycode ;
|
||||||
|
ktp->k_fp = nbp->n_func ;
|
||||||
|
ktp->k_nbp = nbp ;
|
||||||
|
ktp += 1 ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* memorize position after last valid function entry */
|
||||||
|
lastidx = nbp - names ;
|
||||||
|
|
||||||
|
/* Process extra key bindings if any */
|
||||||
|
for( nbp++ ; nbp->n_func != NULL ; nbp++) {
|
||||||
|
#ifdef PARANOID
|
||||||
|
/* Check entry */
|
||||||
|
assert( nbp->n_keycode && (nbp->n_name == NULL)) ;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Look for corresponding function and add extra key binding */
|
||||||
|
const name_bind *fnbp ;
|
||||||
|
for( fnbp = names ; fnbp->n_func != NULL ; fnbp++)
|
||||||
|
if( fnbp->n_func == nbp->n_func) {
|
||||||
|
ktp->k_code = nbp->n_keycode ;
|
||||||
|
ktp->k_fp = nbp->n_func ;
|
||||||
|
ktp->k_nbp = fnbp ;
|
||||||
|
ktp += 1 ;
|
||||||
|
break ;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef PARANOID
|
||||||
|
/* Insure there is a name entry for the keycode and no double keycode */
|
||||||
|
assert( fnbp->n_func != NULL) ;
|
||||||
|
int kcnt = 0 ;
|
||||||
|
for( key_tab *kktp = keytab ; kktp < ktp ; kktp++)
|
||||||
|
if( kktp->k_code == (ktp - 1)->k_code)
|
||||||
|
kcnt += 1 ;
|
||||||
|
|
||||||
|
assert( kcnt == 1) ;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Mark position after last valid key entry */
|
||||||
|
ktp->k_code = 0 ;
|
||||||
|
ktp->k_fp = NULL ;
|
||||||
|
ktp->k_nbp = NULL ;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define BINARY 1
|
||||||
|
|
||||||
const name_bind *fncmatch( char *name) {
|
const name_bind *fncmatch( char *name) {
|
||||||
int found = ARRAY_SIZE( names) - 1 ; /* index of last entry/ catch all */
|
#ifdef BINARY
|
||||||
|
int found = lastidx ;
|
||||||
int low = 0 ;
|
int low = 0 ;
|
||||||
int high = found - 1 ;
|
int high = found - 1 ;
|
||||||
do {
|
do {
|
||||||
@ -253,6 +364,14 @@ const name_bind *fncmatch( char *name) {
|
|||||||
} while( low <= high) ;
|
} while( low <= high) ;
|
||||||
|
|
||||||
return &names[ found] ;
|
return &names[ found] ;
|
||||||
|
#else
|
||||||
|
const name_bind *nbp ;
|
||||||
|
for( nbp = names ; nbp->n_func != NULL ; nbp++)
|
||||||
|
if( !strcmp( name, bind_name( nbp)))
|
||||||
|
break ;
|
||||||
|
|
||||||
|
return nbp ;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/* end of names.c */
|
/* end of names.c */
|
||||||
|
24
names.h
24
names.h
@ -1,20 +1,40 @@
|
|||||||
|
/* names.h -- mapping of functions to names and keys */
|
||||||
|
|
||||||
#ifndef _NAMES_H_
|
#ifndef _NAMES_H_
|
||||||
#define _NAMES_H_
|
#define _NAMES_H_
|
||||||
|
|
||||||
/* Generic uEMACS function pointer type */
|
/* Generic uEMACS function pointer type */
|
||||||
typedef int (*fnp_t)( int, int) ;
|
typedef int (*fnp_t)( int, int) ;
|
||||||
|
|
||||||
|
|
||||||
/* Structure for the name binding table. */
|
/* Structure for the name binding table. */
|
||||||
typedef struct name_bind {
|
typedef struct {
|
||||||
const char *n_name ; /* name starting with one tag character */
|
const char *n_name ; /* name starting with one tag character */
|
||||||
fnp_t n_func ; /* function the name is bound to */
|
fnp_t n_func ; /* function the name is bound to */
|
||||||
|
unsigned n_keycode ; /* default key assignment, 0 when none */
|
||||||
} name_bind ;
|
} name_bind ;
|
||||||
|
|
||||||
#define bind_name( p) (&(p)->n_name[ 1])
|
#define bind_name( p) (&(p)->n_name[ 1])
|
||||||
#define bind_tag( p) (p)->n_name[ 0]
|
#define bind_tag( p) (p)->n_name[ 0]
|
||||||
|
|
||||||
|
/* Structure for the key bindings table. */
|
||||||
|
typedef struct {
|
||||||
|
unsigned k_code ; /* Key code */
|
||||||
|
fnp_t k_fp ; /* Routine to handle it */
|
||||||
|
const name_bind *k_nbp ; /* entry in name to function map table */
|
||||||
|
} key_tab ;
|
||||||
|
|
||||||
|
|
||||||
extern const name_bind names[] ; /* name to function mapping table */
|
extern const name_bind names[] ; /* name to function mapping table */
|
||||||
|
|
||||||
|
/* keycode to function mapping table */
|
||||||
|
#define NBINDS 256 /* max # of bound keys */
|
||||||
|
extern key_tab keytab[ NBINDS] ; /* key bind to functions table */
|
||||||
|
|
||||||
|
|
||||||
|
void init_bindings( void) ;
|
||||||
const name_bind *fncmatch( char *name) ; /* look up by name */
|
const name_bind *fncmatch( char *name) ; /* look up by name */
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* end of names.h */
|
||||||
|
Loading…
Reference in New Issue
Block a user