summaryrefslogtreecommitdiff
path: root/usr.bin/mg/kbd.h
blob: 93332d1517a0566e5b3435cd96615e72a46d795d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*	$OpenBSD: kbd.h,v 1.4 2001/01/29 01:58:07 niklas Exp $	*/

/*
 * kbd.h: type definitions for symbol.c and kbd.c for mg experimental
 */

typedef struct {
	KCHAR            k_base;	/* first key in element		 */
	KCHAR            k_num;		/* last key in element		 */
	PF              *k_funcp;	/* pointer to array of pointers
					 * to functions */
	struct keymap_s *k_prefmap;	/* keymap of ONLY prefix key in
					 * element */
} MAP_ELEMENT;

/*
 * predefined keymaps are NOT type KEYMAP because final array needs
 * dimension.  If any changes are made to this struct, they must be reflected
 * in all keymap declarations.
 */

#define KEYMAPE(NUM)	{						\
	short	map_num;		/* elements used */		\
	short	map_max;		/* elements allocated */	\
	PF	map_default;		/* default function */		\
	MAP_ELEMENT map_element[NUM];	/* really [e_max] */		\
}
typedef struct keymap_s KEYMAPE(1) KEYMAP;

#define none	ctrlg
#define prefix	(PF)NULL

/* Number of map_elements to grow an overflowed keymap by */
#define IMAPEXT 0
#define MAPGROW 3
#define MAPINIT (MAPGROW+1)

/* Max number of default bindings added to avoid creating new element */
#define MAPELEDEF 4

typedef struct MAPS_S {
	KEYMAP         *p_map;
	char           *p_name;
} MAPS;

extern MAPS     map_table[];

typedef struct {
	PF              n_funct;
	char           *n_name;
} FUNCTNAMES;

int	 dobindkey		__P((KEYMAP *, char *, char *));
KEYMAP  *name_map		__P((char *));
MAPS    *name_mode		__P((char *));
PF       doscan			__P((KEYMAP *, int));
PF       name_function		__P((char *));
char    *function_name		__P((PF));
char    *map_name		__P((KEYMAP *));

extern int		 nfunct;
extern FUNCTNAMES	 functnames[];
extern MAP_ELEMENT	*ele;
extern MAPS		*defb_modes[];