2021-07-22 22:47:58 -04:00
|
|
|
/* names.h -- mapping of functions to names and keys */
|
|
|
|
|
2021-07-19 03:39:00 -04:00
|
|
|
#ifndef _NAMES_H_
|
|
|
|
#define _NAMES_H_
|
|
|
|
|
2021-07-24 04:34:54 -04:00
|
|
|
#include "retcode.h"
|
|
|
|
|
|
|
|
|
2021-07-31 00:35:39 -04:00
|
|
|
#define CTRL 0x01000000 /* Control flag, or'ed in */
|
|
|
|
#define META 0x02000000 /* Meta flag, or'ed in */
|
|
|
|
#define CTLX 0x04000000 /* ^X flag, or'ed in */
|
|
|
|
#define SPEC 0x08000000 /* special key (function keys) */
|
|
|
|
#define PRFXMASK 0x0F000000 /* prefix mask */
|
2021-07-30 04:24:52 -04:00
|
|
|
|
|
|
|
|
2021-07-23 20:58:23 -04:00
|
|
|
/* Bindable uEMACS function pointer type and definition template */
|
2021-07-29 21:30:12 -04:00
|
|
|
#define BINDABLE( fname) int fname( int f, int n)
|
2021-07-23 20:58:23 -04:00
|
|
|
|
|
|
|
typedef BINDABLE( (*fnp_t)) ;
|
2021-07-19 03:39:00 -04:00
|
|
|
|
2021-07-22 22:47:58 -04:00
|
|
|
|
2013-05-31 01:18:10 -04:00
|
|
|
/* Structure for the name binding table. */
|
2021-07-22 22:47:58 -04:00
|
|
|
typedef struct {
|
2021-07-29 21:30:12 -04:00
|
|
|
const char *n_name ; /* name starting with one tag character */
|
|
|
|
fnp_t n_func ; /* function the name is bound to */
|
|
|
|
unsigned n_keycode ; /* default key assignment, 0 when none */
|
2021-07-19 03:39:00 -04:00
|
|
|
} name_bind ;
|
2013-05-31 01:18:10 -04:00
|
|
|
|
2021-07-29 21:30:12 -04:00
|
|
|
typedef const name_bind *nbind_p ;
|
|
|
|
|
2021-07-23 20:58:23 -04:00
|
|
|
#define bind_name( p) (&( p)->n_name[ 1])
|
|
|
|
#define bind_tag( p) ( p)->n_name[ 0]
|
2021-07-19 23:24:32 -04:00
|
|
|
|
2021-07-29 21:30:12 -04:00
|
|
|
|
2021-07-22 22:47:58 -04:00
|
|
|
/* Structure for the key bindings table. */
|
|
|
|
typedef struct {
|
2021-07-29 21:30:12 -04:00
|
|
|
unsigned k_code ; /* Key code */
|
|
|
|
nbind_p k_nbp ; /* entry in name to function map table */
|
|
|
|
} *kbind_p ;
|
2021-07-22 22:47:58 -04:00
|
|
|
|
|
|
|
|
2021-07-29 21:30:12 -04:00
|
|
|
extern const name_bind names[] ; /* name to function mapping table */
|
|
|
|
extern kbind_p keytab ; /* key bind to functions table */
|
2021-07-22 22:47:58 -04:00
|
|
|
|
|
|
|
|
2021-07-24 04:34:54 -04:00
|
|
|
boolean init_bindings( void) ;
|
2021-07-29 21:30:12 -04:00
|
|
|
kbind_p setkeybinding( unsigned key, nbind_p nbp) ;
|
2021-07-24 04:34:54 -04:00
|
|
|
boolean delkeybinding( unsigned key) ;
|
2021-07-30 04:24:52 -04:00
|
|
|
kbind_p getkeybinding( unsigned key) ; /* look up by key code */
|
|
|
|
|
|
|
|
/* find a name to function association in the name to function mapping table */
|
2021-07-29 21:30:12 -04:00
|
|
|
nbind_p fncmatch( char *name) ; /* look up by name */
|
2021-07-21 04:40:36 -04:00
|
|
|
|
2021-07-30 04:24:52 -04:00
|
|
|
|
2021-07-23 20:58:23 -04:00
|
|
|
/* bindable functions mapped to prefix keys and hooks */
|
|
|
|
BINDABLE( nullproc) ;
|
|
|
|
BINDABLE( metafn) ;
|
|
|
|
BINDABLE( cex) ;
|
|
|
|
BINDABLE( unarg) ;
|
|
|
|
|
2021-07-19 03:39:00 -04:00
|
|
|
#endif
|
2021-07-22 22:47:58 -04:00
|
|
|
|
|
|
|
/* end of names.h */
|