Mercurial > emacs
annotate src/keyboard.c @ 1609:5beb9d2bc959
* bytecomp.el: Declare unread-command-char an obsolete variable.
* vip.el (vip-escape-to-emacs, vip-prefix-arg-value,
vip-prefix-arg-com): Use unread-command-event instead of
unread-command-char; respect its new semantics.
* electric.el (Electric-command-loop): Same.
author | Jim Blandy <jimb@redhat.com> |
---|---|
date | Mon, 16 Nov 1992 01:31:33 +0000 |
parents | 11cd7c23f538 |
children | fe6f6e55182f |
rev | line source |
---|---|
518 | 1 /* Keyboard and mouse input; editor command loop. |
586 | 2 Copyright (C) 1985, 1986, 1987, 1988, 1989, 1992 Free Software Foundation, Inc. |
518 | 3 |
4 This file is part of GNU Emacs. | |
5 | |
6 GNU Emacs is free software; you can redistribute it and/or modify | |
7 it under the terms of the GNU General Public License as published by | |
8 the Free Software Foundation; either version 1, or (at your option) | |
9 any later version. | |
10 | |
11 GNU Emacs is distributed in the hope that it will be useful, | |
12 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 GNU General Public License for more details. | |
15 | |
16 You should have received a copy of the GNU General Public License | |
17 along with GNU Emacs; see the file COPYING. If not, write to | |
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
19 | |
20 /* Allow config.h to undefine symbols found here. */ | |
21 #include <signal.h> | |
22 | |
23 #include "config.h" | |
24 #include <stdio.h> | |
25 #undef NULL | |
26 #include "termchar.h" | |
27 #include "termopts.h" | |
28 #include "lisp.h" | |
29 #include "termhooks.h" | |
30 #include "macros.h" | |
765 | 31 #include "frame.h" |
518 | 32 #include "window.h" |
33 #include "commands.h" | |
34 #include "buffer.h" | |
35 #include "disptab.h" | |
1515
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
36 #include "dispextern.h" |
518 | 37 #include "keyboard.h" |
38 #include <setjmp.h> | |
39 #include <errno.h> | |
40 | |
562 | 41 #ifndef VMS |
42 #include <sys/ioctl.h> | |
43 #endif | |
44 | |
45 #include "syssignal.h" | |
1046
d4b1e5db2b2a
* keyboard.c: Include "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1008
diff
changeset
|
46 #include "systty.h" |
648 | 47 #include "systime.h" |
518 | 48 |
49 extern int errno; | |
50 | |
51 #ifdef HAVE_X_WINDOWS | |
52 extern Lisp_Object Vmouse_grabbed; | |
53 | |
54 /* Make all keyboard buffers much bigger when using X windows. */ | |
55 #define KBD_BUFFER_SIZE 4096 | |
56 #else /* No X-windows, character input */ | |
57 #define KBD_BUFFER_SIZE 256 | |
58 #endif /* No X-windows */ | |
59 | |
60 /* Following definition copied from eval.c */ | |
61 | |
62 struct backtrace | |
63 { | |
64 struct backtrace *next; | |
65 Lisp_Object *function; | |
66 Lisp_Object *args; /* Points to vector of args. */ | |
67 int nargs; /* length of vector. If nargs is UNEVALLED, | |
68 args points to slot holding list of | |
69 unevalled args */ | |
70 char evalargs; | |
71 }; | |
72 | |
73 /* Non-nil disable property on a command means | |
74 do not execute it; call disabled-command-hook's value instead. */ | |
75 Lisp_Object Qdisabled, Vdisabled_command_hook; | |
76 | |
77 #define NUM_RECENT_KEYS (100) | |
78 int recent_keys_index; /* Index for storing next element into recent_keys */ | |
79 int total_keys; /* Total number of elements stored into recent_keys */ | |
1261
60b30565326c
* keyboard.c (recent_keys): Turn this from an array, which is a
Jim Blandy <jimb@redhat.com>
parents:
1239
diff
changeset
|
80 Lisp_Object recent_keys; /* A vector, holding the last 100 keystrokes */ |
518 | 81 |
1439
b3b2d1181d3a
* keyboard.c (this_command_keys): Make this a vector, instead of
Jim Blandy <jimb@redhat.com>
parents:
1404
diff
changeset
|
82 /* Vector holding the key sequence that invoked the current command. |
b3b2d1181d3a
* keyboard.c (this_command_keys): Make this a vector, instead of
Jim Blandy <jimb@redhat.com>
parents:
1404
diff
changeset
|
83 It is reused for each command, and it may be longer than the current |
b3b2d1181d3a
* keyboard.c (this_command_keys): Make this a vector, instead of
Jim Blandy <jimb@redhat.com>
parents:
1404
diff
changeset
|
84 sequence; this_command_key_count indicates how many elements |
b3b2d1181d3a
* keyboard.c (this_command_keys): Make this a vector, instead of
Jim Blandy <jimb@redhat.com>
parents:
1404
diff
changeset
|
85 actually mean something. |
b3b2d1181d3a
* keyboard.c (this_command_keys): Make this a vector, instead of
Jim Blandy <jimb@redhat.com>
parents:
1404
diff
changeset
|
86 It's easier to staticpro a single Lisp_Object than an array. */ |
b3b2d1181d3a
* keyboard.c (this_command_keys): Make this a vector, instead of
Jim Blandy <jimb@redhat.com>
parents:
1404
diff
changeset
|
87 Lisp_Object this_command_keys; |
b3b2d1181d3a
* keyboard.c (this_command_keys): Make this a vector, instead of
Jim Blandy <jimb@redhat.com>
parents:
1404
diff
changeset
|
88 int this_command_key_count; |
518 | 89 |
90 extern int minbuf_level; | |
91 | |
92 extern struct backtrace *backtrace_list; | |
93 | |
94 /* Nonzero means do menu prompting. */ | |
95 static int menu_prompting; | |
96 | |
97 /* Character to see next line of menu prompt. */ | |
98 static Lisp_Object menu_prompt_more_char; | |
99 | |
100 /* For longjmp to where kbd input is being done. */ | |
101 static jmp_buf getcjmp; | |
102 | |
103 /* True while doing kbd input. */ | |
104 int waiting_for_input; | |
105 | |
106 /* True while displaying for echoing. Delays C-g throwing. */ | |
107 static int echoing; | |
108 | |
109 /* Nonzero means C-G should cause immediate error-signal. */ | |
110 int immediate_quit; | |
111 | |
112 /* Character to recognize as the help char. */ | |
113 Lisp_Object help_char; | |
114 | |
115 /* Form to execute when help char is typed. */ | |
116 Lisp_Object Vhelp_form; | |
117 | |
118 /* Character that causes a quit. Normally C-g. | |
119 | |
120 If we are running on an ordinary terminal, this must be an ordinary | |
121 ASCII char, since we want to make it our interrupt character. | |
122 | |
123 If we are not running on an ordinary terminal, it still needs to be | |
124 an ordinary ASCII char. This character needs to be recognized in | |
125 the input interrupt handler. At this point, the keystroke is | |
126 represented as a struct input_event, while the desired quit | |
127 character is specified as a lispy event. The mapping from struct | |
128 input_events to lispy events cannot run in an interrupt handler, | |
129 and the reverse mapping is difficult for anything but ASCII | |
130 keystrokes. | |
131 | |
132 FOR THESE ELABORATE AND UNSATISFYING REASONS, quit_char must be an | |
133 ASCII character. */ | |
134 int quit_char; | |
135 | |
136 extern Lisp_Object current_global_map; | |
137 extern int minibuf_level; | |
138 | |
139 /* Current depth in recursive edits. */ | |
140 int command_loop_level; | |
141 | |
142 /* Total number of times command_loop has read a key sequence. */ | |
143 int num_input_keys; | |
144 | |
145 /* Last input character read as a command. */ | |
146 Lisp_Object last_command_char; | |
147 | |
1083
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
148 /* Last input character read as a command, not counting menus |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
149 reached by the mouse. */ |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
150 Lisp_Object last_nonmenu_event; |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
151 |
518 | 152 /* Last input character read for any purpose. */ |
153 Lisp_Object last_input_char; | |
154 | |
155 /* If not Qnil, an object to be read as the next command input. */ | |
1590
11cd7c23f538
* keyboard.c (unread_switch_frame): Don't declare this static.
Jim Blandy <jimb@redhat.com>
parents:
1565
diff
changeset
|
156 Lisp_Object unread_command_event; |
518 | 157 |
1386
5845050f9d5c
* keyboard.c (Vlast_event_frame): Make this variable exist even
Jim Blandy <jimb@redhat.com>
parents:
1328
diff
changeset
|
158 /* If not Qnil, this is a switch-frame event which we decided to put |
5845050f9d5c
* keyboard.c (Vlast_event_frame): Make this variable exist even
Jim Blandy <jimb@redhat.com>
parents:
1328
diff
changeset
|
159 off until the end of a key sequence. This should be read as the |
1590
11cd7c23f538
* keyboard.c (unread_switch_frame): Don't declare this static.
Jim Blandy <jimb@redhat.com>
parents:
1565
diff
changeset
|
160 next command input, after any unread_command_event. |
11cd7c23f538
* keyboard.c (unread_switch_frame): Don't declare this static.
Jim Blandy <jimb@redhat.com>
parents:
1565
diff
changeset
|
161 |
11cd7c23f538
* keyboard.c (unread_switch_frame): Don't declare this static.
Jim Blandy <jimb@redhat.com>
parents:
1565
diff
changeset
|
162 read_key_sequence uses this to delay switch-frame events until the |
11cd7c23f538
* keyboard.c (unread_switch_frame): Don't declare this static.
Jim Blandy <jimb@redhat.com>
parents:
1565
diff
changeset
|
163 end of the key sequence; Fread_char uses it to put off switch-frame |
11cd7c23f538
* keyboard.c (unread_switch_frame): Don't declare this static.
Jim Blandy <jimb@redhat.com>
parents:
1565
diff
changeset
|
164 events until a non-ASCII event is acceptable as input. */ |
11cd7c23f538
* keyboard.c (unread_switch_frame): Don't declare this static.
Jim Blandy <jimb@redhat.com>
parents:
1565
diff
changeset
|
165 Lisp_Object unread_switch_frame; |
1386
5845050f9d5c
* keyboard.c (Vlast_event_frame): Make this variable exist even
Jim Blandy <jimb@redhat.com>
parents:
1328
diff
changeset
|
166 |
518 | 167 /* Char to use as prefix when a meta character is typed in. |
168 This is bound on entry to minibuffer in case ESC is changed there. */ | |
169 | |
170 Lisp_Object meta_prefix_char; | |
171 | |
172 /* Last size recorded for a current buffer which is not a minibuffer. */ | |
173 static int last_non_minibuf_size; | |
174 | |
687
e2b747dd6a6e
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
682
diff
changeset
|
175 /* Number of idle seconds before an auto-save and garbage collection. */ |
518 | 176 static Lisp_Object Vauto_save_timeout; |
177 | |
178 /* Total number of times read_char has returned. */ | |
179 int num_input_chars; | |
180 | |
1104
f3a7122a68e1
(num_nonmacro_input_chars): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
1097
diff
changeset
|
181 /* Total number of times read_char has returned, outside of macros. */ |
f3a7122a68e1
(num_nonmacro_input_chars): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
1097
diff
changeset
|
182 int num_nonmacro_input_chars; |
f3a7122a68e1
(num_nonmacro_input_chars): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
1097
diff
changeset
|
183 |
518 | 184 /* Auto-save automatically when this many characters have been typed |
185 since the last time. */ | |
186 | |
187 static int auto_save_interval; | |
188 | |
1104
f3a7122a68e1
(num_nonmacro_input_chars): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
1097
diff
changeset
|
189 /* Value of num_nonmacro_input_chars as of last auto save. */ |
518 | 190 |
191 int last_auto_save; | |
192 | |
193 /* Last command executed by the editor command loop, not counting | |
194 commands that set the prefix argument. */ | |
195 | |
196 Lisp_Object last_command; | |
197 | |
198 /* The command being executed by the command loop. | |
199 Commands may set this, and the value set will be copied into last_command | |
200 instead of the actual command. */ | |
201 Lisp_Object this_command; | |
202 | |
1565
a681f63f93fa
* keyboard.c (read_key_sequence): Removed the
Jim Blandy <jimb@redhat.com>
parents:
1515
diff
changeset
|
203 #ifdef MULTI_FRAME |
1239
52afa4976154
* keyboard.c (read_char): If we're returning an event from a
Jim Blandy <jimb@redhat.com>
parents:
1140
diff
changeset
|
204 /* The frame in which the last input event occurred, or Qmacro if the |
1590
11cd7c23f538
* keyboard.c (unread_switch_frame): Don't declare this static.
Jim Blandy <jimb@redhat.com>
parents:
1565
diff
changeset
|
205 last event came from a macro. */ |
765 | 206 Lisp_Object Vlast_event_frame; |
1565
a681f63f93fa
* keyboard.c (read_key_sequence): Removed the
Jim Blandy <jimb@redhat.com>
parents:
1515
diff
changeset
|
207 #endif |
518 | 208 |
708 | 209 /* The timestamp of the last input event we received from the X server. |
210 X Windows wants this for selection ownership. */ | |
518 | 211 unsigned long last_event_timestamp; |
212 | |
213 Lisp_Object Qself_insert_command; | |
214 Lisp_Object Qforward_char; | |
215 Lisp_Object Qbackward_char; | |
216 | |
217 /* read_key_sequence stores here the command definition of the | |
218 key sequence that it reads. */ | |
219 Lisp_Object read_key_sequence_cmd; | |
220 | |
221 /* Form to evaluate (if non-nil) when Emacs is started. */ | |
222 Lisp_Object Vtop_level; | |
223 | |
224 /* User-supplied string to translate input characters through. */ | |
225 Lisp_Object Vkeyboard_translate_table; | |
226 | |
227 /* Keymap mapping ASCII function key sequences onto their preferred forms. */ | |
228 extern Lisp_Object Vfunction_key_map; | |
229 | |
230 /* File in which we write all commands we read. */ | |
231 FILE *dribble; | |
232 | |
233 /* Nonzero if input is available. */ | |
234 int input_pending; | |
235 | |
236 /* Nonzero if should obey 0200 bit in input chars as "Meta". */ | |
237 int meta_key; | |
238 | |
239 extern char *pending_malloc_warning; | |
240 | |
241 /* Circular buffer for pre-read keyboard input. */ | |
242 static struct input_event kbd_buffer[KBD_BUFFER_SIZE]; | |
243 | |
244 /* Pointer to next available character in kbd_buffer. | |
245 If kbd_fetch_ptr == kbd_store_ptr, the buffer is empty. | |
246 This may be kbd_buffer + KBD_BUFFER_SIZE, meaning that the the | |
247 next available char is in kbd_buffer[0]. */ | |
248 static struct input_event *kbd_fetch_ptr; | |
249 | |
250 /* Pointer to next place to store character in kbd_buffer. This | |
251 may be kbd_buffer + KBD_BUFFER_SIZE, meaning that the next | |
252 character should go in kbd_buffer[0]. */ | |
253 static struct input_event *kbd_store_ptr; | |
254 | |
255 /* The above pair of variables forms a "queue empty" flag. When we | |
256 enqueue a non-hook event, we increment kbd_write_count. When we | |
257 dequeue a non-hook event, we increment kbd_read_count. We say that | |
258 there is input available iff the two counters are equal. | |
259 | |
260 Why not just have a flag set and cleared by the enqueuing and | |
261 dequeuing functions? Such a flag could be screwed up by interrupts | |
262 at inopportune times. */ | |
263 | |
264 /* If this flag is non-zero, mouse movement events will appear in the | |
265 input stream. If is zero, mouse movement will be ignored. */ | |
266 int do_mouse_tracking; | |
267 | |
268 /* The window system handling code should set this if the mouse has | |
269 moved since the last call to the mouse_position_hook. Calling that | |
270 hook should clear this. Code assumes that if this is set, it can | |
271 call mouse_position_hook to get the promised position, so don't set | |
272 it unless you're prepared to substantiate the claim! */ | |
273 int mouse_moved; | |
274 | |
275 /* True iff there is an event in kbd_buffer, or if mouse tracking is | |
276 enabled and there is a new mouse position in the mouse movement | |
277 buffer. Note that if this is false, that doesn't mean that there | |
278 is readable input; all the events in the queue might be button-up | |
279 events, and do_mouse_tracking might be off. */ | |
280 #define EVENT_QUEUES_EMPTY \ | |
281 ((kbd_fetch_ptr == kbd_store_ptr) && (!do_mouse_tracking || !mouse_moved)) | |
282 | |
283 | |
284 /* Symbols to head events. */ | |
285 Lisp_Object Qmouse_movement; | |
286 | |
287 Lisp_Object Qvscrollbar_part; | |
288 Lisp_Object Qvslider_part; | |
289 Lisp_Object Qvthumbup_part; | |
290 Lisp_Object Qvthumbdown_part; | |
291 | |
292 Lisp_Object Qhscrollbar_part; | |
293 Lisp_Object Qhslider_part; | |
294 Lisp_Object Qhthumbleft_part; | |
295 Lisp_Object Qhthumbright_part; | |
296 | |
1386
5845050f9d5c
* keyboard.c (Vlast_event_frame): Make this variable exist even
Jim Blandy <jimb@redhat.com>
parents:
1328
diff
changeset
|
297 Lisp_Object Qswitch_frame; |
5845050f9d5c
* keyboard.c (Vlast_event_frame): Make this variable exist even
Jim Blandy <jimb@redhat.com>
parents:
1328
diff
changeset
|
298 |
518 | 299 /* Symbols to denote kinds of events. */ |
300 Lisp_Object Qfunction_key; | |
301 Lisp_Object Qmouse_click; | |
302 /* Lisp_Object Qmouse_movement; - also an event header */ | |
303 Lisp_Object Qscrollbar_click; | |
304 | |
305 /* Properties of event headers. */ | |
306 Lisp_Object Qevent_kind; | |
1310
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
307 Lisp_Object Qevent_symbol_elements; |
518 | 308 |
1328
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
309 /* An event header symbol HEAD may have a property named |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
310 Qevent_symbol_element_mask, which is of the form (BASE MODIFIERS); |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
311 BASE is the base, unmodified version of HEAD, and MODIFIERS is the |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
312 mask of modifiers applied to it. If present, this is used to help |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
313 speed up parse_modifiers. */ |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
314 Lisp_Object Qevent_symbol_element_mask; |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
315 |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
316 /* An unmodified event header BASE may have a property named |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
317 Qmodifier_cache, which is an alist mapping modifier masks onto |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
318 modified versions of BASE. If present, this helps speed up |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
319 apply_modifiers. */ |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
320 Lisp_Object Qmodifier_cache; |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
321 |
518 | 322 /* Symbols to use for non-text mouse positions. */ |
323 Lisp_Object Qmode_line; | |
732 | 324 Lisp_Object Qvertical_line; |
518 | 325 |
1515
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
326 Lisp_Object recursive_edit_unwind (), command_loop (); |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
327 Lisp_Object Fthis_command_keys (); |
518 | 328 |
648 | 329 /* Address (if not 0) of EMACS_TIME to zero out if a SIGIO interrupt |
330 happens. */ | |
331 EMACS_TIME *input_available_clear_time; | |
518 | 332 |
333 /* Nonzero means use SIGIO interrupts; zero means use CBREAK mode. | |
334 Default is 1 if INTERRUPT_INPUT is defined. */ | |
335 int interrupt_input; | |
336 | |
337 /* Nonzero while interrupts are temporarily deferred during redisplay. */ | |
338 int interrupts_deferred; | |
339 | |
340 /* nonzero means use ^S/^Q for flow control. */ | |
341 int flow_control; | |
342 | |
343 /* Allow m- file to inhibit use of FIONREAD. */ | |
344 #ifdef BROKEN_FIONREAD | |
345 #undef FIONREAD | |
346 #endif | |
347 | |
348 /* We are unable to use interrupts if FIONREAD is not available, | |
349 so flush SIGIO so we won't try. */ | |
350 #ifndef FIONREAD | |
351 #ifdef SIGIO | |
352 #undef SIGIO | |
353 #endif | |
354 #endif | |
355 | |
356 /* If we support X Windows, and won't get an interrupt when input | |
357 arrives from the server, poll periodically so we can detect C-g. */ | |
358 #ifdef HAVE_X_WINDOWS | |
359 #ifndef SIGIO | |
360 #define POLL_FOR_INPUT | |
361 #endif | |
362 #endif | |
363 | |
364 /* Global variable declarations. */ | |
365 | |
366 /* Function for init_keyboard to call with no args (if nonzero). */ | |
367 void (*keyboard_init_hook) (); | |
368 | |
369 static int read_avail_input (); | |
370 static void get_input_pending (); | |
371 | |
372 /* > 0 if we are to echo keystrokes. */ | |
373 static int echo_keystrokes; | |
374 | |
375 /* Nonzero means echo each character as typed. */ | |
376 static int immediate_echo; | |
377 | |
378 /* The text we're echoing in the modeline - partial key sequences, | |
1515
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
379 usually. '\0'-terminated. This really shouldn't have a fixed size. */ |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
380 static char echobuf[300]; |
518 | 381 |
382 /* Where to append more text to echobuf if we want to. */ | |
383 static char *echoptr; | |
384 | |
385 #define min(a,b) ((a)<(b)?(a):(b)) | |
386 #define max(a,b) ((a)>(b)?(a):(b)) | |
387 | |
388 /* Install the string STR as the beginning of the string of echoing, | |
389 so that it serves as a prompt for the next character. | |
390 Also start echoing. */ | |
391 | |
392 echo_prompt (str) | |
393 char *str; | |
394 { | |
395 int len = strlen (str); | |
396 if (len > sizeof echobuf - 4) | |
397 len = sizeof echobuf - 4; | |
1328
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
398 bcopy (str, echobuf, len); |
518 | 399 echoptr = echobuf + len; |
1328
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
400 *echoptr = '\0'; |
518 | 401 |
402 echo (); | |
403 } | |
404 | |
405 /* Add C to the echo string, if echoing is going on. | |
406 C can be a character, which is printed prettily ("M-C-x" and all that | |
407 jazz), or a symbol, whose name is printed. */ | |
408 | |
409 echo_char (c) | |
410 Lisp_Object c; | |
411 { | |
412 extern char *push_key_description (); | |
413 | |
414 if (immediate_echo) | |
415 { | |
416 char *ptr = echoptr; | |
417 | |
418 if (ptr != echobuf) | |
419 *ptr++ = ' '; | |
420 | |
421 /* If someone has passed us a composite event, use its head symbol. */ | |
1310
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
422 c = EVENT_HEAD (c); |
518 | 423 |
424 if (XTYPE (c) == Lisp_Int) | |
425 { | |
426 if (ptr - echobuf > sizeof echobuf - 6) | |
427 return; | |
428 | |
429 ptr = push_key_description (c, ptr); | |
430 } | |
431 else if (XTYPE (c) == Lisp_Symbol) | |
432 { | |
433 struct Lisp_String *name = XSYMBOL (c)->name; | |
434 if (((ptr - echobuf) + name->size + 4) > sizeof echobuf) | |
435 return; | |
436 bcopy (name->data, ptr, name->size); | |
437 ptr += name->size; | |
438 } | |
439 | |
1515
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
440 if (echoptr == echobuf && EQ (c, help_char)) |
518 | 441 { |
442 strcpy (ptr, " (Type ? for further options)"); | |
443 ptr += strlen (ptr); | |
444 } | |
445 | |
446 *ptr = 0; | |
447 echoptr = ptr; | |
448 | |
449 echo (); | |
450 } | |
451 } | |
452 | |
453 /* Temporarily add a dash to the end of the echo string if it's not | |
454 empty, so that it serves as a mini-prompt for the very next character. */ | |
455 | |
456 echo_dash () | |
457 { | |
458 if (!immediate_echo && echoptr == echobuf) | |
459 return; | |
460 | |
461 /* Put a dash at the end of the buffer temporarily, | |
462 but make it go away when the next character is added. */ | |
463 echoptr[0] = '-'; | |
464 echoptr[1] = 0; | |
465 | |
466 echo (); | |
467 } | |
468 | |
469 /* Display the current echo string, and begin echoing if not already | |
470 doing so. */ | |
471 | |
472 echo () | |
473 { | |
474 if (!immediate_echo) | |
475 { | |
476 int i; | |
477 immediate_echo = 1; | |
478 | |
479 for (i = 0; i < this_command_key_count; i++) | |
1439
b3b2d1181d3a
* keyboard.c (this_command_keys): Make this a vector, instead of
Jim Blandy <jimb@redhat.com>
parents:
1404
diff
changeset
|
480 echo_char (XVECTOR (this_command_keys)->contents[i]); |
518 | 481 echo_dash (); |
482 } | |
483 | |
484 echoing = 1; | |
485 message1 (echobuf); | |
486 echoing = 0; | |
487 | |
488 if (waiting_for_input && !NILP (Vquit_flag)) | |
489 quit_throw_to_read_char (); | |
490 } | |
491 | |
492 /* Turn off echoing, for the start of a new command. */ | |
493 | |
494 cancel_echoing () | |
495 { | |
496 immediate_echo = 0; | |
497 echoptr = echobuf; | |
498 } | |
499 | |
500 /* Return the length of the current echo string. */ | |
501 | |
502 static int | |
503 echo_length () | |
504 { | |
505 return echoptr - echobuf; | |
506 } | |
507 | |
508 /* Truncate the current echo message to its first LEN chars. | |
509 This and echo_char get used by read_key_sequence when the user | |
765 | 510 switches frames while entering a key sequence. */ |
518 | 511 |
512 static void | |
513 echo_truncate (len) | |
514 int len; | |
515 { | |
516 echobuf[len] = '\0'; | |
1328
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
517 echoptr = echobuf + len; |
518 | 518 } |
519 | |
520 | |
521 /* Functions for manipulating this_command_keys. */ | |
522 static void | |
523 add_command_key (key) | |
524 Lisp_Object key; | |
525 { | |
1439
b3b2d1181d3a
* keyboard.c (this_command_keys): Make this a vector, instead of
Jim Blandy <jimb@redhat.com>
parents:
1404
diff
changeset
|
526 int size = XVECTOR (this_command_keys)->size; |
b3b2d1181d3a
* keyboard.c (this_command_keys): Make this a vector, instead of
Jim Blandy <jimb@redhat.com>
parents:
1404
diff
changeset
|
527 |
b3b2d1181d3a
* keyboard.c (this_command_keys): Make this a vector, instead of
Jim Blandy <jimb@redhat.com>
parents:
1404
diff
changeset
|
528 if (this_command_key_count >= size) |
518 | 529 { |
1439
b3b2d1181d3a
* keyboard.c (this_command_keys): Make this a vector, instead of
Jim Blandy <jimb@redhat.com>
parents:
1404
diff
changeset
|
530 Lisp_Object new_keys = Fmake_vector (make_number (size * 2), Qnil); |
b3b2d1181d3a
* keyboard.c (this_command_keys): Make this a vector, instead of
Jim Blandy <jimb@redhat.com>
parents:
1404
diff
changeset
|
531 |
b3b2d1181d3a
* keyboard.c (this_command_keys): Make this a vector, instead of
Jim Blandy <jimb@redhat.com>
parents:
1404
diff
changeset
|
532 bcopy (XVECTOR (this_command_keys)->contents, |
b3b2d1181d3a
* keyboard.c (this_command_keys): Make this a vector, instead of
Jim Blandy <jimb@redhat.com>
parents:
1404
diff
changeset
|
533 XVECTOR (new_keys)->contents, |
1590
11cd7c23f538
* keyboard.c (unread_switch_frame): Don't declare this static.
Jim Blandy <jimb@redhat.com>
parents:
1565
diff
changeset
|
534 size * sizeof (Lisp_Object)); |
1439
b3b2d1181d3a
* keyboard.c (this_command_keys): Make this a vector, instead of
Jim Blandy <jimb@redhat.com>
parents:
1404
diff
changeset
|
535 |
b3b2d1181d3a
* keyboard.c (this_command_keys): Make this a vector, instead of
Jim Blandy <jimb@redhat.com>
parents:
1404
diff
changeset
|
536 this_command_keys = new_keys; |
518 | 537 } |
1439
b3b2d1181d3a
* keyboard.c (this_command_keys): Make this a vector, instead of
Jim Blandy <jimb@redhat.com>
parents:
1404
diff
changeset
|
538 |
b3b2d1181d3a
* keyboard.c (this_command_keys): Make this a vector, instead of
Jim Blandy <jimb@redhat.com>
parents:
1404
diff
changeset
|
539 XVECTOR (this_command_keys)->contents[this_command_key_count++] = key; |
518 | 540 } |
541 | |
542 Lisp_Object | |
543 recursive_edit_1 () | |
544 { | |
545 int count = specpdl_ptr - specpdl; | |
546 Lisp_Object val; | |
547 | |
548 if (command_loop_level > 0) | |
549 { | |
550 specbind (Qstandard_output, Qt); | |
551 specbind (Qstandard_input, Qt); | |
552 } | |
553 | |
554 val = command_loop (); | |
555 if (EQ (val, Qt)) | |
556 Fsignal (Qquit, Qnil); | |
557 | |
558 unbind_to (count); | |
559 return Qnil; | |
560 } | |
561 | |
562 /* When an auto-save happens, record the "time", and don't do again soon. */ | |
563 record_auto_save () | |
564 { | |
1104
f3a7122a68e1
(num_nonmacro_input_chars): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
1097
diff
changeset
|
565 last_auto_save = num_nonmacro_input_chars; |
518 | 566 } |
567 | |
568 DEFUN ("recursive-edit", Frecursive_edit, Srecursive_edit, 0, 0, "", | |
569 "Invoke the editor command loop recursively.\n\ | |
570 To get out of the recursive edit, a command can do `(throw 'exit nil)';\n\ | |
571 that tells this function to return.\n\ | |
572 Alternately, `(throw 'exit t)' makes this function signal an error.\n\ | |
573 This function is called by the editor initialization to begin editing.") | |
574 () | |
575 { | |
576 int count = specpdl_ptr - specpdl; | |
577 Lisp_Object val; | |
578 | |
579 command_loop_level++; | |
580 update_mode_lines = 1; | |
581 | |
582 record_unwind_protect (recursive_edit_unwind, | |
583 (command_loop_level | |
584 && current_buffer != XBUFFER (XWINDOW (selected_window)->buffer)) | |
585 ? Fcurrent_buffer () | |
586 : Qnil); | |
587 recursive_edit_1 (); | |
588 return unbind_to (count, Qnil); | |
589 } | |
590 | |
591 Lisp_Object | |
592 recursive_edit_unwind (buffer) | |
593 Lisp_Object buffer; | |
594 { | |
595 if (!NILP (buffer)) | |
596 Fset_buffer (buffer); | |
597 | |
598 command_loop_level--; | |
599 update_mode_lines = 1; | |
600 return Qnil; | |
601 } | |
602 | |
603 Lisp_Object | |
604 cmd_error (data) | |
605 Lisp_Object data; | |
606 { | |
607 Lisp_Object errmsg, tail, errname, file_error; | |
608 Lisp_Object stream; | |
609 struct gcpro gcpro1; | |
610 int i; | |
611 | |
612 Vquit_flag = Qnil; | |
613 Vinhibit_quit = Qt; | |
614 Vstandard_output = Qt; | |
615 Vstandard_input = Qt; | |
616 Vexecuting_macro = Qnil; | |
617 echo_area_glyphs = 0; | |
618 | |
765 | 619 /* If the window system or terminal frame hasn't been initialized |
518 | 620 yet, or we're not interactive, it's best to dump this message out |
621 to stderr and exit. */ | |
765 | 622 if (! FRAME_MESSAGE_BUF (selected_frame) |
518 | 623 || noninteractive) |
624 stream = Qexternal_debugging_output; | |
625 else | |
626 { | |
627 Fdiscard_input (); | |
628 bitch_at_user (); | |
629 stream = Qt; | |
630 } | |
631 | |
632 errname = Fcar (data); | |
633 | |
634 if (EQ (errname, Qerror)) | |
635 { | |
636 data = Fcdr (data); | |
637 if (!CONSP (data)) data = Qnil; | |
638 errmsg = Fcar (data); | |
639 file_error = Qnil; | |
640 } | |
641 else | |
642 { | |
643 errmsg = Fget (errname, Qerror_message); | |
644 file_error = Fmemq (Qfile_error, | |
645 Fget (errname, Qerror_conditions)); | |
646 } | |
647 | |
648 /* Print an error message including the data items. | |
649 This is done by printing it into a scratch buffer | |
650 and then making a copy of the text in the buffer. */ | |
651 | |
652 if (!CONSP (data)) data = Qnil; | |
653 tail = Fcdr (data); | |
654 GCPRO1 (tail); | |
655 | |
656 /* For file-error, make error message by concatenating | |
657 all the data items. They are all strings. */ | |
658 if (!NILP (file_error) && !NILP (tail)) | |
659 errmsg = XCONS (tail)->car, tail = XCONS (tail)->cdr; | |
660 | |
661 if (XTYPE (errmsg) == Lisp_String) | |
662 Fprinc (errmsg, stream); | |
663 else | |
664 write_string_1 ("peculiar error", -1, stream); | |
665 | |
666 for (i = 0; CONSP (tail); tail = Fcdr (tail), i++) | |
667 { | |
668 write_string_1 (i ? ", " : ": ", 2, stream); | |
669 if (!NILP (file_error)) | |
670 Fprinc (Fcar (tail), stream); | |
671 else | |
672 Fprin1 (Fcar (tail), stream); | |
673 } | |
674 UNGCPRO; | |
675 | |
765 | 676 /* If the window system or terminal frame hasn't been initialized |
518 | 677 yet, or we're in -batch mode, this error should cause Emacs to exit. */ |
765 | 678 if (! FRAME_MESSAGE_BUF (selected_frame) |
518 | 679 || noninteractive) |
680 { | |
681 Fterpri (stream); | |
682 Fkill_emacs (make_number (-1)); | |
683 } | |
684 | |
685 Vquit_flag = Qnil; | |
686 | |
687 Vinhibit_quit = Qnil; | |
688 return make_number (0); | |
689 } | |
690 | |
691 Lisp_Object command_loop_1 (); | |
692 Lisp_Object command_loop_2 (); | |
693 Lisp_Object top_level_1 (); | |
694 | |
695 /* Entry to editor-command-loop. | |
696 This level has the catches for exiting/returning to editor command loop. | |
697 It returns nil to exit recursive edit, t to abort it. */ | |
698 | |
699 Lisp_Object | |
700 command_loop () | |
701 { | |
702 if (command_loop_level > 0 || minibuf_level > 0) | |
703 { | |
704 return internal_catch (Qexit, command_loop_2, Qnil); | |
705 } | |
706 else | |
707 while (1) | |
708 { | |
709 internal_catch (Qtop_level, top_level_1, Qnil); | |
710 internal_catch (Qtop_level, command_loop_2, Qnil); | |
711 | |
712 /* End of file in -batch run causes exit here. */ | |
713 if (noninteractive) | |
714 Fkill_emacs (Qt); | |
715 } | |
716 } | |
717 | |
718 /* Here we catch errors in execution of commands within the | |
719 editing loop, and reenter the editing loop. | |
720 When there is an error, cmd_error runs and returns a non-nil | |
721 value to us. A value of nil means that cmd_loop_1 itself | |
722 returned due to end of file (or end of kbd macro). */ | |
723 | |
724 Lisp_Object | |
725 command_loop_2 () | |
726 { | |
727 register Lisp_Object val; | |
728 | |
729 do | |
730 val = internal_condition_case (command_loop_1, Qerror, cmd_error); | |
731 while (!NILP (val)); | |
732 | |
733 return Qnil; | |
734 } | |
735 | |
736 Lisp_Object | |
737 top_level_2 () | |
738 { | |
739 return Feval (Vtop_level); | |
740 } | |
741 | |
742 Lisp_Object | |
743 top_level_1 () | |
744 { | |
745 /* On entry to the outer level, run the startup file */ | |
746 if (!NILP (Vtop_level)) | |
747 internal_condition_case (top_level_2, Qerror, cmd_error); | |
748 else if (!NILP (Vpurify_flag)) | |
749 message ("Bare impure Emacs (standard Lisp code not loaded)"); | |
750 else | |
751 message ("Bare Emacs (standard Lisp code not loaded)"); | |
752 return Qnil; | |
753 } | |
754 | |
755 DEFUN ("top-level", Ftop_level, Stop_level, 0, 0, "", | |
756 "Exit all recursive editing levels.") | |
757 () | |
758 { | |
759 Fthrow (Qtop_level, Qnil); | |
760 } | |
761 | |
762 DEFUN ("exit-recursive-edit", Fexit_recursive_edit, Sexit_recursive_edit, 0, 0, "", | |
763 "Exit from the innermost recursive edit or minibuffer.") | |
764 () | |
765 { | |
766 if (command_loop_level > 0 || minibuf_level > 0) | |
767 Fthrow (Qexit, Qnil); | |
768 | |
769 error ("No recursive edit is in progress"); | |
770 } | |
771 | |
772 DEFUN ("abort-recursive-edit", Fabort_recursive_edit, Sabort_recursive_edit, 0, 0, "", | |
773 "Abort the command that requested this recursive edit or minibuffer input.") | |
774 () | |
775 { | |
776 if (command_loop_level > 0 || minibuf_level > 0) | |
777 Fthrow (Qexit, Qt); | |
778 | |
779 error ("No recursive edit is in progress"); | |
780 } | |
781 | |
782 /* This is the actual command reading loop, | |
783 sans error-handling encapsulation. */ | |
784 | |
785 Lisp_Object Fcommand_execute (); | |
786 static int read_key_sequence (); | |
787 | |
788 Lisp_Object | |
789 command_loop_1 () | |
790 { | |
791 Lisp_Object cmd; | |
792 int lose; | |
793 int nonundocount; | |
794 Lisp_Object keybuf[30]; | |
795 int i; | |
796 int no_redisplay; | |
797 int no_direct; | |
798 | |
799 Vprefix_arg = Qnil; | |
800 waiting_for_input = 0; | |
801 cancel_echoing (); | |
802 | |
803 /* Don't clear out last_command at the beginning of a macro. */ | |
804 if (XTYPE (Vexecuting_macro) != Lisp_String) | |
805 last_command = Qt; | |
806 | |
807 nonundocount = 0; | |
808 no_redisplay = 0; | |
809 this_command_key_count = 0; | |
810 | |
811 while (1) | |
812 { | |
813 /* Install chars successfully executed in kbd macro. */ | |
814 | |
815 if (defining_kbd_macro && NILP (Vprefix_arg)) | |
816 finalize_kbd_macro_chars (); | |
817 | |
818 /* Make sure the current window's buffer is selected. */ | |
819 if (XBUFFER (XWINDOW (selected_window)->buffer) != current_buffer) | |
820 set_buffer_internal (XBUFFER (XWINDOW (selected_window)->buffer)); | |
821 | |
822 /* Display any malloc warning that just came out. Use while because | |
823 displaying one warning can cause another. */ | |
824 | |
825 while (pending_malloc_warning) | |
826 display_malloc_warning (); | |
827 | |
828 no_direct = 0; | |
829 | |
830 /* If minibuffer on and echo area in use, | |
831 wait 2 sec and redraw minibufer. */ | |
832 | |
833 if (minibuf_level && echo_area_glyphs) | |
834 { | |
1097
d9efc1c88574
(command_loop_1): Bind inhibit-quit to t when in Fsit_for.
Richard M. Stallman <rms@gnu.org>
parents:
1083
diff
changeset
|
835 /* Bind inhibit-quit to t so that C-g gets read in |
d9efc1c88574
(command_loop_1): Bind inhibit-quit to t when in Fsit_for.
Richard M. Stallman <rms@gnu.org>
parents:
1083
diff
changeset
|
836 rather than quitting back to the minibuffer. */ |
d9efc1c88574
(command_loop_1): Bind inhibit-quit to t when in Fsit_for.
Richard M. Stallman <rms@gnu.org>
parents:
1083
diff
changeset
|
837 int count = specpdl_ptr - specpdl; |
d9efc1c88574
(command_loop_1): Bind inhibit-quit to t when in Fsit_for.
Richard M. Stallman <rms@gnu.org>
parents:
1083
diff
changeset
|
838 specbind (Qinhibit_quit, Qt); |
518 | 839 Fsit_for (make_number (2), Qnil, Qnil); |
1097
d9efc1c88574
(command_loop_1): Bind inhibit-quit to t when in Fsit_for.
Richard M. Stallman <rms@gnu.org>
parents:
1083
diff
changeset
|
840 unbind_to (count); |
d9efc1c88574
(command_loop_1): Bind inhibit-quit to t when in Fsit_for.
Richard M. Stallman <rms@gnu.org>
parents:
1083
diff
changeset
|
841 |
518 | 842 echo_area_glyphs = 0; |
843 no_direct = 1; | |
844 if (!NILP (Vquit_flag)) | |
845 { | |
846 Vquit_flag = Qnil; | |
1590
11cd7c23f538
* keyboard.c (unread_switch_frame): Don't declare this static.
Jim Blandy <jimb@redhat.com>
parents:
1565
diff
changeset
|
847 unread_command_event = make_number (quit_char); |
518 | 848 } |
849 } | |
850 | |
851 #ifdef C_ALLOCA | |
852 alloca (0); /* Cause a garbage collection now */ | |
853 /* Since we can free the most stuff here. */ | |
854 #endif /* C_ALLOCA */ | |
855 | |
1590
11cd7c23f538
* keyboard.c (unread_switch_frame): Don't declare this static.
Jim Blandy <jimb@redhat.com>
parents:
1565
diff
changeset
|
856 #if 0 |
765 | 857 #ifdef MULTI_FRAME |
1590
11cd7c23f538
* keyboard.c (unread_switch_frame): Don't declare this static.
Jim Blandy <jimb@redhat.com>
parents:
1565
diff
changeset
|
858 /* Select the frame that the last event came from. Usually, |
11cd7c23f538
* keyboard.c (unread_switch_frame): Don't declare this static.
Jim Blandy <jimb@redhat.com>
parents:
1565
diff
changeset
|
859 switch-frame events will take care of this, but if some lisp |
11cd7c23f538
* keyboard.c (unread_switch_frame): Don't declare this static.
Jim Blandy <jimb@redhat.com>
parents:
1565
diff
changeset
|
860 code swallows a switch-frame event, we'll fix things up here. |
11cd7c23f538
* keyboard.c (unread_switch_frame): Don't declare this static.
Jim Blandy <jimb@redhat.com>
parents:
1565
diff
changeset
|
861 Is this a good idea? */ |
765 | 862 if (XTYPE (Vlast_event_frame) == Lisp_Frame |
863 && XFRAME (Vlast_event_frame) != selected_frame) | |
864 Fselect_frame (Vlast_event_frame, Qnil); | |
518 | 865 #endif |
1386
5845050f9d5c
* keyboard.c (Vlast_event_frame): Make this variable exist even
Jim Blandy <jimb@redhat.com>
parents:
1328
diff
changeset
|
866 #endif |
518 | 867 |
1590
11cd7c23f538
* keyboard.c (unread_switch_frame): Don't declare this static.
Jim Blandy <jimb@redhat.com>
parents:
1565
diff
changeset
|
868 /* Read next key sequence; i gets its length. */ |
11cd7c23f538
* keyboard.c (unread_switch_frame): Don't declare this static.
Jim Blandy <jimb@redhat.com>
parents:
1565
diff
changeset
|
869 i = read_key_sequence (keybuf, (sizeof keybuf / sizeof (keybuf[0])), 0); |
11cd7c23f538
* keyboard.c (unread_switch_frame): Don't declare this static.
Jim Blandy <jimb@redhat.com>
parents:
1565
diff
changeset
|
870 |
11cd7c23f538
* keyboard.c (unread_switch_frame): Don't declare this static.
Jim Blandy <jimb@redhat.com>
parents:
1565
diff
changeset
|
871 ++num_input_keys; |
11cd7c23f538
* keyboard.c (unread_switch_frame): Don't declare this static.
Jim Blandy <jimb@redhat.com>
parents:
1565
diff
changeset
|
872 |
518 | 873 /* Now we have read a key sequence of length I, |
874 or else I is 0 and we found end of file. */ | |
875 | |
876 if (i == 0) /* End of file -- happens only in */ | |
877 return Qnil; /* a kbd macro, at the end. */ | |
878 | |
879 last_command_char = keybuf[i - 1]; | |
880 | |
881 cmd = read_key_sequence_cmd; | |
882 if (!NILP (Vexecuting_macro)) | |
883 { | |
884 if (!NILP (Vquit_flag)) | |
885 { | |
886 Vexecuting_macro = Qt; | |
887 QUIT; /* Make some noise. */ | |
888 /* Will return since macro now empty. */ | |
889 } | |
890 } | |
891 | |
892 /* Do redisplay processing after this command except in special | |
893 cases identified below that set no_redisplay to 1. */ | |
894 no_redisplay = 0; | |
895 | |
896 /* Execute the command. */ | |
897 | |
898 if (NILP (cmd)) | |
899 { | |
900 /* nil means key is undefined. */ | |
901 bitch_at_user (); | |
902 defining_kbd_macro = 0; | |
903 update_mode_lines = 1; | |
904 Vprefix_arg = Qnil; | |
905 } | |
906 else | |
907 { | |
908 this_command = cmd; | |
909 if (NILP (Vprefix_arg) && ! no_direct) | |
910 { | |
911 /* Recognize some common commands in common situations and | |
912 do them directly. */ | |
913 if (EQ (cmd, Qforward_char) && point < ZV) | |
914 { | |
915 struct Lisp_Vector *dp | |
916 = window_display_table (XWINDOW (selected_window)); | |
917 lose = FETCH_CHAR (point); | |
918 SET_PT (point + 1); | |
919 if (((dp == 0 && lose >= 040 && lose < 0177) | |
920 || | |
921 (dp && (XTYPE (dp->contents[lose]) != Lisp_String | |
922 || XSTRING (dp->contents[lose])->size == sizeof (GLYPH)))) | |
923 && (XFASTINT (XWINDOW (selected_window)->last_modified) | |
924 >= MODIFF) | |
925 && (XFASTINT (XWINDOW (selected_window)->last_point) | |
926 == point - 1) | |
927 && !windows_or_buffers_changed | |
928 && EQ (current_buffer->selective_display, Qnil) | |
929 && !detect_input_pending () | |
930 && NILP (Vexecuting_macro)) | |
931 no_redisplay = direct_output_forward_char (1); | |
932 goto directly_done; | |
933 } | |
934 else if (EQ (cmd, Qbackward_char) && point > BEGV) | |
935 { | |
936 struct Lisp_Vector *dp | |
937 = window_display_table (XWINDOW (selected_window)); | |
938 SET_PT (point - 1); | |
939 lose = FETCH_CHAR (point); | |
940 if (((dp == 0 && lose >= 040 && lose < 0177) | |
941 || | |
942 (dp && (XTYPE (dp->contents[lose]) != Lisp_String | |
943 || XSTRING (dp->contents[lose])->size == sizeof (GLYPH)))) | |
944 && (XFASTINT (XWINDOW (selected_window)->last_modified) | |
945 >= MODIFF) | |
946 && (XFASTINT (XWINDOW (selected_window)->last_point) | |
947 == point + 1) | |
948 && !windows_or_buffers_changed | |
949 && EQ (current_buffer->selective_display, Qnil) | |
950 && !detect_input_pending () | |
951 && NILP (Vexecuting_macro)) | |
952 no_redisplay = direct_output_forward_char (-1); | |
953 goto directly_done; | |
954 } | |
955 else if (EQ (cmd, Qself_insert_command) | |
956 /* Try this optimization only on ascii keystrokes. */ | |
957 && XTYPE (last_command_char) == Lisp_Int) | |
958 { | |
959 unsigned char c = XINT (last_command_char); | |
960 | |
961 if (NILP (Vexecuting_macro) && | |
962 !EQ (minibuf_window, selected_window)) | |
963 { | |
964 if (!nonundocount || nonundocount >= 20) | |
965 { | |
966 Fundo_boundary (); | |
967 nonundocount = 0; | |
968 } | |
969 nonundocount++; | |
970 } | |
971 lose = (XFASTINT (XWINDOW (selected_window)->last_modified) | |
972 < MODIFF) | |
973 || (XFASTINT (XWINDOW (selected_window)->last_point) | |
974 != point) | |
975 || MODIFF <= current_buffer->save_modified | |
976 || windows_or_buffers_changed | |
977 || !EQ (current_buffer->selective_display, Qnil) | |
978 || detect_input_pending () | |
979 || !NILP (Vexecuting_macro); | |
980 if (internal_self_insert (c, 0)) | |
981 { | |
982 lose = 1; | |
983 nonundocount = 0; | |
984 } | |
985 if (!lose && | |
986 (point == ZV || FETCH_CHAR (point) == '\n')) | |
987 { | |
988 struct Lisp_Vector *dp | |
989 = window_display_table (XWINDOW (selected_window)); | |
990 | |
991 if (dp == 0 || XTYPE (dp->contents[c]) != Lisp_String) | |
992 no_redisplay = direct_output_for_insert (c); | |
993 else if (XSTRING (dp->contents[c])->size | |
994 == sizeof (GLYPH)) | |
995 no_redisplay = | |
996 direct_output_for_insert (*(GLYPH *)XSTRING (dp->contents[c])->data); | |
997 } | |
998 goto directly_done; | |
999 } | |
1000 } | |
1001 | |
1002 /* Here for a command that isn't executed directly */ | |
1003 | |
1004 nonundocount = 0; | |
1005 if (NILP (Vprefix_arg)) | |
1006 Fundo_boundary (); | |
1007 Fcommand_execute (cmd, Qnil); | |
1008 | |
1009 } | |
547 | 1010 directly_done: ; |
518 | 1011 |
1012 /* If there is a prefix argument, | |
1013 1) We don't want last_command to be ``universal-argument'' | |
1014 (that would be dumb), so don't set last_command, | |
1015 2) we want to leave echoing on so that the prefix will be | |
1016 echoed as part of this key sequence, so don't call | |
1017 cancel_echoing, and | |
1018 3) we want to leave this_command_key_count non-zero, so that | |
1019 read_char will realize that it is re-reading a character, and | |
1020 not echo it a second time. */ | |
1021 if (NILP (Vprefix_arg)) | |
1022 { | |
1023 last_command = this_command; | |
1024 cancel_echoing (); | |
1025 this_command_key_count = 0; | |
1026 } | |
1027 } | |
1028 } | |
1029 | |
1030 /* Number of seconds between polling for input. */ | |
1031 int polling_period; | |
1032 | |
1033 /* Nonzero means polling for input is temporarily suppresed. */ | |
1034 int poll_suppress_count; | |
1035 | |
1036 #ifdef POLL_FOR_INPUT | |
1037 int polling_for_input; | |
1038 | |
1039 /* Handle an alarm once each second and read pending input | |
1040 so as to handle a C-g if it comces in. */ | |
1041 | |
1042 SIGTYPE | |
1043 input_poll_signal () | |
1044 { | |
1045 #ifdef HAVE_X_WINDOWS | |
1046 extern int x_input_blocked; | |
1047 if (x_input_blocked == 0) | |
1048 #endif | |
1049 if (!waiting_for_input) | |
1050 read_avail_input (0); | |
1051 signal (SIGALRM, input_poll_signal); | |
1052 alarm (polling_period); | |
1053 } | |
1054 | |
1055 #endif | |
1056 | |
1057 /* Begin signals to poll for input, if they are appropriate. | |
1058 This function is called unconditionally from various places. */ | |
1059 | |
1060 start_polling () | |
1061 { | |
1062 #ifdef POLL_FOR_INPUT | |
1063 if (read_socket_hook) | |
1064 { | |
1065 poll_suppress_count--; | |
1066 if (poll_suppress_count == 0) | |
1067 { | |
1068 signal (SIGALRM, input_poll_signal); | |
1069 polling_for_input = 1; | |
1070 alarm (polling_period); | |
1071 } | |
1072 } | |
1073 #endif | |
1074 } | |
1075 | |
1076 /* Turn off polling. */ | |
1077 | |
1078 stop_polling () | |
1079 { | |
1080 #ifdef POLL_FOR_INPUT | |
1081 if (read_socket_hook) | |
1082 { | |
1083 if (poll_suppress_count == 0) | |
1084 { | |
1085 polling_for_input = 0; | |
1086 alarm (0); | |
1087 } | |
1088 poll_suppress_count++; | |
1089 } | |
1090 #endif | |
1091 } | |
1092 | |
1093 /* Input of single characters from keyboard */ | |
1094 | |
1095 Lisp_Object print_help (); | |
1096 static Lisp_Object kbd_buffer_get_event (); | |
1097 | |
1098 /* read a character from the keyboard; call the redisplay if needed */ | |
1099 /* commandflag 0 means do not do auto-saving, but do do redisplay. | |
1100 -1 means do not do redisplay, but do do autosaving. | |
1101 1 means do both. */ | |
1102 | |
1083
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
1103 /* The arguments MAPS and NMAPS are for menu prompting. |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
1104 MAPS is an array of keymaps; NMAPS is the length of MAPS. |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
1105 |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
1106 PREV_EVENT is the previous input event, or nil if we are reading |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
1107 the first event of a key sequence. |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
1108 |
1439
b3b2d1181d3a
* keyboard.c (this_command_keys): Make this a vector, instead of
Jim Blandy <jimb@redhat.com>
parents:
1404
diff
changeset
|
1109 If USED_MOUSE_MENU is non-zero, then we set *USED_MOUSE_MENU to 1 |
b3b2d1181d3a
* keyboard.c (this_command_keys): Make this a vector, instead of
Jim Blandy <jimb@redhat.com>
parents:
1404
diff
changeset
|
1110 if we used a mouse menu to read the input, or zero otherwise. If |
b3b2d1181d3a
* keyboard.c (this_command_keys): Make this a vector, instead of
Jim Blandy <jimb@redhat.com>
parents:
1404
diff
changeset
|
1111 USED_MOUSE_MENU is zero, *USED_MOUSE_MENU is left alone. */ |
1083
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
1112 |
518 | 1113 Lisp_Object |
1083
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
1114 read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu) |
518 | 1115 int commandflag; |
1083
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
1116 int nmaps; |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
1117 Lisp_Object *maps; |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
1118 Lisp_Object prev_event; |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
1119 int *used_mouse_menu; |
518 | 1120 { |
1121 register Lisp_Object c; | |
1122 int count; | |
1123 jmp_buf save_jump; | |
1124 | |
1590
11cd7c23f538
* keyboard.c (unread_switch_frame): Don't declare this static.
Jim Blandy <jimb@redhat.com>
parents:
1565
diff
changeset
|
1125 if (!NILP (unread_command_event)) |
518 | 1126 { |
1590
11cd7c23f538
* keyboard.c (unread_switch_frame): Don't declare this static.
Jim Blandy <jimb@redhat.com>
parents:
1565
diff
changeset
|
1127 c = unread_command_event; |
11cd7c23f538
* keyboard.c (unread_switch_frame): Don't declare this static.
Jim Blandy <jimb@redhat.com>
parents:
1565
diff
changeset
|
1128 unread_command_event = Qnil; |
518 | 1129 |
1130 if (this_command_key_count == 0) | |
1131 goto reread_first; | |
1132 else | |
1133 goto reread; | |
1134 } | |
1135 | |
1136 if (!NILP (Vexecuting_macro)) | |
1137 { | |
1565
a681f63f93fa
* keyboard.c (read_key_sequence): Removed the
Jim Blandy <jimb@redhat.com>
parents:
1515
diff
changeset
|
1138 #ifdef MULTI_FRAME |
1239
52afa4976154
* keyboard.c (read_char): If we're returning an event from a
Jim Blandy <jimb@redhat.com>
parents:
1140
diff
changeset
|
1139 /* We set this to Qmacro; since that's not a frame, nobody will |
52afa4976154
* keyboard.c (read_char): If we're returning an event from a
Jim Blandy <jimb@redhat.com>
parents:
1140
diff
changeset
|
1140 try to switch frames on us, and the selected window will |
52afa4976154
* keyboard.c (read_char): If we're returning an event from a
Jim Blandy <jimb@redhat.com>
parents:
1140
diff
changeset
|
1141 remain unchanged. |
52afa4976154
* keyboard.c (read_char): If we're returning an event from a
Jim Blandy <jimb@redhat.com>
parents:
1140
diff
changeset
|
1142 |
52afa4976154
* keyboard.c (read_char): If we're returning an event from a
Jim Blandy <jimb@redhat.com>
parents:
1140
diff
changeset
|
1143 Since this event came from a macro, it would be misleading to |
52afa4976154
* keyboard.c (read_char): If we're returning an event from a
Jim Blandy <jimb@redhat.com>
parents:
1140
diff
changeset
|
1144 leave Vlast_event_frame set to whereever the last real event |
52afa4976154
* keyboard.c (read_char): If we're returning an event from a
Jim Blandy <jimb@redhat.com>
parents:
1140
diff
changeset
|
1145 came from. Normally, command_loop_1 selects |
52afa4976154
* keyboard.c (read_char): If we're returning an event from a
Jim Blandy <jimb@redhat.com>
parents:
1140
diff
changeset
|
1146 Vlast_event_frame after each command is read, but events read |
52afa4976154
* keyboard.c (read_char): If we're returning an event from a
Jim Blandy <jimb@redhat.com>
parents:
1140
diff
changeset
|
1147 from a macro should never cause a new frame to be selected. */ |
52afa4976154
* keyboard.c (read_char): If we're returning an event from a
Jim Blandy <jimb@redhat.com>
parents:
1140
diff
changeset
|
1148 Vlast_event_frame = Qmacro; |
1565
a681f63f93fa
* keyboard.c (read_key_sequence): Removed the
Jim Blandy <jimb@redhat.com>
parents:
1515
diff
changeset
|
1149 #endif |
1239
52afa4976154
* keyboard.c (read_char): If we're returning an event from a
Jim Blandy <jimb@redhat.com>
parents:
1140
diff
changeset
|
1150 |
1515
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
1151 if (executing_macro_index >= XFASTINT (Flength (Vexecuting_macro))) |
518 | 1152 { |
1153 XSET (c, Lisp_Int, -1); | |
1154 return c; | |
1155 } | |
1156 | |
1157 c = Faref (Vexecuting_macro, make_number (executing_macro_index)); | |
1158 executing_macro_index++; | |
1159 | |
1160 goto from_macro; | |
1161 } | |
1162 | |
1386
5845050f9d5c
* keyboard.c (Vlast_event_frame): Make this variable exist even
Jim Blandy <jimb@redhat.com>
parents:
1328
diff
changeset
|
1163 if (!NILP (unread_switch_frame)) |
5845050f9d5c
* keyboard.c (Vlast_event_frame): Make this variable exist even
Jim Blandy <jimb@redhat.com>
parents:
1328
diff
changeset
|
1164 { |
5845050f9d5c
* keyboard.c (Vlast_event_frame): Make this variable exist even
Jim Blandy <jimb@redhat.com>
parents:
1328
diff
changeset
|
1165 c = unread_switch_frame; |
5845050f9d5c
* keyboard.c (Vlast_event_frame): Make this variable exist even
Jim Blandy <jimb@redhat.com>
parents:
1328
diff
changeset
|
1166 unread_switch_frame = Qnil; |
5845050f9d5c
* keyboard.c (Vlast_event_frame): Make this variable exist even
Jim Blandy <jimb@redhat.com>
parents:
1328
diff
changeset
|
1167 |
5845050f9d5c
* keyboard.c (Vlast_event_frame): Make this variable exist even
Jim Blandy <jimb@redhat.com>
parents:
1328
diff
changeset
|
1168 /* This event should make it into this_command_keys, and get echoed |
1515
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
1169 again, so we go to reread_first, rather than reread. */ |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
1170 goto reread_first; |
1386
5845050f9d5c
* keyboard.c (Vlast_event_frame): Make this variable exist even
Jim Blandy <jimb@redhat.com>
parents:
1328
diff
changeset
|
1171 } |
5845050f9d5c
* keyboard.c (Vlast_event_frame): Make this variable exist even
Jim Blandy <jimb@redhat.com>
parents:
1328
diff
changeset
|
1172 |
518 | 1173 /* Save outer setjmp data, in case called recursively. */ |
650 | 1174 save_getcjmp (save_jump); |
518 | 1175 |
1176 stop_polling (); | |
1177 | |
1178 if (commandflag >= 0 && !input_pending && !detect_input_pending ()) | |
1179 redisplay (); | |
1180 | |
1181 if (_setjmp (getcjmp)) | |
1182 { | |
1183 XSET (c, Lisp_Int, quit_char); | |
1565
a681f63f93fa
* keyboard.c (read_key_sequence): Removed the
Jim Blandy <jimb@redhat.com>
parents:
1515
diff
changeset
|
1184 #ifdef MULTI_FRAME |
765 | 1185 XSET (Vlast_event_frame, Lisp_Frame, selected_frame); |
1565
a681f63f93fa
* keyboard.c (read_key_sequence): Removed the
Jim Blandy <jimb@redhat.com>
parents:
1515
diff
changeset
|
1186 #endif |
518 | 1187 |
1188 goto non_reread; | |
1189 } | |
1190 | |
1191 /* Message turns off echoing unless more keystrokes turn it on again. */ | |
1192 if (echo_area_glyphs && *echo_area_glyphs && echo_area_glyphs != echobuf) | |
1193 cancel_echoing (); | |
1194 else | |
1195 /* If already echoing, continue. */ | |
1196 echo_dash (); | |
1197 | |
1198 /* If in middle of key sequence and minibuffer not active, | |
1199 start echoing if enough time elapses. */ | |
1200 if (minibuf_level == 0 && !immediate_echo && this_command_key_count > 0 | |
1201 && echo_keystrokes > 0 | |
1202 && (echo_area_glyphs == 0 || *echo_area_glyphs == 0)) | |
1203 { | |
1204 Lisp_Object tem0; | |
1205 | |
1083
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
1206 /* After a mouse event, start echoing right away. |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
1207 This is because we are probably about to display a menu, |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
1208 and we don't want to delay before doing so. */ |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
1209 if (XTYPE (prev_event) == Lisp_Cons) |
518 | 1210 echo (); |
1083
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
1211 else |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
1212 { |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
1213 tem0 = sit_for (echo_keystrokes, 0, 1, 1); |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
1214 if (EQ (tem0, Qt)) |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
1215 echo (); |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
1216 } |
518 | 1217 } |
1218 | |
1219 /* Maybe auto save due to number of keystrokes or idle time. */ | |
1220 | |
1221 if (commandflag != 0 | |
1222 && auto_save_interval > 0 | |
1104
f3a7122a68e1
(num_nonmacro_input_chars): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
1097
diff
changeset
|
1223 && num_nonmacro_input_chars - last_auto_save > max (auto_save_interval, 20) |
518 | 1224 && !detect_input_pending ()) |
1225 { | |
1226 jmp_buf temp; | |
1227 save_getcjmp (temp); | |
1228 Fdo_auto_save (Qnil, Qnil); | |
1229 restore_getcjmp (temp); | |
1230 } | |
1231 | |
1083
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
1232 /* Try reading a character via menu prompting. |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
1233 Try this before the sit-for, because the sit-for |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
1234 would do the wrong thing if we are supposed to do |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
1235 menu prompting. */ |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
1236 c = Qnil; |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
1237 if (INTERACTIVE && !NILP (prev_event)) |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
1238 c = read_char_menu_prompt (nmaps, maps, prev_event, used_mouse_menu); |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
1239 |
518 | 1240 /* Slow down auto saves logarithmically in size of current buffer, |
1241 and garbage collect while we're at it. */ | |
1083
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
1242 if (NILP (c)) |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
1243 { |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
1244 int delay_level, buffer_size; |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
1245 |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
1246 if (! MINI_WINDOW_P (XWINDOW (selected_window))) |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
1247 last_non_minibuf_size = Z - BEG; |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
1248 buffer_size = (last_non_minibuf_size >> 8) + 1; |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
1249 delay_level = 0; |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
1250 while (buffer_size > 64) |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
1251 delay_level++, buffer_size -= buffer_size >> 2; |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
1252 if (delay_level < 4) delay_level = 4; |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
1253 /* delay_level is 4 for files under around 50k, 7 at 100k, |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
1254 9 at 200k, 11 at 300k, and 12 at 500k. It is 15 at 1 meg. */ |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
1255 |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
1256 /* Auto save if enough time goes by without input. */ |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
1257 if (commandflag != 0 |
1104
f3a7122a68e1
(num_nonmacro_input_chars): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
1097
diff
changeset
|
1258 && num_nonmacro_input_chars > last_auto_save |
1083
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
1259 && XTYPE (Vauto_save_timeout) == Lisp_Int |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
1260 && XINT (Vauto_save_timeout) > 0) |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
1261 { |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
1262 Lisp_Object tem0; |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
1263 int delay = delay_level * XFASTINT (Vauto_save_timeout) / 4; |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
1264 tem0 = sit_for (delay, 0, 1, 1); |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
1265 if (EQ (tem0, Qt)) |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
1266 { |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
1267 jmp_buf temp; |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
1268 save_getcjmp (temp); |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
1269 Fdo_auto_save (Qnil, Qnil); |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
1270 restore_getcjmp (temp); |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
1271 |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
1272 /* If we have auto-saved and there is still no input |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
1273 available, garbage collect if there has been enough |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
1274 consing going on to make it worthwhile. */ |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
1275 if (!detect_input_pending () |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
1276 && consing_since_gc > gc_cons_threshold / 2) |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
1277 Fgarbage_collect (); |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
1278 } |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
1279 } |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
1280 } |
518 | 1281 |
1282 /* Actually read a character, waiting if necessary. */ | |
1083
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
1283 if (NILP (c)) |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
1284 c = kbd_buffer_get_event (); |
518 | 1285 |
1286 if (NILP (c)) | |
1287 abort (); /* Don't think this can happen. */ | |
1288 | |
1289 /* Terminate Emacs in batch mode if at eof. */ | |
1083
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
1290 if (noninteractive && XTYPE (c) == Lisp_Int && XINT (c) < 0) |
518 | 1291 Fkill_emacs (make_number (1)); |
1292 | |
1293 non_reread: | |
1294 | |
650 | 1295 restore_getcjmp (save_jump); |
518 | 1296 |
1297 start_polling (); | |
1298 | |
1299 echo_area_glyphs = 0; | |
1300 | |
1301 /* Handle things that only apply to characters. */ | |
1302 if (XTYPE (c) == Lisp_Int) | |
1303 { | |
1304 /* If kbd_buffer_get_event gave us an EOF, return that. */ | |
1305 if (XINT (c) < 0) | |
1306 return c; | |
1307 | |
1308 /* Strip the high bits, and maybe the meta bit too. */ | |
1515
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
1309 XSETINT (c, XINT (c) & (meta_key ? 0377 : 0177)); |
518 | 1310 |
1311 if (XTYPE (Vkeyboard_translate_table) == Lisp_String | |
1515
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
1312 && XSTRING (Vkeyboard_translate_table)->size > XFASTINT (c)) |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
1313 XSETINT (c, XSTRING (Vkeyboard_translate_table)->data[XFASTINT (c)]); |
518 | 1314 } |
1315 | |
1316 total_keys++; | |
1261
60b30565326c
* keyboard.c (recent_keys): Turn this from an array, which is a
Jim Blandy <jimb@redhat.com>
parents:
1239
diff
changeset
|
1317 XVECTOR (recent_keys)->contents[recent_keys_index] = c; |
60b30565326c
* keyboard.c (recent_keys): Turn this from an array, which is a
Jim Blandy <jimb@redhat.com>
parents:
1239
diff
changeset
|
1318 if (++recent_keys_index >= NUM_RECENT_KEYS) |
518 | 1319 recent_keys_index = 0; |
1320 | |
1321 /* Write c to the dribble file. If c is a lispy event, write | |
1322 the event's symbol to the dribble file, in <brackets>. Bleaugh. | |
1323 If you, dear reader, have a better idea, you've got the source. :-) */ | |
1324 if (dribble) | |
1325 { | |
1326 if (XTYPE (c) == Lisp_Int) | |
1515
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
1327 putc (XINT (c), dribble); |
518 | 1328 else |
1329 { | |
1330 Lisp_Object dribblee = c; | |
1331 | |
1332 /* If it's a structured event, take the event header. */ | |
1310
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1333 dribblee = EVENT_HEAD (dribblee); |
518 | 1334 |
1590
11cd7c23f538
* keyboard.c (unread_switch_frame): Don't declare this static.
Jim Blandy <jimb@redhat.com>
parents:
1565
diff
changeset
|
1335 if (XTYPE (dribblee) == Lisp_Symbol) |
518 | 1336 { |
1337 putc ('<', dribble); | |
1590
11cd7c23f538
* keyboard.c (unread_switch_frame): Don't declare this static.
Jim Blandy <jimb@redhat.com>
parents:
1565
diff
changeset
|
1338 fwrite (XSYMBOL (dribblee)->name->data, sizeof (char), |
11cd7c23f538
* keyboard.c (unread_switch_frame): Don't declare this static.
Jim Blandy <jimb@redhat.com>
parents:
1565
diff
changeset
|
1339 XSYMBOL (dribblee)->name->size, |
518 | 1340 dribble); |
1341 putc ('>', dribble); | |
1342 } | |
1343 } | |
1344 | |
1345 fflush (dribble); | |
1346 } | |
1347 | |
1348 store_kbd_macro_char (c); | |
1349 | |
1104
f3a7122a68e1
(num_nonmacro_input_chars): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
1097
diff
changeset
|
1350 num_nonmacro_input_chars++; |
f3a7122a68e1
(num_nonmacro_input_chars): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
1097
diff
changeset
|
1351 |
518 | 1352 from_macro: |
1353 reread_first: | |
1354 echo_char (c); | |
1355 | |
1356 /* Record this character as part of the current key. */ | |
1357 add_command_key (c); | |
1358 | |
1359 /* Re-reading in the middle of a command */ | |
1360 reread: | |
1361 last_input_char = c; | |
1362 num_input_chars++; | |
1363 | |
1364 /* Process the help character specially if enabled */ | |
1365 if (EQ (c, help_char) && !NILP (Vhelp_form)) | |
1366 { | |
1367 Lisp_Object tem0; | |
1368 count = specpdl_ptr - specpdl; | |
1369 | |
1370 record_unwind_protect (Fset_window_configuration, | |
1371 Fcurrent_window_configuration (Qnil)); | |
1372 | |
1373 tem0 = Feval (Vhelp_form); | |
1374 if (XTYPE (tem0) == Lisp_String) | |
1375 internal_with_output_to_temp_buffer ("*Help*", print_help, tem0); | |
1376 | |
1377 cancel_echoing (); | |
1439
b3b2d1181d3a
* keyboard.c (this_command_keys): Make this a vector, instead of
Jim Blandy <jimb@redhat.com>
parents:
1404
diff
changeset
|
1378 c = read_char (0, 0, 0, Qnil, 0); |
765 | 1379 /* Remove the help from the frame */ |
518 | 1380 unbind_to (count, Qnil); |
1381 redisplay (); | |
1382 if (EQ (c, make_number (040))) | |
1383 { | |
1384 cancel_echoing (); | |
1083
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
1385 c = read_char (0, 0, 0, Qnil, 0); |
518 | 1386 } |
1387 } | |
1388 | |
1389 return c; | |
1390 } | |
1391 | |
1392 Lisp_Object | |
1393 print_help (object) | |
1394 Lisp_Object object; | |
1395 { | |
1396 Fprinc (object, Qnil); | |
1397 return Qnil; | |
1398 } | |
1399 | |
1400 /* Copy out or in the info on where C-g should throw to. | |
1401 This is used when running Lisp code from within get_char, | |
1402 in case get_char is called recursively. | |
1403 See read_process_output. */ | |
1404 | |
1405 save_getcjmp (temp) | |
1406 jmp_buf temp; | |
1407 { | |
1408 bcopy (getcjmp, temp, sizeof getcjmp); | |
1409 } | |
1410 | |
1411 restore_getcjmp (temp) | |
1412 jmp_buf temp; | |
1413 { | |
1414 bcopy (temp, getcjmp, sizeof getcjmp); | |
1415 } | |
1416 | |
1417 | |
1418 /* Low level keyboard/mouse input. | |
1419 kbd_buffer_store_event places events in kbd_buffer, and | |
1420 kbd_buffer_get_event retrieves them. | |
1421 mouse_moved indicates when the mouse has moved again, and | |
1422 *mouse_position_hook provides the mouse position. */ | |
1423 | |
1424 /* Set this for debugging, to have a way to get out */ | |
1425 int stop_character; | |
1426 | |
765 | 1427 extern int frame_garbaged; |
518 | 1428 |
1429 /* Return true iff there are any events in the queue that read-char | |
1430 would return. If this returns false, a read-char would block. */ | |
1431 static int | |
1432 readable_events () | |
1433 { | |
1310
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1434 return ! EVENT_QUEUES_EMPTY; |
518 | 1435 } |
1436 | |
1437 | |
1438 /* Restore mouse tracking enablement. See Ftrack_mouse for the only use | |
1439 of this function. */ | |
1440 static Lisp_Object | |
1441 tracking_off (old_value) | |
1442 Lisp_Object old_value; | |
1443 { | |
1444 if (! XFASTINT (old_value)) | |
1445 { | |
1446 do_mouse_tracking = 0; | |
1447 | |
1448 /* Redisplay may have been preempted because there was input | |
1449 available, and it assumes it will be called again after the | |
1450 input has been processed. If the only input available was | |
1451 the sort that we have just disabled, then we need to call | |
1452 redisplay. */ | |
1453 if (!readable_events ()) | |
1454 { | |
1455 redisplay_preserve_echo_area (); | |
1456 get_input_pending (&input_pending); | |
1457 } | |
1458 } | |
1459 } | |
1460 | |
1461 DEFUN ("track-mouse", Ftrack_mouse, Strack_mouse, 0, UNEVALLED, 0, | |
1462 "Evaluate BODY with mouse movement and button release events enabled.\n\ | |
682
71f59bd24996
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
650
diff
changeset
|
1463 Within a `track-mouse', mouse motion and button releases generate input\n\ |
71f59bd24996
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
650
diff
changeset
|
1464 events that you can read with `read-event'.\n\ |
71f59bd24996
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
650
diff
changeset
|
1465 Normally, these occurrences don't generate events.") |
518 | 1466 (args) |
1467 Lisp_Object args; | |
1468 { | |
1469 int count = specpdl_ptr - specpdl; | |
1470 Lisp_Object val; | |
1471 | |
1472 XSET (val, Lisp_Int, do_mouse_tracking); | |
1473 record_unwind_protect (tracking_off, val); | |
1474 | |
1475 do_mouse_tracking = 1; | |
1476 | |
1477 val = Fprogn (args); | |
1478 return unbind_to (count, val); | |
1479 } | |
1480 | |
1481 /* Store an event obtained at interrupt level into kbd_buffer, fifo */ | |
1482 | |
1483 void | |
1484 kbd_buffer_store_event (event) | |
1485 register struct input_event *event; | |
1486 { | |
1487 if (event->kind == no_event) | |
1488 abort (); | |
1489 | |
1490 if (event->kind == ascii_keystroke) | |
1491 { | |
1492 register int c = XFASTINT (event->code) & 0377; | |
1493 | |
1494 if (c == quit_char | |
1495 || ((c == (0200 | quit_char)) && !meta_key)) | |
1496 { | |
985
952aa214a3d0
* keyboard.c (Fexecute_mouse_event): dyked-out function deleted.
Jim Blandy <jimb@redhat.com>
parents:
966
diff
changeset
|
1497 extern SIGTYPE interrupt_signal (); |
952aa214a3d0
* keyboard.c (Fexecute_mouse_event): dyked-out function deleted.
Jim Blandy <jimb@redhat.com>
parents:
966
diff
changeset
|
1498 |
1565
a681f63f93fa
* keyboard.c (read_key_sequence): Removed the
Jim Blandy <jimb@redhat.com>
parents:
1515
diff
changeset
|
1499 #ifdef MULTI_FRAME |
518 | 1500 /* If this results in a quit_char being returned to Emacs as |
765 | 1501 input, set last-event-frame properly. If this doesn't |
518 | 1502 get returned to Emacs as an event, the next event read |
765 | 1503 will set Vlast_event_frame again, so this is safe to do. */ |
1504 Vlast_event_frame = FRAME_FOCUS_FRAME (event->frame); | |
1565
a681f63f93fa
* keyboard.c (read_key_sequence): Removed the
Jim Blandy <jimb@redhat.com>
parents:
1515
diff
changeset
|
1505 #endif |
985
952aa214a3d0
* keyboard.c (Fexecute_mouse_event): dyked-out function deleted.
Jim Blandy <jimb@redhat.com>
parents:
966
diff
changeset
|
1506 |
648 | 1507 last_event_timestamp = event->timestamp; |
518 | 1508 interrupt_signal (); |
1509 return; | |
1510 } | |
1511 | |
1512 if (c && c == stop_character) | |
1513 { | |
1514 sys_suspend (); | |
1515 return; | |
1516 } | |
1517 | |
1518 XSET (event->code, Lisp_Int, c); | |
1519 } | |
1520 | |
1521 if (kbd_store_ptr - kbd_buffer == KBD_BUFFER_SIZE) | |
1522 kbd_store_ptr = kbd_buffer; | |
1523 | |
1524 /* Don't let the very last slot in the buffer become full, | |
1525 since that would make the two pointers equal, | |
1526 and that is indistinguishable from an empty buffer. | |
1527 Discard the event if it would fill the last slot. */ | |
1528 if (kbd_fetch_ptr - 1 != kbd_store_ptr) | |
1529 { | |
1530 kbd_store_ptr->kind = event->kind; | |
1531 kbd_store_ptr->code = event->code; | |
1532 kbd_store_ptr->part = event->part; | |
765 | 1533 kbd_store_ptr->frame = event->frame; |
518 | 1534 kbd_store_ptr->modifiers = event->modifiers; |
1535 kbd_store_ptr->x = event->x; | |
1536 kbd_store_ptr->y = event->y; | |
1537 kbd_store_ptr->timestamp = event->timestamp; | |
1538 | |
1539 kbd_store_ptr++; | |
1540 } | |
1541 } | |
1542 | |
1543 static Lisp_Object make_lispy_event (); | |
1544 static Lisp_Object make_lispy_movement (); | |
1545 static Lisp_Object modify_event_symbol (); | |
1386
5845050f9d5c
* keyboard.c (Vlast_event_frame): Make this variable exist even
Jim Blandy <jimb@redhat.com>
parents:
1328
diff
changeset
|
1546 static Lisp_Object make_lispy_switch_frame (); |
518 | 1547 |
1548 static Lisp_Object | |
1549 kbd_buffer_get_event () | |
1550 { | |
1551 register int c; | |
1552 Lisp_Object obj; | |
1553 | |
1554 if (noninteractive) | |
1555 { | |
1556 c = getchar (); | |
1557 XSET (obj, Lisp_Int, c); | |
1558 return obj; | |
1559 } | |
1560 | |
1561 /* Wait until there is input available. */ | |
1562 for (;;) | |
1563 { | |
1564 if (!EVENT_QUEUES_EMPTY) | |
1565 break; | |
1566 | |
1567 /* If the quit flag is set, then read_char will return | |
1568 quit_char, so that counts as "available input." */ | |
1569 if (!NILP (Vquit_flag)) | |
1570 quit_throw_to_read_char (); | |
1571 | |
1572 /* One way or another, wait until input is available; then, if | |
1573 interrupt handlers have not read it, read it now. */ | |
1574 | |
1575 #ifdef OLDVMS | |
1576 wait_for_kbd_input (); | |
1577 #else | |
1578 /* Note SIGIO has been undef'd if FIONREAD is missing. */ | |
1579 #ifdef SIGIO | |
1580 gobble_input (0); | |
1581 #endif /* SIGIO */ | |
1582 if (EVENT_QUEUES_EMPTY) | |
1583 { | |
650 | 1584 Lisp_Object minus_one; |
1585 | |
1586 XSET (minus_one, Lisp_Int, -1); | |
1587 wait_reading_process_input (0, 0, minus_one, 1); | |
518 | 1588 |
1589 if (!interrupt_input && EVENT_QUEUES_EMPTY) | |
1590 { | |
1591 read_avail_input (0); | |
1592 } | |
1593 } | |
1594 #endif /* not VMS */ | |
1595 } | |
1596 | |
1597 /* At this point, we know that there is a readable event available | |
1598 somewhere. If the event queue is empty, then there must be a | |
1599 mouse movement enabled and available. */ | |
1600 if (kbd_fetch_ptr != kbd_store_ptr) | |
1601 { | |
1386
5845050f9d5c
* keyboard.c (Vlast_event_frame): Make this variable exist even
Jim Blandy <jimb@redhat.com>
parents:
1328
diff
changeset
|
1602 struct input_event *event; |
5845050f9d5c
* keyboard.c (Vlast_event_frame): Make this variable exist even
Jim Blandy <jimb@redhat.com>
parents:
1328
diff
changeset
|
1603 |
1404
1c2080f78a36
* keyboard.c (kbd_buffer_get_event): Fix fencepost bug in
Jim Blandy <jimb@redhat.com>
parents:
1402
diff
changeset
|
1604 event = ((kbd_fetch_ptr < kbd_buffer + KBD_BUFFER_SIZE) |
1386
5845050f9d5c
* keyboard.c (Vlast_event_frame): Make this variable exist even
Jim Blandy <jimb@redhat.com>
parents:
1328
diff
changeset
|
1605 ? kbd_fetch_ptr |
5845050f9d5c
* keyboard.c (Vlast_event_frame): Make this variable exist even
Jim Blandy <jimb@redhat.com>
parents:
1328
diff
changeset
|
1606 : kbd_buffer); |
5845050f9d5c
* keyboard.c (Vlast_event_frame): Make this variable exist even
Jim Blandy <jimb@redhat.com>
parents:
1328
diff
changeset
|
1607 |
5845050f9d5c
* keyboard.c (Vlast_event_frame): Make this variable exist even
Jim Blandy <jimb@redhat.com>
parents:
1328
diff
changeset
|
1608 last_event_timestamp = event->timestamp; |
1565
a681f63f93fa
* keyboard.c (read_key_sequence): Removed the
Jim Blandy <jimb@redhat.com>
parents:
1515
diff
changeset
|
1609 |
a681f63f93fa
* keyboard.c (read_key_sequence): Removed the
Jim Blandy <jimb@redhat.com>
parents:
1515
diff
changeset
|
1610 { |
a681f63f93fa
* keyboard.c (read_key_sequence): Removed the
Jim Blandy <jimb@redhat.com>
parents:
1515
diff
changeset
|
1611 #ifdef MULTI_FRAME |
a681f63f93fa
* keyboard.c (read_key_sequence): Removed the
Jim Blandy <jimb@redhat.com>
parents:
1515
diff
changeset
|
1612 Lisp_Object frame; |
a681f63f93fa
* keyboard.c (read_key_sequence): Removed the
Jim Blandy <jimb@redhat.com>
parents:
1515
diff
changeset
|
1613 |
a681f63f93fa
* keyboard.c (read_key_sequence): Removed the
Jim Blandy <jimb@redhat.com>
parents:
1515
diff
changeset
|
1614 /* If this event is on a different frame, return a switch-frame this |
a681f63f93fa
* keyboard.c (read_key_sequence): Removed the
Jim Blandy <jimb@redhat.com>
parents:
1515
diff
changeset
|
1615 time, and leave the event in the queue for next time. */ |
a681f63f93fa
* keyboard.c (read_key_sequence): Removed the
Jim Blandy <jimb@redhat.com>
parents:
1515
diff
changeset
|
1616 XSET (frame, Lisp_Frame, XFRAME (FRAME_FOCUS_FRAME (event->frame))); |
a681f63f93fa
* keyboard.c (read_key_sequence): Removed the
Jim Blandy <jimb@redhat.com>
parents:
1515
diff
changeset
|
1617 if (! EQ (frame, Vlast_event_frame)) |
a681f63f93fa
* keyboard.c (read_key_sequence): Removed the
Jim Blandy <jimb@redhat.com>
parents:
1515
diff
changeset
|
1618 { |
a681f63f93fa
* keyboard.c (read_key_sequence): Removed the
Jim Blandy <jimb@redhat.com>
parents:
1515
diff
changeset
|
1619 Vlast_event_frame = frame; |
a681f63f93fa
* keyboard.c (read_key_sequence): Removed the
Jim Blandy <jimb@redhat.com>
parents:
1515
diff
changeset
|
1620 obj = make_lispy_switch_frame (frame); |
a681f63f93fa
* keyboard.c (read_key_sequence): Removed the
Jim Blandy <jimb@redhat.com>
parents:
1515
diff
changeset
|
1621 } |
a681f63f93fa
* keyboard.c (read_key_sequence): Removed the
Jim Blandy <jimb@redhat.com>
parents:
1515
diff
changeset
|
1622 else |
a681f63f93fa
* keyboard.c (read_key_sequence): Removed the
Jim Blandy <jimb@redhat.com>
parents:
1515
diff
changeset
|
1623 #endif |
a681f63f93fa
* keyboard.c (read_key_sequence): Removed the
Jim Blandy <jimb@redhat.com>
parents:
1515
diff
changeset
|
1624 { |
a681f63f93fa
* keyboard.c (read_key_sequence): Removed the
Jim Blandy <jimb@redhat.com>
parents:
1515
diff
changeset
|
1625 obj = make_lispy_event (event); |
a681f63f93fa
* keyboard.c (read_key_sequence): Removed the
Jim Blandy <jimb@redhat.com>
parents:
1515
diff
changeset
|
1626 if (XTYPE (obj) == Lisp_Int) |
a681f63f93fa
* keyboard.c (read_key_sequence): Removed the
Jim Blandy <jimb@redhat.com>
parents:
1515
diff
changeset
|
1627 XSET (obj, Lisp_Int, XINT (obj) & (meta_key ? 0377 : 0177)); |
1386
5845050f9d5c
* keyboard.c (Vlast_event_frame): Make this variable exist even
Jim Blandy <jimb@redhat.com>
parents:
1328
diff
changeset
|
1628 |
1565
a681f63f93fa
* keyboard.c (read_key_sequence): Removed the
Jim Blandy <jimb@redhat.com>
parents:
1515
diff
changeset
|
1629 /* Wipe out this event, to catch bugs. */ |
a681f63f93fa
* keyboard.c (read_key_sequence): Removed the
Jim Blandy <jimb@redhat.com>
parents:
1515
diff
changeset
|
1630 event->kind = no_event; |
a681f63f93fa
* keyboard.c (read_key_sequence): Removed the
Jim Blandy <jimb@redhat.com>
parents:
1515
diff
changeset
|
1631 |
a681f63f93fa
* keyboard.c (read_key_sequence): Removed the
Jim Blandy <jimb@redhat.com>
parents:
1515
diff
changeset
|
1632 kbd_fetch_ptr = event + 1; |
a681f63f93fa
* keyboard.c (read_key_sequence): Removed the
Jim Blandy <jimb@redhat.com>
parents:
1515
diff
changeset
|
1633 } |
a681f63f93fa
* keyboard.c (read_key_sequence): Removed the
Jim Blandy <jimb@redhat.com>
parents:
1515
diff
changeset
|
1634 } |
518 | 1635 } |
1636 else if (do_mouse_tracking && mouse_moved) | |
1637 { | |
765 | 1638 FRAME_PTR frame; |
732 | 1639 Lisp_Object x, y; |
1640 unsigned long time; | |
518 | 1641 |
765 | 1642 (*mouse_position_hook) (&frame, &x, &y, &time); |
1386
5845050f9d5c
* keyboard.c (Vlast_event_frame): Make this variable exist even
Jim Blandy <jimb@redhat.com>
parents:
1328
diff
changeset
|
1643 |
1565
a681f63f93fa
* keyboard.c (read_key_sequence): Removed the
Jim Blandy <jimb@redhat.com>
parents:
1515
diff
changeset
|
1644 #ifdef MULTI_FRAME |
1402
6a0dcfc81b4f
* keyboard.c (kbd_buffer_get_event): Remember that
Jim Blandy <jimb@redhat.com>
parents:
1386
diff
changeset
|
1645 /* Decide if we should generate a switch-frame event. Don't generate |
6a0dcfc81b4f
* keyboard.c (kbd_buffer_get_event): Remember that
Jim Blandy <jimb@redhat.com>
parents:
1386
diff
changeset
|
1646 switch-frame events for motion outside of all Emacs frames. */ |
1590
11cd7c23f538
* keyboard.c (unread_switch_frame): Don't declare this static.
Jim Blandy <jimb@redhat.com>
parents:
1565
diff
changeset
|
1647 if (frame |
11cd7c23f538
* keyboard.c (unread_switch_frame): Don't declare this static.
Jim Blandy <jimb@redhat.com>
parents:
1565
diff
changeset
|
1648 && (XTYPE (Vlast_event_frame) != Lisp_Frame |
11cd7c23f538
* keyboard.c (unread_switch_frame): Don't declare this static.
Jim Blandy <jimb@redhat.com>
parents:
1565
diff
changeset
|
1649 || frame != XFRAME (Vlast_event_frame))) |
1386
5845050f9d5c
* keyboard.c (Vlast_event_frame): Make this variable exist even
Jim Blandy <jimb@redhat.com>
parents:
1328
diff
changeset
|
1650 { |
5845050f9d5c
* keyboard.c (Vlast_event_frame): Make this variable exist even
Jim Blandy <jimb@redhat.com>
parents:
1328
diff
changeset
|
1651 XSET (Vlast_event_frame, Lisp_Frame, frame); |
5845050f9d5c
* keyboard.c (Vlast_event_frame): Make this variable exist even
Jim Blandy <jimb@redhat.com>
parents:
1328
diff
changeset
|
1652 obj = make_lispy_switch_frame (Vlast_event_frame); |
5845050f9d5c
* keyboard.c (Vlast_event_frame): Make this variable exist even
Jim Blandy <jimb@redhat.com>
parents:
1328
diff
changeset
|
1653 } |
5845050f9d5c
* keyboard.c (Vlast_event_frame): Make this variable exist even
Jim Blandy <jimb@redhat.com>
parents:
1328
diff
changeset
|
1654 else |
1565
a681f63f93fa
* keyboard.c (read_key_sequence): Removed the
Jim Blandy <jimb@redhat.com>
parents:
1515
diff
changeset
|
1655 #endif |
1386
5845050f9d5c
* keyboard.c (Vlast_event_frame): Make this variable exist even
Jim Blandy <jimb@redhat.com>
parents:
1328
diff
changeset
|
1656 obj = make_lispy_movement (frame, x, y, time); |
518 | 1657 } |
1658 else | |
1659 /* We were promised by the above while loop that there was | |
1660 something for us to read! */ | |
1661 abort (); | |
1662 | |
1663 input_pending = readable_events (); | |
1664 | |
1665 return (obj); | |
1666 } | |
1667 | |
1668 /* Caches for modify_event_symbol. */ | |
1669 static Lisp_Object func_key_syms; | |
1670 static Lisp_Object mouse_syms; | |
1671 | |
1672 /* You'll notice that this table is arranged to be conveniently | |
1673 indexed by X Windows keysym values. */ | |
1674 static char *lispy_function_keys[] = | |
1675 { | |
1676 /* X Keysym value */ | |
1677 | |
1678 "home", /* 0xff50 */ /* IsCursorKey */ | |
1679 "left", | |
1680 "up", | |
1681 "right", | |
1682 "down", | |
1683 "prior", | |
1684 "next", | |
1685 "end", | |
1686 "begin", | |
1687 0, /* 0xff59 */ | |
1688 0, 0, 0, 0, 0, 0, | |
1689 "select", /* 0xff60 */ /* IsMiscFunctionKey */ | |
1690 "print", | |
1691 "execute", | |
1692 "insert", | |
1693 0, /* 0xff64 */ | |
1694 "undo", | |
1695 "redo", | |
1696 "menu", | |
1697 "find", | |
1698 "cancel", | |
1699 "help", | |
1700 "break", /* 0xff6b */ | |
1701 | |
1702 /* Here are some keys found mostly on HP keyboards. The X event | |
1703 handling code will strip bit 29, which flags vendor-specific | |
1704 keysyms. */ | |
1705 "reset", /* 0x1000ff6c */ | |
1706 "system", | |
1707 "user", | |
1708 "clearline", | |
1709 "insertline", | |
1710 "deleteline", | |
1711 "insertchar", | |
1712 "deletechar", | |
1713 "backtab", | |
1714 "kp_backtab", /* 0x1000ff75 */ | |
1715 0, /* 0xff76 */ | |
1716 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xff7f */ | |
1717 "kp-space", /* 0xff80 */ /* IsKeypadKey */ | |
1718 0, 0, 0, 0, 0, 0, 0, 0, | |
1719 "kp-tab", /* 0xff89 */ | |
1720 0, 0, 0, | |
1721 "kp-enter", /* 0xff8d */ | |
1722 0, 0, 0, | |
1723 "kp-f1", /* 0xff91 */ | |
1724 "kp-f2", | |
1725 "kp-f3", | |
1726 "kp-f4", | |
1727 0, /* 0xff95 */ | |
1728 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |
1729 "kp-multiply", /* 0xffaa */ | |
1730 "kp-add", | |
1731 "kp-separator", | |
1732 "kp-subtract", | |
1733 "kp-decimal", | |
1734 "kp-divide", /* 0xffaf */ | |
1735 "kp-0", /* 0xffb0 */ | |
1736 "kp-1", "kp-2", "kp-3", "kp-4", "kp-5", "kp-6", "kp-7", "kp-8", "kp-9", | |
1737 0, /* 0xffba */ | |
1738 0, 0, | |
1739 "kp-equal", /* 0xffbd */ | |
1740 "f1", /* 0xffbe */ /* IsFunctionKey */ | |
1741 "f2", "f3", "f4", | |
1742 "f5", "f6", "f7", "f8", "f9", "f10", "f11", "f12", | |
1743 "f13", "f14", "f15", "f16", "f17", "f18", "f19", "f20", | |
1744 "f21", "f22", "f23", "f24", "f25", "f26", "f27", "f28", | |
1745 "f29", "f30", "f31", "f32", "f33", "f34", "f35" /* 0xffe0 */ | |
1746 }; | |
1747 | |
1748 static char *lispy_mouse_names[] = | |
1749 { | |
1750 "mouse-1", "mouse-2", "mouse-3", "mouse-4", "mouse-5" | |
1751 }; | |
1752 | |
1310
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1753 /* make_lispy_event stores the down-going location of the currently |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1754 depressed buttons in button_down_locations. */ |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1755 struct mouse_position { |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1756 Lisp_Object window; |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1757 Lisp_Object buffer_pos; |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1758 Lisp_Object x, y; |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1759 Lisp_Object timestamp; |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1760 }; |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1761 static struct mouse_position button_down_location[NUM_MOUSE_BUTTONS]; |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1762 |
518 | 1763 /* Given a struct input_event, build the lisp event which represents |
1764 it. If EVENT is 0, build a mouse movement event from the mouse | |
1310
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1765 movement buffer, which should have a movement event in it. |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1766 |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1767 Note that events must be passed to this function in the order they |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1768 are received; this function stores the location of button presses |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1769 in order to build drag events when the button is released. */ |
518 | 1770 |
1771 static Lisp_Object | |
1772 make_lispy_event (event) | |
1773 struct input_event *event; | |
1774 { | |
1775 #ifdef SWITCH_ENUM_BUG | |
1776 switch ((int) event->kind) | |
1777 #else | |
1778 switch (event->kind) | |
1779 #endif | |
1780 { | |
1781 /* A simple keystroke. */ | |
1782 case ascii_keystroke: | |
1328
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
1783 return XFASTINT (event->code); |
518 | 1784 break; |
1785 | |
1786 /* A function key. The symbol may need to have modifier prefixes | |
1787 tacked onto it. */ | |
1788 case non_ascii_keystroke: | |
1789 return modify_event_symbol (XFASTINT (event->code), event->modifiers, | |
1790 Qfunction_key, | |
1791 lispy_function_keys, &func_key_syms, | |
1792 (sizeof (lispy_function_keys) | |
1793 / sizeof (lispy_function_keys[0]))); | |
1794 break; | |
1795 | |
1310
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1796 /* A mouse click. Figure out where it is, decide whether it's |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1797 a press, click or drag, and build the appropriate structure. */ |
518 | 1798 case mouse_click: |
1799 { | |
1328
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
1800 int button = XFASTINT (event->code); |
518 | 1801 int part; |
1310
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1802 Lisp_Object window; |
518 | 1803 Lisp_Object posn; |
1310
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1804 struct mouse_position *loc; |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1805 |
1328
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
1806 if (button < 0 || button >= NUM_MOUSE_BUTTONS) |
1310
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1807 abort (); |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1808 |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1809 /* Where did this mouse click occur? */ |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1810 window = window_from_coordinates (event->frame, |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1811 XINT (event->x), XINT (event->y), |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1812 &part); |
518 | 1813 if (XTYPE (window) != Lisp_Window) |
1814 posn = Qnil; | |
1815 else | |
1816 { | |
1817 XSETINT (event->x, (XINT (event->x) | |
1818 - XINT (XWINDOW (window)->left))); | |
1819 XSETINT (event->y, (XINT (event->y) | |
1820 - XINT (XWINDOW (window)->top))); | |
1821 if (part == 1) | |
1822 posn = Qmode_line; | |
1823 else if (part == 2) | |
732 | 1824 posn = Qvertical_line; |
518 | 1825 else |
1826 XSET (posn, Lisp_Int, | |
1827 buffer_posn_from_coords (XWINDOW (window), | |
1828 XINT (event->x), | |
1829 XINT (event->y))); | |
1830 } | |
1831 | |
1310
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1832 /* If this is a button press, squirrel away the location, so we |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1833 can decide later whether it was a click or a drag. */ |
1328
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
1834 loc = button_down_location + button; |
1310
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1835 if (event->modifiers & down_modifier) |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1836 { |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1837 loc->window = window; |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1838 loc->buffer_pos = posn; |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1839 loc->x = event->x; |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1840 loc->y = event->y; |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1841 loc->timestamp = event->timestamp; |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1842 } |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1843 |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1844 /* Now we're releasing a button - check the co-ordinates to |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1845 see if this was a click or a drag. */ |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1846 else if (event->modifiers & up_modifier) |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1847 { |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1848 event->modifiers &= ~up_modifier; |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1849 event->modifiers |= ((event->x == loc->x && event->y == loc->y) |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1850 ? click_modifier |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1851 : drag_modifier); |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1852 } |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1853 else |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1854 /* Every mouse event should either have the down_modifier or |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1855 the up_modifier set. */ |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1856 abort (); |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1857 |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1858 |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1859 /* Build the event. */ |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1860 { |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1861 Lisp_Object head, start, end; |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1862 |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1863 /* Build the components of the event. */ |
1328
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
1864 head = modify_event_symbol (button - 1, |
1310
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1865 event->modifiers, |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1866 Qmouse_click, |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1867 lispy_mouse_names, &mouse_syms, |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1868 (sizeof (lispy_mouse_names) |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1869 / sizeof (lispy_mouse_names[0]))); |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1870 end = Fcons (window, |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1871 Fcons (posn, |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1872 Fcons (Fcons (event->x, event->y), |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1873 Fcons (make_number (event->timestamp), |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1874 Qnil)))); |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1875 if (event->modifiers & drag_modifier) |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1876 start = Fcons (loc->window, |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1877 Fcons (loc->buffer_pos, |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1878 Fcons (Fcons (loc->x, loc->y), |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1879 Fcons (make_number (loc->timestamp), |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1880 Qnil)))); |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1881 |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1882 /* Assemble the pieces. */ |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1883 if (event->modifiers & drag_modifier) |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1884 return Fcons (head, |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1885 Fcons (start, |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1886 Fcons (end, |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1887 Qnil))); |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1888 else |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1889 return Fcons (head, |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1890 Fcons (end, |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1891 Qnil)); |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1892 } |
518 | 1893 } |
1894 | |
1895 /* A scrollbar click. Build a list containing the relevant | |
1896 information. */ | |
1897 case scrollbar_click: | |
1898 { | |
1899 Lisp_Object button | |
1900 = modify_event_symbol (XFASTINT (event->code) - 1, | |
1901 event->modifiers, | |
1902 Qmouse_click, | |
1903 lispy_mouse_names, &mouse_syms, | |
1904 (sizeof (lispy_mouse_names) | |
1905 / sizeof (lispy_mouse_names[0]))); | |
1906 return Fcons (event->part, | |
765 | 1907 Fcons (FRAME_SELECTED_WINDOW (event->frame), |
518 | 1908 Fcons (button, |
1909 Fcons (Fcons (event->x, event->y), | |
708 | 1910 Fcons (make_number |
1911 (event->timestamp), | |
518 | 1912 Qnil))))); |
1913 } | |
1914 | |
1915 /* The 'kind' field of the event is something we don't recognize. */ | |
1916 default: | |
1917 abort(); | |
1918 } | |
1919 } | |
1920 | |
1921 static Lisp_Object | |
765 | 1922 make_lispy_movement (frame, x, y, time) |
1923 FRAME_PTR frame; | |
518 | 1924 Lisp_Object x, y; |
732 | 1925 unsigned long time; |
518 | 1926 { |
1927 Lisp_Object window; | |
1928 int ix, iy; | |
1929 Lisp_Object posn; | |
1930 int part; | |
1931 | |
1932 ix = XINT (x); | |
1933 iy = XINT (y); | |
765 | 1934 window = (frame |
1935 ? window_from_coordinates (frame, ix, iy, &part) | |
518 | 1936 : Qnil); |
1937 if (XTYPE (window) != Lisp_Window) | |
1938 posn = Qnil; | |
1939 else | |
1940 { | |
1941 ix -= XINT (XWINDOW (window)->left); | |
1942 iy -= XINT (XWINDOW (window)->top); | |
1943 if (part == 1) | |
1944 posn = Qmode_line; | |
1945 else if (part == 2) | |
732 | 1946 posn = Qvertical_line; |
518 | 1947 else |
1948 XSET (posn, Lisp_Int, buffer_posn_from_coords (XWINDOW (window), | |
1949 ix, iy)); | |
1950 } | |
1951 | |
1952 XSETINT (x, ix); | |
1953 XSETINT (y, iy); | |
1954 return Fcons (Qmouse_movement, | |
1310
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1955 Fcons (Fcons (window, |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1956 Fcons (posn, |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1957 Fcons (Fcons (x, y), |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1958 Fcons (make_number (time), |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1959 Qnil)))), |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
1960 Qnil)); |
518 | 1961 } |
1962 | |
1963 | |
1386
5845050f9d5c
* keyboard.c (Vlast_event_frame): Make this variable exist even
Jim Blandy <jimb@redhat.com>
parents:
1328
diff
changeset
|
1964 /* Construct a switch frame event. */ |
5845050f9d5c
* keyboard.c (Vlast_event_frame): Make this variable exist even
Jim Blandy <jimb@redhat.com>
parents:
1328
diff
changeset
|
1965 static Lisp_Object |
5845050f9d5c
* keyboard.c (Vlast_event_frame): Make this variable exist even
Jim Blandy <jimb@redhat.com>
parents:
1328
diff
changeset
|
1966 make_lispy_switch_frame (frame) |
5845050f9d5c
* keyboard.c (Vlast_event_frame): Make this variable exist even
Jim Blandy <jimb@redhat.com>
parents:
1328
diff
changeset
|
1967 Lisp_Object frame; |
5845050f9d5c
* keyboard.c (Vlast_event_frame): Make this variable exist even
Jim Blandy <jimb@redhat.com>
parents:
1328
diff
changeset
|
1968 { |
5845050f9d5c
* keyboard.c (Vlast_event_frame): Make this variable exist even
Jim Blandy <jimb@redhat.com>
parents:
1328
diff
changeset
|
1969 return Fcons (Qswitch_frame, Fcons (frame, Qnil)); |
5845050f9d5c
* keyboard.c (Vlast_event_frame): Make this variable exist even
Jim Blandy <jimb@redhat.com>
parents:
1328
diff
changeset
|
1970 } |
5845050f9d5c
* keyboard.c (Vlast_event_frame): Make this variable exist even
Jim Blandy <jimb@redhat.com>
parents:
1328
diff
changeset
|
1971 |
1328
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
1972 |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
1973 /* Manipulating modifiers. */ |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
1974 |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
1975 /* Parse the name of SYMBOL, and return the set of modifiers it contains. |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
1976 |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
1977 If MODIFIER_END is non-zero, set *MODIFIER_END to the position in |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
1978 SYMBOL's name of the end of the modifiers; the string from this |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
1979 position is the unmodified symbol name. |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
1980 |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
1981 This doesn't use any caches. */ |
518 | 1982 static int |
1328
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
1983 parse_modifiers_uncached (symbol, modifier_end) |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
1984 Lisp_Object symbol; |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
1985 int *modifier_end; |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
1986 { |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
1987 struct Lisp_String *name; |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
1988 int i; |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
1989 int modifiers; |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
1990 |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
1991 CHECK_SYMBOL (symbol, 1); |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
1992 |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
1993 modifiers = 0; |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
1994 name = XSYMBOL (symbol)->name; |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
1995 |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
1996 |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
1997 for (i = 0; i+2 <= name->size; ) |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
1998 switch (name->data[i]) |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
1999 { |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2000 #define SINGLE_LETTER_MOD(bit) \ |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2001 if (name->data[i+1] != '-') \ |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2002 goto no_more_modifiers; \ |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2003 modifiers |= bit; \ |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2004 i += 2; |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2005 |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2006 case 'A': |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2007 SINGLE_LETTER_MOD (alt_modifier); |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2008 break; |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2009 |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2010 case 'C': |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2011 SINGLE_LETTER_MOD (ctrl_modifier); |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2012 break; |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2013 |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2014 case 'H': |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2015 SINGLE_LETTER_MOD (hyper_modifier); |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2016 break; |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2017 |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2018 case 'M': |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2019 SINGLE_LETTER_MOD (meta_modifier); |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2020 break; |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2021 |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2022 case 'S': |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2023 SINGLE_LETTER_MOD (shift_modifier); |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2024 break; |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2025 |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2026 case 's': |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2027 if (i + 6 > name->size |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2028 || strncmp (name->data + i, "super-", 6)) |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2029 goto no_more_modifiers; |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2030 modifiers |= super_modifier; |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2031 i += 6; |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2032 break; |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2033 |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2034 case 'd': |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2035 if (i + 5 > name->size) |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2036 goto no_more_modifiers; |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2037 if (! strncmp (name->data + i, "drag-", 5)) |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2038 { |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2039 modifiers |= drag_modifier; |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2040 i += 5; |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2041 } |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2042 else if (! strncmp (name->data + i, "down-", 5)) |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2043 { |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2044 modifiers |= down_modifier; |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2045 i += 5; |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2046 } |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2047 else |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2048 goto no_more_modifiers; |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2049 break; |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2050 |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2051 default: |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2052 goto no_more_modifiers; |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2053 |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2054 #undef SINGLE_LETTER_MOD |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2055 } |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2056 no_more_modifiers: |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2057 |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2058 /* Should we include the `click' modifier? */ |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2059 if (! (modifiers & (down_modifier | drag_modifier)) |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2060 && i + 7 == name->size |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2061 && strncmp (name->data + i, "mouse-", 6) |
1439
b3b2d1181d3a
* keyboard.c (this_command_keys): Make this a vector, instead of
Jim Blandy <jimb@redhat.com>
parents:
1404
diff
changeset
|
2062 && ('0' <= name->data[i + 6] && name->data[i + 6] <= '9')) |
1328
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2063 modifiers |= click_modifier; |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2064 |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2065 if (modifier_end) |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2066 *modifier_end = i; |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2067 |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2068 return modifiers; |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2069 } |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2070 |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2071 |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2072 /* Return a symbol whose name is the modifier prefixes for MODIFIERS |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2073 prepended to the string BASE[0..BASE_LEN-1]. |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2074 This doesn't use any caches. */ |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2075 static Lisp_Object |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2076 apply_modifiers_uncached (modifiers, base, base_len) |
518 | 2077 int modifiers; |
1328
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2078 char *base; |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2079 int base_len; |
518 | 2080 { |
1328
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2081 /* Since BASE could contain nulls, we can't use intern here; we have |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2082 to use Fintern, which expects a genuine Lisp_String, and keeps a |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2083 reference to it. */ |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2084 char *new_mods = |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2085 (char *) alloca (sizeof ("A-C-H-M-S-super-down-drag-")); |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2086 int mod_len; |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2087 |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2088 { |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2089 char *p = new_mods; |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2090 |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2091 /* Only the event queue may use the `up' modifier; it should always |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2092 be turned into a click or drag event before presented to lisp code. */ |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2093 if (modifiers & up_modifier) |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2094 abort (); |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2095 |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2096 if (modifiers & alt_modifier) { *p++ = 'A'; *p++ = '-'; } |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2097 if (modifiers & ctrl_modifier) { *p++ = 'C'; *p++ = '-'; } |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2098 if (modifiers & hyper_modifier) { *p++ = 'H'; *p++ = '-'; } |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2099 if (modifiers & meta_modifier) { *p++ = 'M'; *p++ = '-'; } |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2100 if (modifiers & shift_modifier) { *p++ = 'S'; *p++ = '-'; } |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2101 if (modifiers & super_modifier) { strcpy (p, "super-"); p += 6; } |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2102 if (modifiers & down_modifier) { strcpy (p, "down-"); p += 5; } |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2103 if (modifiers & drag_modifier) { strcpy (p, "drag-"); p += 5; } |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2104 /* The click modifier is denoted by the absence of other modifiers. */ |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2105 |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2106 *p = '\0'; |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2107 |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2108 mod_len = p - new_mods; |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2109 } |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2110 |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2111 { |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2112 Lisp_Object new_name = make_uninit_string (mod_len + base_len); |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2113 |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2114 bcopy (new_mods, XSTRING (new_name)->data, mod_len); |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2115 bcopy (base, XSTRING (new_name)->data + mod_len, base_len); |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2116 |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2117 return Fintern (new_name, Qnil); |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2118 } |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2119 } |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2120 |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2121 |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2122 static char *modifier_names[] = |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2123 { |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2124 "up", "alt", "control", "hyper", "meta", "shift", "super", "down", "drag", |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2125 "click" |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2126 }; |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2127 |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2128 static Lisp_Object modifier_symbols; |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2129 |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2130 /* Return the list of modifier symbols corresponding to the mask MODIFIERS. */ |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2131 static Lisp_Object |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2132 lispy_modifier_list (modifiers) |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2133 int modifiers; |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2134 { |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2135 Lisp_Object modifier_list; |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2136 int i; |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2137 |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2138 modifier_list = Qnil; |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2139 for (i = 0; (1<<i) <= modifiers; i++) |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2140 if (modifiers & (1<<i)) |
1590
11cd7c23f538
* keyboard.c (unread_switch_frame): Don't declare this static.
Jim Blandy <jimb@redhat.com>
parents:
1565
diff
changeset
|
2141 { |
11cd7c23f538
* keyboard.c (unread_switch_frame): Don't declare this static.
Jim Blandy <jimb@redhat.com>
parents:
1565
diff
changeset
|
2142 if (i >= XVECTOR (modifier_symbols)->size) |
11cd7c23f538
* keyboard.c (unread_switch_frame): Don't declare this static.
Jim Blandy <jimb@redhat.com>
parents:
1565
diff
changeset
|
2143 abort (); |
11cd7c23f538
* keyboard.c (unread_switch_frame): Don't declare this static.
Jim Blandy <jimb@redhat.com>
parents:
1565
diff
changeset
|
2144 modifier_list = Fcons (XVECTOR (modifier_symbols)->contents[i], |
11cd7c23f538
* keyboard.c (unread_switch_frame): Don't declare this static.
Jim Blandy <jimb@redhat.com>
parents:
1565
diff
changeset
|
2145 modifier_list); |
11cd7c23f538
* keyboard.c (unread_switch_frame): Don't declare this static.
Jim Blandy <jimb@redhat.com>
parents:
1565
diff
changeset
|
2146 } |
1328
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2147 |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2148 return modifier_list; |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2149 } |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2150 |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2151 |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2152 /* Parse the modifiers on SYMBOL, and return a list like (UNMODIFIED MASK), |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2153 where UNMODIFIED is the unmodified form of SYMBOL, |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2154 MASK is the set of modifiers present in SYMBOL's name. |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2155 This is similar to parse_modifiers_uncached, but uses the cache in |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2156 SYMBOL's Qevent_symbol_element_mask property, and maintains the |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2157 Qevent_symbol_elements property. */ |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2158 static Lisp_Object |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2159 parse_modifiers (symbol) |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2160 Lisp_Object symbol; |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2161 { |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2162 Lisp_Object elements = Fget (symbol, Qevent_symbol_element_mask); |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2163 |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2164 if (CONSP (elements)) |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2165 return elements; |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2166 else |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2167 { |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2168 int end; |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2169 int modifiers = parse_modifiers_uncached (symbol, &end); |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2170 Lisp_Object unmodified |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2171 = Fintern (make_string (XSYMBOL (symbol)->name->data + end, |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2172 XSYMBOL (symbol)->name->size - end), |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2173 Qnil); |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2174 Lisp_Object mask; |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2175 |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2176 XFASTINT (mask) = modifiers; |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2177 elements = Fcons (unmodified, Fcons (mask, Qnil)); |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2178 |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2179 /* Cache the parsing results on SYMBOL. */ |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2180 Fput (symbol, Qevent_symbol_element_mask, |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2181 elements); |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2182 Fput (symbol, Qevent_symbol_elements, |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2183 Fcons (unmodified, lispy_modifier_list (modifiers))); |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2184 |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2185 /* Since we know that SYMBOL is modifiers applied to unmodified, |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2186 it would be nice to put that in unmodified's cache. |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2187 But we can't, since we're not sure that parse_modifiers is |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2188 canonical. */ |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2189 |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2190 return elements; |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2191 } |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2192 } |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2193 |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2194 /* Apply the modifiers MODIFIERS to the symbol BASE. |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2195 BASE must be unmodified. |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2196 |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2197 This is like apply_modifiers_uncached, but uses BASE's |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2198 Qmodifier_cache property, if present. It also builds |
1386
5845050f9d5c
* keyboard.c (Vlast_event_frame): Make this variable exist even
Jim Blandy <jimb@redhat.com>
parents:
1328
diff
changeset
|
2199 Qevent_symbol_elements properties, since it has that info anyway. |
5845050f9d5c
* keyboard.c (Vlast_event_frame): Make this variable exist even
Jim Blandy <jimb@redhat.com>
parents:
1328
diff
changeset
|
2200 |
5845050f9d5c
* keyboard.c (Vlast_event_frame): Make this variable exist even
Jim Blandy <jimb@redhat.com>
parents:
1328
diff
changeset
|
2201 apply_modifiers copies the value of BASE's Qevent_kind property to |
5845050f9d5c
* keyboard.c (Vlast_event_frame): Make this variable exist even
Jim Blandy <jimb@redhat.com>
parents:
1328
diff
changeset
|
2202 the modified symbol. */ |
1328
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2203 static Lisp_Object |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2204 apply_modifiers (modifiers, base) |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2205 int modifiers; |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2206 Lisp_Object base; |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2207 { |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2208 Lisp_Object cache, index, entry; |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2209 |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2210 /* The click modifier never figures into cache indices. */ |
1386
5845050f9d5c
* keyboard.c (Vlast_event_frame): Make this variable exist even
Jim Blandy <jimb@redhat.com>
parents:
1328
diff
changeset
|
2211 cache = Fget (base, Qmodifier_cache); |
1328
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2212 XFASTINT (index) = (modifiers & ~click_modifier); |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2213 entry = Fassq (index, cache); |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2214 |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2215 if (CONSP (entry)) |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2216 return XCONS (entry)->cdr; |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2217 |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2218 /* We have to create the symbol ourselves. */ |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2219 { |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2220 Lisp_Object new_symbol |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2221 = apply_modifiers_uncached (modifiers, |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2222 XSYMBOL (base)->name->data, |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2223 XSYMBOL (base)->name->size); |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2224 |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2225 /* Add the new symbol to the base's cache. */ |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2226 Fput (base, Qmodifier_cache, |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2227 Fcons (Fcons (index, new_symbol), cache)); |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2228 |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2229 /* We have the parsing info now for free, so add it to the caches. */ |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2230 XFASTINT (index) = modifiers; |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2231 Fput (new_symbol, Qevent_symbol_element_mask, |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2232 Fcons (base, Fcons (index, Qnil))); |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2233 Fput (new_symbol, Qevent_symbol_elements, |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2234 Fcons (base, lispy_modifier_list (modifiers))); |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2235 |
1386
5845050f9d5c
* keyboard.c (Vlast_event_frame): Make this variable exist even
Jim Blandy <jimb@redhat.com>
parents:
1328
diff
changeset
|
2236 /* This symbol is of the same kind as BASE. */ |
5845050f9d5c
* keyboard.c (Vlast_event_frame): Make this variable exist even
Jim Blandy <jimb@redhat.com>
parents:
1328
diff
changeset
|
2237 Fput (new_symbol, Qevent_kind, Fget (new_symbol, Qevent_kind)); |
5845050f9d5c
* keyboard.c (Vlast_event_frame): Make this variable exist even
Jim Blandy <jimb@redhat.com>
parents:
1328
diff
changeset
|
2238 |
1328
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2239 return new_symbol; |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2240 } |
518 | 2241 } |
2242 | |
2243 | |
2244 /* Given a symbol whose name begins with modifiers ("C-", "M-", etc), | |
2245 return a symbol with the modifiers placed in the canonical order. | |
1239
52afa4976154
* keyboard.c (read_char): If we're returning an event from a
Jim Blandy <jimb@redhat.com>
parents:
1140
diff
changeset
|
2246 Canonical order is alphabetical, except for down and drag, which |
1310
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
2247 always come last. The 'click' modifier is never written out. |
518 | 2248 |
2249 Fdefine_key calls this to make sure that (for example) C-M-foo | |
2250 and M-C-foo end up being equivalent in the keymap. */ | |
2251 | |
2252 Lisp_Object | |
2253 reorder_modifiers (symbol) | |
2254 Lisp_Object symbol; | |
2255 { | |
1328
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2256 /* It's hopefully okay to write the code this way, since everything |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2257 will soon be in caches, and no consing will be done at all. */ |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2258 Lisp_Object parsed = parse_modifiers (symbol); |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2259 |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2260 return apply_modifiers (XCONS (XCONS (parsed)->cdr)->car, |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2261 XCONS (parsed)->car); |
518 | 2262 } |
2263 | |
2264 | |
2265 /* For handling events, we often want to produce a symbol whose name | |
2266 is a series of modifier key prefixes ("M-", "C-", etcetera) attached | |
2267 to some base, like the name of a function key or mouse button. | |
2268 modify_event_symbol produces symbols of this sort. | |
2269 | |
2270 NAME_TABLE should point to an array of strings, such that NAME_TABLE[i] | |
2271 is the name of the i'th symbol. TABLE_SIZE is the number of elements | |
2272 in the table. | |
2273 | |
2274 SYMBOL_TABLE should be a pointer to a Lisp_Object whose value will | |
2275 persist between calls to modify_event_symbol that it can use to | |
2276 store a cache of the symbols it's generated for this NAME_TABLE | |
2277 before. | |
2278 | |
2279 SYMBOL_NUM is the number of the base name we want from NAME_TABLE. | |
2280 | |
2281 MODIFIERS is a set of modifier bits (as given in struct input_events) | |
2282 whose prefixes should be applied to the symbol name. | |
2283 | |
2284 SYMBOL_KIND is the value to be placed in the event_kind property of | |
1310
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
2285 the returned symbol. |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
2286 |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
2287 The symbols we create are supposed to have an |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
2288 `event-symbol-elements' propery, which lists the modifiers present |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
2289 in the symbol's name. */ |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
2290 |
518 | 2291 static Lisp_Object |
2292 modify_event_symbol (symbol_num, modifiers, symbol_kind, name_table, | |
2293 symbol_table, table_size) | |
2294 int symbol_num; | |
2295 unsigned modifiers; | |
2296 Lisp_Object symbol_kind; | |
2297 char **name_table; | |
2298 Lisp_Object *symbol_table; | |
2299 int table_size; | |
2300 { | |
1310
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
2301 Lisp_Object *slot; |
518 | 2302 |
2303 /* Is this a request for a valid symbol? */ | |
1310
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
2304 if (symbol_num < 0 || symbol_num >= table_size) |
518 | 2305 abort (); |
2306 | |
1328
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2307 /* If *symbol_table doesn't seem to be initialized properly, fix that. |
1310
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
2308 *symbol_table should be a lisp vector TABLE_SIZE elements long, |
1328
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2309 where the Nth element is the symbol for NAME_TABLE[N]. */ |
518 | 2310 if (XTYPE (*symbol_table) != Lisp_Vector |
2311 || XVECTOR (*symbol_table)->size != table_size) | |
2312 { | |
1328
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2313 Lisp_Object size; |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2314 |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2315 XFASTINT (size) = table_size; |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2316 *symbol_table = Fmake_vector (size, Qnil); |
518 | 2317 } |
2318 | |
1310
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
2319 slot = & XVECTOR (*symbol_table)->contents[symbol_num]; |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
2320 |
1328
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2321 /* Have we already used this symbol before? */ |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2322 if (NILP (*slot)) |
1310
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
2323 { |
1328
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2324 /* No; let's create it. */ |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2325 *slot = intern (name_table[symbol_num]); |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2326 |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2327 /* Fill in the cache entries for this symbol; this also |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2328 builds the Qevent_symbol_elements property, which the user |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2329 cares about. */ |
1439
b3b2d1181d3a
* keyboard.c (this_command_keys): Make this a vector, instead of
Jim Blandy <jimb@redhat.com>
parents:
1404
diff
changeset
|
2330 apply_modifiers (modifiers & click_modifier, *slot); |
1328
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2331 Fput (*slot, Qevent_kind, symbol_kind); |
1310
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
2332 } |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
2333 |
1328
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2334 /* Apply modifiers to that symbol. */ |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2335 return apply_modifiers (modifiers, *slot); |
518 | 2336 } |
1328
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2337 |
518 | 2338 |
2339 DEFUN ("mouse-click-p", Fmouse_click_p, Smouse_click_p, 1, 1, 0, | |
2340 "Return non-nil iff OBJECT is a representation of a mouse event.\n\ | |
2341 A mouse event is a list of five elements whose car is a symbol of the\n\ | |
2342 form <MODIFIERS>mouse-<DIGIT>. I hope this is a temporary hack.") | |
2343 (object) | |
2344 Lisp_Object object; | |
2345 { | |
2346 if (EVENT_HAS_PARAMETERS (object) | |
2347 && EQ (EVENT_HEAD_KIND (EVENT_HEAD (object)), | |
2348 Qmouse_click)) | |
2349 return Qt; | |
2350 else | |
2351 return Qnil; | |
2352 } | |
2353 | |
2354 /* Store into *addr a value nonzero if terminal input chars are available. | |
2355 Serves the purpose of ioctl (0, FIONREAD, addr) | |
2356 but works even if FIONREAD does not exist. | |
2357 (In fact, this may actually read some input.) */ | |
2358 | |
2359 static void | |
2360 get_input_pending (addr) | |
2361 int *addr; | |
2362 { | |
2363 /* First of all, have we already counted some input? */ | |
2364 *addr = !NILP (Vquit_flag) || readable_events (); | |
2365 | |
2366 /* If input is being read as it arrives, and we have none, there is none. */ | |
2367 if (*addr > 0 || (interrupt_input && ! interrupts_deferred)) | |
2368 return; | |
2369 | |
2370 /* Try to read some input and see how much we get. */ | |
2371 gobble_input (0); | |
2372 *addr = !NILP (Vquit_flag) || readable_events (); | |
2373 } | |
2374 | |
2375 /* Interface to read_avail_input, blocking SIGIO if necessary. */ | |
2376 | |
2377 int | |
2378 gobble_input (expected) | |
2379 int expected; | |
2380 { | |
2381 #ifndef VMS | |
2382 #ifdef SIGIO | |
2383 if (interrupt_input) | |
2384 { | |
624 | 2385 SIGMASKTYPE mask; |
638 | 2386 mask = sigblockx (SIGIO); |
518 | 2387 read_avail_input (expected); |
638 | 2388 sigsetmask (mask); |
518 | 2389 } |
2390 else | |
2391 #endif | |
2392 read_avail_input (expected); | |
2393 #endif | |
2394 } | |
2395 | |
2396 #ifndef VMS | |
2397 | |
2398 /* Read any terminal input already buffered up by the system | |
2399 into the kbd_buffer, but do not wait. | |
2400 | |
2401 EXPECTED should be nonzero if the caller knows there is some input. | |
2402 | |
2403 Except on VMS, all input is read by this function. | |
2404 If interrupt_input is nonzero, this function MUST be called | |
2405 only when SIGIO is blocked. | |
2406 | |
2407 Returns the number of keyboard chars read, or -1 meaning | |
2408 this is a bad time to try to read input. */ | |
2409 | |
2410 static int | |
2411 read_avail_input (expected) | |
2412 int expected; | |
2413 { | |
2414 struct input_event buf[KBD_BUFFER_SIZE]; | |
2415 register int i; | |
2416 int nread; | |
2417 | |
2418 if (read_socket_hook) | |
2419 /* No need for FIONREAD or fcntl; just say don't wait. */ | |
2420 nread = (*read_socket_hook) (0, buf, KBD_BUFFER_SIZE, expected, expected); | |
2421 else | |
2422 { | |
2423 unsigned char cbuf[KBD_BUFFER_SIZE]; | |
2424 | |
2425 #ifdef FIONREAD | |
2426 /* Find out how much input is available. */ | |
2427 if (ioctl (0, FIONREAD, &nread) < 0) | |
2428 /* Formerly simply reported no input, but that sometimes led to | |
2429 a failure of Emacs to terminate. | |
2430 SIGHUP seems appropriate if we can't reach the terminal. */ | |
2431 kill (getpid (), SIGHUP); | |
2432 if (nread == 0) | |
2433 return 0; | |
2434 if (nread > sizeof cbuf) | |
2435 nread = sizeof cbuf; | |
2436 #else /* no FIONREAD */ | |
2437 #ifdef USG | |
2438 /* Read some input if available, but don't wait. */ | |
2439 nread = sizeof cbuf; | |
2440 fcntl (fileno (stdin), F_SETFL, O_NDELAY); | |
2441 #else | |
2442 you lose; | |
2443 #endif | |
2444 #endif | |
2445 | |
2446 /* Now read; for one reason or another, this will not block. */ | |
2447 while (1) | |
2448 { | |
2449 nread = read (fileno (stdin), cbuf, nread); | |
2450 #ifdef AIX | |
2451 /* The kernel sometimes fails to deliver SIGHUP for ptys. | |
2452 This looks incorrect, but it isn't, because _BSD causes | |
2453 O_NDELAY to be defined in fcntl.h as O_NONBLOCK, | |
2454 and that causes a value other than 0 when there is no input. */ | |
2455 if (nread == 0) | |
2456 kill (SIGHUP, 0); | |
2457 #endif | |
2458 /* Retry the read if it is interrupted. */ | |
2459 if (nread >= 0 | |
2460 || ! (errno == EAGAIN || errno == EFAULT | |
2461 #ifdef EBADSLT | |
2462 || errno == EBADSLT | |
2463 #endif | |
2464 )) | |
2465 break; | |
2466 } | |
2467 | |
2468 #ifndef FIONREAD | |
2469 #ifdef USG | |
2470 fcntl (fileno (stdin), F_SETFL, 0); | |
2471 #endif /* USG */ | |
2472 #endif /* no FIONREAD */ | |
2473 for (i = 0; i < nread; i++) | |
2474 { | |
2475 buf[i].kind = ascii_keystroke; | |
2476 XSET (buf[i].code, Lisp_Int, cbuf[i]); | |
765 | 2477 buf[i].frame = selected_frame; |
518 | 2478 } |
2479 } | |
2480 | |
2481 /* Scan the chars for C-g and store them in kbd_buffer. */ | |
2482 for (i = 0; i < nread; i++) | |
2483 { | |
2484 kbd_buffer_store_event (&buf[i]); | |
2485 /* Don't look at input that follows a C-g too closely. | |
2486 This reduces lossage due to autorepeat on C-g. */ | |
2487 if (buf[i].kind == ascii_keystroke | |
2488 && XINT(buf[i].code) == quit_char) | |
2489 break; | |
2490 } | |
2491 | |
2492 return nread; | |
2493 } | |
2494 #endif /* not VMS */ | |
2495 | |
2496 #ifdef SIGIO /* for entire page */ | |
2497 /* Note SIGIO has been undef'd if FIONREAD is missing. */ | |
2498 | |
1119
5d315d54b8b4
* keyboard.c (kbd_buffer_get_event): When performing the
Jim Blandy <jimb@redhat.com>
parents:
1104
diff
changeset
|
2499 SIGTYPE |
518 | 2500 input_available_signal (signo) |
2501 int signo; | |
2502 { | |
2503 /* Must preserve main program's value of errno. */ | |
2504 int old_errno = errno; | |
2505 #ifdef BSD4_1 | |
2506 extern int select_alarmed; | |
2507 #endif | |
2508 | |
2509 #ifdef USG | |
2510 /* USG systems forget handlers when they are used; | |
2511 must reestablish each time */ | |
2512 signal (signo, input_available_signal); | |
2513 #endif /* USG */ | |
2514 | |
2515 #ifdef BSD4_1 | |
2516 sigisheld (SIGIO); | |
2517 #endif | |
2518 | |
648 | 2519 if (input_available_clear_time) |
2520 EMACS_SET_SECS_USECS (*input_available_clear_time, 0, 0); | |
518 | 2521 |
2522 while (1) | |
2523 { | |
2524 int nread; | |
2525 nread = read_avail_input (1); | |
2526 /* -1 means it's not ok to read the input now. | |
2527 UNBLOCK_INPUT will read it later; now, avoid infinite loop. | |
2528 0 means there was no keyboard input available. */ | |
2529 if (nread <= 0) | |
2530 break; | |
2531 | |
2532 #ifdef BSD4_1 | |
2533 select_alarmed = 1; /* Force the select emulator back to life */ | |
2534 #endif | |
2535 } | |
2536 | |
2537 #ifdef BSD4_1 | |
2538 sigfree (); | |
2539 #endif | |
2540 errno = old_errno; | |
2541 } | |
2542 #endif /* SIGIO */ | |
2543 | |
2544 /* Return the prompt-string of a sparse keymap. | |
2545 This is the first element which is a string. | |
2546 Return nil if there is none. */ | |
2547 | |
2548 Lisp_Object | |
2549 map_prompt (map) | |
2550 Lisp_Object map; | |
2551 { | |
2552 while (CONSP (map)) | |
2553 { | |
2554 register Lisp_Object tem; | |
2555 tem = Fcar (map); | |
2556 if (XTYPE (tem) == Lisp_String) | |
2557 return tem; | |
2558 map = Fcdr (map); | |
2559 } | |
2560 return Qnil; | |
2561 } | |
2562 | |
2563 static int echo_flag; | |
2564 static int echo_now; | |
2565 | |
2566 /* Read a character like read_char but optionally prompt based on maps | |
1083
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2567 in the array MAPS. NMAPS is the length of MAPS. |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2568 |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2569 PREV_EVENT is the previous input event, or nil if we are reading |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2570 the first event of a key sequence. |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2571 |
1439
b3b2d1181d3a
* keyboard.c (this_command_keys): Make this a vector, instead of
Jim Blandy <jimb@redhat.com>
parents:
1404
diff
changeset
|
2572 If USED_MOUSE_MENU is non-zero, then we set *USED_MOUSE_MENU to 1 |
b3b2d1181d3a
* keyboard.c (this_command_keys): Make this a vector, instead of
Jim Blandy <jimb@redhat.com>
parents:
1404
diff
changeset
|
2573 if we used a mouse menu to read the input, or zero otherwise. If |
b3b2d1181d3a
* keyboard.c (this_command_keys): Make this a vector, instead of
Jim Blandy <jimb@redhat.com>
parents:
1404
diff
changeset
|
2574 USED_MOUSE_MENU is zero, *USED_MOUSE_MENU is left alone. |
518 | 2575 |
2576 The prompting is done based on the prompt-string of the map | |
2577 and the strings associated with various map elements. */ | |
2578 | |
2579 Lisp_Object | |
1083
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2580 read_char_menu_prompt (nmaps, maps, prev_event, used_mouse_menu) |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2581 int nmaps; |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2582 Lisp_Object *maps; |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2583 Lisp_Object prev_event; |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2584 int *used_mouse_menu; |
518 | 2585 { |
1083
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2586 int mapno; |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2587 register Lisp_Object name; |
518 | 2588 int nlength; |
765 | 2589 int width = FRAME_WIDTH (selected_frame) - 4; |
1083
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2590 char *menu = (char *) alloca (width + 4); |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2591 int idx = -1; |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2592 Lisp_Object rest, vector; |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2593 |
1439
b3b2d1181d3a
* keyboard.c (this_command_keys): Make this a vector, instead of
Jim Blandy <jimb@redhat.com>
parents:
1404
diff
changeset
|
2594 if (used_mouse_menu) |
b3b2d1181d3a
* keyboard.c (this_command_keys): Make this a vector, instead of
Jim Blandy <jimb@redhat.com>
parents:
1404
diff
changeset
|
2595 *used_mouse_menu = 0; |
518 | 2596 |
2597 /* Use local over global Menu maps */ | |
2598 | |
1083
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2599 if (! menu_prompting) |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2600 return Qnil; |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2601 |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2602 /* Get the menu name from the first map that has one (a prompt string). */ |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2603 for (mapno = 0; mapno < nmaps; mapno++) |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2604 { |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2605 name = map_prompt (maps[mapno]); |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2606 if (!NILP (name)) |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2607 break; |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2608 } |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2609 |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2610 /* If we don't have any menus, just read a character normally. */ |
518 | 2611 if (NILP (name)) |
1083
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2612 return Qnil; |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2613 |
1140
5c36807e445c
(read_char_menu_prompt): Use X menu code if HAVE_X_WINDOWS and not NO_X_MENU.
Richard M. Stallman <rms@gnu.org>
parents:
1119
diff
changeset
|
2614 #ifdef HAVE_X_WINDOW |
5c36807e445c
(read_char_menu_prompt): Use X menu code if HAVE_X_WINDOWS and not NO_X_MENU.
Richard M. Stallman <rms@gnu.org>
parents:
1119
diff
changeset
|
2615 #ifndef NO_X_MENU |
1083
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2616 /* If we got to this point via a mouse click, |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2617 use a real menu for mouse selection. */ |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2618 if (XTYPE (prev_event) == Lisp_Cons) |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2619 { |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2620 /* Display the menu and get the selection. */ |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2621 Lisp_Object *realmaps |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2622 = (Lisp_Object *) alloca (nmaps * sizeof (Lisp_Object)); |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2623 Lisp_Object value; |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2624 int nmaps1 = 0; |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2625 |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2626 /* Use the maps that are not nil. */ |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2627 for (mapno = 0; mapno < nmaps; mapno++) |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2628 if (!NILP (maps[mapno])) |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2629 realmaps[nmaps1++] = maps[mapno]; |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2630 |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2631 value = Fx_popup_menu (prev_event, Flist (nmaps1, realmaps)); |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2632 if (NILP (value)) |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2633 XSET (value, Lisp_Int, quit_char); |
1439
b3b2d1181d3a
* keyboard.c (this_command_keys): Make this a vector, instead of
Jim Blandy <jimb@redhat.com>
parents:
1404
diff
changeset
|
2634 if (used_mouse_menu) |
b3b2d1181d3a
* keyboard.c (this_command_keys): Make this a vector, instead of
Jim Blandy <jimb@redhat.com>
parents:
1404
diff
changeset
|
2635 *used_mouse_menu = 1; |
1083
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2636 return value; |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2637 } |
1140
5c36807e445c
(read_char_menu_prompt): Use X menu code if HAVE_X_WINDOWS and not NO_X_MENU.
Richard M. Stallman <rms@gnu.org>
parents:
1119
diff
changeset
|
2638 #endif /* not NO_X_MENU */ |
5c36807e445c
(read_char_menu_prompt): Use X menu code if HAVE_X_WINDOWS and not NO_X_MENU.
Richard M. Stallman <rms@gnu.org>
parents:
1119
diff
changeset
|
2639 #endif /* HAVE_X_WINDOW */ |
518 | 2640 |
2641 /* Prompt string always starts with map's prompt, and a space. */ | |
2642 strcpy (menu, XSTRING (name)->data); | |
2643 nlength = XSTRING (name)->size; | |
1083
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2644 menu[nlength++] = ':'; |
518 | 2645 menu[nlength++] = ' '; |
2646 menu[nlength] = 0; | |
2647 | |
1083
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2648 /* Start prompting at start of first map. */ |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2649 mapno = 0; |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2650 rest = maps[mapno]; |
518 | 2651 |
2652 /* Present the documented bindings, a line at a time. */ | |
2653 while (1) | |
2654 { | |
2655 int notfirst = 0; | |
2656 int i = nlength; | |
2657 Lisp_Object obj; | |
2658 int ch; | |
2659 | |
2660 /* Loop over elements of map. */ | |
1083
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2661 while (i < width) |
518 | 2662 { |
1083
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2663 Lisp_Object s, elt; |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2664 |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2665 /* If reached end of map, start at beginning of next map. */ |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2666 if (NILP (rest)) |
518 | 2667 { |
1083
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2668 mapno++; |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2669 /* At end of last map, wrap around to first map if just starting, |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2670 or end this line if already have something on it. */ |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2671 if (mapno == nmaps) |
518 | 2672 { |
1083
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2673 if (notfirst) |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2674 break; |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2675 else |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2676 mapno = 0; |
518 | 2677 } |
1083
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2678 rest = maps[mapno]; |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2679 } |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2680 |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2681 /* Look at the next element of the map. */ |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2682 if (idx >= 0) |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2683 elt = XVECTOR (vector)->contents[idx]; |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2684 else |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2685 elt = Fcar_safe (rest); |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2686 |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2687 if (idx < 0 && XTYPE (elt) == Lisp_Vector) |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2688 { |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2689 /* If we found a dense table in the keymap, |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2690 advanced past it, but start scanning its contents. */ |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2691 rest = Fcdr_safe (rest); |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2692 vector = elt; |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2693 idx = 0; |
518 | 2694 } |
2695 else | |
2696 { | |
1083
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2697 /* An ordinary element. */ |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2698 s = Fcar_safe (Fcdr_safe (elt)); |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2699 if (XTYPE (s) != Lisp_String) |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2700 /* Ignore the element if it has no prompt string. */ |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2701 ; |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2702 /* If we have room for the prompt string, add it to this line. |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2703 If this is the first on the line, always add it. */ |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2704 else if (XSTRING (s)->size + i < width |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2705 || !notfirst) |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2706 { |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2707 int thiswidth; |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2708 |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2709 /* Punctuate between strings. */ |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2710 if (notfirst) |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2711 { |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2712 strcpy (menu + i, ", "); |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2713 i += 2; |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2714 } |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2715 notfirst = 1; |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2716 |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2717 /* Add as much of string as fits. */ |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2718 thiswidth = XSTRING (s)->size; |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2719 if (thiswidth + i > width) |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2720 thiswidth = width - i; |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2721 bcopy (XSTRING (s)->data, menu + i, thiswidth); |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2722 i += thiswidth; |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2723 } |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2724 else |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2725 { |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2726 /* If this element does not fit, end the line now, |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2727 and save the element for the next line. */ |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2728 strcpy (menu + i, "..."); |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2729 break; |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2730 } |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2731 |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2732 /* Move past this element. */ |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2733 if (idx >= 0 && idx + 1 >= XVECTOR (rest)->size) |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2734 /* Handle reaching end of dense table. */ |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2735 idx = -1; |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2736 if (idx >= 0) |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2737 idx++; |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2738 else |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2739 rest = Fcdr_safe (rest); |
518 | 2740 } |
2741 } | |
2742 | |
2743 /* Prompt with that and read response. */ | |
2744 message1 (menu); | |
1083
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2745 obj = read_char (1, 0, 0, Qnil, 0); |
518 | 2746 |
2747 if (XTYPE (obj) != Lisp_Int) | |
2748 return obj; | |
2749 else | |
2750 ch = XINT (obj); | |
2751 | |
1515
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
2752 if (! EQ (obj, menu_prompt_more_char) |
518 | 2753 && (XTYPE (menu_prompt_more_char) != Lisp_Int |
1515
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
2754 || ! EQ (obj, make_number (Ctl (XINT (menu_prompt_more_char)))))) |
518 | 2755 return obj; |
2756 } | |
2757 } | |
2758 | |
2759 /* Reading key sequences. */ | |
2760 | |
2761 /* Follow KEY in the maps in CURRENT[0..NMAPS-1], placing its bindings | |
2762 in DEFS[0..NMAPS-1]. Set NEXT[i] to DEFS[i] if DEFS[i] is a | |
2763 keymap, or nil otherwise. Return the index of the first keymap in | |
2764 which KEY has any binding, or NMAPS if no map has a binding. | |
2765 | |
2766 If KEY is a meta ASCII character, treat it like meta-prefix-char | |
2767 followed by the corresponding non-meta character. Keymaps in | |
2768 CURRENT with non-prefix bindings for meta-prefix-char become nil in | |
2769 NEXT. | |
2770 | |
2771 When KEY is not defined in any of the keymaps, if it is an upper | |
2772 case letter and there are bindings for the corresponding lower-case | |
2773 letter, return the bindings for the lower-case letter. | |
2774 | |
1310
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
2775 If KEY has no bindings in any of the CURRENT maps, NEXT is left |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
2776 unmodified. |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
2777 |
518 | 2778 NEXT may == CURRENT. */ |
2779 | |
2780 static int | |
2781 follow_key (key, nmaps, current, defs, next) | |
2782 Lisp_Object key; | |
2783 Lisp_Object *current, *defs, *next; | |
2784 int nmaps; | |
2785 { | |
2786 int i, first_binding; | |
2787 | |
2788 /* If KEY is a meta ASCII character, treat it like meta-prefix-char | |
2789 followed by the corresponding non-meta character. */ | |
2790 if (XTYPE (key) == Lisp_Int | |
2791 && XINT (key) >= 0200) | |
2792 { | |
2793 for (i = 0; i < nmaps; i++) | |
2794 if (! NILP (current[i])) | |
2795 { | |
1386
5845050f9d5c
* keyboard.c (Vlast_event_frame): Make this variable exist even
Jim Blandy <jimb@redhat.com>
parents:
1328
diff
changeset
|
2796 next[i] = |
5845050f9d5c
* keyboard.c (Vlast_event_frame): Make this variable exist even
Jim Blandy <jimb@redhat.com>
parents:
1328
diff
changeset
|
2797 get_keyelt (access_keymap (current[i], meta_prefix_char, 1)); |
518 | 2798 |
2799 /* Note that since we pass the resulting bindings through | |
2800 get_keymap_1, non-prefix bindings for meta-prefix-char | |
2801 disappear. */ | |
1515
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
2802 next[i] = get_keymap_1 (next[i], 0, 1); |
518 | 2803 } |
2804 else | |
2805 next[i] = Qnil; | |
2806 | |
2807 current = next; | |
2808 XSET (key, Lisp_Int, XFASTINT (key) & 0177); | |
2809 } | |
2810 | |
2811 first_binding = nmaps; | |
2812 for (i = nmaps - 1; i >= 0; i--) | |
2813 { | |
2814 if (! NILP (current[i])) | |
2815 { | |
1386
5845050f9d5c
* keyboard.c (Vlast_event_frame): Make this variable exist even
Jim Blandy <jimb@redhat.com>
parents:
1328
diff
changeset
|
2816 defs[i] = get_keyelt (access_keymap (current[i], key, 1)); |
518 | 2817 if (! NILP (defs[i])) |
2818 first_binding = i; | |
2819 } | |
2820 else | |
2821 defs[i] = Qnil; | |
2822 } | |
2823 | |
2824 /* When KEY is not defined in any of the keymaps, if it is an upper | |
2825 case letter and there are bindings for the corresponding | |
2826 lower-case letter, return the bindings for the lower-case letter. */ | |
2827 if (first_binding == nmaps | |
2828 && XTYPE (key) == Lisp_Int | |
2829 && UPPERCASEP (XINT (key))) | |
2830 { | |
2831 XSETINT (key, DOWNCASE (XINT (key))); | |
2832 | |
2833 first_binding = nmaps; | |
2834 for (i = nmaps - 1; i >= 0; i--) | |
2835 { | |
2836 if (! NILP (current[i])) | |
2837 { | |
1386
5845050f9d5c
* keyboard.c (Vlast_event_frame): Make this variable exist even
Jim Blandy <jimb@redhat.com>
parents:
1328
diff
changeset
|
2838 defs[i] = get_keyelt (access_keymap (current[i], key, 1)); |
518 | 2839 if (! NILP (defs[i])) |
2840 first_binding = i; | |
2841 } | |
2842 else | |
2843 defs[i] = Qnil; | |
2844 } | |
2845 } | |
2846 | |
2847 /* Given the set of bindings we've found, produce the next set of maps. */ | |
1328
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2848 if (first_binding < nmaps) |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2849 for (i = 0; i < nmaps; i++) |
1515
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
2850 next[i] = NILP (defs[i]) ? Qnil : get_keymap_1 (defs[i], 0, 1); |
518 | 2851 |
2852 return first_binding; | |
2853 } | |
2854 | |
1515
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
2855 /* Read a sequence of keys that ends with a non prefix character, |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
2856 storing it in KEYBUF, a buffer of size BUFSIZE. |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
2857 Prompt with PROMPT. |
518 | 2858 Return the length of the key sequence stored. |
2859 | |
1515
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
2860 Echo starting immediately unless `prompt' is 0. |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
2861 |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
2862 Where a key sequence ends depends on the currently active keymaps. |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
2863 These include any minor mode keymaps active in the current buffer, |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
2864 the current buffer's local map, and the global map. |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
2865 |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
2866 If a key sequence has no other bindings, we check Vfunction_key_map |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
2867 to see if some trailing subsequence might be the beginning of a |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
2868 function key's sequence. If so, we try to read the whole function |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
2869 key, and substitute its symbolic name into the key sequence. |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
2870 |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
2871 We ignore unbound `down-' mouse clicks. We turn unbound `drag-' |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
2872 events into similar click events, if that would make them bound. |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
2873 |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
2874 If we get a mouse click in a mode line, vertical divider, or other |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
2875 non-text area, we treat the click as if it were prefixed by the |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
2876 symbol denoting that area - `mode-line', `vertical-line', or |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
2877 whatever. |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
2878 |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
2879 If the sequence starts with a mouse click, we read the key sequence |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
2880 with respect to the buffer clicked on, not the current buffer. |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
2881 |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
2882 If the user switches frames in the midst of a key sequence, we put |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
2883 off the switch-frame event until later; the next call to |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
2884 read_char will return it. */ |
518 | 2885 static int |
2886 read_key_sequence (keybuf, bufsize, prompt) | |
2887 Lisp_Object *keybuf; | |
2888 int bufsize; | |
1515
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
2889 char *prompt; |
518 | 2890 { |
1515
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
2891 int count = specpdl_ptr - specpdl; |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
2892 |
518 | 2893 /* How many keys there are in the current key sequence. */ |
2894 int t; | |
2895 | |
2896 /* The length of the echo buffer when we started reading, and | |
2897 the length of this_command_keys when we started reading. */ | |
2898 int echo_start; | |
1515
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
2899 int keys_start; |
518 | 2900 |
2901 /* The number of keymaps we're scanning right now, and the number of | |
2902 keymaps we have allocated space for. */ | |
2903 int nmaps; | |
2904 int nmaps_allocated = 0; | |
2905 | |
2906 /* defs[0..nmaps-1] are the definitions of KEYBUF[0..t-1] in | |
2907 the current keymaps. */ | |
2908 Lisp_Object *defs; | |
2909 | |
1515
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
2910 /* submaps[0..nmaps-1] are the prefix definitions of KEYBUF[0..t-1] |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
2911 in the current keymaps, or nil where it is not a prefix. */ |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
2912 Lisp_Object *submaps; |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
2913 |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
2914 /* The index in defs[] of the first keymap that has a binding for |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
2915 this key sequence. In other words, the lowest i such that |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
2916 defs[i] is non-nil. */ |
518 | 2917 int first_binding; |
2918 | |
1515
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
2919 /* If t < mock_input, then KEYBUF[t] should be read as the next |
899 | 2920 input key. |
2921 | |
2922 We use this to recover after recognizing a function key. Once we | |
2923 realize that a suffix of the current key sequence is actually a | |
2924 function key's escape sequence, we replace the suffix with the | |
2925 function key's binding from Vfunction_key_map. Now keybuf | |
1515
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
2926 contains a new and different key sequence, so the echo area, |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
2927 this_command_keys, and the submaps and defs arrays are wrong. In |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
2928 this situation, we set mock_input to t, set t to 0, and jump to |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
2929 restart_sequence; the loop will read keys from keybuf up until |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
2930 mock_input, thus rebuilding the state; and then it will resume |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
2931 reading characters from the keyboard. */ |
518 | 2932 int mock_input = 0; |
2933 | |
899 | 2934 /* If the sequence is unbound in submaps[], then |
1515
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
2935 keybuf[fkey_start..fkey_end-1] is a prefix in Vfunction_key_map, |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
2936 and fkey_map is its binding. |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
2937 |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
2938 These might be > t, indicating that all function key scanning |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
2939 should hold off until t reaches them. We do this when we've just |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
2940 recognized a function key, to avoid searching for the function |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
2941 key's again in Vfunction_key_map. */ |
518 | 2942 int fkey_start = 0, fkey_end = 0; |
2943 Lisp_Object fkey_map = Vfunction_key_map; | |
2944 | |
1386
5845050f9d5c
* keyboard.c (Vlast_event_frame): Make this variable exist even
Jim Blandy <jimb@redhat.com>
parents:
1328
diff
changeset
|
2945 /* If we receive a ``switch-frame'' event in the middle of a key sequence, |
5845050f9d5c
* keyboard.c (Vlast_event_frame): Make this variable exist even
Jim Blandy <jimb@redhat.com>
parents:
1328
diff
changeset
|
2946 we put it off for later. While we're reading, we keep the event here. */ |
5845050f9d5c
* keyboard.c (Vlast_event_frame): Make this variable exist even
Jim Blandy <jimb@redhat.com>
parents:
1328
diff
changeset
|
2947 Lisp_Object delayed_switch_frame = Qnil; |
5845050f9d5c
* keyboard.c (Vlast_event_frame): Make this variable exist even
Jim Blandy <jimb@redhat.com>
parents:
1328
diff
changeset
|
2948 |
1515
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
2949 |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
2950 /* If there is no function key map, turn off function key scanning. */ |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
2951 if (NILP (Fkeymapp (Vfunction_key_map))) |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
2952 fkey_start = fkey_end = bufsize + 1; |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
2953 |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
2954 /* We need to save the current buffer in case we switch buffers to |
1590
11cd7c23f538
* keyboard.c (unread_switch_frame): Don't declare this static.
Jim Blandy <jimb@redhat.com>
parents:
1565
diff
changeset
|
2955 find the right binding for a mouse click. Note that we can't use |
11cd7c23f538
* keyboard.c (unread_switch_frame): Don't declare this static.
Jim Blandy <jimb@redhat.com>
parents:
1565
diff
changeset
|
2956 save_excursion_{save,restore} here, because they save point as |
11cd7c23f538
* keyboard.c (unread_switch_frame): Don't declare this static.
Jim Blandy <jimb@redhat.com>
parents:
1565
diff
changeset
|
2957 well as the current buffer; we don't want to save point, because |
11cd7c23f538
* keyboard.c (unread_switch_frame): Don't declare this static.
Jim Blandy <jimb@redhat.com>
parents:
1565
diff
changeset
|
2958 redisplay may change it, to accomodate a Fset_window_start or |
11cd7c23f538
* keyboard.c (unread_switch_frame): Don't declare this static.
Jim Blandy <jimb@redhat.com>
parents:
1565
diff
changeset
|
2959 something. */ |
11cd7c23f538
* keyboard.c (unread_switch_frame): Don't declare this static.
Jim Blandy <jimb@redhat.com>
parents:
1565
diff
changeset
|
2960 record_unwind_protect (Fset_buffer, Fcurrent_buffer ()); |
1515
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
2961 |
1083
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2962 last_nonmenu_event = Qnil; |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
2963 |
518 | 2964 if (INTERACTIVE) |
2965 { | |
2966 if (prompt) | |
2967 echo_prompt (prompt); | |
2968 else if (cursor_in_echo_area) | |
2969 /* This doesn't put in a dash if the echo buffer is empty, so | |
2970 you don't always see a dash hanging out in the minibuffer. */ | |
2971 echo_dash (); | |
2972 } | |
2973 | |
1515
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
2974 /* Record the initial state of the echo area and this_command_keys; |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
2975 we will need to restore them if we replay a key sequence. */ |
1328
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
2976 if (INTERACTIVE) |
1515
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
2977 echo_start = echo_length (); |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
2978 keys_start = this_command_key_count; |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
2979 |
1565
a681f63f93fa
* keyboard.c (read_key_sequence): Removed the
Jim Blandy <jimb@redhat.com>
parents:
1515
diff
changeset
|
2980 replay_sequence: |
1515
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
2981 /* Build our list of keymaps. |
1565
a681f63f93fa
* keyboard.c (read_key_sequence): Removed the
Jim Blandy <jimb@redhat.com>
parents:
1515
diff
changeset
|
2982 If we recognize a function key and replace its escape sequence in |
a681f63f93fa
* keyboard.c (read_key_sequence): Removed the
Jim Blandy <jimb@redhat.com>
parents:
1515
diff
changeset
|
2983 keybuf with its symbol, or if the sequence starts with a mouse |
a681f63f93fa
* keyboard.c (read_key_sequence): Removed the
Jim Blandy <jimb@redhat.com>
parents:
1515
diff
changeset
|
2984 click and we need to switch buffers, we jump back here to rebuild |
a681f63f93fa
* keyboard.c (read_key_sequence): Removed the
Jim Blandy <jimb@redhat.com>
parents:
1515
diff
changeset
|
2985 the initial keymaps from the current buffer. */ |
518 | 2986 { |
2987 Lisp_Object *maps; | |
2988 | |
2989 nmaps = current_minor_maps (0, &maps) + 2; | |
2990 if (nmaps > nmaps_allocated) | |
2991 { | |
899 | 2992 submaps = (Lisp_Object *) alloca (nmaps * sizeof (submaps[0])); |
518 | 2993 defs = (Lisp_Object *) alloca (nmaps * sizeof (defs[0])); |
2994 nmaps_allocated = nmaps; | |
2995 } | |
899 | 2996 bcopy (maps, submaps, (nmaps - 2) * sizeof (submaps[0])); |
1515
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
2997 submaps[nmaps-2] = current_buffer->keymap; |
899 | 2998 submaps[nmaps-1] = global_map; |
518 | 2999 } |
3000 | |
3001 /* Find an accurate initial value for first_binding. */ | |
3002 for (first_binding = 0; first_binding < nmaps; first_binding++) | |
899 | 3003 if (! NILP (submaps[first_binding])) |
518 | 3004 break; |
3005 | |
1515
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3006 /* We jump here when a function key substitution has forced us to |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3007 reprocess the current key sequence. keybuf[0..mock_input] is the |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3008 sequence we want to reread. */ |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3009 t = 0; |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3010 |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3011 /* These are no-ops the first time through, but if we restart, they |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3012 revert the echo area and this_command_keys to their original state. */ |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3013 this_command_key_count = keys_start; |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3014 if (INTERACTIVE) |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3015 echo_truncate (echo_start); |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3016 |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3017 /* If the best binding for the current key sequence is a keymap, |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3018 or we may be looking at a function key's escape sequence, keep |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3019 on reading. */ |
899 | 3020 while ((first_binding < nmaps && ! NILP (submaps[first_binding])) |
518 | 3021 || (first_binding >= nmaps && fkey_start < t)) |
3022 { | |
3023 Lisp_Object key; | |
1083
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
3024 int used_mouse_menu = 0; |
518 | 3025 |
1328
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
3026 /* These variables are analogous to echo_start and keys_start; |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
3027 while those allow us to restart the entire key sequence, |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
3028 echo_local_start and keys_local_start allow us to throw away |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
3029 just one key. */ |
1515
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3030 int echo_local_start, keys_local_start, local_first_binding; |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3031 |
518 | 3032 if (t >= bufsize) |
3033 error ("key sequence too long"); | |
3034 | |
1515
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3035 if (INTERACTIVE) |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3036 echo_local_start = echo_length (); |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3037 keys_local_start = this_command_key_count; |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3038 local_first_binding = first_binding; |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3039 |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3040 replay_key: |
1328
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
3041 /* These are no-ops, unless we throw away a keystroke below and |
1515
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3042 jumped back up to replay_key; in that case, these restore the |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3043 variables to their original state, allowing us to replay the |
1328
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
3044 loop. */ |
1515
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3045 if (INTERACTIVE) |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3046 echo_truncate (echo_local_start); |
1328
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
3047 this_command_key_count = keys_local_start; |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
3048 first_binding = local_first_binding; |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
3049 |
1515
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3050 /* Does mock_input indicate that we are re-reading a key sequence? */ |
518 | 3051 if (t < mock_input) |
3052 { | |
3053 key = keybuf[t]; | |
3054 add_command_key (key); | |
3055 echo_char (key); | |
3056 } | |
899 | 3057 |
3058 /* If not, we should actually read a character. */ | |
518 | 3059 else |
3060 { | |
1083
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
3061 key = read_char (!prompt, nmaps, submaps, last_nonmenu_event, |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
3062 &used_mouse_menu); |
518 | 3063 |
1515
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3064 /* read_char returns -1 at the end of a macro. |
518 | 3065 Emacs 18 handles this by returning immediately with a |
3066 zero, so that's what we'll do. */ | |
3067 if (XTYPE (key) == Lisp_Int && XINT (key) < 0) | |
1386
5845050f9d5c
* keyboard.c (Vlast_event_frame): Make this variable exist even
Jim Blandy <jimb@redhat.com>
parents:
1328
diff
changeset
|
3068 { |
1515
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3069 t = 0; |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3070 goto done; |
1386
5845050f9d5c
* keyboard.c (Vlast_event_frame): Make this variable exist even
Jim Blandy <jimb@redhat.com>
parents:
1328
diff
changeset
|
3071 } |
518 | 3072 |
3073 Vquit_flag = Qnil; | |
3074 | |
1328
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
3075 /* Clicks in non-text areas get prefixed by the symbol |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
3076 in their CHAR-ADDRESS field. For example, a click on |
1515
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3077 the mode line is prefixed by the symbol `mode-line'. |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3078 |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3079 Furthermore, key sequences beginning with mouse clicks |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3080 are read using the keymaps of the buffer clicked on, not |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3081 the current buffer. So we may have to switch the buffer |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3082 here. */ |
1386
5845050f9d5c
* keyboard.c (Vlast_event_frame): Make this variable exist even
Jim Blandy <jimb@redhat.com>
parents:
1328
diff
changeset
|
3083 if (EVENT_HAS_PARAMETERS (key)) |
1328
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
3084 { |
1386
5845050f9d5c
* keyboard.c (Vlast_event_frame): Make this variable exist even
Jim Blandy <jimb@redhat.com>
parents:
1328
diff
changeset
|
3085 Lisp_Object kind = EVENT_HEAD_KIND (EVENT_HEAD (key)); |
1515
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3086 |
1386
5845050f9d5c
* keyboard.c (Vlast_event_frame): Make this variable exist even
Jim Blandy <jimb@redhat.com>
parents:
1328
diff
changeset
|
3087 if (EQ (kind, Qmouse_click)) |
1328
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
3088 { |
1515
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3089 Lisp_Object window = POSN_WINDOW (EVENT_START (key)); |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3090 Lisp_Object posn = POSN_BUFFER_POSN (EVENT_START (key)); |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3091 |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3092 /* Key sequences beginning with mouse clicks are |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3093 read using the keymaps in the buffer clicked on, |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3094 not the current buffer. If we're at the |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3095 beginning of a key sequence, switch buffers. */ |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3096 if (t == 0 |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3097 && XTYPE (window) == Lisp_Window |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3098 && XTYPE (XWINDOW (window)->buffer) == Lisp_Buffer |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3099 && XBUFFER (XWINDOW (window)->buffer) != current_buffer) |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3100 { |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3101 if (XTYPE (posn) == Lisp_Symbol) |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3102 { |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3103 if (t + 1 >= bufsize) |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3104 error ("key sequence too long"); |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3105 keybuf[t] = posn; |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3106 keybuf[t+1] = key; |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3107 mock_input = t + 2; |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3108 } |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3109 else |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3110 { |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3111 keybuf[t] = key; |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3112 mock_input = t + 1; |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3113 } |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3114 |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3115 set_buffer_internal (XBUFFER (XWINDOW (window)->buffer)); |
1565
a681f63f93fa
* keyboard.c (read_key_sequence): Removed the
Jim Blandy <jimb@redhat.com>
parents:
1515
diff
changeset
|
3116 goto replay_sequence; |
1515
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3117 } |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3118 else if (XTYPE (posn) == Lisp_Symbol) |
1386
5845050f9d5c
* keyboard.c (Vlast_event_frame): Make this variable exist even
Jim Blandy <jimb@redhat.com>
parents:
1328
diff
changeset
|
3119 { |
5845050f9d5c
* keyboard.c (Vlast_event_frame): Make this variable exist even
Jim Blandy <jimb@redhat.com>
parents:
1328
diff
changeset
|
3120 if (t + 1 >= bufsize) |
5845050f9d5c
* keyboard.c (Vlast_event_frame): Make this variable exist even
Jim Blandy <jimb@redhat.com>
parents:
1328
diff
changeset
|
3121 error ("key sequence too long"); |
5845050f9d5c
* keyboard.c (Vlast_event_frame): Make this variable exist even
Jim Blandy <jimb@redhat.com>
parents:
1328
diff
changeset
|
3122 keybuf[t] = posn; |
5845050f9d5c
* keyboard.c (Vlast_event_frame): Make this variable exist even
Jim Blandy <jimb@redhat.com>
parents:
1328
diff
changeset
|
3123 keybuf[t+1] = key; |
5845050f9d5c
* keyboard.c (Vlast_event_frame): Make this variable exist even
Jim Blandy <jimb@redhat.com>
parents:
1328
diff
changeset
|
3124 mock_input = t + 2; |
5845050f9d5c
* keyboard.c (Vlast_event_frame): Make this variable exist even
Jim Blandy <jimb@redhat.com>
parents:
1328
diff
changeset
|
3125 |
1515
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3126 goto replay_key; |
1386
5845050f9d5c
* keyboard.c (Vlast_event_frame): Make this variable exist even
Jim Blandy <jimb@redhat.com>
parents:
1328
diff
changeset
|
3127 } |
5845050f9d5c
* keyboard.c (Vlast_event_frame): Make this variable exist even
Jim Blandy <jimb@redhat.com>
parents:
1328
diff
changeset
|
3128 } |
5845050f9d5c
* keyboard.c (Vlast_event_frame): Make this variable exist even
Jim Blandy <jimb@redhat.com>
parents:
1328
diff
changeset
|
3129 else if (EQ (kind, Qswitch_frame)) |
5845050f9d5c
* keyboard.c (Vlast_event_frame): Make this variable exist even
Jim Blandy <jimb@redhat.com>
parents:
1328
diff
changeset
|
3130 { |
5845050f9d5c
* keyboard.c (Vlast_event_frame): Make this variable exist even
Jim Blandy <jimb@redhat.com>
parents:
1328
diff
changeset
|
3131 /* If we're at the beginning of a key sequence, go |
5845050f9d5c
* keyboard.c (Vlast_event_frame): Make this variable exist even
Jim Blandy <jimb@redhat.com>
parents:
1328
diff
changeset
|
3132 ahead and return this event. If we're in the |
5845050f9d5c
* keyboard.c (Vlast_event_frame): Make this variable exist even
Jim Blandy <jimb@redhat.com>
parents:
1328
diff
changeset
|
3133 midst of a key sequence, delay it until the end. */ |
5845050f9d5c
* keyboard.c (Vlast_event_frame): Make this variable exist even
Jim Blandy <jimb@redhat.com>
parents:
1328
diff
changeset
|
3134 if (t > 0) |
5845050f9d5c
* keyboard.c (Vlast_event_frame): Make this variable exist even
Jim Blandy <jimb@redhat.com>
parents:
1328
diff
changeset
|
3135 { |
5845050f9d5c
* keyboard.c (Vlast_event_frame): Make this variable exist even
Jim Blandy <jimb@redhat.com>
parents:
1328
diff
changeset
|
3136 delayed_switch_frame = key; |
1515
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3137 goto replay_key; |
1386
5845050f9d5c
* keyboard.c (Vlast_event_frame): Make this variable exist even
Jim Blandy <jimb@redhat.com>
parents:
1328
diff
changeset
|
3138 } |
1328
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
3139 } |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
3140 } |
518 | 3141 } |
1515
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3142 |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3143 /* We have finally decided that KEY is something we might want |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3144 to look up. */ |
518 | 3145 first_binding = (follow_key (key, |
3146 nmaps - first_binding, | |
899 | 3147 submaps + first_binding, |
518 | 3148 defs + first_binding, |
899 | 3149 submaps + first_binding) |
518 | 3150 + first_binding); |
1328
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
3151 |
1515
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3152 /* If KEY wasn't bound, we'll try some fallbacks. */ |
1328
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
3153 if (first_binding >= nmaps) |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
3154 { |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
3155 Lisp_Object head = EVENT_HEAD (key); |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
3156 |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
3157 if (XTYPE (head) == Lisp_Symbol) |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
3158 { |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
3159 Lisp_Object breakdown = parse_modifiers (head); |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
3160 Lisp_Object modifiers = |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
3161 XINT (XCONS (XCONS (breakdown)->cdr)->car); |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
3162 |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
3163 /* We drop unbound `down-' events altogether. */ |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
3164 if (modifiers & down_modifier) |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
3165 { |
1515
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3166 /* To make sure that mock_input doesn't just give |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3167 this event back to us; we want to delete this |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3168 event from the mock input queue. We could delete |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3169 keybuf[t] and shift everything after that to the |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3170 left by one spot, but we'd also have to fix up |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3171 any variable that points into keybuf, and shifting |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3172 isn't really necessary anyway. |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3173 |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3174 Adding prefixes for non-textual mouse clicks creates |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3175 two characters of mock input, and this must be the |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3176 second, so mock_input would be over anyway; it's okay |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3177 to zero it. |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3178 |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3179 Beyond that, only function key expansion could |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3180 create more than two keys, but that should never |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3181 generate mouse events, so it's okay to zero |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3182 mock_input in that case too. |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3183 |
1328
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
3184 Isn't this just the most wonderful code ever? */ |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
3185 mock_input = 0; |
1515
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3186 goto replay_key; |
1328
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
3187 } |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
3188 |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
3189 /* We turn unbound `drag-' events into `click-' |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
3190 events, if the click would be bound. */ |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
3191 else if (modifiers & drag_modifier) |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
3192 { |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
3193 Lisp_Object new_head = |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
3194 apply_modifiers (modifiers & ~drag_modifier, |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
3195 XCONS (breakdown)->car); |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
3196 Lisp_Object new_click = |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
3197 Fcons (new_head, Fcons (EVENT_START (key), Qnil)); |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
3198 |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
3199 /* Look for a binding for this new key. follow_key |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
3200 promises that it didn't munge submaps the |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
3201 last time we called it, since key was unbound. */ |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
3202 first_binding = |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
3203 (follow_key (new_click, |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
3204 nmaps - local_first_binding, |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
3205 submaps + local_first_binding, |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
3206 defs + local_first_binding, |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
3207 submaps + local_first_binding) |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
3208 + local_first_binding); |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
3209 |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
3210 /* If that click is bound, go for it. */ |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
3211 if (first_binding < nmaps) |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
3212 key = new_click; |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
3213 /* Otherwise, we'll leave key set to the drag event. */ |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
3214 } |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
3215 } |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
3216 } |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
3217 |
518 | 3218 keybuf[t++] = key; |
1083
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
3219 /* Normally, last_nonmenu_event gets the previous key we read. |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
3220 But when a mouse popup menu is being used, |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
3221 we don't update last_nonmenu_event; it continues to hold the mouse |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
3222 event that preceded the first level of menu. */ |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
3223 if (!used_mouse_menu) |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
3224 last_nonmenu_event = key; |
518 | 3225 |
3226 /* If the sequence is unbound, see if we can hang a function key | |
899 | 3227 off the end of it. We only want to scan real keyboard input |
3228 for function key sequences, so if mock_input says that we're | |
1515
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3229 re-reading old events, don't examine it. */ |
518 | 3230 if (first_binding >= nmaps |
899 | 3231 && t >= mock_input) |
518 | 3232 { |
3233 Lisp_Object fkey_next; | |
3234 | |
3235 /* Scan from fkey_end until we find a bound suffix. */ | |
3236 while (fkey_end < t) | |
3237 { | |
1515
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3238 Lisp_Object key; |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3239 |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3240 key = keybuf[fkey_end++]; |
853 | 3241 /* Look up meta-characters by prefixing them |
3242 with meta_prefix_char. I hate this. */ | |
1515
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3243 if (XTYPE (key) == Lisp_Int && XINT (key) & 0x80) |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3244 { |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3245 fkey_next = |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3246 get_keymap_1 |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3247 (get_keyelt |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3248 (access_keymap |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3249 (fkey_map, meta_prefix_char, 1)), |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3250 0, 1); |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3251 XFASTINT (key) = XFASTINT (key) & 0x7f; |
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3252 } |
853 | 3253 else |
3254 fkey_next = fkey_map; | |
3255 | |
518 | 3256 fkey_next = |
1515
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3257 get_keyelt (access_keymap (fkey_next, key, 1)); |
939
c4dcdc9aed70
Clear the eighth bit of the character from the key sequence, NOT the
Jim Blandy <jimb@redhat.com>
parents:
899
diff
changeset
|
3258 |
c4dcdc9aed70
Clear the eighth bit of the character from the key sequence, NOT the
Jim Blandy <jimb@redhat.com>
parents:
899
diff
changeset
|
3259 /* If keybuf[fkey_start..fkey_end] is bound in the |
547 | 3260 function key map and it's a suffix of the current |
939
c4dcdc9aed70
Clear the eighth bit of the character from the key sequence, NOT the
Jim Blandy <jimb@redhat.com>
parents:
899
diff
changeset
|
3261 sequence (i.e. fkey_end == t), replace it with |
547 | 3262 the binding and restart with fkey_start at the end. */ |
518 | 3263 if (XTYPE (fkey_next) == Lisp_Vector |
3264 && fkey_end == t) | |
3265 { | |
3266 t = fkey_start + XVECTOR (fkey_next)->size; | |
3267 if (t >= bufsize) | |
3268 error ("key sequence too long"); | |
3269 | |
3270 bcopy (XVECTOR (fkey_next)->contents, | |
3271 keybuf + fkey_start, | |
3272 (t - fkey_start) * sizeof (keybuf[0])); | |
3273 | |
3274 mock_input = t; | |
3275 fkey_start = fkey_end = t; | |
3276 | |
1515
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3277 goto replay_sequence; |
518 | 3278 } |
3279 | |
1515
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3280 fkey_map = get_keymap_1 (fkey_next, 0, 1); |
518 | 3281 |
547 | 3282 /* If we no longer have a bound suffix, try a new positions for |
3283 fkey_start. */ | |
518 | 3284 if (NILP (fkey_map)) |
3285 { | |
3286 fkey_end = ++fkey_start; | |
3287 fkey_map = Vfunction_key_map; | |
3288 } | |
3289 } | |
3290 } | |
3291 } | |
3292 | |
3293 read_key_sequence_cmd = (first_binding < nmaps | |
3294 ? defs[first_binding] | |
3295 : Qnil); | |
3296 | |
1515
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3297 done: |
1386
5845050f9d5c
* keyboard.c (Vlast_event_frame): Make this variable exist even
Jim Blandy <jimb@redhat.com>
parents:
1328
diff
changeset
|
3298 unread_switch_frame = delayed_switch_frame; |
1515
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3299 unbind_to (count, Qnil); |
518 | 3300 return t; |
3301 } | |
3302 | |
691
cae8c3ef1677
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
687
diff
changeset
|
3303 DEFUN ("read-key-sequence", Fread_key_sequence, Sread_key_sequence, 1, 2, 0, |
518 | 3304 "Read a sequence of keystrokes and return as a string or vector.\n\ |
3305 The sequence is sufficient to specify a non-prefix command in the\n\ | |
3306 current local and global maps.\n\ | |
3307 \n\ | |
691
cae8c3ef1677
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
687
diff
changeset
|
3308 First arg PROMPT is a prompt string. If nil, do not prompt specially.\n\ |
cae8c3ef1677
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
687
diff
changeset
|
3309 Second (optional) arg CONTINUE-ECHO, if non-nil, means this key echos\n\ |
cae8c3ef1677
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
687
diff
changeset
|
3310 as a continuation of the previous key.\n\ |
518 | 3311 \n\ |
765 | 3312 If Emacs is running on multiple frames, switching between frames in\n\ |
518 | 3313 the midst of a keystroke will toss any prefix typed so far. A C-g\n\ |
3314 typed while in this function is treated like any other character, and\n\ | |
3315 `quit-flag' is not set.") | |
691
cae8c3ef1677
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
687
diff
changeset
|
3316 (prompt, continue_echo) |
cae8c3ef1677
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
687
diff
changeset
|
3317 Lisp_Object prompt, continue_echo; |
518 | 3318 { |
3319 Lisp_Object keybuf[30]; | |
3320 register int i; | |
3321 struct gcpro gcpro1, gcpro2; | |
3322 | |
3323 if (!NILP (prompt)) | |
3324 CHECK_STRING (prompt, 0); | |
3325 QUIT; | |
3326 | |
3327 bzero (keybuf, sizeof keybuf); | |
3328 GCPRO1 (keybuf[0]); | |
3329 gcpro1.nvars = (sizeof keybuf/sizeof (keybuf[0])); | |
3330 | |
727 | 3331 if (NILP (continue_echo)) |
691
cae8c3ef1677
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
687
diff
changeset
|
3332 this_command_key_count = 0; |
cae8c3ef1677
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
687
diff
changeset
|
3333 |
518 | 3334 i = read_key_sequence (keybuf, (sizeof keybuf/sizeof (keybuf[0])), |
1515
8cc7bc81d2aa
* keyboard.c: #include dispextern.h.
Jim Blandy <jimb@redhat.com>
parents:
1449
diff
changeset
|
3335 NILP (prompt) ? 0 : XSTRING (prompt)->data); |
518 | 3336 |
3337 UNGCPRO; | |
3338 return make_array (i, keybuf); | |
3339 } | |
3340 | |
3341 DEFUN ("command-execute", Fcommand_execute, Scommand_execute, 1, 2, 0, | |
3342 "Execute CMD as an editor command.\n\ | |
3343 CMD must be a symbol that satisfies the `commandp' predicate.\n\ | |
3344 Optional second arg RECORD-FLAG non-nil\n\ | |
3345 means unconditionally put this command in `command-history'.\n\ | |
3346 Otherwise, that is done only if an arg is read using the minibuffer.") | |
3347 (cmd, record) | |
3348 Lisp_Object cmd, record; | |
3349 { | |
3350 register Lisp_Object final; | |
3351 register Lisp_Object tem; | |
3352 Lisp_Object prefixarg; | |
3353 struct backtrace backtrace; | |
3354 extern int debug_on_next_call; | |
3355 | |
3356 prefixarg = Vprefix_arg, Vprefix_arg = Qnil; | |
3357 Vcurrent_prefix_arg = prefixarg; | |
3358 debug_on_next_call = 0; | |
3359 | |
3360 if (XTYPE (cmd) == Lisp_Symbol) | |
3361 { | |
3362 tem = Fget (cmd, Qdisabled); | |
3363 if (!NILP (tem)) | |
3364 return call1 (Vrun_hooks, Vdisabled_command_hook); | |
3365 } | |
3366 | |
3367 while (1) | |
3368 { | |
648 | 3369 final = Findirect_function (cmd); |
518 | 3370 |
3371 if (CONSP (final) && (tem = Fcar (final), EQ (tem, Qautoload))) | |
3372 do_autoload (final, cmd); | |
3373 else | |
3374 break; | |
3375 } | |
3376 | |
3377 if (XTYPE (final) == Lisp_String | |
3378 || XTYPE (final) == Lisp_Vector) | |
3379 { | |
3380 /* If requested, place the macro in the command history. For | |
3381 other sorts of commands, call-interactively takes care of | |
3382 this. */ | |
3383 if (!NILP (record)) | |
3384 Vcommand_history | |
3385 = Fcons (Fcons (Qexecute_kbd_macro, | |
3386 Fcons (final, Fcons (prefixarg, Qnil))), | |
3387 Vcommand_history); | |
3388 | |
3389 return Fexecute_kbd_macro (final, prefixarg); | |
3390 } | |
3391 if (CONSP (final) || XTYPE (final) == Lisp_Subr | |
3392 || XTYPE (final) == Lisp_Compiled) | |
3393 { | |
3394 backtrace.next = backtrace_list; | |
3395 backtrace_list = &backtrace; | |
3396 backtrace.function = &Qcall_interactively; | |
3397 backtrace.args = &cmd; | |
3398 backtrace.nargs = 1; | |
3399 backtrace.evalargs = 0; | |
3400 | |
3401 tem = Fcall_interactively (cmd, record); | |
3402 | |
3403 backtrace_list = backtrace.next; | |
3404 return tem; | |
3405 } | |
3406 return Qnil; | |
3407 } | |
3408 | |
3409 DEFUN ("execute-extended-command", Fexecute_extended_command, Sexecute_extended_command, | |
3410 1, 1, "P", | |
3411 "Read function name, then read its arguments and call it.") | |
3412 (prefixarg) | |
3413 Lisp_Object prefixarg; | |
3414 { | |
3415 Lisp_Object function; | |
3416 char buf[40]; | |
3417 Lisp_Object saved_keys; | |
3418 struct gcpro gcpro1; | |
3419 | |
3420 saved_keys = Fthis_command_keys (); | |
3421 buf[0] = 0; | |
3422 GCPRO1 (saved_keys); | |
3423 | |
3424 if (EQ (prefixarg, Qminus)) | |
3425 strcpy (buf, "- "); | |
3426 else if (CONSP (prefixarg) && XINT (XCONS (prefixarg)->car) == 4) | |
3427 strcpy (buf, "C-u "); | |
3428 else if (CONSP (prefixarg) && XTYPE (XCONS (prefixarg)->car) == Lisp_Int) | |
3429 sprintf (buf, "%d ", XINT (XCONS (prefixarg)->car)); | |
3430 else if (XTYPE (prefixarg) == Lisp_Int) | |
3431 sprintf (buf, "%d ", XINT (prefixarg)); | |
3432 | |
3433 /* This isn't strictly correct if execute-extended-command | |
3434 is bound to anything else. Perhaps it should use | |
3435 this_command_keys? */ | |
3436 strcat (buf, "M-x "); | |
3437 | |
3438 /* Prompt with buf, and then read a string, completing from and | |
3439 restricting to the set of all defined commands. Don't provide | |
3440 any initial input. The last Qnil says not to perform a | |
3441 peculiar hack on the initial input. */ | |
3442 function = Fcompleting_read (build_string (buf), | |
3443 Vobarray, Qcommandp, | |
3444 Qt, Qnil, Qnil); | |
3445 | |
708 | 3446 /* Set this_command_keys to the concatenation of saved_keys and |
3447 function, followed by a RET. */ | |
518 | 3448 { |
708 | 3449 struct Lisp_String *str; |
518 | 3450 int i; |
3451 Lisp_Object tem; | |
3452 | |
708 | 3453 this_command_key_count = 0; |
3454 | |
3455 str = XSTRING (saved_keys); | |
3456 for (i = 0; i < str->size; i++) | |
518 | 3457 { |
708 | 3458 XFASTINT (tem) = str->data[i]; |
518 | 3459 add_command_key (tem); |
3460 } | |
708 | 3461 |
3462 str = XSTRING (function); | |
3463 for (i = 0; i < str->size; i++) | |
3464 { | |
3465 XFASTINT (tem) = str->data[i]; | |
3466 add_command_key (tem); | |
3467 } | |
3468 | |
3469 XFASTINT (tem) = '\015'; | |
3470 add_command_key (tem); | |
518 | 3471 } |
3472 | |
3473 UNGCPRO; | |
3474 | |
1328
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
3475 function = Fintern (function, Qnil); |
518 | 3476 Vprefix_arg = prefixarg; |
3477 this_command = function; | |
3478 | |
3479 return Fcommand_execute (function, Qt); | |
3480 } | |
3481 | |
3482 | |
3483 detect_input_pending () | |
3484 { | |
3485 if (!input_pending) | |
3486 get_input_pending (&input_pending); | |
3487 | |
3488 return input_pending; | |
3489 } | |
3490 | |
648 | 3491 /* This is called in some cases before a possible quit. |
3492 It cases the next call to detect_input_pending to recompute input_pending. | |
3493 So calling this function unnecessarily can't do any harm. */ | |
3494 clear_input_pending () | |
3495 { | |
3496 input_pending = 0; | |
3497 } | |
3498 | |
518 | 3499 DEFUN ("input-pending-p", Finput_pending_p, Sinput_pending_p, 0, 0, 0, |
3500 "T if command input is currently available with no waiting.\n\ | |
3501 Actually, the value is nil only if we can be sure that no input is available.") | |
3502 () | |
3503 { | |
1590
11cd7c23f538
* keyboard.c (unread_switch_frame): Don't declare this static.
Jim Blandy <jimb@redhat.com>
parents:
1565
diff
changeset
|
3504 if (!NILP (unread_command_event)) |
518 | 3505 return (Qt); |
3506 | |
3507 return detect_input_pending () ? Qt : Qnil; | |
3508 } | |
3509 | |
3510 DEFUN ("recent-keys", Frecent_keys, Srecent_keys, 0, 0, 0, | |
727 | 3511 "Return vector of last 100 chars read from terminal.") |
518 | 3512 () |
3513 { | |
1261
60b30565326c
* keyboard.c (recent_keys): Turn this from an array, which is a
Jim Blandy <jimb@redhat.com>
parents:
1239
diff
changeset
|
3514 Lisp_Object *keys = XVECTOR (recent_keys)->contents; |
518 | 3515 Lisp_Object val; |
3516 | |
3517 if (total_keys < NUM_RECENT_KEYS) | |
1261
60b30565326c
* keyboard.c (recent_keys): Turn this from an array, which is a
Jim Blandy <jimb@redhat.com>
parents:
1239
diff
changeset
|
3518 return Fvector (total_keys, keys); |
518 | 3519 else |
3520 { | |
1261
60b30565326c
* keyboard.c (recent_keys): Turn this from an array, which is a
Jim Blandy <jimb@redhat.com>
parents:
1239
diff
changeset
|
3521 val = Fvector (NUM_RECENT_KEYS, keys); |
60b30565326c
* keyboard.c (recent_keys): Turn this from an array, which is a
Jim Blandy <jimb@redhat.com>
parents:
1239
diff
changeset
|
3522 bcopy (keys + recent_keys_index, |
518 | 3523 XVECTOR (val)->contents, |
3524 (NUM_RECENT_KEYS - recent_keys_index) * sizeof (Lisp_Object)); | |
1261
60b30565326c
* keyboard.c (recent_keys): Turn this from an array, which is a
Jim Blandy <jimb@redhat.com>
parents:
1239
diff
changeset
|
3525 bcopy (keys, |
518 | 3526 XVECTOR (val)->contents + NUM_RECENT_KEYS - recent_keys_index, |
3527 recent_keys_index * sizeof (Lisp_Object)); | |
3528 return val; | |
3529 } | |
3530 } | |
3531 | |
3532 DEFUN ("this-command-keys", Fthis_command_keys, Sthis_command_keys, 0, 0, 0, | |
3533 "Return string of the keystrokes that invoked this command.") | |
3534 () | |
3535 { | |
1439
b3b2d1181d3a
* keyboard.c (this_command_keys): Make this a vector, instead of
Jim Blandy <jimb@redhat.com>
parents:
1404
diff
changeset
|
3536 return make_array (this_command_key_count, |
b3b2d1181d3a
* keyboard.c (this_command_keys): Make this a vector, instead of
Jim Blandy <jimb@redhat.com>
parents:
1404
diff
changeset
|
3537 XVECTOR (this_command_keys)->contents); |
518 | 3538 } |
3539 | |
3540 DEFUN ("recursion-depth", Frecursion_depth, Srecursion_depth, 0, 0, 0, | |
3541 "Return the current depth in recursive edits.") | |
3542 () | |
3543 { | |
3544 Lisp_Object temp; | |
3545 XFASTINT (temp) = command_loop_level + minibuf_level; | |
3546 return temp; | |
3547 } | |
3548 | |
3549 DEFUN ("open-dribble-file", Fopen_dribble_file, Sopen_dribble_file, 1, 1, | |
3550 "FOpen dribble file: ", | |
3551 "Start writing all keyboard characters to FILE.") | |
3552 (file) | |
3553 Lisp_Object file; | |
3554 { | |
3555 if (NILP (file)) | |
3556 { | |
3557 fclose (dribble); | |
3558 dribble = 0; | |
3559 } | |
3560 else | |
3561 { | |
3562 file = Fexpand_file_name (file, Qnil); | |
3563 dribble = fopen (XSTRING (file)->data, "w"); | |
3564 } | |
3565 return Qnil; | |
3566 } | |
3567 | |
3568 DEFUN ("discard-input", Fdiscard_input, Sdiscard_input, 0, 0, 0, | |
3569 "Discard the contents of the terminal input buffer.\n\ | |
3570 Also cancel any kbd macro being defined.") | |
3571 () | |
3572 { | |
3573 defining_kbd_macro = 0; | |
3574 update_mode_lines++; | |
3575 | |
1590
11cd7c23f538
* keyboard.c (unread_switch_frame): Don't declare this static.
Jim Blandy <jimb@redhat.com>
parents:
1565
diff
changeset
|
3576 unread_command_event = Qnil; |
518 | 3577 |
3578 discard_tty_input (); | |
3579 | |
3580 kbd_fetch_ptr = kbd_store_ptr; | |
3581 input_pending = 0; | |
3582 | |
3583 return Qnil; | |
3584 } | |
3585 | |
3586 DEFUN ("suspend-emacs", Fsuspend_emacs, Ssuspend_emacs, 0, 1, "", | |
3587 "Stop Emacs and return to superior process. You can resume later.\n\ | |
3588 On systems that don't have job control, run a subshell instead.\n\n\ | |
3589 If optional arg STUFFSTRING is non-nil, its characters are stuffed\n\ | |
3590 to be read as terminal input by Emacs's superior shell.\n\ | |
3591 Before suspending, if `suspend-hook' is bound and value is non-nil\n\ | |
3592 call the value as a function of no args. Don't suspend if it returns non-nil.\n\ | |
3593 Otherwise, suspend normally and after resumption call\n\ | |
3594 `suspend-resume-hook' if that is bound and non-nil.\n\ | |
3595 \n\ | |
3596 Some operating systems cannot stop the Emacs process and resume it later.\n\ | |
3597 On such systems, Emacs will start a subshell and wait for it to exit.") | |
3598 (stuffstring) | |
3599 Lisp_Object stuffstring; | |
3600 { | |
3601 register Lisp_Object tem; | |
3602 int count = specpdl_ptr - specpdl; | |
3603 int old_height, old_width; | |
3604 int width, height; | |
3605 struct gcpro gcpro1; | |
3606 extern init_sys_modes (); | |
3607 | |
3608 if (!NILP (stuffstring)) | |
3609 CHECK_STRING (stuffstring, 0); | |
3610 GCPRO1 (stuffstring); | |
3611 | |
3612 /* Call value of suspend-hook | |
3613 if it is bound and value is non-nil. */ | |
3614 if (!NILP (Vrun_hooks)) | |
3615 { | |
3616 tem = call1 (Vrun_hooks, intern ("suspend-hook")); | |
3617 if (!EQ (tem, Qnil)) return Qnil; | |
3618 } | |
3619 | |
765 | 3620 get_frame_size (&old_width, &old_height); |
518 | 3621 reset_sys_modes (); |
3622 /* sys_suspend can get an error if it tries to fork a subshell | |
3623 and the system resources aren't available for that. */ | |
3624 record_unwind_protect (init_sys_modes, 0); | |
3625 stuff_buffered_input (stuffstring); | |
3626 sys_suspend (); | |
3627 unbind_to (count, Qnil); | |
3628 | |
3629 /* Check if terminal/window size has changed. | |
3630 Note that this is not useful when we are running directly | |
3631 with a window system; but suspend should be disabled in that case. */ | |
765 | 3632 get_frame_size (&width, &height); |
518 | 3633 if (width != old_width || height != old_height) |
966
eb74884fc95a
* keyboard.c (Fsuspend_emacs): Call change_frame_size with the
Jim Blandy <jimb@redhat.com>
parents:
939
diff
changeset
|
3634 change_frame_size (0, height, width, 0, 0); |
518 | 3635 |
3636 /* Call value of suspend-resume-hook | |
3637 if it is bound and value is non-nil. */ | |
3638 if (!NILP (Vrun_hooks)) | |
3639 call1 (Vrun_hooks, intern ("suspend-resume-hook")); | |
3640 | |
3641 UNGCPRO; | |
3642 return Qnil; | |
3643 } | |
3644 | |
3645 /* If STUFFSTRING is a string, stuff its contents as pending terminal input. | |
3646 Then in any case stuff anthing Emacs has read ahead and not used. */ | |
3647 | |
3648 stuff_buffered_input (stuffstring) | |
3649 Lisp_Object stuffstring; | |
3650 { | |
3651 register unsigned char *p; | |
3652 | |
3653 /* stuff_char works only in BSD, versions 4.2 and up. */ | |
3654 #ifdef BSD | |
3655 #ifndef BSD4_1 | |
3656 if (XTYPE (stuffstring) == Lisp_String) | |
3657 { | |
3658 register int count; | |
3659 | |
3660 p = XSTRING (stuffstring)->data; | |
3661 count = XSTRING (stuffstring)->size; | |
3662 while (count-- > 0) | |
3663 stuff_char (*p++); | |
3664 stuff_char ('\n'); | |
3665 } | |
3666 /* Anything we have read ahead, put back for the shell to read. */ | |
3667 while (kbd_fetch_ptr != kbd_store_ptr) | |
3668 { | |
3669 if (kbd_fetch_ptr == kbd_buffer + KBD_BUFFER_SIZE) | |
3670 kbd_fetch_ptr = kbd_buffer; | |
3671 if (kbd_fetch_ptr->kind == ascii_keystroke) | |
3672 stuff_char (XINT (kbd_fetch_ptr->code)); | |
3673 kbd_fetch_ptr++; | |
3674 } | |
3675 input_pending = 0; | |
3676 #endif | |
3677 #endif /* BSD and not BSD4_1 */ | |
3678 } | |
3679 | |
648 | 3680 set_waiting_for_input (time_to_clear) |
3681 EMACS_TIME *time_to_clear; | |
518 | 3682 { |
648 | 3683 input_available_clear_time = time_to_clear; |
518 | 3684 |
3685 /* Tell interrupt_signal to throw back to read_char, */ | |
3686 waiting_for_input = 1; | |
3687 | |
3688 /* If interrupt_signal was called before and buffered a C-g, | |
3689 make it run again now, to avoid timing error. */ | |
3690 if (!NILP (Vquit_flag)) | |
3691 quit_throw_to_read_char (); | |
3692 | |
3693 /* If alarm has gone off already, echo now. */ | |
3694 if (echo_flag) | |
3695 { | |
3696 echo (); | |
3697 echo_flag = 0; | |
3698 } | |
3699 } | |
3700 | |
3701 clear_waiting_for_input () | |
3702 { | |
3703 /* Tell interrupt_signal not to throw back to read_char, */ | |
3704 waiting_for_input = 0; | |
648 | 3705 input_available_clear_time = 0; |
518 | 3706 } |
3707 | |
3708 /* This routine is called at interrupt level in response to C-G. | |
3709 If interrupt_input, this is the handler for SIGINT. | |
3710 Otherwise, it is called from kbd_buffer_store_event, | |
3711 in handling SIGIO or SIGTINT. | |
3712 | |
3713 If `waiting_for_input' is non zero, then unless `echoing' is nonzero, | |
3714 immediately throw back to read_char. | |
3715 | |
3716 Otherwise it sets the Lisp variable quit-flag not-nil. | |
3717 This causes eval to throw, when it gets a chance. | |
3718 If quit-flag is already non-nil, it stops the job right away. */ | |
3719 | |
3720 SIGTYPE | |
3721 interrupt_signal () | |
3722 { | |
3723 char c; | |
3724 /* Must preserve main program's value of errno. */ | |
3725 int old_errno = errno; | |
3726 extern Lisp_Object Vwindow_system; | |
3727 | |
3728 #ifdef USG | |
3729 /* USG systems forget handlers when they are used; | |
3730 must reestablish each time */ | |
3731 signal (SIGINT, interrupt_signal); | |
3732 signal (SIGQUIT, interrupt_signal); | |
3733 #endif /* USG */ | |
3734 | |
3735 cancel_echoing (); | |
3736 | |
966
eb74884fc95a
* keyboard.c (Fsuspend_emacs): Call change_frame_size with the
Jim Blandy <jimb@redhat.com>
parents:
939
diff
changeset
|
3737 if (!NILP (Vquit_flag) && FRAME_TERMCAP_P (selected_frame)) |
518 | 3738 { |
3739 fflush (stdout); | |
3740 reset_sys_modes (); | |
3741 sigfree (); | |
3742 #ifdef SIGTSTP /* Support possible in later USG versions */ | |
3743 /* | |
3744 * On systems which can suspend the current process and return to the original | |
3745 * shell, this command causes the user to end up back at the shell. | |
3746 * The "Auto-save" and "Abort" questions are not asked until | |
3747 * the user elects to return to emacs, at which point he can save the current | |
3748 * job and either dump core or continue. | |
3749 */ | |
3750 sys_suspend (); | |
3751 #else | |
3752 #ifdef VMS | |
3753 if (sys_suspend () == -1) | |
3754 { | |
3755 printf ("Not running as a subprocess;\n"); | |
3756 printf ("you can continue or abort.\n"); | |
3757 } | |
3758 #else /* not VMS */ | |
3759 /* Perhaps should really fork an inferior shell? | |
3760 But that would not provide any way to get back | |
3761 to the original shell, ever. */ | |
3762 printf ("No support for stopping a process on this operating system;\n"); | |
3763 printf ("you can continue or abort.\n"); | |
3764 #endif /* not VMS */ | |
3765 #endif /* not SIGTSTP */ | |
3766 printf ("Auto-save? (y or n) "); | |
3767 fflush (stdout); | |
3768 if (((c = getchar ()) & ~040) == 'Y') | |
3769 Fdo_auto_save (Qnil, Qnil); | |
3770 while (c != '\n') c = getchar (); | |
3771 #ifdef VMS | |
3772 printf ("Abort (and enter debugger)? (y or n) "); | |
3773 #else /* not VMS */ | |
3774 printf ("Abort (and dump core)? (y or n) "); | |
3775 #endif /* not VMS */ | |
3776 fflush (stdout); | |
3777 if (((c = getchar ()) & ~040) == 'Y') | |
3778 abort (); | |
3779 while (c != '\n') c = getchar (); | |
3780 printf ("Continuing...\n"); | |
3781 fflush (stdout); | |
3782 init_sys_modes (); | |
3783 } | |
3784 else | |
3785 { | |
3786 /* If executing a function that wants to be interrupted out of | |
3787 and the user has not deferred quitting by binding `inhibit-quit' | |
3788 then quit right away. */ | |
3789 if (immediate_quit && NILP (Vinhibit_quit)) | |
3790 { | |
3791 immediate_quit = 0; | |
3792 sigfree (); | |
3793 Fsignal (Qquit, Qnil); | |
3794 } | |
3795 else | |
3796 /* Else request quit when it's safe */ | |
3797 Vquit_flag = Qt; | |
3798 } | |
3799 | |
3800 if (waiting_for_input && !echoing) | |
3801 quit_throw_to_read_char (); | |
3802 | |
3803 errno = old_errno; | |
3804 } | |
3805 | |
3806 /* Handle a C-g by making read_char return C-g. */ | |
3807 | |
3808 quit_throw_to_read_char () | |
3809 { | |
3810 quit_error_check (); | |
3811 sigfree (); | |
3812 /* Prevent another signal from doing this before we finish. */ | |
650 | 3813 clear_waiting_for_input (); |
518 | 3814 input_pending = 0; |
3815 | |
1590
11cd7c23f538
* keyboard.c (unread_switch_frame): Don't declare this static.
Jim Blandy <jimb@redhat.com>
parents:
1565
diff
changeset
|
3816 unread_command_event = Qnil; |
518 | 3817 |
3818 _longjmp (getcjmp, 1); | |
3819 } | |
3820 | |
3821 DEFUN ("set-input-mode", Fset_input_mode, Sset_input_mode, 3, 4, 0, | |
3822 "Set mode of reading keyboard input.\n\ | |
695
e3fac20d3015
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
691
diff
changeset
|
3823 First arg INTERRUPT non-nil means use input interrupts;\n\ |
e3fac20d3015
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
691
diff
changeset
|
3824 nil means use CBREAK mode.\n\ |
e3fac20d3015
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
691
diff
changeset
|
3825 Second arg FLOW non-nil means use ^S/^Q flow control for output to terminal\n\ |
518 | 3826 (no effect except in CBREAK mode).\n\ |
695
e3fac20d3015
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
691
diff
changeset
|
3827 Third arg META non-nil means accept 8-bit input (for a Meta key).\n\ |
518 | 3828 Otherwise, the top bit is ignored, on the assumption it is parity.\n\ |
695
e3fac20d3015
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
691
diff
changeset
|
3829 Optional fourth arg QUIT if non-nil specifies character to use for quitting.") |
518 | 3830 (interrupt, flow, meta, quit) |
3831 Lisp_Object interrupt, flow, meta, quit; | |
3832 { | |
3833 if (!NILP (quit) | |
3834 && (XTYPE (quit) != Lisp_Int | |
3835 || XINT (quit) < 0 || XINT (quit) > 0400)) | |
3836 error ("set-input-mode: QUIT must be an ASCII character."); | |
3837 | |
3838 reset_sys_modes (); | |
3839 #ifdef SIGIO | |
3840 /* Note SIGIO has been undef'd if FIONREAD is missing. */ | |
3841 #ifdef NO_SOCK_SIGIO | |
3842 if (read_socket_hook) | |
3843 interrupt_input = 0; /* No interrupts if reading from a socket. */ | |
3844 else | |
3845 #endif /* NO_SOCK_SIGIO */ | |
3846 interrupt_input = !NILP (interrupt); | |
3847 #else /* not SIGIO */ | |
3848 interrupt_input = 0; | |
3849 #endif /* not SIGIO */ | |
3850 /* Our VMS input only works by interrupts, as of now. */ | |
3851 #ifdef VMS | |
3852 interrupt_input = 1; | |
3853 #endif | |
3854 flow_control = !NILP (flow); | |
3855 meta_key = !NILP (meta); | |
3856 if (!NILP (quit)) | |
3857 /* Don't let this value be out of range. */ | |
3858 quit_char = XINT (quit) & (meta_key ? 0377 : 0177); | |
3859 | |
3860 init_sys_modes (); | |
3861 return Qnil; | |
3862 } | |
3863 | |
3864 init_keyboard () | |
3865 { | |
3866 /* This is correct before outermost invocation of the editor loop */ | |
3867 command_loop_level = -1; | |
3868 immediate_quit = 0; | |
3869 quit_char = Ctl ('g'); | |
1590
11cd7c23f538
* keyboard.c (unread_switch_frame): Don't declare this static.
Jim Blandy <jimb@redhat.com>
parents:
1565
diff
changeset
|
3870 unread_command_event = Qnil; |
518 | 3871 total_keys = 0; |
1262
c9fc221502e4
* keyboard.c: Initialize recent_keys in syms_of_keyboard, not
Jim Blandy <jimb@redhat.com>
parents:
1261
diff
changeset
|
3872 recent_keys_index = 0; |
518 | 3873 kbd_fetch_ptr = kbd_buffer; |
3874 kbd_store_ptr = kbd_buffer; | |
3875 do_mouse_tracking = 0; | |
3876 input_pending = 0; | |
3877 | |
1565
a681f63f93fa
* keyboard.c (read_key_sequence): Removed the
Jim Blandy <jimb@redhat.com>
parents:
1515
diff
changeset
|
3878 #ifdef MULTI_FRAME |
1590
11cd7c23f538
* keyboard.c (unread_switch_frame): Don't declare this static.
Jim Blandy <jimb@redhat.com>
parents:
1565
diff
changeset
|
3879 /* This means that command_loop_1 won't try to select anything the first |
11cd7c23f538
* keyboard.c (unread_switch_frame): Don't declare this static.
Jim Blandy <jimb@redhat.com>
parents:
1565
diff
changeset
|
3880 time through. */ |
11cd7c23f538
* keyboard.c (unread_switch_frame): Don't declare this static.
Jim Blandy <jimb@redhat.com>
parents:
1565
diff
changeset
|
3881 Vlast_event_frame = Qnil; |
1565
a681f63f93fa
* keyboard.c (read_key_sequence): Removed the
Jim Blandy <jimb@redhat.com>
parents:
1515
diff
changeset
|
3882 #endif |
a681f63f93fa
* keyboard.c (read_key_sequence): Removed the
Jim Blandy <jimb@redhat.com>
parents:
1515
diff
changeset
|
3883 |
518 | 3884 if (!noninteractive) |
3885 { | |
3886 signal (SIGINT, interrupt_signal); | |
3887 #ifdef HAVE_TERMIO | |
3888 /* For systems with SysV TERMIO, C-g is set up for both SIGINT and | |
3889 SIGQUIT and we can't tell which one it will give us. */ | |
3890 signal (SIGQUIT, interrupt_signal); | |
3891 #endif /* HAVE_TERMIO */ | |
3892 /* Note SIGIO has been undef'd if FIONREAD is missing. */ | |
3893 #ifdef SIGIO | |
3894 signal (SIGIO, input_available_signal); | |
1008
f1df63f98e5c
* keyboard.c (init_keyboard): Changed "#endif SIGIO" to
Jim Blandy <jimb@redhat.com>
parents:
985
diff
changeset
|
3895 #endif /* SIGIO */ |
518 | 3896 } |
3897 | |
3898 /* Use interrupt input by default, if it works and noninterrupt input | |
3899 has deficiencies. */ | |
3900 | |
3901 #ifdef INTERRUPT_INPUT | |
3902 interrupt_input = 1; | |
3903 #else | |
3904 interrupt_input = 0; | |
3905 #endif | |
3906 | |
3907 /* Our VMS input only works by interrupts, as of now. */ | |
3908 #ifdef VMS | |
3909 interrupt_input = 1; | |
3910 #endif | |
3911 | |
3912 sigfree (); | |
3913 dribble = 0; | |
3914 | |
3915 if (keyboard_init_hook) | |
3916 (*keyboard_init_hook) (); | |
3917 | |
3918 #ifdef POLL_FOR_INPUT | |
3919 poll_suppress_count = 1; | |
3920 start_polling (); | |
3921 #endif | |
3922 } | |
3923 | |
3924 /* This type's only use is in syms_of_keyboard, to initialize the | |
3925 event header symbols and put properties on them. */ | |
3926 struct event_head { | |
3927 Lisp_Object *var; | |
3928 char *name; | |
3929 Lisp_Object *kind; | |
3930 }; | |
3931 | |
3932 struct event_head head_table[] = { | |
3933 &Qmouse_movement, "mouse-movement", &Qmouse_movement, | |
3934 &Qvscrollbar_part, "vscrollbar-part", &Qscrollbar_click, | |
3935 &Qvslider_part, "vslider-part", &Qscrollbar_click, | |
3936 &Qvthumbup_part, "vthumbup-part", &Qscrollbar_click, | |
3937 &Qvthumbdown_part, "vthumbdown-part", &Qscrollbar_click, | |
3938 &Qhscrollbar_part, "hscrollbar-part", &Qscrollbar_click, | |
3939 &Qhslider_part, "hslider-part", &Qscrollbar_click, | |
3940 &Qhthumbleft_part, "hthumbleft-part", &Qscrollbar_click, | |
1386
5845050f9d5c
* keyboard.c (Vlast_event_frame): Make this variable exist even
Jim Blandy <jimb@redhat.com>
parents:
1328
diff
changeset
|
3941 &Qhthumbright_part,"hthumbright-part", &Qscrollbar_click, |
5845050f9d5c
* keyboard.c (Vlast_event_frame): Make this variable exist even
Jim Blandy <jimb@redhat.com>
parents:
1328
diff
changeset
|
3942 &Qswitch_frame, "switch-frame", &Qswitch_frame |
518 | 3943 }; |
3944 | |
3945 syms_of_keyboard () | |
3946 { | |
3947 Qself_insert_command = intern ("self-insert-command"); | |
3948 staticpro (&Qself_insert_command); | |
3949 | |
3950 Qforward_char = intern ("forward-char"); | |
3951 staticpro (&Qforward_char); | |
3952 | |
3953 Qbackward_char = intern ("backward-char"); | |
3954 staticpro (&Qbackward_char); | |
3955 | |
3956 Qdisabled = intern ("disabled"); | |
3957 staticpro (&Qdisabled); | |
3958 | |
3959 Qfunction_key = intern ("function-key"); | |
3960 staticpro (&Qfunction_key); | |
1322
5f327f1dddd3
* keyboard.c (modify_event_symbol): Make sure that the unmodified
Jim Blandy <jimb@redhat.com>
parents:
1310
diff
changeset
|
3961 Qmouse_click = intern ("mouse-click"); |
518 | 3962 staticpro (&Qmouse_click); |
3963 Qmouse_movement = intern ("scrollbar-click"); | |
3964 staticpro (&Qmouse_movement); | |
3965 | |
3966 Qmode_line = intern ("mode-line"); | |
3967 staticpro (&Qmode_line); | |
732 | 3968 Qvertical_line = intern ("vertical-line"); |
3969 staticpro (&Qvertical_line); | |
518 | 3970 |
1386
5845050f9d5c
* keyboard.c (Vlast_event_frame): Make this variable exist even
Jim Blandy <jimb@redhat.com>
parents:
1328
diff
changeset
|
3971 Qevent_kind = intern ("event-kind"); |
518 | 3972 staticpro (&Qevent_kind); |
1310
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
3973 Qevent_symbol_elements = intern ("event-symbol-elements"); |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
3974 staticpro (&Qevent_symbol_elements); |
1328
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
3975 Qevent_symbol_element_mask = intern ("event-symbol-element-mask"); |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
3976 staticpro (&Qevent_symbol_element_mask); |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
3977 Qmodifier_cache = intern ("modifier-cache"); |
c4eb3aa71303
* keyboard.c (read_key_sequence): Treat mouse clicks on non-text
Jim Blandy <jimb@redhat.com>
parents:
1322
diff
changeset
|
3978 staticpro (&Qmodifier_cache); |
518 | 3979 |
3980 { | |
3981 struct event_head *p; | |
3982 | |
3983 for (p = head_table; | |
3984 p < head_table + (sizeof (head_table) / sizeof (head_table[0])); | |
3985 p++) | |
3986 { | |
3987 *p->var = intern (p->name); | |
3988 staticpro (p->var); | |
3989 Fput (*p->var, Qevent_kind, *p->kind); | |
1310
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
3990 Fput (*p->var, Qevent_symbol_elements, Fcons (*p->var, Qnil)); |
518 | 3991 } |
3992 } | |
3993 | |
1310
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
3994 { |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
3995 int i; |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
3996 |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
3997 for (i = 0; i < NUM_MOUSE_BUTTONS; i++) |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
3998 staticpro (&button_down_location[i].window); |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
3999 } |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
4000 |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
4001 { |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
4002 int i; |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
4003 int len = sizeof (modifier_names) / sizeof (modifier_names[0]); |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
4004 |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
4005 modifier_symbols = Fmake_vector (make_number (len), Qnil); |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
4006 for (i = 0; i < len; i++) |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
4007 XVECTOR (modifier_symbols)->contents[i] = intern (modifier_names[i]); |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
4008 staticpro (&modifier_symbols); |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
4009 } |
8db103d11270
* keyboard.c (echo_char, read_char): Apply EVENT_HEAD without first
Jim Blandy <jimb@redhat.com>
parents:
1262
diff
changeset
|
4010 |
1262
c9fc221502e4
* keyboard.c: Initialize recent_keys in syms_of_keyboard, not
Jim Blandy <jimb@redhat.com>
parents:
1261
diff
changeset
|
4011 recent_keys = Fmake_vector (make_number (NUM_RECENT_KEYS), Qnil); |
c9fc221502e4
* keyboard.c: Initialize recent_keys in syms_of_keyboard, not
Jim Blandy <jimb@redhat.com>
parents:
1261
diff
changeset
|
4012 staticpro (&recent_keys); |
c9fc221502e4
* keyboard.c: Initialize recent_keys in syms_of_keyboard, not
Jim Blandy <jimb@redhat.com>
parents:
1261
diff
changeset
|
4013 |
1439
b3b2d1181d3a
* keyboard.c (this_command_keys): Make this a vector, instead of
Jim Blandy <jimb@redhat.com>
parents:
1404
diff
changeset
|
4014 this_command_keys = Fmake_vector (make_number (40), Qnil); |
1449
7f2b81dc2dd1
(syms_of_keyboard): Properly staticpro this_command_keys.
Richard M. Stallman <rms@gnu.org>
parents:
1439
diff
changeset
|
4015 staticpro (&this_command_keys); |
1439
b3b2d1181d3a
* keyboard.c (this_command_keys): Make this a vector, instead of
Jim Blandy <jimb@redhat.com>
parents:
1404
diff
changeset
|
4016 |
518 | 4017 func_key_syms = Qnil; |
4018 staticpro (&func_key_syms); | |
4019 | |
4020 mouse_syms = Qnil; | |
4021 staticpro (&mouse_syms); | |
4022 | |
1386
5845050f9d5c
* keyboard.c (Vlast_event_frame): Make this variable exist even
Jim Blandy <jimb@redhat.com>
parents:
1328
diff
changeset
|
4023 unread_switch_frame = Qnil; |
5845050f9d5c
* keyboard.c (Vlast_event_frame): Make this variable exist even
Jim Blandy <jimb@redhat.com>
parents:
1328
diff
changeset
|
4024 staticpro (&unread_switch_frame); |
5845050f9d5c
* keyboard.c (Vlast_event_frame): Make this variable exist even
Jim Blandy <jimb@redhat.com>
parents:
1328
diff
changeset
|
4025 |
518 | 4026 defsubr (&Sread_key_sequence); |
4027 defsubr (&Srecursive_edit); | |
4028 defsubr (&Strack_mouse); | |
4029 defsubr (&Smouse_click_p); | |
4030 defsubr (&Sinput_pending_p); | |
4031 defsubr (&Scommand_execute); | |
4032 defsubr (&Srecent_keys); | |
4033 defsubr (&Sthis_command_keys); | |
4034 defsubr (&Ssuspend_emacs); | |
4035 defsubr (&Sabort_recursive_edit); | |
4036 defsubr (&Sexit_recursive_edit); | |
4037 defsubr (&Srecursion_depth); | |
4038 defsubr (&Stop_level); | |
4039 defsubr (&Sdiscard_input); | |
4040 defsubr (&Sopen_dribble_file); | |
4041 defsubr (&Sset_input_mode); | |
4042 defsubr (&Sexecute_extended_command); | |
4043 | |
4044 DEFVAR_LISP ("disabled-command-hook", &Vdisabled_command_hook, | |
4045 "Value is called instead of any command that is disabled\n\ | |
1083
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
4046 \(has a non-nil `disabled' property)."); |
518 | 4047 |
4048 DEFVAR_LISP ("last-command-char", &last_command_char, | |
4049 "Last terminal input key that was part of a command."); | |
4050 | |
1083
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
4051 DEFVAR_LISP ("last-nonmenu-event", &last_nonmenu_event, |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
4052 "Last terminal input key in a command, except for mouse menus.\n\ |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
4053 Mouse menus give back keys that don't look like mouse events;\n\ |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
4054 this variable holds the actual mouse event that led to the menu,\n\ |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
4055 so that you can determine whether the command was run by mouse or not."); |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
4056 |
518 | 4057 DEFVAR_LISP ("last-input-char", &last_input_char, |
4058 "Last terminal input key."); | |
4059 | |
1590
11cd7c23f538
* keyboard.c (unread_switch_frame): Don't declare this static.
Jim Blandy <jimb@redhat.com>
parents:
1565
diff
changeset
|
4060 DEFVAR_LISP ("unread-command-event", &unread_command_event, |
518 | 4061 "Object to be read as next input from input stream, or nil if none."); |
4062 | |
4063 DEFVAR_LISP ("meta-prefix-char", &meta_prefix_char, | |
4064 "Meta-prefix character code. Meta-foo as command input\n\ | |
4065 turns into this character followed by foo."); | |
4066 XSET (meta_prefix_char, Lisp_Int, 033); | |
4067 | |
4068 DEFVAR_LISP ("last-command", &last_command, | |
4069 "The last command executed. Normally a symbol with a function definition,\n\ | |
4070 but can be whatever was found in the keymap, or whatever the variable\n\ | |
4071 `this-command' was set to by that command."); | |
4072 last_command = Qnil; | |
4073 | |
4074 DEFVAR_LISP ("this-command", &this_command, | |
4075 "The command now being executed.\n\ | |
4076 The command can set this variable; whatever is put here\n\ | |
4077 will be in `last-command' during the following command."); | |
4078 this_command = Qnil; | |
4079 | |
4080 DEFVAR_INT ("auto-save-interval", &auto_save_interval, | |
4081 "*Number of keyboard input characters between auto-saves.\n\ | |
4082 Zero means disable autosaving due to number of characters typed."); | |
4083 auto_save_interval = 300; | |
4084 | |
4085 DEFVAR_LISP ("auto-save-timeout", &Vauto_save_timeout, | |
4086 "*Number of seconds idle time before auto-save.\n\ | |
687
e2b747dd6a6e
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
682
diff
changeset
|
4087 Zero or nil means disable auto-saving due to idleness.\n\ |
e2b747dd6a6e
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
682
diff
changeset
|
4088 After auto-saving due to this many seconds of idle time,\n\ |
701 | 4089 Emacs also does a garbage collection if that seems to be warranted."); |
518 | 4090 XFASTINT (Vauto_save_timeout) = 30; |
4091 | |
4092 DEFVAR_INT ("echo-keystrokes", &echo_keystrokes, | |
4093 "*Nonzero means echo unfinished commands after this many seconds of pause."); | |
4094 echo_keystrokes = 1; | |
4095 | |
4096 DEFVAR_INT ("polling-period", &polling_period, | |
4097 "*Interval between polling for input during Lisp execution.\n\ | |
4098 The reason for polling is to make C-g work to stop a running program.\n\ | |
4099 Polling is needed only when using X windows and SIGIO does not work.\n\ | |
4100 Polling is automatically disabled in all other cases."); | |
4101 polling_period = 2; | |
4102 | |
4103 DEFVAR_INT ("num-input-keys", &num_input_keys, | |
4104 "*Number of complete keys read from the keyboard so far."); | |
4105 num_input_keys = 0; | |
4106 | |
1565
a681f63f93fa
* keyboard.c (read_key_sequence): Removed the
Jim Blandy <jimb@redhat.com>
parents:
1515
diff
changeset
|
4107 #ifdef MULTI_FRAME |
765 | 4108 DEFVAR_LISP ("last-event-frame", &Vlast_event_frame, |
1239
52afa4976154
* keyboard.c (read_char): If we're returning an event from a
Jim Blandy <jimb@redhat.com>
parents:
1140
diff
changeset
|
4109 "*The frame in which the most recently read event occurred.\n\ |
52afa4976154
* keyboard.c (read_char): If we're returning an event from a
Jim Blandy <jimb@redhat.com>
parents:
1140
diff
changeset
|
4110 If the last event came from a keyboard macro, this is set to `macro'."); |
765 | 4111 Vlast_event_frame = Qnil; |
1565
a681f63f93fa
* keyboard.c (read_key_sequence): Removed the
Jim Blandy <jimb@redhat.com>
parents:
1515
diff
changeset
|
4112 #endif |
518 | 4113 |
4114 DEFVAR_LISP ("help-char", &help_char, | |
4115 "Character to recognize as meaning Help.\n\ | |
4116 When it is read, do `(eval help-form)', and display result if it's a string.\n\ | |
4117 If the value of `help-form' is nil, this char can be read normally."); | |
4118 XSET (help_char, Lisp_Int, Ctl ('H')); | |
4119 | |
4120 DEFVAR_LISP ("help-form", &Vhelp_form, | |
4121 "Form to execute when character help-char is read.\n\ | |
4122 If the form returns a string, that string is displayed.\n\ | |
4123 If `help-form' is nil, the help char is not recognized."); | |
4124 Vhelp_form = Qnil; | |
4125 | |
4126 DEFVAR_LISP ("top-level", &Vtop_level, | |
4127 "Form to evaluate when Emacs starts up.\n\ | |
4128 Useful to set before you dump a modified Emacs."); | |
4129 Vtop_level = Qnil; | |
4130 | |
4131 DEFVAR_LISP ("keyboard-translate-table", &Vkeyboard_translate_table, | |
4132 "String used as translate table for keyboard input, or nil.\n\ | |
4133 Each character is looked up in this string and the contents used instead.\n\ | |
4134 If string is of length N, character codes N and up are untranslated."); | |
4135 Vkeyboard_translate_table = Qnil; | |
4136 | |
4137 DEFVAR_BOOL ("menu-prompting", &menu_prompting, | |
1083
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
4138 "Non-nil means prompt with menus when appropriate.\n\ |
518 | 4139 This is done when reading from a keymap that has a prompt string,\n\ |
1083
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
4140 for elements that have prompt strings.\n\ |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
4141 The menu is displayed on the screen\n\ |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
4142 if X menus were enabled at configuration\n\ |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
4143 time and the previous event was a mouse click prefix key.\n\ |
cbbbe0a96ecc
(last_nonmenu_event): New var.
Richard M. Stallman <rms@gnu.org>
parents:
1046
diff
changeset
|
4144 Otherwise, menu prompting uses the echo area."); |
518 | 4145 menu_prompting = 1; |
4146 | |
4147 DEFVAR_LISP ("menu-prompt-more-char", &menu_prompt_more_char, | |
4148 "Character to see next line of menu prompt.\n\ | |
4149 Type this character while in a menu prompt to rotate around the lines of it."); | |
4150 XSET (menu_prompt_more_char, Lisp_Int, ' '); | |
4151 } | |
4152 | |
4153 keys_of_keyboard () | |
4154 { | |
4155 initial_define_key (global_map, Ctl ('Z'), "suspend-emacs"); | |
4156 initial_define_key (control_x_map, Ctl ('Z'), "suspend-emacs"); | |
4157 initial_define_key (meta_map, Ctl ('C'), "exit-recursive-edit"); | |
4158 initial_define_key (global_map, Ctl (']'), "abort-recursive-edit"); | |
4159 initial_define_key (meta_map, 'x', "execute-extended-command"); | |
4160 } |