Mercurial > emacs
comparison src/keyboard.c @ 10985:d917a965cb47
(unlock_display): current_perdisplay now is never null.
(cmd_error, command_loop_1, read_char): Likewise.
(kbd_buffer_get_event, read_key_sequence): Likewise.
(read_char): Handle synchronous quit_char on a different display.
(read_char): Rewrite queue-searching code.
(read_key_sequence): Save selected_frame.
(init_keyboard): Initialize current_perdisplay.
author | Karl Heuer <kwzh@gnu.org> |
---|---|
date | Mon, 13 Mar 1995 03:09:40 +0000 |
parents | 0409e4548077 |
children | 66d853abce42 |
comparison
equal
deleted
inserted
replaced
10984:0409e4548077 | 10985:d917a965cb47 |
---|---|
523 current_perdisplay->echo_after_prompt = len; | 523 current_perdisplay->echo_after_prompt = len; |
524 | 524 |
525 echo (); | 525 echo (); |
526 } | 526 } |
527 | 527 |
528 /* Add C to the echo string, if echoing is going on. | 528 /* Add C to the echo string, if echoing is going on. |
529 C can be a character, which is printed prettily ("M-C-x" and all that | 529 C can be a character, which is printed prettily ("M-C-x" and all that |
530 jazz), or a symbol, whose name is printed. */ | 530 jazz), or a symbol, whose name is printed. */ |
531 | 531 |
532 echo_char (c) | 532 echo_char (c) |
533 Lisp_Object c; | 533 Lisp_Object c; |
535 extern char *push_key_description (); | 535 extern char *push_key_description (); |
536 | 536 |
537 if (current_perdisplay->immediate_echo) | 537 if (current_perdisplay->immediate_echo) |
538 { | 538 { |
539 char *ptr = current_perdisplay->echoptr; | 539 char *ptr = current_perdisplay->echoptr; |
540 | 540 |
541 if (ptr != current_perdisplay->echobuf) | 541 if (ptr != current_perdisplay->echobuf) |
542 *ptr++ = ' '; | 542 *ptr++ = ' '; |
543 | 543 |
544 /* If someone has passed us a composite event, use its head symbol. */ | 544 /* If someone has passed us a composite event, use its head symbol. */ |
545 c = EVENT_HEAD (c); | 545 c = EVENT_HEAD (c); |
760 current_perdisplay->kbd_queue | 760 current_perdisplay->kbd_queue |
761 = nconc2 (Vunread_command_events, current_perdisplay->kbd_queue); | 761 = nconc2 (Vunread_command_events, current_perdisplay->kbd_queue); |
762 current_perdisplay->kbd_queue_has_data = 1; | 762 current_perdisplay->kbd_queue_has_data = 1; |
763 } | 763 } |
764 Vunread_command_events = Qnil; | 764 Vunread_command_events = Qnil; |
765 current_perdisplay = 0; | |
766 display_locked = 0; | 765 display_locked = 0; |
767 } | 766 } |
768 #endif | 767 #endif |
769 | 768 |
770 Lisp_Object | 769 Lisp_Object |
774 Lisp_Object old_level, old_length; | 773 Lisp_Object old_level, old_length; |
775 | 774 |
776 Vstandard_output = Qt; | 775 Vstandard_output = Qt; |
777 Vstandard_input = Qt; | 776 Vstandard_input = Qt; |
778 Vexecuting_macro = Qnil; | 777 Vexecuting_macro = Qnil; |
779 if (current_perdisplay) | 778 clear_prefix_arg (); |
780 { | 779 cancel_echoing (); |
781 clear_prefix_arg (); | |
782 cancel_echoing (); | |
783 } | |
784 | 780 |
785 /* Avoid unquittable loop if data contains a circular list. */ | 781 /* Avoid unquittable loop if data contains a circular list. */ |
786 old_level = Vprint_level; | 782 old_level = Vprint_level; |
787 old_length = Vprint_length; | 783 old_length = Vprint_length; |
788 XSETFASTINT(Vprint_level, 10); | 784 XSETFASTINT(Vprint_level, 10); |
793 | 789 |
794 Vquit_flag = Qnil; | 790 Vquit_flag = Qnil; |
795 | 791 |
796 Vinhibit_quit = Qnil; | 792 Vinhibit_quit = Qnil; |
797 #ifdef MULTI_PERDISPLAY | 793 #ifdef MULTI_PERDISPLAY |
798 if (current_perdisplay) | 794 unlock_display (); |
799 unlock_display (); | |
800 #endif | 795 #endif |
801 | 796 |
802 return make_number (0); | 797 return make_number (0); |
803 } | 798 } |
804 | 799 |
903 else | 898 else |
904 while (1) | 899 while (1) |
905 { | 900 { |
906 internal_catch (Qtop_level, top_level_1, Qnil); | 901 internal_catch (Qtop_level, top_level_1, Qnil); |
907 internal_catch (Qtop_level, command_loop_2, Qnil); | 902 internal_catch (Qtop_level, command_loop_2, Qnil); |
908 | 903 |
909 /* End of file in -batch run causes exit here. */ | 904 /* End of file in -batch run causes exit here. */ |
910 if (noninteractive) | 905 if (noninteractive) |
911 Fkill_emacs (Qt); | 906 Fkill_emacs (Qt); |
912 } | 907 } |
913 } | 908 } |
999 int was_locked = display_locked; | 994 int was_locked = display_locked; |
1000 #endif | 995 #endif |
1001 | 996 |
1002 Vdeactivate_mark = Qnil; | 997 Vdeactivate_mark = Qnil; |
1003 waiting_for_input = 0; | 998 waiting_for_input = 0; |
1004 if (current_perdisplay) | 999 cancel_echoing (); |
1005 cancel_echoing (); | |
1006 | 1000 |
1007 nonundocount = 0; | 1001 nonundocount = 0; |
1008 no_redisplay = 0; | 1002 no_redisplay = 0; |
1009 this_command_key_count = 0; | 1003 this_command_key_count = 0; |
1010 | 1004 |
1604 || executing_macro_index >= XFASTINT (Flength (Vexecuting_macro))) | 1598 || executing_macro_index >= XFASTINT (Flength (Vexecuting_macro))) |
1605 { | 1599 { |
1606 XSETINT (c, -1); | 1600 XSETINT (c, -1); |
1607 return c; | 1601 return c; |
1608 } | 1602 } |
1609 | 1603 |
1610 c = Faref (Vexecuting_macro, make_number (executing_macro_index)); | 1604 c = Faref (Vexecuting_macro, make_number (executing_macro_index)); |
1611 if (STRINGP (Vexecuting_macro) | 1605 if (STRINGP (Vexecuting_macro) |
1612 && (XINT (c) & 0x80)) | 1606 && (XINT (c) & 0x80)) |
1613 XSETFASTINT (c, CHAR_META | (XINT (c) & ~0x80)); | 1607 XSETFASTINT (c, CHAR_META | (XINT (c) & ~0x80)); |
1614 | 1608 |
1651 /* If we report the quit char as an event, | 1645 /* If we report the quit char as an event, |
1652 don't do so more than once. */ | 1646 don't do so more than once. */ |
1653 if (!NILP (Vinhibit_quit)) | 1647 if (!NILP (Vinhibit_quit)) |
1654 Vquit_flag = Qnil; | 1648 Vquit_flag = Qnil; |
1655 | 1649 |
1650 #ifdef MULTI_PERDISPLAY | |
1651 { | |
1652 PERDISPLAY *perd = get_perdisplay (selected_frame); | |
1653 if (perd != current_perdisplay) | |
1654 { | |
1655 Lisp_Object *tailp = &perd->kbd_queue; | |
1656 /* We shouldn't get here if we were locked onto one display! */ | |
1657 if (display_locked) | |
1658 abort (); | |
1659 while (CONSP (*tailp)) | |
1660 tailp = &XCONS (*tailp)->cdr; | |
1661 if (!NILP (*tailp)) | |
1662 abort (); | |
1663 *tailp = Fcons (c, Qnil); | |
1664 perd->kbd_queue_has_data = 1; | |
1665 current_perdisplay = perd; | |
1666 longjmp (wrong_display_jmpbuf, 1); | |
1667 } | |
1668 } | |
1669 #endif | |
1656 goto non_reread; | 1670 goto non_reread; |
1657 } | 1671 } |
1658 | 1672 |
1659 if (current_perdisplay) | 1673 /* Message turns off echoing unless more keystrokes turn it on again. */ |
1660 { | 1674 if (echo_area_glyphs && *echo_area_glyphs |
1661 /* Message turns off echoing unless more keystrokes turn it on again. */ | 1675 && echo_area_glyphs != current_perdisplay->echobuf) |
1662 if (echo_area_glyphs && *echo_area_glyphs | 1676 cancel_echoing (); |
1663 && echo_area_glyphs != current_perdisplay->echobuf) | 1677 else |
1664 cancel_echoing (); | 1678 /* If already echoing, continue. */ |
1665 else | 1679 echo_dash (); |
1666 /* If already echoing, continue. */ | |
1667 echo_dash (); | |
1668 } | |
1669 | 1680 |
1670 /* Try reading a character via menu prompting in the minibuf. | 1681 /* Try reading a character via menu prompting in the minibuf. |
1671 Try this before the sit-for, because the sit-for | 1682 Try this before the sit-for, because the sit-for |
1672 would do the wrong thing if we are supposed to do | 1683 would do the wrong thing if we are supposed to do |
1673 menu prompting. If EVENT_HAS_PARAMETERS then we are reading | 1684 menu prompting. If EVENT_HAS_PARAMETERS then we are reading |
1688 } | 1699 } |
1689 } | 1700 } |
1690 | 1701 |
1691 /* If in middle of key sequence and minibuffer not active, | 1702 /* If in middle of key sequence and minibuffer not active, |
1692 start echoing if enough time elapses. */ | 1703 start echoing if enough time elapses. */ |
1693 if (current_perdisplay | 1704 if (minibuf_level == 0 && !current_perdisplay->immediate_echo |
1694 && minibuf_level == 0 | |
1695 && !current_perdisplay->immediate_echo | |
1696 && this_command_key_count > 0 | 1705 && this_command_key_count > 0 |
1697 && ! noninteractive | 1706 && ! noninteractive |
1698 && echo_keystrokes > 0 | 1707 && echo_keystrokes > 0 |
1699 && (echo_area_glyphs == 0 || *echo_area_glyphs == 0)) | 1708 && (echo_area_glyphs == 0 || *echo_area_glyphs == 0)) |
1700 { | 1709 { |
1784 } | 1793 } |
1785 } | 1794 } |
1786 | 1795 |
1787 if (NILP (c)) | 1796 if (NILP (c)) |
1788 { | 1797 { |
1789 PERDISPLAY *perd; | 1798 /* Primary consideration goes to current_perdisplay's side queue. |
1790 /* Check for something on one of the side queues. Give priority to | 1799 If that's empty, then we check the other side queues and throw |
1791 the current display, but if we're not locked, then check the other | 1800 if we find something there. Finally, we read from the main queue, |
1792 displays as well. */ | 1801 and if that gives us something we can't use yet, we put it on the |
1793 if (current_perdisplay && current_perdisplay->kbd_queue_has_data) | 1802 appropriate side queue and try again. */ |
1794 perd = current_perdisplay; | 1803 if (current_perdisplay->kbd_queue_has_data) |
1795 else if (!display_locked) | |
1796 { | 1804 { |
1797 for (perd = all_perdisplays; perd; perd = perd->next_perdisplay) | 1805 if (!CONSP (current_perdisplay->kbd_queue)) |
1798 if (perd->kbd_queue_has_data) | |
1799 break; | |
1800 } | |
1801 else | |
1802 perd = 0; | |
1803 | |
1804 /* If we found something on a side queue, use that. | |
1805 Otherwise, read from the main queue, and if that gives us | |
1806 something we can't use yet, put it on the side queue and | |
1807 try again. */ | |
1808 if (perd) | |
1809 { | |
1810 if (!CONSP (perd->kbd_queue)) | |
1811 abort (); | 1806 abort (); |
1812 c = XCONS (perd->kbd_queue)->car; | 1807 c = XCONS (current_perdisplay->kbd_queue)->car; |
1813 perd->kbd_queue = XCONS (perd->kbd_queue)->cdr; | 1808 current_perdisplay->kbd_queue |
1814 if (NILP (perd->kbd_queue)) | 1809 = XCONS (current_perdisplay->kbd_queue)->cdr; |
1815 perd->kbd_queue_has_data = 0; | 1810 if (NILP (current_perdisplay->kbd_queue)) |
1811 current_perdisplay->kbd_queue_has_data = 0; | |
1816 input_pending = readable_events (); | 1812 input_pending = readable_events (); |
1817 #ifdef MULTI_FRAME | 1813 #ifdef MULTI_FRAME |
1818 if (EVENT_HAS_PARAMETERS (c) | 1814 if (EVENT_HAS_PARAMETERS (c) |
1819 && EQ (EVENT_HEAD_KIND (EVENT_HEAD (c)), Qswitch_frame)) | 1815 && EQ (EVENT_HEAD_KIND (EVENT_HEAD (c)), Qswitch_frame)) |
1820 internal_last_event_frame = XCONS (XCONS (c)->cdr)->car; | 1816 internal_last_event_frame = XCONS (XCONS (c)->cdr)->car; |
1821 Vlast_event_frame = internal_last_event_frame; | 1817 Vlast_event_frame = internal_last_event_frame; |
1822 #endif | 1818 #endif |
1823 } | 1819 } |
1824 else | 1820 else |
1825 { | 1821 { |
1822 PERDISPLAY *perd; | |
1823 #ifdef MULTI_PERDISPLAY | |
1824 if (!display_locked) | |
1825 { | |
1826 for (perd = all_perdisplays; perd; perd = perd->next_perdisplay) | |
1827 if (perd->kbd_queue_has_data) | |
1828 { | |
1829 current_perdisplay = perd; | |
1830 longjmp (wrong_display_jmpbuf, 1); | |
1831 } | |
1832 } | |
1833 #endif | |
1834 | |
1826 wrong_display: | 1835 wrong_display: |
1827 /* Actually read a character, waiting if necessary. */ | 1836 /* Actually read a character, waiting if necessary. */ |
1828 while (c = kbd_buffer_get_event (&perd), NILP (c)) | 1837 while (c = kbd_buffer_get_event (&perd), NILP (c)) |
1829 { | 1838 { |
1830 if (commandflag >= 0 | 1839 if (commandflag >= 0 |
1832 { | 1841 { |
1833 prepare_menu_bars (); | 1842 prepare_menu_bars (); |
1834 redisplay (); | 1843 redisplay (); |
1835 } | 1844 } |
1836 } | 1845 } |
1837 if (display_locked && perd != current_perdisplay) | 1846 #ifdef MULTI_PERDISPLAY |
1847 if (perd != current_perdisplay) | |
1838 { | 1848 { |
1839 Lisp_Object *tailp = &perd->kbd_queue; | 1849 Lisp_Object *tailp = &perd->kbd_queue; |
1840 while (CONSP (*tailp)) | 1850 while (CONSP (*tailp)) |
1841 tailp = &XCONS (*tailp)->cdr; | 1851 tailp = &XCONS (*tailp)->cdr; |
1842 if (!NILP (*tailp)) | 1852 if (!NILP (*tailp)) |
1843 abort (); | 1853 abort (); |
1844 *tailp = Fcons (c, Qnil); | 1854 *tailp = Fcons (c, Qnil); |
1845 perd->kbd_queue_has_data = 1; | 1855 perd->kbd_queue_has_data = 1; |
1846 goto wrong_display; | 1856 if (display_locked) |
1857 goto wrong_display; | |
1858 current_perdisplay = perd; | |
1859 longjmp (wrong_display_jmpbuf, 1); | |
1847 } | 1860 } |
1861 #endif | |
1848 } | 1862 } |
1849 #ifdef MULTI_PERDISPLAY | |
1850 if (perd != current_perdisplay) | |
1851 { | |
1852 /* We shouldn't get here if we were locked onto one display! */ | |
1853 if (display_locked) | |
1854 abort (); | |
1855 perd->kbd_queue = Fcons (c, perd->kbd_queue); | |
1856 perd->kbd_queue_has_data = 1; | |
1857 current_perdisplay = perd; | |
1858 longjmp (wrong_display_jmpbuf, 1); | |
1859 } | |
1860 #endif | |
1861 } | 1863 } |
1862 /* Terminate Emacs in batch mode if at eof. */ | 1864 /* Terminate Emacs in batch mode if at eof. */ |
1863 if (noninteractive && INTEGERP (c) && XINT (c) < 0) | 1865 if (noninteractive && INTEGERP (c) && XINT (c) < 0) |
1864 Fkill_emacs (make_number (1)); | 1866 Fkill_emacs (make_number (1)); |
1865 | 1867 |
2109 | 2111 |
2110 if (!input_pending && !detect_input_pending ()) | 2112 if (!input_pending && !detect_input_pending ()) |
2111 prepare_menu_bars (); | 2113 prepare_menu_bars (); |
2112 | 2114 |
2113 XSETFRAME (do_mouse_tracking, selected_frame); | 2115 XSETFRAME (do_mouse_tracking, selected_frame); |
2114 | 2116 |
2115 val = Fprogn (args); | 2117 val = Fprogn (args); |
2116 return unbind_to (count, val); | 2118 return unbind_to (count, val); |
2117 } | 2119 } |
2118 | 2120 |
2119 #endif /* HAVE_MOUSE */ | 2121 #endif /* HAVE_MOUSE */ |
2453 Lisp_Object bar_window; | 2455 Lisp_Object bar_window; |
2454 enum scroll_bar_part part; | 2456 enum scroll_bar_part part; |
2455 Lisp_Object x, y; | 2457 Lisp_Object x, y; |
2456 unsigned long time; | 2458 unsigned long time; |
2457 | 2459 |
2458 if (!current_perdisplay) | |
2459 abort (); | |
2460 | |
2461 *perdp = current_perdisplay; | 2460 *perdp = current_perdisplay; |
2462 /* Note that this uses F to determine which display to look at. | 2461 /* Note that this uses F to determine which display to look at. |
2463 If there is no valid info, it does not store anything | 2462 If there is no valid info, it does not store anything |
2464 so x remains nil. */ | 2463 so x remains nil. */ |
2465 x = Qnil; | 2464 x = Qnil; |
2484 obj = make_lispy_switch_frame (frame); | 2483 obj = make_lispy_switch_frame (frame); |
2485 internal_last_event_frame = frame; | 2484 internal_last_event_frame = frame; |
2486 } | 2485 } |
2487 #endif | 2486 #endif |
2488 | 2487 |
2489 /* If we didn't decide to make a switch-frame event, go ahead and | 2488 /* If we didn't decide to make a switch-frame event, go ahead and |
2490 return a mouse-motion event. */ | 2489 return a mouse-motion event. */ |
2491 if (!NILP (x) && NILP (obj)) | 2490 if (!NILP (x) && NILP (obj)) |
2492 obj = make_lispy_movement (f, bar_window, part, x, y, time); | 2491 obj = make_lispy_movement (f, bar_window, part, x, y, time); |
2493 } | 2492 } |
2494 #endif /* HAVE_MOUSE */ | 2493 #endif /* HAVE_MOUSE */ |
2750 0, 0, 0, 0, 0, 0, 0, 0, | 2749 0, 0, 0, 0, 0, 0, 0, 0, |
2751 0, 0, 0, 0, 0, 0, 0, 0, /* 0xfff0 */ | 2750 0, 0, 0, 0, 0, 0, 0, 0, /* 0xfff0 */ |
2752 0, 0, 0, 0, 0, 0, 0, "delete" | 2751 0, 0, 0, 0, 0, 0, 0, "delete" |
2753 }; | 2752 }; |
2754 | 2753 |
2755 static char *lispy_mouse_names[] = | 2754 static char *lispy_mouse_names[] = |
2756 { | 2755 { |
2757 "mouse-1", "mouse-2", "mouse-3", "mouse-4", "mouse-5" | 2756 "mouse-1", "mouse-2", "mouse-3", "mouse-4", "mouse-5" |
2758 }; | 2757 }; |
2759 | 2758 |
2760 /* Scroll bar parts. */ | 2759 /* Scroll bar parts. */ |
2871 (sizeof (lispy_function_keys) | 2870 (sizeof (lispy_function_keys) |
2872 / sizeof (lispy_function_keys[0]))); | 2871 / sizeof (lispy_function_keys[0]))); |
2873 break; | 2872 break; |
2874 | 2873 |
2875 #if defined (MULTI_FRAME) || defined (HAVE_MOUSE) | 2874 #if defined (MULTI_FRAME) || defined (HAVE_MOUSE) |
2876 /* A mouse click. Figure out where it is, decide whether it's | 2875 /* A mouse click. Figure out where it is, decide whether it's |
2877 a press, click or drag, and build the appropriate structure. */ | 2876 a press, click or drag, and build the appropriate structure. */ |
2878 case mouse_click: | 2877 case mouse_click: |
2879 case scroll_bar_click: | 2878 case scroll_bar_click: |
2880 { | 2879 { |
2881 int button = event->code; | 2880 int button = event->code; |
3239 struct Lisp_String *name; | 3238 struct Lisp_String *name; |
3240 int i; | 3239 int i; |
3241 int modifiers; | 3240 int modifiers; |
3242 | 3241 |
3243 CHECK_SYMBOL (symbol, 1); | 3242 CHECK_SYMBOL (symbol, 1); |
3244 | 3243 |
3245 modifiers = 0; | 3244 modifiers = 0; |
3246 name = XSYMBOL (symbol)->name; | 3245 name = XSYMBOL (symbol)->name; |
3247 | 3246 |
3248 for (i = 0; i+2 <= name->size; ) | 3247 for (i = 0; i+2 <= name->size; ) |
3249 { | 3248 { |
3355 mod_len = p - new_mods; | 3354 mod_len = p - new_mods; |
3356 } | 3355 } |
3357 | 3356 |
3358 { | 3357 { |
3359 Lisp_Object new_name; | 3358 Lisp_Object new_name; |
3360 | 3359 |
3361 new_name = make_uninit_string (mod_len + base_len); | 3360 new_name = make_uninit_string (mod_len + base_len); |
3362 bcopy (new_mods, XSTRING (new_name)->data, mod_len); | 3361 bcopy (new_mods, XSTRING (new_name)->data, mod_len); |
3363 bcopy (base, XSTRING (new_name)->data + mod_len, base_len); | 3362 bcopy (base, XSTRING (new_name)->data + mod_len, base_len); |
3364 | 3363 |
3365 return Fintern (new_name, Qnil); | 3364 return Fintern (new_name, Qnil); |
3468 | 3467 |
3469 if (CONSP (entry)) | 3468 if (CONSP (entry)) |
3470 new_symbol = XCONS (entry)->cdr; | 3469 new_symbol = XCONS (entry)->cdr; |
3471 else | 3470 else |
3472 { | 3471 { |
3473 /* We have to create the symbol ourselves. */ | 3472 /* We have to create the symbol ourselves. */ |
3474 new_symbol = apply_modifiers_uncached (modifiers, | 3473 new_symbol = apply_modifiers_uncached (modifiers, |
3475 XSYMBOL (base)->name->data, | 3474 XSYMBOL (base)->name->data, |
3476 XSYMBOL (base)->name->size); | 3475 XSYMBOL (base)->name->size); |
3477 | 3476 |
3478 /* Add the new symbol to the base's cache. */ | 3477 /* Add the new symbol to the base's cache. */ |
3485 Fcons (base, Fcons (index, Qnil))); | 3484 Fcons (base, Fcons (index, Qnil))); |
3486 Fput (new_symbol, Qevent_symbol_elements, | 3485 Fput (new_symbol, Qevent_symbol_elements, |
3487 Fcons (base, lispy_modifier_list (modifiers))); | 3486 Fcons (base, lispy_modifier_list (modifiers))); |
3488 } | 3487 } |
3489 | 3488 |
3490 /* Make sure this symbol is of the same kind as BASE. | 3489 /* Make sure this symbol is of the same kind as BASE. |
3491 | 3490 |
3492 You'd think we could just set this once and for all when we | 3491 You'd think we could just set this once and for all when we |
3493 intern the symbol above, but reorder_modifiers may call us when | 3492 intern the symbol above, but reorder_modifiers may call us when |
3494 BASE's property isn't set right; we can't assume that just | 3493 BASE's property isn't set right; we can't assume that just |
3495 because it has a Qmodifier_cache property it must have its | 3494 because it has a Qmodifier_cache property it must have its |
3545 persist between calls to modify_event_symbol that it can use to | 3544 persist between calls to modify_event_symbol that it can use to |
3546 store a cache of the symbols it's generated for this NAME_TABLE | 3545 store a cache of the symbols it's generated for this NAME_TABLE |
3547 before. The object stored there may be a vector or an alist. | 3546 before. The object stored there may be a vector or an alist. |
3548 | 3547 |
3549 SYMBOL_NUM is the number of the base name we want from NAME_TABLE. | 3548 SYMBOL_NUM is the number of the base name we want from NAME_TABLE. |
3550 | 3549 |
3551 MODIFIERS is a set of modifier bits (as given in struct input_events) | 3550 MODIFIERS is a set of modifier bits (as given in struct input_events) |
3552 whose prefixes should be applied to the symbol name. | 3551 whose prefixes should be applied to the symbol name. |
3553 | 3552 |
3554 SYMBOL_KIND is the value to be placed in the event_kind property of | 3553 SYMBOL_KIND is the value to be placed in the event_kind property of |
3555 the returned symbol. | 3554 the returned symbol. |
3556 | 3555 |
3557 The symbols we create are supposed to have an | 3556 The symbols we create are supposed to have an |
3558 `event-symbol-elements' property, which lists the modifiers present | 3557 `event-symbol-elements' property, which lists the modifiers present |
3559 in the symbol's name. */ | 3558 in the symbol's name. */ |
3560 | 3559 |
3618 if (CONSP (*symbol_table)) | 3617 if (CONSP (*symbol_table)) |
3619 *symbol_table = Fcons (value, *symbol_table); | 3618 *symbol_table = Fcons (value, *symbol_table); |
3620 else | 3619 else |
3621 XVECTOR (*symbol_table)->contents[symbol_num] = value; | 3620 XVECTOR (*symbol_table)->contents[symbol_num] = value; |
3622 | 3621 |
3623 /* Fill in the cache entries for this symbol; this also | 3622 /* Fill in the cache entries for this symbol; this also |
3624 builds the Qevent_symbol_elements property, which the user | 3623 builds the Qevent_symbol_elements property, which the user |
3625 cares about. */ | 3624 cares about. */ |
3626 apply_modifiers (modifiers & click_modifier, value); | 3625 apply_modifiers (modifiers & click_modifier, value); |
3627 Fput (value, Qevent_kind, symbol_kind); | 3626 Fput (value, Qevent_kind, symbol_kind); |
3628 } | 3627 } |
4091 dealing with, without assuming that every file which uses | 4090 dealing with, without assuming that every file which uses |
4092 UNBLOCK_INPUT also has #included the files necessary to get SIGIO. */ | 4091 UNBLOCK_INPUT also has #included the files necessary to get SIGIO. */ |
4093 void | 4092 void |
4094 reinvoke_input_signal () | 4093 reinvoke_input_signal () |
4095 { | 4094 { |
4096 #ifdef SIGIO | 4095 #ifdef SIGIO |
4097 kill (0, SIGIO); | 4096 kill (0, SIGIO); |
4098 #endif | 4097 #endif |
4099 } | 4098 } |
4100 | 4099 |
4101 | 4100 |
4162 during redisplay, during which a quit is fatal. So inhibit | 4161 during redisplay, during which a quit is fatal. So inhibit |
4163 quitting while building the menus. | 4162 quitting while building the menus. |
4164 We do this instead of specbind because (1) errors will clear it anyway | 4163 We do this instead of specbind because (1) errors will clear it anyway |
4165 and (2) this avoids risk of specpdl overflow. */ | 4164 and (2) this avoids risk of specpdl overflow. */ |
4166 oquit = Vinhibit_quit; | 4165 oquit = Vinhibit_quit; |
4167 Vinhibit_quit = Qt; | 4166 Vinhibit_quit = Qt; |
4168 | 4167 |
4169 if (!NILP (old)) | 4168 if (!NILP (old)) |
4170 menu_bar_items_vector = old; | 4169 menu_bar_items_vector = old; |
4171 else | 4170 else |
4172 menu_bar_items_vector = Fmake_vector (make_number (24), Qnil); | 4171 menu_bar_items_vector = Fmake_vector (make_number (24), Qnil); |
4177 /* Build our list of keymaps. | 4176 /* Build our list of keymaps. |
4178 If we recognize a function key and replace its escape sequence in | 4177 If we recognize a function key and replace its escape sequence in |
4179 keybuf with its symbol, or if the sequence starts with a mouse | 4178 keybuf with its symbol, or if the sequence starts with a mouse |
4180 click and we need to switch buffers, we jump back here to rebuild | 4179 click and we need to switch buffers, we jump back here to rebuild |
4181 the initial keymaps from the current buffer. */ | 4180 the initial keymaps from the current buffer. */ |
4182 { | 4181 { |
4183 Lisp_Object *tmaps; | 4182 Lisp_Object *tmaps; |
4184 | 4183 |
4185 /* Should overriding-local-map apply, here? */ | 4184 /* Should overriding-local-map apply, here? */ |
4186 if (!NILP (Voverriding_local_map_menu_flag)) | 4185 if (!NILP (Voverriding_local_map_menu_flag)) |
4187 { | 4186 { |
4431 If USED_MOUSE_MENU is non-zero, then we set *USED_MOUSE_MENU to 1 | 4430 If USED_MOUSE_MENU is non-zero, then we set *USED_MOUSE_MENU to 1 |
4432 if we used a mouse menu to read the input, or zero otherwise. If | 4431 if we used a mouse menu to read the input, or zero otherwise. If |
4433 USED_MOUSE_MENU is zero, *USED_MOUSE_MENU is left alone. | 4432 USED_MOUSE_MENU is zero, *USED_MOUSE_MENU is left alone. |
4434 | 4433 |
4435 The prompting is done based on the prompt-string of the map | 4434 The prompting is done based on the prompt-string of the map |
4436 and the strings associated with various map elements. | 4435 and the strings associated with various map elements. |
4437 | 4436 |
4438 This can be done with X menus or with menus put in the minibuf. | 4437 This can be done with X menus or with menus put in the minibuf. |
4439 These are done in different ways, depending on how the input will be read. | 4438 These are done in different ways, depending on how the input will be read. |
4440 Menus using X are done after auto-saving in read-char, getting the input | 4439 Menus using X are done after auto-saving in read-char, getting the input |
4441 event from Fx_popup_menu; menus using the minibuf use read_char recursively | 4440 event from Fx_popup_menu; menus using the minibuf use read_char recursively |
4652 } | 4651 } |
4653 | 4652 |
4654 /* Prompt with that and read response. */ | 4653 /* Prompt with that and read response. */ |
4655 message1 (menu); | 4654 message1 (menu); |
4656 | 4655 |
4657 /* Make believe its not a keyboard macro in case the help char | 4656 /* Make believe its not a keyboard macro in case the help char |
4658 is pressed. Help characters are not recorded because menu prompting | 4657 is pressed. Help characters are not recorded because menu prompting |
4659 is not used on replay. | 4658 is not used on replay. |
4660 */ | 4659 */ |
4661 orig_defn_macro = current_perdisplay->defining_kbd_macro; | 4660 orig_defn_macro = current_perdisplay->defining_kbd_macro; |
4662 current_perdisplay->defining_kbd_macro = Qnil; | 4661 current_perdisplay->defining_kbd_macro = Qnil; |
4748 next[i] = NILP (defs[i]) ? Qnil : get_keymap_1 (defs[i], 0, 1); | 4747 next[i] = NILP (defs[i]) ? Qnil : get_keymap_1 (defs[i], 0, 1); |
4749 | 4748 |
4750 return first_binding; | 4749 return first_binding; |
4751 } | 4750 } |
4752 | 4751 |
4753 /* Read a sequence of keys that ends with a non prefix character, | 4752 /* Read a sequence of keys that ends with a non prefix character, |
4754 storing it in KEYBUF, a buffer of size BUFSIZE. | 4753 storing it in KEYBUF, a buffer of size BUFSIZE. |
4755 Prompt with PROMPT. | 4754 Prompt with PROMPT. |
4756 Return the length of the key sequence stored. | 4755 Return the length of the key sequence stored. |
4757 Return -1 if the user rejected a command menu. | 4756 Return -1 if the user rejected a command menu. |
4758 | 4757 |
4907 } | 4906 } |
4908 | 4907 |
4909 /* Record the initial state of the echo area and this_command_keys; | 4908 /* Record the initial state of the echo area and this_command_keys; |
4910 we will need to restore them if we replay a key sequence. */ | 4909 we will need to restore them if we replay a key sequence. */ |
4911 if (INTERACTIVE) | 4910 if (INTERACTIVE) |
4912 echo_start = (current_perdisplay ? echo_length () : 0); | 4911 echo_start = echo_length (); |
4913 keys_start = this_command_key_count; | 4912 keys_start = this_command_key_count; |
4914 | 4913 |
4915 #if defined (GOBBLE_FIRST_EVENT) | 4914 #if defined (GOBBLE_FIRST_EVENT) |
4916 /* This doesn't quite work, because some of the things that read_char | 4915 /* This doesn't quite work, because some of the things that read_char |
4917 does cannot safely be bypassed. It seems too risky to try to make | 4916 does cannot safely be bypassed. It seems too risky to try to make |
4918 this work right. */ | 4917 this work right. */ |
4919 | 4918 |
4920 /* Read the first char of the sequence specially, before setting | 4919 /* Read the first char of the sequence specially, before setting |
4921 up any keymaps, in case a filter runs and switches buffers on us. */ | 4920 up any keymaps, in case a filter runs and switches buffers on us. */ |
4922 first_event = read_char (NILP (prompt), 0, submaps, last_nonmenu_event, | 4921 first_event = read_char (NILP (prompt), 0, submaps, last_nonmenu_event, |
4923 &junk); | 4922 &junk); |
4937 /* Build our list of keymaps. | 4936 /* Build our list of keymaps. |
4938 If we recognize a function key and replace its escape sequence in | 4937 If we recognize a function key and replace its escape sequence in |
4939 keybuf with its symbol, or if the sequence starts with a mouse | 4938 keybuf with its symbol, or if the sequence starts with a mouse |
4940 click and we need to switch buffers, we jump back here to rebuild | 4939 click and we need to switch buffers, we jump back here to rebuild |
4941 the initial keymaps from the current buffer. */ | 4940 the initial keymaps from the current buffer. */ |
4942 { | 4941 { |
4943 Lisp_Object *maps; | 4942 Lisp_Object *maps; |
4944 | 4943 |
4945 if (!NILP (Voverriding_local_map)) | 4944 if (!NILP (Voverriding_local_map)) |
4946 { | 4945 { |
4947 nmaps = 2; | 4946 nmaps = 2; |
4981 t = 0; | 4980 t = 0; |
4982 | 4981 |
4983 /* These are no-ops the first time through, but if we restart, they | 4982 /* These are no-ops the first time through, but if we restart, they |
4984 revert the echo area and this_command_keys to their original state. */ | 4983 revert the echo area and this_command_keys to their original state. */ |
4985 this_command_key_count = keys_start; | 4984 this_command_key_count = keys_start; |
4986 if (INTERACTIVE && t < mock_input && current_perdisplay) | 4985 if (INTERACTIVE && t < mock_input) |
4987 echo_truncate (echo_start); | 4986 echo_truncate (echo_start); |
4988 | 4987 |
4989 /* If the best binding for the current key sequence is a keymap, or | 4988 /* If the best binding for the current key sequence is a keymap, or |
4990 we may be looking at a function key's escape sequence, keep on | 4989 we may be looking at a function key's escape sequence, keep on |
4991 reading. */ | 4990 reading. */ |
5024 | 5023 |
5025 if (INTERACTIVE) | 5024 if (INTERACTIVE) |
5026 echo_local_start = echo_length (); | 5025 echo_local_start = echo_length (); |
5027 keys_local_start = this_command_key_count; | 5026 keys_local_start = this_command_key_count; |
5028 local_first_binding = first_binding; | 5027 local_first_binding = first_binding; |
5029 | 5028 |
5030 replay_key: | 5029 replay_key: |
5031 /* These are no-ops, unless we throw away a keystroke below and | 5030 /* These are no-ops, unless we throw away a keystroke below and |
5032 jumped back up to replay_key; in that case, these restore the | 5031 jumped back up to replay_key; in that case, these restore the |
5033 variables to their original state, allowing us to replay the | 5032 variables to their original state, allowing us to replay the |
5034 loop. */ | 5033 loop. */ |
5055 struct buffer *buf = current_buffer; | 5054 struct buffer *buf = current_buffer; |
5056 | 5055 |
5057 { | 5056 { |
5058 #ifdef MULTI_PERDISPLAY | 5057 #ifdef MULTI_PERDISPLAY |
5059 PERDISPLAY *interrupted_perdisplay = current_perdisplay; | 5058 PERDISPLAY *interrupted_perdisplay = current_perdisplay; |
5059 struct frame *interrupted_frame = selected_frame; | |
5060 if (setjmp (wrong_display_jmpbuf)) | 5060 if (setjmp (wrong_display_jmpbuf)) |
5061 { | 5061 { |
5062 while (t > 0) | 5062 while (t > 0) |
5063 interrupted_perdisplay->kbd_queue | 5063 interrupted_perdisplay->kbd_queue |
5064 = Fcons (keybuf[--t], interrupted_perdisplay->kbd_queue); | 5064 = Fcons (keybuf[--t], interrupted_perdisplay->kbd_queue); |
5065 /* Ensure that the side queue begins with a switch-frame, so | |
5066 we'll be in the right context when we replay it later. */ | |
5067 if (!(CONSP (interrupted_perdisplay->kbd_queue) | |
5068 && (key = XCONS (interrupted_perdisplay->kbd_queue)->car, | |
5069 EVENT_HAS_PARAMETERS (key)) | |
5070 && EQ (EVENT_HEAD_KIND (EVENT_HEAD (key)), | |
5071 Qswitch_frame))) | |
5072 { | |
5073 Lisp_Object frame; | |
5074 XSETFRAME (frame, interrupted_frame); | |
5075 interrupted_perdisplay->kbd_queue | |
5076 = Fcons (make_lispy_switch_frame (frame), | |
5077 interrupted_perdisplay->kbd_queue); | |
5078 } | |
5065 mock_input = 0; | 5079 mock_input = 0; |
5066 orig_local_map = get_local_map (PT, current_buffer); | 5080 orig_local_map = get_local_map (PT, current_buffer); |
5067 goto replay_sequence; | 5081 goto replay_sequence; |
5068 } | 5082 } |
5069 #endif | 5083 #endif |
5085 /* The Microsoft C compiler can't handle the goto that | 5099 /* The Microsoft C compiler can't handle the goto that |
5086 would go here. */ | 5100 would go here. */ |
5087 dummyflag = 1; | 5101 dummyflag = 1; |
5088 break; | 5102 break; |
5089 } | 5103 } |
5090 | 5104 |
5091 /* If the current buffer has been changed from under us, the | 5105 /* If the current buffer has been changed from under us, the |
5092 keymap may have changed, so replay the sequence. */ | 5106 keymap may have changed, so replay the sequence. */ |
5093 if (BUFFERP (key)) | 5107 if (BUFFERP (key)) |
5094 { | 5108 { |
5095 mock_input = t; | 5109 mock_input = t; |
5110 } | 5124 } |
5111 | 5125 |
5112 Vquit_flag = Qnil; | 5126 Vquit_flag = Qnil; |
5113 } | 5127 } |
5114 | 5128 |
5115 /* Clicks in non-text areas get prefixed by the symbol | 5129 /* Clicks in non-text areas get prefixed by the symbol |
5116 in their CHAR-ADDRESS field. For example, a click on | 5130 in their CHAR-ADDRESS field. For example, a click on |
5117 the mode line is prefixed by the symbol `mode-line'. | 5131 the mode line is prefixed by the symbol `mode-line'. |
5118 | 5132 |
5119 Furthermore, key sequences beginning with mouse clicks | 5133 Furthermore, key sequences beginning with mouse clicks |
5120 are read using the keymaps of the buffer clicked on, not | 5134 are read using the keymaps of the buffer clicked on, not |
5462 GCPRO3 (fkey_map, keytran_map, delayed_switch_frame); | 5476 GCPRO3 (fkey_map, keytran_map, delayed_switch_frame); |
5463 fkey_next = call1 (fkey_next, prompt); | 5477 fkey_next = call1 (fkey_next, prompt); |
5464 UNGCPRO; | 5478 UNGCPRO; |
5465 /* If the function returned something invalid, | 5479 /* If the function returned something invalid, |
5466 barf--don't ignore it. | 5480 barf--don't ignore it. |
5467 (To ignore it safely, we would need to gcpro a bunch of | 5481 (To ignore it safely, we would need to gcpro a bunch of |
5468 other variables.) */ | 5482 other variables.) */ |
5469 if (! (VECTORP (fkey_next) || STRINGP (fkey_next))) | 5483 if (! (VECTORP (fkey_next) || STRINGP (fkey_next))) |
5470 error ("Function in function-key-map returns invalid key sequence"); | 5484 error ("Function in function-key-map returns invalid key sequence"); |
5471 } | 5485 } |
5472 | 5486 |
5495 | 5509 |
5496 for (i = 0; i < len; i++) | 5510 for (i = 0; i < len; i++) |
5497 XSETFASTINT (keybuf[fkey_start + i], | 5511 XSETFASTINT (keybuf[fkey_start + i], |
5498 XSTRING (fkey_next)->data[i]); | 5512 XSTRING (fkey_next)->data[i]); |
5499 } | 5513 } |
5500 | 5514 |
5501 mock_input = t; | 5515 mock_input = t; |
5502 fkey_start = fkey_end = t; | 5516 fkey_start = fkey_end = t; |
5503 fkey_map = Vfunction_key_map; | 5517 fkey_map = Vfunction_key_map; |
5504 | 5518 |
5505 /* Do pass the results through key-translation-map. */ | 5519 /* Do pass the results through key-translation-map. */ |
5506 keytran_start = keytran_end = 0; | 5520 keytran_start = keytran_end = 0; |
5507 keytran_map = Vkey_translation_map; | 5521 keytran_map = Vkey_translation_map; |
5508 | 5522 |
5509 goto replay_sequence; | 5523 goto replay_sequence; |
5510 } | 5524 } |
5511 | 5525 |
5512 fkey_map = get_keymap_1 (fkey_next, 0, 1); | 5526 fkey_map = get_keymap_1 (fkey_next, 0, 1); |
5513 | 5527 |
5514 /* If we no longer have a bound suffix, try a new positions for | 5528 /* If we no longer have a bound suffix, try a new positions for |
5515 fkey_start. */ | 5529 fkey_start. */ |
5516 if (NILP (fkey_map)) | 5530 if (NILP (fkey_map)) |
5517 { | 5531 { |
5518 fkey_end = ++fkey_start; | 5532 fkey_end = ++fkey_start; |
5519 fkey_map = Vfunction_key_map; | 5533 fkey_map = Vfunction_key_map; |
5562 GCPRO3 (fkey_map, keytran_map, delayed_switch_frame); | 5576 GCPRO3 (fkey_map, keytran_map, delayed_switch_frame); |
5563 keytran_next = call1 (keytran_next, prompt); | 5577 keytran_next = call1 (keytran_next, prompt); |
5564 UNGCPRO; | 5578 UNGCPRO; |
5565 /* If the function returned something invalid, | 5579 /* If the function returned something invalid, |
5566 barf--don't ignore it. | 5580 barf--don't ignore it. |
5567 (To ignore it safely, we would need to gcpro a bunch of | 5581 (To ignore it safely, we would need to gcpro a bunch of |
5568 other variables.) */ | 5582 other variables.) */ |
5569 if (! (VECTORP (keytran_next) || STRINGP (keytran_next))) | 5583 if (! (VECTORP (keytran_next) || STRINGP (keytran_next))) |
5570 error ("Function in key-translation-map returns invalid key sequence"); | 5584 error ("Function in key-translation-map returns invalid key sequence"); |
5571 } | 5585 } |
5572 | 5586 |
5610 goto replay_sequence; | 5624 goto replay_sequence; |
5611 } | 5625 } |
5612 | 5626 |
5613 keytran_map = get_keymap_1 (keytran_next, 0, 1); | 5627 keytran_map = get_keymap_1 (keytran_next, 0, 1); |
5614 | 5628 |
5615 /* If we no longer have a bound suffix, try a new positions for | 5629 /* If we no longer have a bound suffix, try a new positions for |
5616 keytran_start. */ | 5630 keytran_start. */ |
5617 if (NILP (keytran_map)) | 5631 if (NILP (keytran_map)) |
5618 { | 5632 { |
5619 keytran_end = ++keytran_start; | 5633 keytran_end = ++keytran_start; |
5620 keytran_map = Vkey_translation_map; | 5634 keytran_map = Vkey_translation_map; |
6091 change_frame_size (selected_frame, height, width, 0, 0); | 6105 change_frame_size (selected_frame, height, width, 0, 0); |
6092 | 6106 |
6093 /* Run suspend-resume-hook. */ | 6107 /* Run suspend-resume-hook. */ |
6094 if (!NILP (Vrun_hooks)) | 6108 if (!NILP (Vrun_hooks)) |
6095 call1 (Vrun_hooks, intern ("suspend-resume-hook")); | 6109 call1 (Vrun_hooks, intern ("suspend-resume-hook")); |
6096 | 6110 |
6097 UNGCPRO; | 6111 UNGCPRO; |
6098 return Qnil; | 6112 return Qnil; |
6099 } | 6113 } |
6100 | 6114 |
6101 /* If STUFFSTRING is a string, stuff its contents as pending terminal input. | 6115 /* If STUFFSTRING is a string, stuff its contents as pending terminal input. |
6451 time through. */ | 6465 time through. */ |
6452 internal_last_event_frame = Qnil; | 6466 internal_last_event_frame = Qnil; |
6453 Vlast_event_frame = internal_last_event_frame; | 6467 Vlast_event_frame = internal_last_event_frame; |
6454 #endif | 6468 #endif |
6455 | 6469 |
6456 #ifndef MULTI_PERDISPLAY | 6470 if (!initialized) |
6471 { | |
6472 #ifdef MULTI_PERDISPLAY | |
6473 current_perdisplay = (PERDISPLAY *)xmalloc (sizeof (PERDISPLAY)); | |
6474 all_perdisplays = current_perdisplay; | |
6475 #endif | |
6476 current_perdisplay->next_perdisplay = 0; | |
6477 } | |
6457 if (initialized) | 6478 if (initialized) |
6458 wipe_perdisplay (&the_only_perdisplay); | 6479 wipe_perdisplay (current_perdisplay); |
6459 init_perdisplay (&the_only_perdisplay); | 6480 init_perdisplay (current_perdisplay); |
6460 #endif | |
6461 | 6481 |
6462 if (initialized) | 6482 if (initialized) |
6463 Ffillarray (kbd_buffer_frame_or_window, Qnil); | 6483 Ffillarray (kbd_buffer_frame_or_window, Qnil); |
6464 | 6484 |
6465 kbd_buffer_frame_or_window | 6485 kbd_buffer_frame_or_window |
6503 poll_suppress_count = 1; | 6523 poll_suppress_count = 1; |
6504 start_polling (); | 6524 start_polling (); |
6505 #endif | 6525 #endif |
6506 } | 6526 } |
6507 | 6527 |
6508 /* This type's only use is in syms_of_keyboard, to initialize the | 6528 /* This type's only use is in syms_of_keyboard, to initialize the |
6509 event header symbols and put properties on them. */ | 6529 event header symbols and put properties on them. */ |
6510 struct event_head { | 6530 struct event_head { |
6511 Lisp_Object *var; | 6531 Lisp_Object *var; |
6512 char *name; | 6532 char *name; |
6513 Lisp_Object *kind; | 6533 Lisp_Object *kind; |
6747 "*Interval between polling for input during Lisp execution.\n\ | 6767 "*Interval between polling for input during Lisp execution.\n\ |
6748 The reason for polling is to make C-g work to stop a running program.\n\ | 6768 The reason for polling is to make C-g work to stop a running program.\n\ |
6749 Polling is needed only when using X windows and SIGIO does not work.\n\ | 6769 Polling is needed only when using X windows and SIGIO does not work.\n\ |
6750 Polling is automatically disabled in all other cases."); | 6770 Polling is automatically disabled in all other cases."); |
6751 polling_period = 2; | 6771 polling_period = 2; |
6752 | 6772 |
6753 DEFVAR_LISP ("double-click-time", &Vdouble_click_time, | 6773 DEFVAR_LISP ("double-click-time", &Vdouble_click_time, |
6754 "*Maximum time between mouse clicks to make a double-click.\n\ | 6774 "*Maximum time between mouse clicks to make a double-click.\n\ |
6755 Measured in milliseconds. nil means disable double-click recognition;\n\ | 6775 Measured in milliseconds. nil means disable double-click recognition;\n\ |
6756 t means double-clicks have no time limit and are detected\n\ | 6776 t means double-clicks have no time limit and are detected\n\ |
6757 by position only."); | 6777 by position only."); |