Mercurial > emacs
comparison src/keyboard.c @ 91239:2fcaae6177a5
Merge from emacs--devo--0
Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-300
author | Miles Bader <miles@gnu.org> |
---|---|
date | Sun, 16 Dec 2007 05:08:49 +0000 |
parents | 53108e6cea98 5da2063a52e4 |
children | 606f2d163a64 |
comparison
equal
deleted
inserted
replaced
91238:5cf14a2107b5 | 91239:2fcaae6177a5 |
---|---|
106 #endif | 106 #endif |
107 #else /* No X-windows, character input */ | 107 #else /* No X-windows, character input */ |
108 #define KBD_BUFFER_SIZE 4096 | 108 #define KBD_BUFFER_SIZE 4096 |
109 #endif /* No X-windows */ | 109 #endif /* No X-windows */ |
110 | 110 |
111 /* Following definition copied from eval.c */ | |
112 | |
113 struct backtrace | |
114 { | |
115 struct backtrace *next; | |
116 Lisp_Object *function; | |
117 Lisp_Object *args; /* Points to vector of args. */ | |
118 int nargs; /* length of vector. If nargs is UNEVALLED, | |
119 args points to slot holding list of | |
120 unevalled args */ | |
121 char evalargs; | |
122 /* Nonzero means call value of debugger when done with this operation. */ | |
123 char debug_on_exit; | |
124 }; | |
125 | |
126 #ifdef MULTI_KBOARD | 111 #ifdef MULTI_KBOARD |
127 KBOARD *initial_kboard; | 112 KBOARD *initial_kboard; |
128 KBOARD *current_kboard; | 113 KBOARD *current_kboard; |
129 KBOARD *all_kboards; | 114 KBOARD *all_kboards; |
130 int single_kboard; | 115 int single_kboard; |
172 static int before_command_echo_length; | 157 static int before_command_echo_length; |
173 | 158 |
174 extern int minbuf_level; | 159 extern int minbuf_level; |
175 | 160 |
176 extern int message_enable_multibyte; | 161 extern int message_enable_multibyte; |
177 | |
178 extern struct backtrace *backtrace_list; | |
179 | 162 |
180 /* If non-nil, the function that implements the display of help. | 163 /* If non-nil, the function that implements the display of help. |
181 It's called with one argument, the help string to display. */ | 164 It's called with one argument, the help string to display. */ |
182 | 165 |
183 Lisp_Object Vshow_help_function; | 166 Lisp_Object Vshow_help_function; |
1563 Lisp_Object cmd; | 1546 Lisp_Object cmd; |
1564 int lose; | 1547 int lose; |
1565 int nonundocount; | 1548 int nonundocount; |
1566 Lisp_Object keybuf[30]; | 1549 Lisp_Object keybuf[30]; |
1567 int i; | 1550 int i; |
1568 int no_direct; | |
1569 int prev_modiff = 0; | 1551 int prev_modiff = 0; |
1570 struct buffer *prev_buffer = NULL; | 1552 struct buffer *prev_buffer = NULL; |
1571 #if 0 /* This shouldn't be necessary anymore. --lorentey */ | 1553 #if 0 /* This shouldn't be necessary anymore. --lorentey */ |
1572 #ifdef MULTI_KBOARD | 1554 #ifdef MULTI_KBOARD |
1573 int was_locked = single_kboard; | 1555 int was_locked = single_kboard; |
1622 /* Display any malloc warning that just came out. Use while because | 1604 /* Display any malloc warning that just came out. Use while because |
1623 displaying one warning can cause another. */ | 1605 displaying one warning can cause another. */ |
1624 | 1606 |
1625 while (pending_malloc_warning) | 1607 while (pending_malloc_warning) |
1626 display_malloc_warning (); | 1608 display_malloc_warning (); |
1627 | |
1628 no_direct = 0; | |
1629 | 1609 |
1630 Vdeactivate_mark = Qnil; | 1610 Vdeactivate_mark = Qnil; |
1631 | 1611 |
1632 /* If minibuffer on and echo area in use, | 1612 /* If minibuffer on and echo area in use, |
1633 wait a short time and redraw minibuffer. */ | 1613 wait a short time and redraw minibuffer. */ |
1785 update_mode_lines = 1; | 1765 update_mode_lines = 1; |
1786 current_kboard->Vprefix_arg = Qnil; | 1766 current_kboard->Vprefix_arg = Qnil; |
1787 } | 1767 } |
1788 else | 1768 else |
1789 { | 1769 { |
1790 if (NILP (current_kboard->Vprefix_arg) && ! no_direct) | 1770 if (NILP (current_kboard->Vprefix_arg)) |
1791 { | 1771 { |
1792 /* In case we jump to directly_done. */ | 1772 /* In case we jump to directly_done. */ |
1793 Vcurrent_prefix_arg = current_kboard->Vprefix_arg; | 1773 Vcurrent_prefix_arg = current_kboard->Vprefix_arg; |
1794 | 1774 |
1795 /* Recognize some common commands in common situations and | 1775 /* Recognize some common commands in common situations and |
5556 | 5536 |
5557 switch (SWITCH_ENUM_CAST (event->kind)) | 5537 switch (SWITCH_ENUM_CAST (event->kind)) |
5558 { | 5538 { |
5559 /* A simple keystroke. */ | 5539 /* A simple keystroke. */ |
5560 case ASCII_KEYSTROKE_EVENT: | 5540 case ASCII_KEYSTROKE_EVENT: |
5561 { | |
5562 Lisp_Object lispy_c; | |
5563 int c = event->code & 0377; | |
5564 /* Turn ASCII characters into control characters | |
5565 when proper. */ | |
5566 if (event->modifiers & ctrl_modifier) | |
5567 c = make_ctrl_char (c); | |
5568 | |
5569 /* Add in the other modifier bits. We took care of ctrl_modifier | |
5570 just above, and the shift key was taken care of by the X code, | |
5571 and applied to control characters by make_ctrl_char. */ | |
5572 c |= (event->modifiers | |
5573 & (meta_modifier | alt_modifier | |
5574 | hyper_modifier | super_modifier)); | |
5575 /* Distinguish Shift-SPC from SPC. */ | |
5576 if ((event->code & 0377) == 040 | |
5577 && event->modifiers & shift_modifier) | |
5578 c |= shift_modifier; | |
5579 button_down_time = 0; | |
5580 XSETFASTINT (lispy_c, c); | |
5581 return lispy_c; | |
5582 } | |
5583 | |
5584 case MULTIBYTE_CHAR_KEYSTROKE_EVENT: | 5541 case MULTIBYTE_CHAR_KEYSTROKE_EVENT: |
5585 { | 5542 { |
5586 Lisp_Object lispy_c; | 5543 Lisp_Object lispy_c; |
5587 int c = event->code; | 5544 int c = event->code; |
5588 | 5545 if (event->kind == ASCII_KEYSTROKE_EVENT) |
5589 /* Add in the other modifier bits. We took care of ctrl_modifier | 5546 { |
5590 just above, and the shift key was taken care of by the X code, | 5547 c &= 0377; |
5591 and applied to control characters by make_ctrl_char. */ | 5548 eassert (c == event->code); |
5549 /* Turn ASCII characters into control characters | |
5550 when proper. */ | |
5551 if (event->modifiers & ctrl_modifier) | |
5552 { | |
5553 c = make_ctrl_char (c); | |
5554 event->modifiers &= ~ctrl_modifier; | |
5555 } | |
5556 } | |
5557 | |
5558 /* Add in the other modifier bits. The shift key was taken care | |
5559 of by the X code. */ | |
5592 c |= (event->modifiers | 5560 c |= (event->modifiers |
5593 & (meta_modifier | alt_modifier | 5561 & (meta_modifier | alt_modifier |
5594 | hyper_modifier | super_modifier | ctrl_modifier)); | 5562 | hyper_modifier | super_modifier | ctrl_modifier)); |
5595 /* What about the `shift' modifier ? */ | 5563 /* Distinguish Shift-SPC from SPC. */ |
5564 if ((event->code) == 040 | |
5565 && event->modifiers & shift_modifier) | |
5566 c |= shift_modifier; | |
5596 button_down_time = 0; | 5567 button_down_time = 0; |
5597 XSETFASTINT (lispy_c, c); | 5568 XSETFASTINT (lispy_c, c); |
5598 return lispy_c; | 5569 return lispy_c; |
5599 } | 5570 } |
5600 | 5571 |
9617 goto replay_key; | 9588 goto replay_key; |
9618 } | 9589 } |
9619 } | 9590 } |
9620 | 9591 |
9621 GROW_RAW_KEYBUF; | 9592 GROW_RAW_KEYBUF; |
9622 XVECTOR (raw_keybuf)->contents[raw_keybuf_count++] = key; | 9593 ASET (raw_keybuf, raw_keybuf_count++, key); |
9623 } | 9594 } |
9624 | 9595 |
9625 /* Clicks in non-text areas get prefixed by the symbol | 9596 /* Clicks in non-text areas get prefixed by the symbol |
9626 in their CHAR-ADDRESS field. For example, a click on | 9597 in their CHAR-ADDRESS field. For example, a click on |
9627 the mode line is prefixed by the symbol `mode-line'. | 9598 the mode line is prefixed by the symbol `mode-line'. |
10399 Lisp_Object cmd, record_flag, keys, special; | 10370 Lisp_Object cmd, record_flag, keys, special; |
10400 { | 10371 { |
10401 register Lisp_Object final; | 10372 register Lisp_Object final; |
10402 register Lisp_Object tem; | 10373 register Lisp_Object tem; |
10403 Lisp_Object prefixarg; | 10374 Lisp_Object prefixarg; |
10404 struct backtrace backtrace; | |
10405 extern int debug_on_next_call; | 10375 extern int debug_on_next_call; |
10406 | 10376 |
10407 debug_on_next_call = 0; | 10377 debug_on_next_call = 0; |
10408 | 10378 |
10409 if (NILP (special)) | 10379 if (NILP (special)) |
10465 | 10435 |
10466 return Fexecute_kbd_macro (final, prefixarg, Qnil); | 10436 return Fexecute_kbd_macro (final, prefixarg, Qnil); |
10467 } | 10437 } |
10468 | 10438 |
10469 if (CONSP (final) || SUBRP (final) || COMPILEDP (final)) | 10439 if (CONSP (final) || SUBRP (final) || COMPILEDP (final)) |
10470 { | 10440 /* Don't call Fcall_interactively directly because we want to make |
10471 backtrace.next = backtrace_list; | 10441 sure the backtrace has an entry for `call-interactively'. |
10472 backtrace_list = &backtrace; | 10442 For the same reason, pass `cmd' rather than `final'. */ |
10473 backtrace.function = &Qcall_interactively; | 10443 return call3 (Qcall_interactively, cmd, record_flag, keys); |
10474 backtrace.args = &cmd; | 10444 |
10475 backtrace.nargs = 1; | |
10476 backtrace.evalargs = 0; | |
10477 backtrace.debug_on_exit = 0; | |
10478 | |
10479 tem = Fcall_interactively (cmd, record_flag, keys); | |
10480 | |
10481 backtrace_list = backtrace.next; | |
10482 return tem; | |
10483 } | |
10484 return Qnil; | 10445 return Qnil; |
10485 } | 10446 } |
10486 | 10447 |
10487 | 10448 |
10488 | 10449 |
10589 Qt, Qnil, Qnil); | 10550 Qt, Qnil, Qnil); |
10590 else | 10551 else |
10591 bindings = Qnil; | 10552 bindings = Qnil; |
10592 | 10553 |
10593 value = Qnil; | 10554 value = Qnil; |
10594 GCPRO2 (bindings, value); | 10555 GCPRO3 (bindings, value, function); |
10595 value = Fcommand_execute (function, Qt, Qnil, Qnil); | 10556 value = Fcommand_execute (function, Qt, Qnil, Qnil); |
10596 | 10557 |
10597 /* If the command has a key binding, print it now. */ | 10558 /* If the command has a key binding, print it now. */ |
10598 if (!NILP (bindings) | 10559 if (!NILP (bindings) |
10599 && ! (VECTORP (bindings) && EQ (Faref (bindings, make_number (0)), | 10560 && ! (VECTORP (bindings) && EQ (Faref (bindings, make_number (0)), |