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