1 /* keymaps.c -- Functions and keymaps for the GNU Readline library. */
3 /* Copyright (C) 1988,1989 Free Software Foundation, Inc.
5 This file is part of GNU Readline, a library for reading lines
6 of text with interactive input and history editing.
8 Readline is free software; you can redistribute it and/or modify it
9 under the terms of the GNU General Public License as published by the
10 Free Software Foundation; either version 2, or (at your option) any
13 Readline is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with Readline; see the file COPYING. If not, write to the Free
20 Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
21 #define READLINE_LIBRARY
23 #if defined (HAVE_CONFIG_H)
27 #if defined (HAVE_STDLIB_H)
30 # include "ansi_stdlib.h"
31 #endif /* HAVE_STDLIB_H */
33 #include <stdio.h> /* for FILE * definition for readline.h */
38 #include "emacs_keymap.c"
41 #include "vi_keymap.c"
46 /* **************************************************************** */
48 /* Functions for manipulating Keymaps. */
50 /* **************************************************************** */
53 /* Return a new, empty keymap.
54 Free it with free() when you are done. */
56 rl_make_bare_keymap ()
59 Keymap keymap
= (Keymap
)xmalloc (KEYMAP_SIZE
* sizeof (KEYMAP_ENTRY
));
61 for (i
= 0; i
< KEYMAP_SIZE
; i
++)
63 keymap
[i
].type
= ISFUNC
;
64 keymap
[i
].function
= (Function
*)NULL
;
67 for (i
= 'A'; i
< ('Z' + 1); i
++)
69 keymap
[i
].type
= ISFUNC
;
70 keymap
[i
].function
= rl_do_lowercase_version
;
76 /* Return a new keymap which is a copy of MAP. */
82 Keymap temp
= rl_make_bare_keymap ();
84 for (i
= 0; i
< KEYMAP_SIZE
; i
++)
86 temp
[i
].type
= map
[i
].type
;
87 temp
[i
].function
= map
[i
].function
;
92 /* Return a new keymap with the printing characters bound to rl_insert,
93 the uppercase Meta characters bound to run their lowercase equivalents,
94 and the Meta digits bound to produce numeric arguments. */
101 newmap
= rl_make_bare_keymap ();
103 /* All ASCII printing characters are self-inserting. */
104 for (i
= ' '; i
< 127; i
++)
105 newmap
[i
].function
= rl_insert
;
107 newmap
[TAB
].function
= rl_insert
;
108 newmap
[RUBOUT
].function
= rl_rubout
; /* RUBOUT == 127 */
109 newmap
[CTRL('H')].function
= rl_rubout
;
111 #if KEYMAP_SIZE > 128
112 /* Printing characters in some 8-bit character sets. */
113 for (i
= 128; i
< 160; i
++)
114 newmap
[i
].function
= rl_insert
;
116 /* ISO Latin-1 printing characters should self-insert. */
117 for (i
= 160; i
< 256; i
++)
118 newmap
[i
].function
= rl_insert
;
119 #endif /* KEYMAP_SIZE > 128 */
124 /* Free the storage associated with MAP. */
126 rl_discard_keymap (map
)
134 for (i
= 0; i
< KEYMAP_SIZE
; i
++)
142 rl_discard_keymap ((Keymap
)map
[i
].function
);
146 free ((char *)map
[i
].function
);