File: key.h

package info (click to toggle)
oleo 1.6-16
  • links: PTS
  • area: main
  • in suites: potato
  • size: 2,640 kB
  • ctags: 3,139
  • sloc: ansic: 39,221; yacc: 1,737; sh: 362; makefile: 88
file content (111 lines) | stat: -rw-r--r-- 2,934 bytes parent folder | download | duplicates (3)
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#ifndef KEYH
#define KEYH

/*	Copyright (C) 1993 Free Software Foundation, Inc.

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this software; see the file COPYING.  If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
/*  t. lord	Thu Jan 21 16:13:14 1993	*/

#include "global.h"
#include "line.h"


/*
 * Keymaps and keybinds.
 * Within a keymap, keys are bound to a `struct key'.
 *
 * Normally,  `the_funcs[akey.vector][akey.code]' is the command binding of a
 * key.  However, the akey.vector == -1, then the binding is to another
 * keymap, found by the_maps[akey.code].  The final exception, is that if
 * both vector and code are -1, then the key is unbound.
 */

struct cmd_func;

struct key
{
  short vector;
  short code;
};

/* For commands that take a keysequence argument: */

struct key_sequence
{
  int top_map;
  struct line * keys;		/* char_to_string name of the key sequence. */
  struct key cmd;		/* The mapping of the sequence. */
};


struct keymap
{
  struct keymap *map_next;
  int id;
  struct key keys[256];
};

extern int num_maps;
extern struct keymap **the_maps;
extern char **map_names;
extern char **map_prompts;

#ifndef CTRL
#define CTRL(X) ((X)&037)
#endif
#ifndef META
#define META(X) ((X)|0200)
#endif


/* String convention conversion. */

#define map_id(NAME)  map_idn(NAME, strlen(NAME))

/*
 * Keymap names.  They can be used as indices into the_maps and map_names.
 */
#define MAIN_MAP map_id("main")
#define EDIT_MAP map_id("edit")
#define DIGIT_MAP map_id("digit")
#define NAVIGATE_MAP map_id("navigate")


#if PROTOTYPES
extern int search_map_for_cmd (struct line * line, int map, int vec, int code);
extern void bind_key (char * keymap, char * function, int ch);
extern void bind_set (char * keymap, char * command, char * keyset);
extern void bind_all_keys (char * keymap, char * function);
extern void write_keys_cmd (FILE *fp);
extern void clear_keymap (struct keymap *m);
extern int map_idn (char *name, int n);
extern void create_keymap (char * mapname, char * parentname);
extern void set_map_prompt (char * map, char * str);
#else /* PROTOTYPES */
extern int search_map_for_cmd ();
extern void bind_key ();
extern void bind_set ();
extern void bind_all_keys ();
extern void write_keys_cmd ();
extern void clear_keymap ();
extern int map_idn ();
extern void create_keymap ();
extern void set_map_prompt ();
#endif /* PROTOTYPES */


#endif  /* KEYH */