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 1, 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, 675 Mass Ave, Cambridge, MA 02139, USA. */
23 #include "emacs_keymap.c"
26 #include "vi_keymap.c"
29 /* Remove these declarations when we have a complete libgnu.a. */
32 extern char *xmalloc (), *xrealloc ();
34 static char *xmalloc (), *xrealloc ();
37 /* **************************************************************** */
39 /* Functions for manipulating Keymaps. */
41 /* **************************************************************** */
44 /* Return a new, empty keymap.
45 Free it with free() when you are done. */
47 rl_make_bare_keymap ()
50 Keymap keymap = (Keymap)xmalloc (128 * sizeof (KEYMAP_ENTRY));
52 for (i = 0; i < 128; i++)
54 keymap[i].type = ISFUNC;
55 keymap[i].function = (Function *)NULL;
58 for (i = 'A'; i < ('Z' + 1); i++)
60 keymap[i].type = ISFUNC;
61 keymap[i].function = rl_do_lowercase_version;
67 /* Return a new keymap which is a copy of MAP. */
73 Keymap temp = rl_make_bare_keymap ();
75 for (i = 0; i < 128; i++)
77 temp[i].type = map[i].type;
78 temp[i].function = map[i].function;
83 /* Return a new keymap with the printing characters bound to rl_insert,
84 the uppercase Meta characters bound to run their lowercase equivalents,
85 and the Meta digits bound to produce numeric arguments. */
89 extern rl_insert (), rl_rubout (), rl_do_lowercase_version ();
90 extern rl_digit_argument ();
94 newmap = rl_make_bare_keymap ();
96 /* All printing characters are self-inserting. */
97 for (i = ' '; i < 126; i++)
98 newmap[i].function = rl_insert;
100 newmap[TAB].function = rl_insert;
101 newmap[RUBOUT].function = rl_rubout;
106 /* Free the storage associated with MAP. */
107 rl_discard_keymap (map)
115 for (i = 0; i < 128; i++)
123 rl_discard_keymap ((Keymap)map[i].function);
127 free ((char *)map[i].function);
135 /* **************************************************************** */
137 /* xmalloc and xrealloc () */
139 /* **************************************************************** */
141 static void memory_error_and_abort ();
147 char *temp = (char *)malloc (bytes);
150 memory_error_and_abort ();
155 xrealloc (pointer, bytes)
159 char *temp = (char *)realloc (pointer, bytes);
162 memory_error_and_abort ();
167 memory_error_and_abort ()
169 fprintf (stderr, "readline: Out of virtual memory!\n");
172 #endif /* STATIC_MALLOC */