aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/keyboard.c114
1 files changed, 79 insertions, 35 deletions
diff --git a/src/keyboard.c b/src/keyboard.c
index 0007045651c..a873c1c7df6 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -1464,6 +1464,7 @@ make_ctrl_char (c)
1464 1464
1465Lisp_Object print_help (); 1465Lisp_Object print_help ();
1466static Lisp_Object kbd_buffer_get_event (); 1466static Lisp_Object kbd_buffer_get_event ();
1467static void record_char ();
1467 1468
1468/* read a character from the keyboard; call the redisplay if needed */ 1469/* read a character from the keyboard; call the redisplay if needed */
1469/* commandflag 0 means do not do auto-saving, but do do redisplay. 1470/* 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)
1494 int count; 1495 int count;
1495 jmp_buf save_jump; 1496 jmp_buf save_jump;
1496 int key_already_recorded = 0; 1497 int key_already_recorded = 0;
1498 Lisp_Object also_record;
1499 also_record = Qnil;
1497 1500
1498 if (CONSP (Vunread_command_events)) 1501 if (CONSP (Vunread_command_events))
1499 { 1502 {
@@ -1773,46 +1776,33 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu)
1773 XSETINT (c, XSTRING (Vkeyboard_translate_table)->data[XFASTINT (c)]); 1776 XSETINT (c, XSTRING (Vkeyboard_translate_table)->data[XFASTINT (c)]);
1774 } 1777 }
1775 1778
1776 total_keys++; 1779 /* If this event is a mouse click in the menu bar,
1777 XVECTOR (recent_keys)->contents[recent_keys_index] = c; 1780 return just menu-bar for now. Modify the mouse click event
1778 if (++recent_keys_index >= NUM_RECENT_KEYS) 1781 so we won't do this twice, then queue it up. */
1779 recent_keys_index = 0; 1782 if (EVENT_HAS_PARAMETERS (c)
1780 1783 && CONSP (XCONS (c)->cdr)
1781 /* Write c to the dribble file. If c is a lispy event, write 1784 && CONSP (EVENT_START (c))
1782 the event's symbol to the dribble file, in <brackets>. Bleaugh. 1785 && CONSP (XCONS (EVENT_START (c))->cdr))
1783 If you, dear reader, have a better idea, you've got the source. :-) */
1784 if (dribble)
1785 { 1786 {
1786 if (INTEGERP (c)) 1787 Lisp_Object posn;
1787 {
1788 if (XUINT (c) < 0x100)
1789 putc (XINT (c), dribble);
1790 else
1791 fprintf (dribble, " 0x%x", XUINT (c));
1792 }
1793 else
1794 {
1795 Lisp_Object dribblee;
1796 1788
1797 /* If it's a structured event, take the event header. */ 1789 posn = POSN_BUFFER_POSN (EVENT_START (c));
1798 dribblee = EVENT_HEAD (c); 1790 /* Handle menu-bar events:
1791 insert the dummy prefix event `menu-bar'. */
1792 if (EQ (posn, Qmenu_bar))
1793 {
1794 /* Change menu-bar to (menu-bar) as the event "position". */
1795 POSN_BUFFER_POSN (EVENT_START (c)) = Fcons (posn, Qnil);
1799 1796
1800 if (SYMBOLP (dribblee)) 1797 also_record = c;
1801 { 1798 Vunread_command_events = Fcons (c, Vunread_command_events);
1802 putc ('<', dribble); 1799 c = posn;
1803 fwrite (XSYMBOL (dribblee)->name->data, sizeof (char),
1804 XSYMBOL (dribblee)->name->size,
1805 dribble);
1806 putc ('>', dribble);
1807 }
1808 } 1800 }
1809
1810 fflush (dribble);
1811 } 1801 }
1812 1802
1813 store_kbd_macro_char (c); 1803 record_char (c);
1814 1804 if (! NILP (also_record))
1815 num_nonmacro_input_chars++; 1805 record_char (also_record);
1816 1806
1817 from_macro: 1807 from_macro:
1818 reread_first: 1808 reread_first:
@@ -1820,10 +1810,16 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu)
1820 /* Don't echo mouse motion events. */ 1810 /* Don't echo mouse motion events. */
1821 if (! (EVENT_HAS_PARAMETERS (c) 1811 if (! (EVENT_HAS_PARAMETERS (c)
1822 && EQ (EVENT_HEAD_KIND (EVENT_HEAD (c)), Qmouse_movement))) 1812 && EQ (EVENT_HEAD_KIND (EVENT_HEAD (c)), Qmouse_movement)))
1823 echo_char (c); 1813 {
1814 echo_char (c);
1815 if (! NILP (also_record))
1816 echo_char (also_record);
1817 }
1824 1818
1825 /* Record this character as part of the current key. */ 1819 /* Record this character as part of the current key. */
1826 add_command_key (c); 1820 add_command_key (c);
1821 if (! NILP (also_record))
1822 add_command_key (also_record);
1827 1823
1828 /* Re-reading in the middle of a command */ 1824 /* Re-reading in the middle of a command */
1829 reread: 1825 reread:
@@ -1863,6 +1859,54 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu)
1863 return c; 1859 return c;
1864} 1860}
1865 1861
1862/* Record the input event C in various ways. */
1863
1864static void
1865record_char (c)
1866 Lisp_Object c;
1867{
1868 total_keys++;
1869 XVECTOR (recent_keys)->contents[recent_keys_index] = c;
1870 if (++recent_keys_index >= NUM_RECENT_KEYS)
1871 recent_keys_index = 0;
1872
1873 /* Write c to the dribble file. If c is a lispy event, write
1874 the event's symbol to the dribble file, in <brackets>. Bleaugh.
1875 If you, dear reader, have a better idea, you've got the source. :-) */
1876 if (dribble)
1877 {
1878 if (INTEGERP (c))
1879 {
1880 if (XUINT (c) < 0x100)
1881 putc (XINT (c), dribble);
1882 else
1883 fprintf (dribble, " 0x%x", XUINT (c));
1884 }
1885 else
1886 {
1887 Lisp_Object dribblee;
1888
1889 /* If it's a structured event, take the event header. */
1890 dribblee = EVENT_HEAD (c);
1891
1892 if (SYMBOLP (dribblee))
1893 {
1894 putc ('<', dribble);
1895 fwrite (XSYMBOL (dribblee)->name->data, sizeof (char),
1896 XSYMBOL (dribblee)->name->size,
1897 dribble);
1898 putc ('>', dribble);
1899 }
1900 }
1901
1902 fflush (dribble);
1903 }
1904
1905 store_kbd_macro_char (c);
1906
1907 num_nonmacro_input_chars++;
1908}
1909
1866Lisp_Object 1910Lisp_Object
1867print_help (object) 1911print_help (object)
1868 Lisp_Object object; 1912 Lisp_Object object;