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