]>
Commit | Line | Data |
---|---|---|
d60d9f65 SS |
1 | /* keymaps.h -- Manipulation of readline keymaps. */ |
2 | ||
3 | /* Copyright (C) 1987, 1989, 1992 Free Software Foundation, Inc. | |
4 | ||
5 | This file is part of the GNU Readline Library, a library for | |
6 | reading lines of text with interactive input and history editing. | |
7 | ||
8 | The GNU Readline Library is free software; you can redistribute it | |
9 | and/or modify it under the terms of the GNU General Public License | |
1b17e766 | 10 | as published by the Free Software Foundation; either version 2, or |
d60d9f65 SS |
11 | (at your option) any later version. |
12 | ||
13 | The GNU Readline Library is distributed in the hope that it will be | |
14 | useful, but WITHOUT ANY WARRANTY; without even the implied warranty | |
15 | of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | GNU General Public License for more details. | |
17 | ||
18 | The GNU General Public License is often shipped with GNU software, and | |
19 | is generally kept in a file called COPYING or LICENSE. If you do not | |
20 | have a copy of the license, write to the Free Software Foundation, | |
1b17e766 | 21 | 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ |
d60d9f65 SS |
22 | |
23 | #ifndef _KEYMAPS_H_ | |
24 | #define _KEYMAPS_H_ | |
25 | ||
1b17e766 EZ |
26 | #ifdef __cplusplus |
27 | extern "C" { | |
28 | #endif | |
29 | ||
d60d9f65 | 30 | #if defined (READLINE_LIBRARY) |
c862e87b | 31 | # include "rlstdc.h" |
d60d9f65 | 32 | # include "chardefs.h" |
9255ee31 | 33 | # include "rltypedefs.h" |
d60d9f65 | 34 | #else |
c862e87b | 35 | # include <readline/rlstdc.h> |
d60d9f65 | 36 | # include <readline/chardefs.h> |
9255ee31 | 37 | # include <readline/rltypedefs.h> |
d60d9f65 SS |
38 | #endif |
39 | ||
40 | /* A keymap contains one entry for each key in the ASCII set. | |
41 | Each entry consists of a type and a pointer. | |
42 | FUNCTION is the address of a function to run, or the | |
43 | address of a keymap to indirect through. | |
44 | TYPE says which kind of thing FUNCTION is. */ | |
45 | typedef struct _keymap_entry { | |
46 | char type; | |
9255ee31 | 47 | rl_command_func_t *function; |
d60d9f65 SS |
48 | } KEYMAP_ENTRY; |
49 | ||
50 | /* This must be large enough to hold bindings for all of the characters | |
51 | in a desired character set (e.g, 128 for ASCII, 256 for ISO Latin-x, | |
9255ee31 EZ |
52 | and so on) plus one for subsequence matching. */ |
53 | #define KEYMAP_SIZE 257 | |
54 | #define ANYOTHERKEY KEYMAP_SIZE-1 | |
d60d9f65 SS |
55 | |
56 | /* I wanted to make the above structure contain a union of: | |
9255ee31 | 57 | union { rl_command_func_t *function; struct _keymap_entry *keymap; } value; |
d60d9f65 SS |
58 | but this made it impossible for me to create a static array. |
59 | Maybe I need C lessons. */ | |
60 | ||
61 | typedef KEYMAP_ENTRY KEYMAP_ENTRY_ARRAY[KEYMAP_SIZE]; | |
62 | typedef KEYMAP_ENTRY *Keymap; | |
63 | ||
64 | /* The values that TYPE can have in a keymap entry. */ | |
65 | #define ISFUNC 0 | |
66 | #define ISKMAP 1 | |
67 | #define ISMACR 2 | |
68 | ||
69 | extern KEYMAP_ENTRY_ARRAY emacs_standard_keymap, emacs_meta_keymap, emacs_ctlx_keymap; | |
70 | extern KEYMAP_ENTRY_ARRAY vi_insertion_keymap, vi_movement_keymap; | |
71 | ||
72 | /* Return a new, empty keymap. | |
73 | Free it with free() when you are done. */ | |
9255ee31 | 74 | extern Keymap rl_make_bare_keymap PARAMS((void)); |
d60d9f65 SS |
75 | |
76 | /* Return a new keymap which is a copy of MAP. */ | |
9255ee31 | 77 | extern Keymap rl_copy_keymap PARAMS((Keymap)); |
d60d9f65 SS |
78 | |
79 | /* Return a new keymap with the printing characters bound to rl_insert, | |
80 | the lowercase Meta characters bound to run their equivalents, and | |
81 | the Meta digits bound to produce numeric arguments. */ | |
9255ee31 | 82 | extern Keymap rl_make_keymap PARAMS((void)); |
d60d9f65 | 83 | |
c862e87b | 84 | /* Free the storage associated with a keymap. */ |
9255ee31 | 85 | extern void rl_discard_keymap PARAMS((Keymap)); |
c862e87b JM |
86 | |
87 | /* These functions actually appear in bind.c */ | |
d60d9f65 SS |
88 | |
89 | /* Return the keymap corresponding to a given name. Names look like | |
c862e87b | 90 | `emacs' or `emacs-meta' or `vi-insert'. */ |
9255ee31 | 91 | extern Keymap rl_get_keymap_by_name PARAMS((const char *)); |
d60d9f65 SS |
92 | |
93 | /* Return the current keymap. */ | |
9255ee31 | 94 | extern Keymap rl_get_keymap PARAMS((void)); |
d60d9f65 SS |
95 | |
96 | /* Set the current keymap to MAP. */ | |
9255ee31 | 97 | extern void rl_set_keymap PARAMS((Keymap)); |
d60d9f65 | 98 | |
1b17e766 EZ |
99 | #ifdef __cplusplus |
100 | } | |
101 | #endif | |
102 | ||
d60d9f65 | 103 | #endif /* _KEYMAPS_H_ */ |