1 /* funmap.c -- attach names to functions. */
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. */
24 extern char *xmalloc (), *xrealloc ();
26 static char *xmalloc (), *xrealloc ();
35 FUNMAP **funmap = (FUNMAP **)NULL;
36 static int funmap_size = 0;
37 static int funmap_entry = 0;
39 static FUNMAP default_funmap[] = {
40 { "beginning-of-line", rl_beg_of_line },
41 { "backward-char", rl_backward },
42 { "delete-char", rl_delete },
43 { "end-of-line", rl_end_of_line },
44 { "forward-char", rl_forward },
45 { "accept-line", rl_newline },
46 { "kill-line", rl_kill_line },
47 { "clear-screen", rl_clear_screen },
48 { "next-history", rl_get_next_history },
49 { "previous-history", rl_get_previous_history },
50 { "quoted-insert", rl_quoted_insert },
51 { "reverse-search-history", rl_reverse_search_history },
52 { "forward-search-history", rl_forward_search_history },
53 { "transpose-chars", rl_transpose_chars },
54 { "unix-line-discard", rl_unix_line_discard },
55 { "unix-word-rubout", rl_unix_word_rubout },
57 { "yank-pop", rl_yank_pop },
58 { "yank-nth-arg", rl_yank_nth_arg },
59 { "backward-delete-char", rl_rubout },
60 { "backward-word", rl_backward_word },
61 { "kill-word", rl_kill_word },
62 { "forward-word", rl_forward_word },
63 { "tab-insert", rl_tab_insert },
64 { "backward-kill-word", rl_backward_kill_word },
65 { "backward-kill-line", rl_backward_kill_line },
66 { "transpose-words", rl_transpose_words },
67 { "digit-argument", rl_digit_argument },
68 { "complete", rl_complete },
69 { "possible-completions", rl_possible_completions },
70 { "do-lowercase-version", rl_do_lowercase_version },
71 { "digit-argument", rl_digit_argument },
72 { "universal-argument", rl_universal_argument },
73 { "abort", rl_abort },
74 { "undo", rl_undo_command },
75 { "upcase-word", rl_upcase_word },
76 { "downcase-word", rl_downcase_word },
77 { "capitalize-word", rl_capitalize_word },
78 { "revert-line", rl_revert_line },
79 { "beginning-of-history", rl_beginning_of_history },
80 { "end-of-history", rl_end_of_history },
81 { "self-insert", rl_insert },
82 { "start-kbd-macro", rl_start_kbd_macro },
83 { "end-kbd-macro", rl_end_kbd_macro },
84 { "re-read-init-file", rl_re_read_init_file },
86 { "vi-movement-mode", rl_vi_movement_mode },
87 { "vi-insertion-mode", rl_vi_insertion_mode },
88 { "vi-arg-digit", rl_vi_arg_digit },
89 { "vi-prev-word", rl_vi_prev_word },
90 { "vi-next-word", rl_vi_next_word },
91 { "vi-char-search", rl_vi_char_search },
92 { "vi-editing-mode", rl_vi_editing_mode },
93 { "vi-eof-maybe", rl_vi_eof_maybe },
94 { "vi-append-mode", rl_vi_append_mode },
95 { "vi-put", rl_vi_put },
96 { "vi-append-eol", rl_vi_append_eol },
97 { "vi-insert-beg", rl_vi_insert_beg },
98 { "vi-delete", rl_vi_delete },
99 { "vi-comment", rl_vi_comment },
100 { "vi-first-print", rl_vi_first_print },
101 { "vi-fword", rl_vi_fword },
102 { "vi-fWord", rl_vi_fWord },
103 { "vi-bword", rl_vi_bword },
104 { "vi-bWord", rl_vi_bWord },
105 { "vi-eword", rl_vi_eword },
106 { "vi-eWord", rl_vi_eWord },
107 { "vi-end-word", rl_vi_end_word },
108 { "vi-change-case", rl_vi_change_case },
109 { "vi-match", rl_vi_match },
110 { "vi-bracktype", rl_vi_bracktype },
111 { "vi-change-char", rl_vi_change_char },
112 { "vi-yank-arg", rl_vi_yank_arg },
113 { "vi-search", rl_vi_search },
114 { "vi-search-again", rl_vi_search_again },
115 { "vi-dosearch", rl_vi_dosearch },
116 { "vi-subst", rl_vi_subst },
117 { "vi-overstrike", rl_vi_overstrike },
118 { "vi-overstrike-delete", rl_vi_overstrike_delete },
119 { "vi-replace, ", rl_vi_replace },
120 { "vi-column", rl_vi_column },
121 { "vi-delete-to", rl_vi_delete_to },
122 { "vi-change-to", rl_vi_change_to },
123 { "vi-yank-to", rl_vi_yank_to },
124 { "vi-complete", rl_vi_complete },
127 {(char *)NULL, (Function *)NULL }
130 rl_add_funmap_entry (name, function)
134 if (funmap_entry + 2 >= funmap_size)
136 funmap = (FUNMAP **)xmalloc ((funmap_size = 80) * sizeof (FUNMAP *));
139 (FUNMAP **)xrealloc (funmap, (funmap_size += 80) * sizeof (FUNMAP *));
141 funmap[funmap_entry] = (FUNMAP *)xmalloc (sizeof (FUNMAP));
142 funmap[funmap_entry]->name = name;
143 funmap[funmap_entry]->function = function;
145 funmap[++funmap_entry] = (FUNMAP *)NULL;
148 static int funmap_initialized = 0;
150 /* Make the funmap contain all of the default entries. */
151 rl_initialize_funmap ()
155 if (funmap_initialized)
158 for (i = 0; default_funmap[i].name; i++)
159 rl_add_funmap_entry (default_funmap[i].name, default_funmap[i].function);
161 funmap_initialized = 1;
164 /* Things that mean `Control'. */
165 char *possible_control_prefixes[] = {
166 "Control-", "C-", "CTRL-", (char *)NULL
169 char *possible_meta_prefixes[] = {
170 "Meta", "M-", (char *)NULL
175 /* **************************************************************** */
177 /* xmalloc and xrealloc () */
179 /* **************************************************************** */
181 static void memory_error_and_abort ();
187 char *temp = (char *)malloc (bytes);
190 memory_error_and_abort ();
195 xrealloc (pointer, bytes)
199 char *temp = (char *)realloc (pointer, bytes);
202 memory_error_and_abort ();
207 memory_error_and_abort ()
209 fprintf (stderr, "history: Out of virtual memory!\n");
212 #endif /* STATIC_MALLOC */