171
|
1 /* infomap.c -- Keymaps for Info. */ |
|
2 |
|
3 /* This file is part of GNU Info, a program for reading online documentation |
|
4 stored in Info format. |
|
5 |
|
6 Copyright (C) 1993 Free Software Foundation, Inc. |
|
7 |
|
8 This program 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 2, or (at your option) |
|
11 any later version. |
|
12 |
|
13 This program 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 this program; if not, write to the Free Software |
|
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
|
21 |
|
22 Written by Brian Fox (bfox@ai.mit.edu). */ |
|
23 |
1242
|
24 #ifdef HAVE_CONFIG_H |
|
25 #include <config.h> |
|
26 #endif |
|
27 |
171
|
28 #include "stdio.h" |
|
29 #include "ctype.h" |
|
30 #include "infomap.h" |
|
31 #include "funs.h" |
|
32 |
|
33 /* Return a new keymap which has all the uppercase letters mapped to run |
|
34 the function info_do_lowercase_version (). */ |
|
35 Keymap |
|
36 keymap_make_keymap () |
|
37 { |
|
38 register int i; |
|
39 Keymap keymap; |
|
40 |
|
41 keymap = (Keymap)xmalloc (256 * sizeof (KEYMAP_ENTRY)); |
|
42 |
|
43 for (i = 0; i < 256; i++) |
|
44 { |
|
45 keymap[i].type = ISFUNC; |
|
46 keymap[i].function = (VFunction *)NULL; |
|
47 } |
|
48 |
|
49 for (i = 'A'; i < ('Z' + 1); i++) |
|
50 { |
|
51 keymap[i].type = ISFUNC; |
|
52 keymap[i].function = info_do_lowercase_version; |
|
53 } |
|
54 |
|
55 return (keymap); |
|
56 } |
|
57 |
|
58 /* Return a new keymap which is a copy of MAP. */ |
|
59 Keymap |
|
60 keymap_copy_keymap (map) |
|
61 Keymap map; |
|
62 { |
|
63 register int i; |
|
64 Keymap keymap; |
|
65 |
|
66 keymap = keymap_make_keymap (); |
|
67 |
|
68 for (i = 0; i < 256; i++) |
|
69 { |
|
70 keymap[i].type = map[i].type; |
|
71 keymap[i].function = map[i].function; |
|
72 } |
|
73 return (keymap); |
|
74 } |
|
75 |
|
76 /* Free the keymap and it's descendents. */ |
|
77 void |
|
78 keymap_discard_keymap (map) |
|
79 Keymap (map); |
|
80 { |
|
81 register int i; |
|
82 |
|
83 if (!map) |
|
84 return; |
|
85 |
|
86 for (i = 0; i < 256; i++) |
|
87 { |
|
88 switch (map[i].type) |
|
89 { |
|
90 case ISFUNC: |
|
91 break; |
|
92 |
|
93 case ISKMAP: |
|
94 keymap_discard_keymap ((Keymap)map[i].function); |
|
95 break; |
|
96 |
|
97 } |
|
98 } |
|
99 } |
|
100 |
|
101 /* Initialize the standard info keymaps. */ |
|
102 |
|
103 Keymap info_keymap = (Keymap)NULL; |
|
104 Keymap echo_area_keymap = (Keymap)NULL; |
|
105 |
|
106 void |
|
107 initialize_info_keymaps () |
|
108 { |
|
109 register int i; |
|
110 Keymap map; |
|
111 |
|
112 if (!info_keymap) |
|
113 { |
|
114 info_keymap = keymap_make_keymap (); |
|
115 info_keymap[ESC].type = ISKMAP; |
|
116 info_keymap[ESC].function = (VFunction *)keymap_make_keymap (); |
|
117 info_keymap[Control ('x')].type = ISKMAP; |
|
118 info_keymap[Control ('x')].function = (VFunction *)keymap_make_keymap (); |
|
119 echo_area_keymap = keymap_make_keymap (); |
|
120 echo_area_keymap[ESC].type = ISKMAP; |
|
121 echo_area_keymap[ESC].function = (VFunction *)keymap_make_keymap (); |
|
122 echo_area_keymap[Control ('x')].type = ISKMAP; |
|
123 echo_area_keymap[Control ('x')].function = |
|
124 (VFunction *)keymap_make_keymap (); |
|
125 } |
|
126 |
|
127 /* Bind numeric arg functions for both echo area and info window maps. */ |
|
128 for (i = '0'; i < '9' + 1; i++) |
|
129 { |
|
130 ((Keymap) info_keymap[ESC].function)[i].function = |
|
131 ((Keymap) echo_area_keymap[ESC].function)[i].function = |
|
132 info_add_digit_to_numeric_arg; |
|
133 } |
|
134 ((Keymap) info_keymap[ESC].function)['-'].function = |
|
135 ((Keymap) echo_area_keymap[ESC].function)['-'].function = |
|
136 info_add_digit_to_numeric_arg; |
|
137 |
|
138 /* Bind the echo area routines. */ |
|
139 map = echo_area_keymap; |
|
140 |
|
141 /* Bind the echo area insert routines. */ |
|
142 for (i = 0; i < 160; i++) |
|
143 if (isprint (i)) |
|
144 map[i].function = ea_insert; |
|
145 |
|
146 map[Control ('a')].function = ea_beg_of_line; |
|
147 map[Control ('b')].function = ea_backward; |
|
148 map[Control ('d')].function = ea_delete; |
|
149 map[Control ('e')].function = ea_end_of_line; |
|
150 map[Control ('f')].function = ea_forward; |
|
151 map[Control ('g')].function = ea_abort; |
|
152 map[Control ('h')].function = ea_rubout; |
|
153 map[Control ('k')].function = ea_kill_line; |
|
154 map[Control ('l')].function = info_redraw_display; |
|
155 map[Control ('q')].function = ea_quoted_insert; |
|
156 map[Control ('t')].function = ea_transpose_chars; |
|
157 map[Control ('u')].function = info_universal_argument; |
|
158 map[Control ('y')].function = ea_yank; |
|
159 |
|
160 map[LFD].function = ea_newline; |
|
161 map[RET].function = ea_newline; |
|
162 map[SPC].function = ea_complete; |
|
163 map[TAB].function = ea_complete; |
|
164 map['?'].function = ea_possible_completions; |
|
165 map[DEL].function = ea_rubout; |
|
166 |
|
167 /* Bind the echo area ESC keymap. */ |
|
168 map = (Keymap)echo_area_keymap[ESC].function; |
|
169 |
|
170 map[Control ('g')].function = ea_abort; |
|
171 map[Control ('v')].function = ea_scroll_completions_window; |
|
172 map['b'].function = ea_backward_word; |
|
173 map['d'].function = ea_kill_word; |
|
174 map['f'].function = ea_forward_word; |
|
175 #if defined (NAMED_FUNCTIONS) |
|
176 /* map['x'].function = info_execute_command; */ |
|
177 #endif /* NAMED_FUNCTIONS */ |
|
178 map['y'].function = ea_yank_pop; |
|
179 map['?'].function = ea_possible_completions; |
|
180 map[TAB].function = ea_tab_insert; |
|
181 map[DEL].function = ea_backward_kill_word; |
|
182 |
|
183 /* Bind the echo area Control-x keymap. */ |
|
184 map = (Keymap)echo_area_keymap[Control ('x')].function; |
|
185 |
|
186 map['o'].function = info_next_window; |
|
187 map[DEL].function = ea_backward_kill_line; |
|
188 |
|
189 /* Bind commands for Info window keymaps. */ |
|
190 map = info_keymap; |
|
191 map[TAB].function = info_move_to_next_xref; |
|
192 map[LFD].function = info_select_reference_this_line; |
|
193 map[RET].function = info_select_reference_this_line; |
|
194 map[SPC].function = info_scroll_forward; |
|
195 map[Control ('a')].function = info_beginning_of_line; |
|
196 map[Control ('b')].function = info_backward_char; |
|
197 map[Control ('e')].function = info_end_of_line; |
|
198 map[Control ('f')].function = info_forward_char; |
|
199 map[Control ('g')].function = info_abort_key; |
|
200 map[Control ('h')].function = info_get_help_window; |
|
201 map[Control ('l')].function = info_redraw_display; |
|
202 map[Control ('n')].function = info_next_line; |
|
203 map[Control ('p')].function = info_prev_line; |
|
204 map[Control ('r')].function = isearch_backward; |
|
205 map[Control ('s')].function = isearch_forward; |
|
206 map[Control ('u')].function = info_universal_argument; |
|
207 map[Control ('v')].function = info_scroll_forward; |
|
208 map[','].function = info_next_index_match; |
|
209 |
|
210 for (i = '1'; i < '9' + 1; i++) |
|
211 map[i].function = info_menu_digit; |
|
212 map['0'].function = info_last_menu_item; |
|
213 |
|
214 map['<'].function = info_first_node; |
|
215 map['>'].function = info_last_node; |
|
216 map['?'].function = info_get_help_window; |
|
217 map['['].function = info_global_prev_node; |
|
218 map[']'].function = info_global_next_node; |
|
219 |
|
220 map['b'].function = info_beginning_of_node; |
|
221 map['d'].function = info_dir_node; |
|
222 map['e'].function = info_end_of_node; |
|
223 map['f'].function = info_xref_item; |
|
224 map['g'].function = info_goto_node; |
|
225 map['h'].function = info_get_info_help_node; |
|
226 map['i'].function = info_index_search; |
|
227 map['l'].function = info_history_node; |
|
228 map['m'].function = info_menu_item; |
|
229 map['n'].function = info_next_node; |
|
230 map['p'].function = info_prev_node; |
|
231 map['q'].function = info_quit; |
|
232 map['r'].function = info_xref_item; |
|
233 map['s'].function = info_search; |
|
234 map['t'].function = info_top_node; |
|
235 map['u'].function = info_up_node; |
|
236 map[DEL].function = info_scroll_backward; |
|
237 |
|
238 /* Bind members in the ESC map for Info windows. */ |
|
239 map = (Keymap)info_keymap[ESC].function; |
|
240 map[Control ('f')].function = info_show_footnotes; |
|
241 map[Control ('g')].function = info_abort_key; |
|
242 map[TAB].function = info_move_to_prev_xref; |
|
243 map[Control ('v')].function = info_scroll_other_window; |
|
244 map['<'].function = info_beginning_of_node; |
|
245 map['>'].function = info_end_of_node; |
|
246 map['b'].function = info_backward_word; |
|
247 map['f'].function = info_forward_word; |
|
248 map['r'].function = info_move_to_window_line; |
|
249 map['v'].function = info_scroll_backward; |
|
250 #if defined (NAMED_FUNCTIONS) |
|
251 map['x'].function = info_execute_command; |
|
252 #endif /* NAMED_FUNCTIONS */ |
|
253 |
|
254 /* Bind members in the Control-X map for Info windows. */ |
|
255 map = (Keymap)info_keymap[Control ('x')].function; |
|
256 |
|
257 map[Control ('b')].function = list_visited_nodes; |
|
258 map[Control ('c')].function = info_quit; |
|
259 map[Control ('f')].function = info_view_file; |
|
260 map[Control ('g')].function = info_abort_key; |
|
261 map[Control ('v')].function = info_view_file; |
|
262 map['0'].function = info_delete_window; |
|
263 map['1'].function = info_keep_one_window; |
|
264 map['2'].function = info_split_window; |
|
265 map['^'].function = info_grow_window; |
|
266 map['b'].function = select_visited_node; |
|
267 map['k'].function = info_kill_node; |
|
268 map['o'].function = info_next_window; |
|
269 map['t'].function = info_tile_windows; |
|
270 map['w'].function = info_toggle_wrap; |
|
271 } |
|
272 |
|
273 |