if (!NILP (Vpre_command_hook))
call1 (Vrun_hooks, Qpre_command_hook);
- if (NILP (cmd))
+ if (NILP (this_command))
{
/* nil means key is undefined. */
bitch_at_user ();
{
/* Recognize some common commands in common situations and
do them directly. */
- if (EQ (cmd, Qforward_char) && point < ZV)
+ if (EQ (this_command, Qforward_char) && point < ZV)
{
struct Lisp_Vector *dp
= window_display_table (XWINDOW (selected_window));
no_redisplay = direct_output_forward_char (1);
goto directly_done;
}
- else if (EQ (cmd, Qbackward_char) && point > BEGV)
+ else if (EQ (this_command, Qbackward_char) && point > BEGV)
{
struct Lisp_Vector *dp
= window_display_table (XWINDOW (selected_window));
no_redisplay = direct_output_forward_char (-1);
goto directly_done;
}
- else if (EQ (cmd, Qself_insert_command)
+ else if (EQ (this_command, Qself_insert_command)
/* Try this optimization only on ascii keystrokes. */
&& XTYPE (last_command_char) == Lisp_Int)
{
nonundocount = 0;
if (NILP (Vprefix_arg))
Fundo_boundary ();
- Fcommand_execute (cmd, Qnil);
+ Fcommand_execute (this_command, Qnil);
}
directly_done: ;
}
#endif
}
+\f
+/* Applying the control modifier to CHARACTER. */
+int
+make_ctrl_char (c)
+ int c;
+{
+ /* Save the upper bits here. */
+ int upper = c & ~0177;
+
+ c &= 0177;
+
+ /* Everything in the columns containing the upper-case letters
+ denotes a control character. */
+ if (c >= 0100 && c < 0140)
+ {
+ int oc = c;
+ c &= ~0140;
+ /* Set the shift modifier for a control char
+ made from a shifted letter. But only for letters! */
+ if (oc >= 'A' && oc <= 'Z')
+ c |= shift_modifier;
+ }
+
+ /* The lower-case letters denote control characters too. */
+ else if (c >= 'a' && c <= 'z')
+ c &= ~0140;
+
+ /* Include the bits for control and shift
+ only if the basic ASCII code can't indicate them. */
+ else if (c >= ' ')
+ c |= ctrl_modifier;
+
+ /* Replace the high bits. */
+ c |= (upper & ~ctrl_modifier);
+
+ return c;
+}
+
+
\f
/* Input of single characters from keyboard */
if ((extra_keyboard_modifiers & CHAR_CTL)
|| ((extra_keyboard_modifiers & 0177) < ' '
&& (extra_keyboard_modifiers & 0177) != 0))
- {
- /* If it's already a control character, don't mess with it. */
- if ((c & 0177) == 0)
- ;
-
- /* Making ? a control character should result in DEL. */
- else if ((c & 0177) == '?')
- c |= 0177;
-
- /* ASCII control chars are made from letters (both cases),
- as well as the non-letters within 0100...0137. */
- else if ((c & 0137) >= 0101 && (c & 0137) <= 0132)
- c = (c & (037 | ~0177));
- else if ((c & 0177) >= 0100 && (c & 0177) <= 0137)
- c = (c & (037 | ~0177));
-
- /* Anything else must get its high control bit set. */
- else
- c = c | ctrl_modifier;
- }
+ XSETINT (c, make_ctrl_char (XINT (c)));
/* Transfer any other modifier bits directly from
extra_keyboard_modifiers to c. Ignore the actual character code
{
register int c = XFASTINT (event->code) & 0377;
+ if (event->modifiers & ctrl_modifier)
+ c = make_ctrl_char (c);
+
if (c == quit_char)
{
extern SIGTYPE interrupt_signal ();
"insertchar",
"deletechar",
"backtab",
- "kp_backtab", /* 0x1000ff75 */
+ "kp-backtab", /* 0x1000ff75 */
0, /* 0xff76 */
- 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xff7f */
+ 0, 0, 0, 0, 0, 0, 0, 0, "kp-numlock", /* 0xff7f */
"kp-space", /* 0xff80 */ /* IsKeypadKey */
0, 0, 0, 0, 0, 0, 0, 0,
"kp-tab", /* 0xff89 */
/* Turn ASCII characters into control characters
when proper. */
if (event->modifiers & ctrl_modifier)
- {
- if (c >= 0100 && c < 0140)
- c &= ~040;
- /* Include the bits for control and shift
- only if the basic ASCII code can't indicate them. */
- c |= ctrl_modifier;
- }
- /* Set the shift modifier for a control char
- made from a shifted letter. But only for letters! */
- if (XFASTINT (event->code) >= 'A' - 0100
- && XFASTINT (event->code) <= 'Z' - 0100
- && (event->modifiers & shift_modifier))
- c |= shift_modifier;
+ c = make_ctrl_char (c);
+
+ /* Add in the other modifier bits. We took care of ctrl_modifier
+ just above, and the shift key was taken care of by the X code,
+ and applied to control characters by make_ctrl_char. */
c |= (event->modifiers
& (meta_modifier | alt_modifier
| hyper_modifier | super_modifier));
{
window = Qnil;
posn = Qnil;
+ XFASTINT (x) = 0;
+ XFASTINT (y) = 0;
}
return Fcons (Qmouse_movement,
static char *modifier_names[] =
{
- "up", 0, 0, 0, 0, 0, 0, "down",
- "drag", "click", 0, 0, 0, 0, 0, 0,
+ "up", "down", "drag", "click", 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, "alt", "super", "hyper", "shift", "control", "meta"
};
#define NUM_MOD_NAMES (sizeof (modifier_names) / sizeof (modifier_names[0]))
if (NILP (*slot))
{
/* No; let's create it. */
- *slot = intern (name_table[symbol_num]);
+ if (name_table[symbol_num])
+ *slot = intern (name_table[symbol_num]);
+ else
+ {
+ char buf[20];
+ sprintf (buf, "key-%d", symbol_num);
+ *slot = intern (buf);
+ }
/* Fill in the cache entries for this symbol; this also
builds the Qevent_symbol_elements property, which the user
lower-case letter, return the bindings for the lower-case letter. */
if (first_binding == nmaps
&& XTYPE (key) == Lisp_Int
- && (UPPERCASEP (XINT (key) & 0x3ffff)
+ && ((((XINT (key) & 0x3ffff)
+ < XSTRING (current_buffer->downcase_table)->size)
+ && UPPERCASEP (XINT (key) & 0x3ffff))
|| (XINT (key) & shift_modifier)))
{
if (XINT (key) & shift_modifier)
if (NILP (Fkeymapp (Vfunction_key_map)))
fkey_start = fkey_end = bufsize + 1;
- /* We need to save the current buffer in case we switch buffers to
- find the right binding for a mouse click. Note that we can't use
- save_excursion_{save,restore} here, because they save point as
- well as the current buffer; we don't want to save point, because
- redisplay may change it, to accomodate a Fset_window_start or
- something. */
- record_unwind_protect (Fset_buffer, Fcurrent_buffer ());
-
last_nonmenu_event = Qnil;
if (INTERACTIVE)
mock_input = t + 1;
}
+ /* Arrange to go back to the original buffer once we're
+ done reading the key sequence. Note that we can't
+ use save_excursion_{save,restore} here, because they
+ save point as well as the current buffer; we don't
+ want to save point, because redisplay may change it,
+ to accomodate a Fset_window_start or something. We
+ don't want to do this at the top of the function,
+ because we may get input from a subprocess which
+ wants to change the selected window and stuff (say,
+ emacsclient). */
+ record_unwind_protect (Fset_buffer, Fcurrent_buffer ());
+
set_buffer_internal (XBUFFER (XWINDOW (window)->buffer));
goto replay_sequence;
}
Third arg META t means accept 8-bit input (for a Meta key).\n\
META nil means ignore the top bit, on the assumption it is parity.\n\
Otherwise, accept 8-bit input and don't use the top bit for Meta.\n\
-Optional fourth arg QUIT if non-nil specifies character to use for quitting.")
+Optional fourth arg QUIT if non-nil specifies character to use for quitting.\n\
+See also `current-input-mode'.")
(interrupt, flow, meta, quit)
Lisp_Object interrupt, flow, meta, quit;
{
nil, Emacs is using CBREAK mode.\n\
FLOW is non-nil if Emacs uses ^S/^Q flow control for output to the\n\
terminal; this does not apply if Emacs uses interrupt-driven input.\n\
- META is non-nil if Emacs is accepting 8-bit input; otherwise, Emacs\n\
- clears the eighth bit of every input character.\n\
+ META is t if accepting 8-bit input with 8th bit as Meta flag.\n\
+ META nil means ignoring the top bit, on the assumption it is parity.\n\
+ META is neither t nor nil if accepting 8-bit input and using\n\
+ all 8 bits as the character code.\n\
QUIT is the character Emacs currently uses to quit.\n\
The elements of this list correspond to the arguments of\n\
-set-input-mode.")
+`set-input-mode'.")
()
{
Lisp_Object val[4];
val[0] = interrupt_input ? Qt : Qnil;
val[1] = flow_control ? Qt : Qnil;
- val[2] = meta_key ? Qt : Qnil;
+ val[2] = meta_key == 2 ? make_number (0) : meta_key == 1 ? Qt : Qnil;
XSETINT (val[3], quit_char);
return Flist (val, sizeof (val) / sizeof (val[0]));