Commit e4fe371d authored by Richard M. Stallman's avatar Richard M. Stallman
Browse files

(record_char): New subroutine.

(read_char): Use record_char.
Split up menu-bar mouse click events here.
Call record_char for both halves; likewise echo_char and add_command_key.
parent 23dab951
......@@ -1464,6 +1464,7 @@ make_ctrl_char (c)
Lisp_Object print_help ();
static Lisp_Object kbd_buffer_get_event ();
static void record_char ();
/* read a character from the keyboard; call the redisplay if needed */
/* commandflag 0 means do not do auto-saving, but do do redisplay.
......@@ -1494,6 +1495,8 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu)
int count;
jmp_buf save_jump;
int key_already_recorded = 0;
Lisp_Object also_record;
also_record = Qnil;
if (CONSP (Vunread_command_events))
{
......@@ -1773,46 +1776,33 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu)
XSETINT (c, XSTRING (Vkeyboard_translate_table)->data[XFASTINT (c)]);
}
total_keys++;
XVECTOR (recent_keys)->contents[recent_keys_index] = c;
if (++recent_keys_index >= NUM_RECENT_KEYS)
recent_keys_index = 0;
/* Write c to the dribble file. If c is a lispy event, write
the event's symbol to the dribble file, in <brackets>. Bleaugh.
If you, dear reader, have a better idea, you've got the source. :-) */
if (dribble)
/* If this event is a mouse click in the menu bar,
return just menu-bar for now. Modify the mouse click event
so we won't do this twice, then queue it up. */
if (EVENT_HAS_PARAMETERS (c)
&& CONSP (XCONS (c)->cdr)
&& CONSP (EVENT_START (c))
&& CONSP (XCONS (EVENT_START (c))->cdr))
{
if (INTEGERP (c))
{
if (XUINT (c) < 0x100)
putc (XINT (c), dribble);
else
fprintf (dribble, " 0x%x", XUINT (c));
}
else
{
Lisp_Object dribblee;
Lisp_Object posn;
/* If it's a structured event, take the event header. */
dribblee = EVENT_HEAD (c);
posn = POSN_BUFFER_POSN (EVENT_START (c));
/* Handle menu-bar events:
insert the dummy prefix event `menu-bar'. */
if (EQ (posn, Qmenu_bar))
{
/* Change menu-bar to (menu-bar) as the event "position". */
POSN_BUFFER_POSN (EVENT_START (c)) = Fcons (posn, Qnil);
if (SYMBOLP (dribblee))
{
putc ('<', dribble);
fwrite (XSYMBOL (dribblee)->name->data, sizeof (char),
XSYMBOL (dribblee)->name->size,
dribble);
putc ('>', dribble);
}
also_record = c;
Vunread_command_events = Fcons (c, Vunread_command_events);
c = posn;
}
fflush (dribble);
}
store_kbd_macro_char (c);
num_nonmacro_input_chars++;
record_char (c);
if (! NILP (also_record))
record_char (also_record);
from_macro:
reread_first:
......@@ -1820,10 +1810,16 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu)
/* Don't echo mouse motion events. */
if (! (EVENT_HAS_PARAMETERS (c)
&& EQ (EVENT_HEAD_KIND (EVENT_HEAD (c)), Qmouse_movement)))
echo_char (c);
{
echo_char (c);
if (! NILP (also_record))
echo_char (also_record);
}
/* Record this character as part of the current key. */
add_command_key (c);
if (! NILP (also_record))
add_command_key (also_record);
/* Re-reading in the middle of a command */
reread:
......@@ -1863,6 +1859,54 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu)
return c;
}
/* Record the input event C in various ways. */
static void
record_char (c)
Lisp_Object c;
{
total_keys++;
XVECTOR (recent_keys)->contents[recent_keys_index] = c;
if (++recent_keys_index >= NUM_RECENT_KEYS)
recent_keys_index = 0;
/* Write c to the dribble file. If c is a lispy event, write
the event's symbol to the dribble file, in <brackets>. Bleaugh.
If you, dear reader, have a better idea, you've got the source. :-) */
if (dribble)
{
if (INTEGERP (c))
{
if (XUINT (c) < 0x100)
putc (XINT (c), dribble);
else
fprintf (dribble, " 0x%x", XUINT (c));
}
else
{
Lisp_Object dribblee;
/* If it's a structured event, take the event header. */
dribblee = EVENT_HEAD (c);
if (SYMBOLP (dribblee))
{
putc ('<', dribble);
fwrite (XSYMBOL (dribblee)->name->data, sizeof (char),
XSYMBOL (dribblee)->name->size,
dribble);
putc ('>', dribble);
}
}
fflush (dribble);
}
store_kbd_macro_char (c);
num_nonmacro_input_chars++;
}
Lisp_Object
print_help (object)
Lisp_Object object;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment