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