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