/************************************************************************ * This program is Copyright (C) 1986 by Jonathan Payne. JOVE is * * provided to you without charge, and with no warranty. You may give * * away copies of JOVE, including sources, provided that this notice is * * included in all the files. * ************************************************************************/ /*+++* * title: maps.h * abstract: definitions for JOVEs keymaps * author: T.R.Hageman, Groningen, The Netherlands. * created: june 1990 * modified: 04-Jul-92, incorporated in JOVE. * description: *---*/ #ifndef _MAPS_H_ #define _MAPS_H_ #ifndef TUNED # include "tune.h" #endif #ifdef Extern RCS_H(maps, "$Id: maps.h,v 14.32 1993/06/22 03:56:07 tom Exp tom $") #endif #ifndef Extern # define Extern extern #endif #define FROZEN 0x8000 /* this keymap is here to stay */ #define VISITED 0x4000 /* set by find_binds, DescMap to detect loops */ #define SPARSE 0x80 /* this is a sparse keymap. */ /* these flags are ORed with the object kind in the Type field of the bind commands */ #ifdef IPROCS # define PMAP 0x10 /* bind to process map */ #endif #ifndef MAPSIZE # define MAPSIZE (0200 + NFKEYS) #endif #ifdef FUNCKEYS # define isfunckey(c) ((c)>=MAPSIZE-NFKEYS) #else # define isfunckey(c) 0 #endif typedef data_obj *keybind[MAPSIZE]; #define NMAPS 4 extern keybind mainmap, /* Builtin key binding tables. */ pref1map, pref2map, miscmap; typedef struct Keymap Keymap; struct Keymap { int Type; /* i.e., KEYMAP */ const char *Name; data_obj **k_bind; /* pointer to binding table. */ #ifndef FIXED_MAPS Keymap *k_next, /* next in a list of existing keymaps */ *k_active; /* next in a list of active keymaps */ #endif }; extern Keymap Maps[]; /* Builtin keymaps. */ extern data_obj * (*const Find[])__(( const char *_(prompt) )); #define FindObj(which, prompt) (*(Find-1)[which])(prompt) #ifndef FIXED_MAPS # define K_NEXT(map) ((map) = (map)->k_next) # define K_ACTIVE_NEXT(map) ((map) = (map)->k_active) extern Keymap *keymaps, *activemap; /* Return currently active keymap, recalculating if necessary. */ extern Keymap *active_map __(( void )); extern data_obj *get_bind __(( const Keymap *_(map), int _(c) )), *get_sparse_bind __(( const Keymap *_(map), int _(c) )), **bind_key __(( Keymap *_(initial_map), int _(options) )); /* Find binding in current Keymap only, do not look in other active maps. */ # define get_shallow_bind(map, c) \ (((map)->Type & SPARSE) ? \ get_sparse_bind((map),(c)) : (map)->k_bind[c]) # define MapKey bind_key #else /* FIXED_MAPS */ # define K_NEXT(map) (++(map) < &Maps[NMAPS]) # define K_ACTIVE_NEXT(map) (0) # define keymaps (&Maps[0]) # define activemap keymaps # define active_map() activemap # define get_bind(map, c) ((map)->k_bind[c]) # define get_shallow_bind(map, c) get_bind(map,c) extern data_obj **bind_key __(( int _(options) )); # define MapKey(initial_map, options) bind_key((options)) #endif /* FIXED_MAPS */ /* Options for MapKey. */ #define MAP_ALLOW_PREFIX 1 #define MAP_BIND 2 #define MAP_FOLLOW_ACTIVE_LIST 4 #define MAP_UNBIND 8 /* Sparse keymap entry, used by various commands. */ typedef struct { data_obj *s_cmd; int s_chr; } sparsemap; extern sparsemap /* Builtin sparse key binding tables. */ #ifndef TINY HelpMap[], #endif WFindMap[]; #define WINDFINDMAP_INDEX NMAPS #ifndef TINY # define HELPMAP_INDEX (NMAPS+1) #endif extern Keymap *IsPrefix __(( const data_obj *_(dp) )); extern data_obj *findsparse __(( const sparsemap *_(smap), int _(c) )); #ifndef NO_TRIV_PROTO extern void DelBind __(( const data_obj *_(dp) )); extern void map_init_visit __(( void )); #endif /* funcdefs.c */ #define FIND_CACHE(n) { const data_obj *hashtab[1+26]; const char *nametab[n]; } struct find_cache FIND_CACHE(1); extern data_obj *find_builtin __(( const data_obj *_(objtab), struct find_cache *_(cache), const char *_(prompt) )); #endif /* _MAPS_H_ */ #undef Extern /*====================================================================== * $Log: maps.h,v $ * Revision 14.32 1993/06/22 03:56:07 tom * (MAPSIZE): allow external definition; * (isfunckey): eliminate explicit 0200 constant; * (FIXED_MAPS MapKey): rename parameter for clarity. * * Revision 14.31 1993/02/15 03:04:40 tom * replace TINY with NO_TRIV_PROTO for clarity of intent. * * Revision 14.30 1993/02/09 17:44:07 tom * cleanup whitespace; add isfunckey(), get_shallow_bind(), FIND_CACHE() * macros; add MAP_UNBIND flag; update function prototypes. * * Revision 14.28 1992/09/24 20:05:57 tom * integrate sparsemaps in regular keymap mechanism; * convert to "port{ansi,defs}.h" conventions. * * Revision 14.26 1992/08/26 23:56:46 tom * add RCS directives. * */