diff options
| author | Jim Blandy | 1992-09-29 13:44:55 +0000 |
|---|---|---|
| committer | Jim Blandy | 1992-09-29 13:44:55 +0000 |
| commit | 5160df46a25f6f1f3dd1dfae9c00b44bc19adefe (patch) | |
| tree | 706a35dc5a65b8ffa8dc944be0778131af3f57c2 | |
| parent | 629a12cfeff16a5e6b6d1e5f400c0a07e5cff385 (diff) | |
| download | emacs-5160df46a25f6f1f3dd1dfae9c00b44bc19adefe.tar.gz emacs-5160df46a25f6f1f3dd1dfae9c00b44bc19adefe.zip | |
* keyboard.c (recent_keys): Turn this from an array, which is a
pain in the neck to staticpro, into a vector, which is easier.
(read_char, Frecent_keys): Access recent_keys as a lisp vector,
not a C array.
(init_keyboard): Set recent_keys to be a vector, and staticpro
it.
| -rw-r--r-- | src/keyboard.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/keyboard.c b/src/keyboard.c index 5a2c7e811bc..2390c8199c1 100644 --- a/src/keyboard.c +++ b/src/keyboard.c | |||
| @@ -76,7 +76,7 @@ Lisp_Object Qdisabled, Vdisabled_command_hook; | |||
| 76 | #define NUM_RECENT_KEYS (100) | 76 | #define NUM_RECENT_KEYS (100) |
| 77 | int recent_keys_index; /* Index for storing next element into recent_keys */ | 77 | int recent_keys_index; /* Index for storing next element into recent_keys */ |
| 78 | int total_keys; /* Total number of elements stored into recent_keys */ | 78 | int total_keys; /* Total number of elements stored into recent_keys */ |
| 79 | Lisp_Object recent_keys[NUM_RECENT_KEYS]; /* Holds last 100 keystrokes */ | 79 | Lisp_Object recent_keys; /* A vector, holding the last 100 keystrokes */ |
| 80 | 80 | ||
| 81 | /* Buffer holding the key that invoked the current command. */ | 81 | /* Buffer holding the key that invoked the current command. */ |
| 82 | Lisp_Object *this_command_keys; | 82 | Lisp_Object *this_command_keys; |
| @@ -1267,8 +1267,8 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu) | |||
| 1267 | } | 1267 | } |
| 1268 | 1268 | ||
| 1269 | total_keys++; | 1269 | total_keys++; |
| 1270 | recent_keys[recent_keys_index] = c; | 1270 | XVECTOR (recent_keys)->contents[recent_keys_index] = c; |
| 1271 | if (++recent_keys_index >= (sizeof (recent_keys)/sizeof(recent_keys[0]))) | 1271 | if (++recent_keys_index >= NUM_RECENT_KEYS) |
| 1272 | recent_keys_index = 0; | 1272 | recent_keys_index = 0; |
| 1273 | 1273 | ||
| 1274 | /* Write c to the dribble file. If c is a lispy event, write | 1274 | /* Write c to the dribble file. If c is a lispy event, write |
| @@ -3113,17 +3113,18 @@ DEFUN ("recent-keys", Frecent_keys, Srecent_keys, 0, 0, 0, | |||
| 3113 | "Return vector of last 100 chars read from terminal.") | 3113 | "Return vector of last 100 chars read from terminal.") |
| 3114 | () | 3114 | () |
| 3115 | { | 3115 | { |
| 3116 | Lisp_Object *keys = XVECTOR (recent_keys)->contents; | ||
| 3116 | Lisp_Object val; | 3117 | Lisp_Object val; |
| 3117 | 3118 | ||
| 3118 | if (total_keys < NUM_RECENT_KEYS) | 3119 | if (total_keys < NUM_RECENT_KEYS) |
| 3119 | return Fvector (total_keys, recent_keys); | 3120 | return Fvector (total_keys, keys); |
| 3120 | else | 3121 | else |
| 3121 | { | 3122 | { |
| 3122 | val = Fvector (NUM_RECENT_KEYS, recent_keys); | 3123 | val = Fvector (NUM_RECENT_KEYS, keys); |
| 3123 | bcopy (recent_keys + recent_keys_index, | 3124 | bcopy (keys + recent_keys_index, |
| 3124 | XVECTOR (val)->contents, | 3125 | XVECTOR (val)->contents, |
| 3125 | (NUM_RECENT_KEYS - recent_keys_index) * sizeof (Lisp_Object)); | 3126 | (NUM_RECENT_KEYS - recent_keys_index) * sizeof (Lisp_Object)); |
| 3126 | bcopy (recent_keys, | 3127 | bcopy (keys, |
| 3127 | XVECTOR (val)->contents + NUM_RECENT_KEYS - recent_keys_index, | 3128 | XVECTOR (val)->contents + NUM_RECENT_KEYS - recent_keys_index, |
| 3128 | recent_keys_index * sizeof (Lisp_Object)); | 3129 | recent_keys_index * sizeof (Lisp_Object)); |
| 3129 | return val; | 3130 | return val; |
| @@ -3472,13 +3473,16 @@ init_keyboard () | |||
| 3472 | immediate_quit = 0; | 3473 | immediate_quit = 0; |
| 3473 | quit_char = Ctl ('g'); | 3474 | quit_char = Ctl ('g'); |
| 3474 | unread_command_char = Qnil; | 3475 | unread_command_char = Qnil; |
| 3475 | recent_keys_index = 0; | ||
| 3476 | total_keys = 0; | 3476 | total_keys = 0; |
| 3477 | kbd_fetch_ptr = kbd_buffer; | 3477 | kbd_fetch_ptr = kbd_buffer; |
| 3478 | kbd_store_ptr = kbd_buffer; | 3478 | kbd_store_ptr = kbd_buffer; |
| 3479 | do_mouse_tracking = 0; | 3479 | do_mouse_tracking = 0; |
| 3480 | input_pending = 0; | 3480 | input_pending = 0; |
| 3481 | 3481 | ||
| 3482 | recent_keys = Fmake_vector (make_number (NUM_RECENT_KEYS), Qnil); | ||
| 3483 | staticpro (&recent_keys); | ||
| 3484 | recent_keys_index = 0; | ||
| 3485 | |||
| 3482 | if (!noninteractive) | 3486 | if (!noninteractive) |
| 3483 | { | 3487 | { |
| 3484 | signal (SIGINT, interrupt_signal); | 3488 | signal (SIGINT, interrupt_signal); |