comparison src/keyboard.c @ 11016:8d8eef563e13

(unlock_kboard): Renamed from unlock_display. (wrong_kboard_jmpbuf): Renamed from wrong_display_jmpbuf. (event_to_kboard): Renamed from event_to_perdisplay. (kbd_buffer_get_event): If no associated kboard, store current_kboard rather than the first kboard in the global list. (init_kboard): Renamed from init_perdisplay. Initialize reference count. (wipe_kboard): Renamed from wipe_perdisplay.
author Karl Heuer <kwzh@gnu.org>
date Wed, 15 Mar 1995 01:55:24 +0000
parents 66d853abce42
children 682ae4a3d465
comparison
equal deleted inserted replaced
11015:3a2547424010 11016:8d8eef563e13
92 args points to slot holding list of 92 args points to slot holding list of
93 unevalled args */ 93 unevalled args */
94 char evalargs; 94 char evalargs;
95 }; 95 };
96 96
97 #ifdef MULTI_PERDISPLAY 97 #ifdef MULTI_KBOARD
98 PERDISPLAY *current_perdisplay; 98 KBOARD *initial_kboard;
99 PERDISPLAY *all_perdisplays; 99 KBOARD *current_kboard;
100 int display_locked; 100 KBOARD *all_kboards;
101 int kboard_locked;
101 #else 102 #else
102 PERDISPLAY the_only_perdisplay; 103 KBOARD the_only_kboard;
103 #endif 104 #endif
104 105
105 /* Non-nil disable property on a command means 106 /* Non-nil disable property on a command means
106 do not execute it; call disabled-command-hook's value instead. */ 107 do not execute it; call disabled-command-hook's value instead. */
107 Lisp_Object Qdisabled, Qdisabled_command_hook; 108 Lisp_Object Qdisabled, Qdisabled_command_hook;
514 { 515 {
515 int len = strlen (str); 516 int len = strlen (str);
516 517
517 if (len > ECHOBUFSIZE - 4) 518 if (len > ECHOBUFSIZE - 4)
518 len = ECHOBUFSIZE - 4; 519 len = ECHOBUFSIZE - 4;
519 bcopy (str, current_perdisplay->echobuf, len); 520 bcopy (str, current_kboard->echobuf, len);
520 current_perdisplay->echoptr = current_perdisplay->echobuf + len; 521 current_kboard->echoptr = current_kboard->echobuf + len;
521 *current_perdisplay->echoptr = '\0'; 522 *current_kboard->echoptr = '\0';
522 523
523 current_perdisplay->echo_after_prompt = len; 524 current_kboard->echo_after_prompt = len;
524 525
525 echo (); 526 echo ();
526 } 527 }
527 528
528 /* Add C to the echo string, if echoing is going on. 529 /* Add C to the echo string, if echoing is going on.
532 echo_char (c) 533 echo_char (c)
533 Lisp_Object c; 534 Lisp_Object c;
534 { 535 {
535 extern char *push_key_description (); 536 extern char *push_key_description ();
536 537
537 if (current_perdisplay->immediate_echo) 538 if (current_kboard->immediate_echo)
538 { 539 {
539 char *ptr = current_perdisplay->echoptr; 540 char *ptr = current_kboard->echoptr;
540 541
541 if (ptr != current_perdisplay->echobuf) 542 if (ptr != current_kboard->echobuf)
542 *ptr++ = ' '; 543 *ptr++ = ' ';
543 544
544 /* If someone has passed us a composite event, use its head symbol. */ 545 /* If someone has passed us a composite event, use its head symbol. */
545 c = EVENT_HEAD (c); 546 c = EVENT_HEAD (c);
546 547
547 if (INTEGERP (c)) 548 if (INTEGERP (c))
548 { 549 {
549 if (ptr - current_perdisplay->echobuf > ECHOBUFSIZE - 6) 550 if (ptr - current_kboard->echobuf > ECHOBUFSIZE - 6)
550 return; 551 return;
551 552
552 ptr = push_key_description (XINT (c), ptr); 553 ptr = push_key_description (XINT (c), ptr);
553 } 554 }
554 else if (SYMBOLP (c)) 555 else if (SYMBOLP (c))
555 { 556 {
556 struct Lisp_String *name = XSYMBOL (c)->name; 557 struct Lisp_String *name = XSYMBOL (c)->name;
557 if (((ptr - current_perdisplay->echobuf) + name->size + 4) 558 if ((ptr - current_kboard->echobuf) + name->size + 4 > ECHOBUFSIZE)
558 > ECHOBUFSIZE)
559 return; 559 return;
560 bcopy (name->data, ptr, name->size); 560 bcopy (name->data, ptr, name->size);
561 ptr += name->size; 561 ptr += name->size;
562 } 562 }
563 563
564 if (current_perdisplay->echoptr == current_perdisplay->echobuf 564 if (current_kboard->echoptr == current_kboard->echobuf
565 && EQ (c, Vhelp_char)) 565 && EQ (c, Vhelp_char))
566 { 566 {
567 strcpy (ptr, " (Type ? for further options)"); 567 strcpy (ptr, " (Type ? for further options)");
568 ptr += strlen (ptr); 568 ptr += strlen (ptr);
569 } 569 }
570 570
571 *ptr = 0; 571 *ptr = 0;
572 current_perdisplay->echoptr = ptr; 572 current_kboard->echoptr = ptr;
573 573
574 echo (); 574 echo ();
575 } 575 }
576 } 576 }
577 577
578 /* Temporarily add a dash to the end of the echo string if it's not 578 /* Temporarily add a dash to the end of the echo string if it's not
579 empty, so that it serves as a mini-prompt for the very next character. */ 579 empty, so that it serves as a mini-prompt for the very next character. */
580 580
581 echo_dash () 581 echo_dash ()
582 { 582 {
583 if (!current_perdisplay->immediate_echo 583 if (!current_kboard->immediate_echo
584 && current_perdisplay->echoptr == current_perdisplay->echobuf) 584 && current_kboard->echoptr == current_kboard->echobuf)
585 return; 585 return;
586 /* Do nothing if we just printed a prompt. */ 586 /* Do nothing if we just printed a prompt. */
587 if (current_perdisplay->echo_after_prompt 587 if (current_kboard->echo_after_prompt
588 == current_perdisplay->echoptr - current_perdisplay->echobuf) 588 == current_kboard->echoptr - current_kboard->echobuf)
589 return; 589 return;
590 /* Do nothing if not echoing at all. */ 590 /* Do nothing if not echoing at all. */
591 if (current_perdisplay->echoptr == 0) 591 if (current_kboard->echoptr == 0)
592 return; 592 return;
593 593
594 /* Put a dash at the end of the buffer temporarily, 594 /* Put a dash at the end of the buffer temporarily,
595 but make it go away when the next character is added. */ 595 but make it go away when the next character is added. */
596 current_perdisplay->echoptr[0] = '-'; 596 current_kboard->echoptr[0] = '-';
597 current_perdisplay->echoptr[1] = 0; 597 current_kboard->echoptr[1] = 0;
598 598
599 echo (); 599 echo ();
600 } 600 }
601 601
602 /* Display the current echo string, and begin echoing if not already 602 /* Display the current echo string, and begin echoing if not already
603 doing so. */ 603 doing so. */
604 604
605 echo () 605 echo ()
606 { 606 {
607 if (!current_perdisplay->immediate_echo) 607 if (!current_kboard->immediate_echo)
608 { 608 {
609 int i; 609 int i;
610 current_perdisplay->immediate_echo = 1; 610 current_kboard->immediate_echo = 1;
611 611
612 for (i = 0; i < this_command_key_count; i++) 612 for (i = 0; i < this_command_key_count; i++)
613 { 613 {
614 Lisp_Object c; 614 Lisp_Object c;
615 c = XVECTOR (this_command_keys)->contents[i]; 615 c = XVECTOR (this_command_keys)->contents[i];
619 } 619 }
620 echo_dash (); 620 echo_dash ();
621 } 621 }
622 622
623 echoing = 1; 623 echoing = 1;
624 message1_nolog (current_perdisplay->echobuf); 624 message1_nolog (current_kboard->echobuf);
625 echoing = 0; 625 echoing = 0;
626 626
627 if (waiting_for_input && !NILP (Vquit_flag)) 627 if (waiting_for_input && !NILP (Vquit_flag))
628 quit_throw_to_read_char (); 628 quit_throw_to_read_char ();
629 } 629 }
630 630
631 /* Turn off echoing, for the start of a new command. */ 631 /* Turn off echoing, for the start of a new command. */
632 632
633 cancel_echoing () 633 cancel_echoing ()
634 { 634 {
635 current_perdisplay->immediate_echo = 0; 635 current_kboard->immediate_echo = 0;
636 current_perdisplay->echoptr = current_perdisplay->echobuf; 636 current_kboard->echoptr = current_kboard->echobuf;
637 current_perdisplay->echo_after_prompt = -1; 637 current_kboard->echo_after_prompt = -1;
638 } 638 }
639 639
640 /* Return the length of the current echo string. */ 640 /* Return the length of the current echo string. */
641 641
642 static int 642 static int
643 echo_length () 643 echo_length ()
644 { 644 {
645 return current_perdisplay->echoptr - current_perdisplay->echobuf; 645 return current_kboard->echoptr - current_kboard->echobuf;
646 } 646 }
647 647
648 /* Truncate the current echo message to its first LEN chars. 648 /* Truncate the current echo message to its first LEN chars.
649 This and echo_char get used by read_key_sequence when the user 649 This and echo_char get used by read_key_sequence when the user
650 switches frames while entering a key sequence. */ 650 switches frames while entering a key sequence. */
651 651
652 static void 652 static void
653 echo_truncate (len) 653 echo_truncate (len)
654 int len; 654 int len;
655 { 655 {
656 current_perdisplay->echobuf[len] = '\0'; 656 current_kboard->echobuf[len] = '\0';
657 current_perdisplay->echoptr = current_perdisplay->echobuf + len; 657 current_kboard->echoptr = current_kboard->echobuf + len;
658 truncate_echo_area (len); 658 truncate_echo_area (len);
659 } 659 }
660 660
661 661
662 /* Functions for manipulating this_command_keys. */ 662 /* Functions for manipulating this_command_keys. */
749 command_loop_level--; 749 command_loop_level--;
750 update_mode_lines = 1; 750 update_mode_lines = 1;
751 return Qnil; 751 return Qnil;
752 } 752 }
753 753
754 #ifdef MULTI_PERDISPLAY 754 #ifdef MULTI_KBOARD
755 static void 755 static void
756 unlock_display () 756 unlock_kboard ()
757 { 757 {
758 if (CONSP (Vunread_command_events)) 758 if (CONSP (Vunread_command_events))
759 { 759 {
760 current_perdisplay->kbd_queue 760 current_kboard->kbd_queue
761 = nconc2 (Vunread_command_events, current_perdisplay->kbd_queue); 761 = nconc2 (Vunread_command_events, current_kboard->kbd_queue);
762 current_perdisplay->kbd_queue_has_data = 1; 762 current_kboard->kbd_queue_has_data = 1;
763 } 763 }
764 Vunread_command_events = Qnil; 764 Vunread_command_events = Qnil;
765 display_locked = 0; 765 kboard_locked = 0;
766 } 766 }
767 #endif 767 #endif
768 768
769 Lisp_Object 769 Lisp_Object
770 cmd_error (data) 770 cmd_error (data)
788 Vprint_length = old_length; 788 Vprint_length = old_length;
789 789
790 Vquit_flag = Qnil; 790 Vquit_flag = Qnil;
791 791
792 Vinhibit_quit = Qnil; 792 Vinhibit_quit = Qnil;
793 #ifdef MULTI_PERDISPLAY 793 #ifdef MULTI_KBOARD
794 unlock_display (); 794 unlock_kboard ();
795 #endif 795 #endif
796 796
797 return make_number (0); 797 return make_number (0);
798 } 798 }
799 799
988 int i; 988 int i;
989 int no_redisplay; 989 int no_redisplay;
990 int no_direct; 990 int no_direct;
991 int prev_modiff; 991 int prev_modiff;
992 struct buffer *prev_buffer; 992 struct buffer *prev_buffer;
993 #ifdef MULTI_PERDISPLAY 993 #ifdef MULTI_KBOARD
994 int was_locked = display_locked; 994 int was_locked = kboard_locked;
995 #endif 995 #endif
996 996
997 Vdeactivate_mark = Qnil; 997 Vdeactivate_mark = Qnil;
998 waiting_for_input = 0; 998 waiting_for_input = 0;
999 cancel_echoing (); 999 cancel_echoing ();
1123 prev_modiff = MODIFF; 1123 prev_modiff = MODIFF;
1124 last_point_position = PT; 1124 last_point_position = PT;
1125 XSETBUFFER (last_point_position_buffer, prev_buffer); 1125 XSETBUFFER (last_point_position_buffer, prev_buffer);
1126 1126
1127 /* If we're building a prefix argument, override minus and digits. */ 1127 /* If we're building a prefix argument, override minus and digits. */
1128 if (current_perdisplay->prefix_partial && i == 1 && NATNUMP (keybuf[0])) 1128 if (current_kboard->prefix_partial && i == 1 && NATNUMP (keybuf[0]))
1129 { 1129 {
1130 if (XFASTINT (keybuf[0]) == '-' 1130 if (XFASTINT (keybuf[0]) == '-'
1131 && NILP (current_perdisplay->prefix_value)) 1131 && NILP (current_kboard->prefix_value))
1132 cmd = Qnegative_argument; 1132 cmd = Qnegative_argument;
1133 else if (XFASTINT (keybuf[0]) >= '0' && XFASTINT (keybuf[0]) <= '9') 1133 else if (XFASTINT (keybuf[0]) >= '0' && XFASTINT (keybuf[0]) <= '9')
1134 cmd = Qdigit_argument; 1134 cmd = Qdigit_argument;
1135 } 1135 }
1136 1136
1144 1144
1145 if (NILP (this_command)) 1145 if (NILP (this_command))
1146 { 1146 {
1147 /* nil means key is undefined. */ 1147 /* nil means key is undefined. */
1148 bitch_at_user (); 1148 bitch_at_user ();
1149 current_perdisplay->defining_kbd_macro = Qnil; 1149 current_kboard->defining_kbd_macro = Qnil;
1150 update_mode_lines = 1; 1150 update_mode_lines = 1;
1151 clear_prefix_arg (); 1151 clear_prefix_arg ();
1152 } 1152 }
1153 else 1153 else
1154 { 1154 {
1155 current_prefix_partial = current_perdisplay->prefix_partial; 1155 current_prefix_partial = current_kboard->prefix_partial;
1156 if (current_perdisplay->prefix_partial) 1156 if (current_kboard->prefix_partial)
1157 finalize_prefix_arg (); 1157 finalize_prefix_arg ();
1158 1158
1159 if (NILP (Vprefix_arg) && ! no_direct) 1159 if (NILP (Vprefix_arg) && ! no_direct)
1160 { 1160 {
1161 /* Recognize some common commands in common situations and 1161 /* Recognize some common commands in common situations and
1301 echoed as part of this key sequence, so don't call 1301 echoed as part of this key sequence, so don't call
1302 cancel_echoing, and 1302 cancel_echoing, and
1303 3) we want to leave this_command_key_count non-zero, so that 1303 3) we want to leave this_command_key_count non-zero, so that
1304 read_char will realize that it is re-reading a character, and 1304 read_char will realize that it is re-reading a character, and
1305 not echo it a second time. */ 1305 not echo it a second time. */
1306 if (NILP (Vprefix_arg) && !current_perdisplay->prefix_partial) 1306 if (NILP (Vprefix_arg) && !current_kboard->prefix_partial)
1307 { 1307 {
1308 last_command = this_command; 1308 last_command = this_command;
1309 cancel_echoing (); 1309 cancel_echoing ();
1310 this_command_key_count = 0; 1310 this_command_key_count = 0;
1311 } 1311 }
1322 } 1322 }
1323 1323
1324 finalize: 1324 finalize:
1325 /* Install chars successfully executed in kbd macro. */ 1325 /* Install chars successfully executed in kbd macro. */
1326 1326
1327 if (!NILP (current_perdisplay->defining_kbd_macro) && NILP (Vprefix_arg) 1327 if (!NILP (current_kboard->defining_kbd_macro) && NILP (Vprefix_arg)
1328 && !current_perdisplay->prefix_partial) 1328 && !current_kboard->prefix_partial)
1329 finalize_kbd_macro_chars (); 1329 finalize_kbd_macro_chars ();
1330 1330
1331 #ifdef MULTI_PERDISPLAY 1331 #ifdef MULTI_KBOARD
1332 if (!was_locked) 1332 if (!was_locked)
1333 unlock_display (); 1333 unlock_kboard ();
1334 #endif 1334 #endif
1335 } 1335 }
1336 } 1336 }
1337 1337
1338 /* If we get an error while running the hook, cause the hook variable 1338 /* If we get an error while running the hook, cause the hook variable
1515 1515
1516 Lisp_Object print_help (); 1516 Lisp_Object print_help ();
1517 static Lisp_Object kbd_buffer_get_event (); 1517 static Lisp_Object kbd_buffer_get_event ();
1518 static void record_char (); 1518 static void record_char ();
1519 1519
1520 #ifdef MULTI_PERDISPLAY 1520 #ifdef MULTI_KBOARD
1521 static jmp_buf wrong_display_jmpbuf; 1521 static jmp_buf wrong_kboard_jmpbuf;
1522 #endif 1522 #endif
1523 1523
1524 /* read a character from the keyboard; call the redisplay if needed */ 1524 /* read a character from the keyboard; call the redisplay if needed */
1525 /* commandflag 0 means do not do auto-saving, but do do redisplay. 1525 /* commandflag 0 means do not do auto-saving, but do do redisplay.
1526 -1 means do not do redisplay, but do do autosaving. 1526 -1 means do not do redisplay, but do do autosaving.
1645 /* If we report the quit char as an event, 1645 /* If we report the quit char as an event,
1646 don't do so more than once. */ 1646 don't do so more than once. */
1647 if (!NILP (Vinhibit_quit)) 1647 if (!NILP (Vinhibit_quit))
1648 Vquit_flag = Qnil; 1648 Vquit_flag = Qnil;
1649 1649
1650 #ifdef MULTI_PERDISPLAY 1650 #ifdef MULTI_KBOARD
1651 { 1651 {
1652 PERDISPLAY *perd = get_perdisplay (selected_frame); 1652 KBOARD *kb = FRAME_KBOARD (selected_frame);
1653 if (perd != current_perdisplay) 1653 if (kb != current_kboard)
1654 { 1654 {
1655 Lisp_Object *tailp = &perd->kbd_queue; 1655 Lisp_Object *tailp = &kb->kbd_queue;
1656 /* We shouldn't get here if we were locked onto one display! */ 1656 /* We shouldn't get here if we were locked onto one kboard! */
1657 if (display_locked) 1657 if (kboard_locked)
1658 abort (); 1658 abort ();
1659 while (CONSP (*tailp)) 1659 while (CONSP (*tailp))
1660 tailp = &XCONS (*tailp)->cdr; 1660 tailp = &XCONS (*tailp)->cdr;
1661 if (!NILP (*tailp)) 1661 if (!NILP (*tailp))
1662 abort (); 1662 abort ();
1663 *tailp = Fcons (c, Qnil); 1663 *tailp = Fcons (c, Qnil);
1664 perd->kbd_queue_has_data = 1; 1664 kb->kbd_queue_has_data = 1;
1665 current_perdisplay = perd; 1665 current_kboard = kb;
1666 longjmp (wrong_display_jmpbuf, 1); 1666 longjmp (wrong_kboard_jmpbuf, 1);
1667 } 1667 }
1668 } 1668 }
1669 #endif 1669 #endif
1670 goto non_reread; 1670 goto non_reread;
1671 } 1671 }
1672 1672
1673 /* Message turns off echoing unless more keystrokes turn it on again. */ 1673 /* Message turns off echoing unless more keystrokes turn it on again. */
1674 if (echo_area_glyphs && *echo_area_glyphs 1674 if (echo_area_glyphs && *echo_area_glyphs
1675 && echo_area_glyphs != current_perdisplay->echobuf) 1675 && echo_area_glyphs != current_kboard->echobuf)
1676 cancel_echoing (); 1676 cancel_echoing ();
1677 else 1677 else
1678 /* If already echoing, continue. */ 1678 /* If already echoing, continue. */
1679 echo_dash (); 1679 echo_dash ();
1680 1680
1699 } 1699 }
1700 } 1700 }
1701 1701
1702 /* If in middle of key sequence and minibuffer not active, 1702 /* If in middle of key sequence and minibuffer not active,
1703 start echoing if enough time elapses. */ 1703 start echoing if enough time elapses. */
1704 if (minibuf_level == 0 && !current_perdisplay->immediate_echo 1704 if (minibuf_level == 0 && !current_kboard->immediate_echo
1705 && this_command_key_count > 0 1705 && this_command_key_count > 0
1706 && ! noninteractive 1706 && ! noninteractive
1707 && echo_keystrokes > 0 1707 && echo_keystrokes > 0
1708 && (echo_area_glyphs == 0 || *echo_area_glyphs == 0)) 1708 && (echo_area_glyphs == 0 || *echo_area_glyphs == 0))
1709 { 1709 {
1793 } 1793 }
1794 } 1794 }
1795 1795
1796 if (NILP (c)) 1796 if (NILP (c))
1797 { 1797 {
1798 /* Primary consideration goes to current_perdisplay's side queue. 1798 /* Primary consideration goes to current_kboard's side queue.
1799 If that's empty, then we check the other side queues and throw 1799 If that's empty, then we check the other side queues and throw
1800 if we find something there. Finally, we read from the main queue, 1800 if we find something there. Finally, we read from the main queue,
1801 and if that gives us something we can't use yet, we put it on the 1801 and if that gives us something we can't use yet, we put it on the
1802 appropriate side queue and try again. */ 1802 appropriate side queue and try again. */
1803 if (current_perdisplay->kbd_queue_has_data) 1803 if (current_kboard->kbd_queue_has_data)
1804 { 1804 {
1805 if (!CONSP (current_perdisplay->kbd_queue)) 1805 if (!CONSP (current_kboard->kbd_queue))
1806 abort (); 1806 abort ();
1807 c = XCONS (current_perdisplay->kbd_queue)->car; 1807 c = XCONS (current_kboard->kbd_queue)->car;
1808 current_perdisplay->kbd_queue 1808 current_kboard->kbd_queue
1809 = XCONS (current_perdisplay->kbd_queue)->cdr; 1809 = XCONS (current_kboard->kbd_queue)->cdr;
1810 if (NILP (current_perdisplay->kbd_queue)) 1810 if (NILP (current_kboard->kbd_queue))
1811 current_perdisplay->kbd_queue_has_data = 0; 1811 current_kboard->kbd_queue_has_data = 0;
1812 input_pending = readable_events (); 1812 input_pending = readable_events ();
1813 #ifdef MULTI_FRAME 1813 #ifdef MULTI_FRAME
1814 if (EVENT_HAS_PARAMETERS (c) 1814 if (EVENT_HAS_PARAMETERS (c)
1815 && EQ (EVENT_HEAD_KIND (EVENT_HEAD (c)), Qswitch_frame)) 1815 && EQ (EVENT_HEAD_KIND (EVENT_HEAD (c)), Qswitch_frame))
1816 internal_last_event_frame = XCONS (XCONS (c)->cdr)->car; 1816 internal_last_event_frame = XCONS (XCONS (c)->cdr)->car;
1817 Vlast_event_frame = internal_last_event_frame; 1817 Vlast_event_frame = internal_last_event_frame;
1818 #endif 1818 #endif
1819 } 1819 }
1820 else 1820 else
1821 { 1821 {
1822 PERDISPLAY *perd; 1822 KBOARD *kb;
1823 #ifdef MULTI_PERDISPLAY 1823 #ifdef MULTI_KBOARD
1824 if (!display_locked) 1824 if (!kboard_locked)
1825 { 1825 {
1826 for (perd = all_perdisplays; perd; perd = perd->next_perdisplay) 1826 for (kb = all_kboards; kb; kb = kb->next_kboard)
1827 if (perd->kbd_queue_has_data) 1827 if (kb->kbd_queue_has_data)
1828 { 1828 {
1829 current_perdisplay = perd; 1829 current_kboard = kb;
1830 longjmp (wrong_display_jmpbuf, 1); 1830 longjmp (wrong_kboard_jmpbuf, 1);
1831 } 1831 }
1832 } 1832 }
1833 #endif 1833 #endif
1834 1834
1835 wrong_display: 1835 wrong_kboard:
1836 /* Actually read a character, waiting if necessary. */ 1836 /* Actually read a character, waiting if necessary. */
1837 while (c = kbd_buffer_get_event (&perd), NILP (c)) 1837 while (c = kbd_buffer_get_event (&kb), NILP (c))
1838 { 1838 {
1839 if (commandflag >= 0 1839 if (commandflag >= 0
1840 && !input_pending && !detect_input_pending ()) 1840 && !input_pending && !detect_input_pending ())
1841 { 1841 {
1842 prepare_menu_bars (); 1842 prepare_menu_bars ();
1843 redisplay (); 1843 redisplay ();
1844 } 1844 }
1845 } 1845 }
1846 #ifdef MULTI_PERDISPLAY 1846 #ifdef MULTI_KBOARD
1847 if (perd != current_perdisplay) 1847 if (kb != current_kboard)
1848 { 1848 {
1849 Lisp_Object *tailp = &perd->kbd_queue; 1849 Lisp_Object *tailp = &kb->kbd_queue;
1850 while (CONSP (*tailp)) 1850 while (CONSP (*tailp))
1851 tailp = &XCONS (*tailp)->cdr; 1851 tailp = &XCONS (*tailp)->cdr;
1852 if (!NILP (*tailp)) 1852 if (!NILP (*tailp))
1853 abort (); 1853 abort ();
1854 *tailp = Fcons (c, Qnil); 1854 *tailp = Fcons (c, Qnil);
1855 perd->kbd_queue_has_data = 1; 1855 kb->kbd_queue_has_data = 1;
1856 if (display_locked) 1856 if (kboard_locked)
1857 goto wrong_display; 1857 goto wrong_kboard;
1858 current_perdisplay = perd; 1858 current_kboard = kb;
1859 longjmp (wrong_display_jmpbuf, 1); 1859 longjmp (wrong_kboard_jmpbuf, 1);
1860 } 1860 }
1861 #endif 1861 #endif
1862 } 1862 }
1863 } 1863 }
1864 /* Terminate Emacs in batch mode if at eof. */ 1864 /* Terminate Emacs in batch mode if at eof. */
2135 return 1; 2135 return 1;
2136 #ifdef HAVE_MOUSE 2136 #ifdef HAVE_MOUSE
2137 if (FRAMEP (do_mouse_tracking) && mouse_moved) 2137 if (FRAMEP (do_mouse_tracking) && mouse_moved)
2138 return 1; 2138 return 1;
2139 #endif 2139 #endif
2140 if (display_locked) 2140 if (kboard_locked)
2141 { 2141 {
2142 if (current_perdisplay->kbd_queue_has_data) 2142 if (current_kboard->kbd_queue_has_data)
2143 return 1; 2143 return 1;
2144 } 2144 }
2145 else 2145 else
2146 { 2146 {
2147 PERDISPLAY *perd; 2147 KBOARD *kb;
2148 for (perd = all_perdisplays; perd; perd = perd->next_perdisplay) 2148 for (kb = all_kboards; kb; kb = kb->next_kboard)
2149 if (perd->kbd_queue_has_data) 2149 if (kb->kbd_queue_has_data)
2150 return 1; 2150 return 1;
2151 } 2151 }
2152 return 0; 2152 return 0;
2153 } 2153 }
2154 2154
2155 /* Set this for debugging, to have a way to get out */ 2155 /* Set this for debugging, to have a way to get out */
2156 int stop_character; 2156 int stop_character;
2157 2157
2158 #ifdef MULTI_PERDISPLAY 2158 #ifdef MULTI_KBOARD
2159 static PERDISPLAY * 2159 static KBOARD *
2160 event_to_perdisplay (event) 2160 event_to_kboard (event)
2161 struct input_event *event; 2161 struct input_event *event;
2162 { 2162 {
2163 Lisp_Object frame; 2163 Lisp_Object frame;
2164 frame = event->frame_or_window; 2164 frame = event->frame_or_window;
2165 if (CONSP (frame)) 2165 if (CONSP (frame))
2170 /* There are still some events that don't set this field. 2170 /* There are still some events that don't set this field.
2171 For now, just ignore the problem. */ 2171 For now, just ignore the problem. */
2172 if (!FRAMEP (frame)) 2172 if (!FRAMEP (frame))
2173 return 0; 2173 return 0;
2174 else 2174 else
2175 return get_perdisplay (XFRAME (frame)); 2175 return FRAME_KBOARD (XFRAME (frame));
2176 } 2176 }
2177 #endif 2177 #endif
2178 2178
2179 /* Store an event obtained at interrupt level into kbd_buffer, fifo */ 2179 /* Store an event obtained at interrupt level into kbd_buffer, fifo */
2180 2180
2197 | hyper_modifier | super_modifier)); 2197 | hyper_modifier | super_modifier));
2198 2198
2199 if (c == quit_char) 2199 if (c == quit_char)
2200 { 2200 {
2201 extern SIGTYPE interrupt_signal (); 2201 extern SIGTYPE interrupt_signal ();
2202 #ifdef MULTI_PERDISPLAY 2202 #ifdef MULTI_KBOARD
2203 PERDISPLAY *perd; 2203 KBOARD *kb;
2204 struct input_event *sp; 2204 struct input_event *sp;
2205 2205
2206 if (display_locked 2206 if (kboard_locked
2207 && (perd = get_perdisplay (XFRAME (event->frame_or_window)), 2207 && (kb = FRAME_KBOARD (XFRAME (event->frame_or_window)),
2208 perd != current_perdisplay)) 2208 kb != current_kboard))
2209 { 2209 {
2210 perd->kbd_queue 2210 kb->kbd_queue
2211 = Fcons (make_lispy_switch_frame (event->frame_or_window), 2211 = Fcons (make_lispy_switch_frame (event->frame_or_window),
2212 Fcons (make_number (c), Qnil)); 2212 Fcons (make_number (c), Qnil));
2213 perd->kbd_queue_has_data = 1; 2213 kb->kbd_queue_has_data = 1;
2214 for (sp = kbd_fetch_ptr; sp != kbd_store_ptr; sp++) 2214 for (sp = kbd_fetch_ptr; sp != kbd_store_ptr; sp++)
2215 { 2215 {
2216 if (sp == kbd_buffer + KBD_BUFFER_SIZE) 2216 if (sp == kbd_buffer + KBD_BUFFER_SIZE)
2217 sp = kbd_buffer; 2217 sp = kbd_buffer;
2218 2218
2219 if (event_to_perdisplay (sp) == perd) 2219 if (event_to_kboard (sp) == kb)
2220 { 2220 {
2221 sp->kind = no_event; 2221 sp->kind = no_event;
2222 sp->frame_or_window = Qnil; 2222 sp->frame_or_window = Qnil;
2223 } 2223 }
2224 } 2224 }
2295 The value is nil for an event that should be ignored, 2295 The value is nil for an event that should be ignored,
2296 or that was handled here. 2296 or that was handled here.
2297 We always read and discard one event. */ 2297 We always read and discard one event. */
2298 2298
2299 static Lisp_Object 2299 static Lisp_Object
2300 kbd_buffer_get_event (PERDISPLAY **perdp) 2300 kbd_buffer_get_event (KBOARD **kbp)
2301 { 2301 {
2302 register int c; 2302 register int c;
2303 Lisp_Object obj; 2303 Lisp_Object obj;
2304 2304
2305 if (noninteractive) 2305 if (noninteractive)
2306 { 2306 {
2307 c = getchar (); 2307 c = getchar ();
2308 XSETINT (obj, c); 2308 XSETINT (obj, c);
2309 *perdp = all_perdisplays; /* There'd better be exactly one! */ 2309 *kbp = all_kboards; /* There'd better be exactly one! */
2310 return obj; 2310 return obj;
2311 } 2311 }
2312 2312
2313 /* Wait until there is input available. */ 2313 /* Wait until there is input available. */
2314 for (;;) 2314 for (;;)
2365 ? kbd_fetch_ptr 2365 ? kbd_fetch_ptr
2366 : kbd_buffer); 2366 : kbd_buffer);
2367 2367
2368 last_event_timestamp = event->timestamp; 2368 last_event_timestamp = event->timestamp;
2369 2369
2370 #ifdef MULTI_PERDISPLAY 2370 #ifdef MULTI_KBOARD
2371 *perdp = event_to_perdisplay (event); 2371 *kbp = event_to_kboard (event);
2372 if (*perdp == 0) 2372 if (*kbp == 0)
2373 *perdp = all_perdisplays; /* Better than returning null ptr? */ 2373 *kbp = current_kboard; /* Better than returning null ptr? */
2374 #else 2374 #else
2375 *perdp = &the_only_perdisplay; 2375 *kbp = &the_only_kboard;
2376 #endif 2376 #endif
2377 2377
2378 obj = Qnil; 2378 obj = Qnil;
2379 2379
2380 /* These two kinds of events get special handling 2380 /* These two kinds of events get special handling
2443 /* The value doesn't matter here; only the type is tested. */ 2443 /* The value doesn't matter here; only the type is tested. */
2444 XSETBUFFER (obj, current_buffer); 2444 XSETBUFFER (obj, current_buffer);
2445 kbd_fetch_ptr = event + 1; 2445 kbd_fetch_ptr = event + 1;
2446 } 2446 }
2447 /* Just discard these, by returning nil. 2447 /* Just discard these, by returning nil.
2448 With MULTI_PERDISPLAY, these events are used as placeholders 2448 With MULTI_KBOARD, these events are used as placeholders
2449 when we need to randomly delete events from the queue. 2449 when we need to randomly delete events from the queue.
2450 (They shouldn't otherwise be found in the buffer, 2450 (They shouldn't otherwise be found in the buffer,
2451 but on some machines it appears they do show up 2451 but on some machines it appears they do show up
2452 even without MULTI_PERDISPLAY.) */ 2452 even without MULTI_KBOARD.) */
2453 else if (event->kind == no_event) 2453 else if (event->kind == no_event)
2454 kbd_fetch_ptr = event + 1; 2454 kbd_fetch_ptr = event + 1;
2455 2455
2456 /* If this event is on a different frame, return a switch-frame this 2456 /* If this event is on a different frame, return a switch-frame this
2457 time, and leave the event in the queue for next time. */ 2457 time, and leave the event in the queue for next time. */
2498 Lisp_Object bar_window; 2498 Lisp_Object bar_window;
2499 enum scroll_bar_part part; 2499 enum scroll_bar_part part;
2500 Lisp_Object x, y; 2500 Lisp_Object x, y;
2501 unsigned long time; 2501 unsigned long time;
2502 2502
2503 *perdp = current_perdisplay; 2503 *kbp = current_kboard;
2504 /* Note that this uses F to determine which display to look at. 2504 /* Note that this uses F to determine which display to look at.
2505 If there is no valid info, it does not store anything 2505 If there is no valid info, it does not store anything
2506 so x remains nil. */ 2506 so x remains nil. */
2507 x = Qnil; 2507 x = Qnil;
2508 (*mouse_position_hook) (&f, &bar_window, &part, &x, &y, &time); 2508 (*mouse_position_hook) (&f, &bar_window, &part, &x, &y, &time);
4698 4698
4699 /* Make believe its not a keyboard macro in case the help char 4699 /* Make believe its not a keyboard macro in case the help char
4700 is pressed. Help characters are not recorded because menu prompting 4700 is pressed. Help characters are not recorded because menu prompting
4701 is not used on replay. 4701 is not used on replay.
4702 */ 4702 */
4703 orig_defn_macro = current_perdisplay->defining_kbd_macro; 4703 orig_defn_macro = current_kboard->defining_kbd_macro;
4704 current_perdisplay->defining_kbd_macro = Qnil; 4704 current_kboard->defining_kbd_macro = Qnil;
4705 do 4705 do
4706 obj = read_char (commandflag, 0, 0, Qnil, 0); 4706 obj = read_char (commandflag, 0, 0, Qnil, 0);
4707 while (BUFFERP (obj)); 4707 while (BUFFERP (obj));
4708 current_perdisplay->defining_kbd_macro = orig_defn_macro; 4708 current_kboard->defining_kbd_macro = orig_defn_macro;
4709 4709
4710 if (!INTEGERP (obj)) 4710 if (!INTEGERP (obj))
4711 return obj; 4711 return obj;
4712 else 4712 else
4713 ch = XINT (obj); 4713 ch = XINT (obj);
4714 4714
4715 if (! EQ (obj, menu_prompt_more_char) 4715 if (! EQ (obj, menu_prompt_more_char)
4716 && (!INTEGERP (menu_prompt_more_char) 4716 && (!INTEGERP (menu_prompt_more_char)
4717 || ! EQ (obj, make_number (Ctl (XINT (menu_prompt_more_char)))))) 4717 || ! EQ (obj, make_number (Ctl (XINT (menu_prompt_more_char))))))
4718 { 4718 {
4719 if (!NILP (current_perdisplay->defining_kbd_macro)) 4719 if (!NILP (current_kboard->defining_kbd_macro))
4720 store_kbd_macro_char (obj); 4720 store_kbd_macro_char (obj);
4721 return obj; 4721 return obj;
4722 } 4722 }
4723 /* Help char - go round again */ 4723 /* Help char - go round again */
4724 } 4724 }
5095 else 5095 else
5096 { 5096 {
5097 struct buffer *buf = current_buffer; 5097 struct buffer *buf = current_buffer;
5098 5098
5099 { 5099 {
5100 #ifdef MULTI_PERDISPLAY 5100 #ifdef MULTI_KBOARD
5101 PERDISPLAY *interrupted_perdisplay = current_perdisplay; 5101 KBOARD *interrupted_kboard = current_kboard;
5102 struct frame *interrupted_frame = selected_frame; 5102 struct frame *interrupted_frame = selected_frame;
5103 if (setjmp (wrong_display_jmpbuf)) 5103 if (setjmp (wrong_kboard_jmpbuf))
5104 { 5104 {
5105 if (!NILP (delayed_switch_frame)) 5105 if (!NILP (delayed_switch_frame))
5106 { 5106 {
5107 interrupted_perdisplay->kbd_queue 5107 interrupted_kboard->kbd_queue
5108 = Fcons (delayed_switch_frame, 5108 = Fcons (delayed_switch_frame,
5109 interrupted_perdisplay->kbd_queue); 5109 interrupted_kboard->kbd_queue);
5110 delayed_switch_frame = Qnil; 5110 delayed_switch_frame = Qnil;
5111 } 5111 }
5112 while (t > 0) 5112 while (t > 0)
5113 interrupted_perdisplay->kbd_queue 5113 interrupted_kboard->kbd_queue
5114 = Fcons (keybuf[--t], interrupted_perdisplay->kbd_queue); 5114 = Fcons (keybuf[--t], interrupted_kboard->kbd_queue);
5115 5115
5116 /* If the side queue is non-empty, ensure it begins with a 5116 /* If the side queue is non-empty, ensure it begins with a
5117 switch-frame, so we'll replay it in the right context. */ 5117 switch-frame, so we'll replay it in the right context. */
5118 if (CONSP (interrupted_perdisplay->kbd_queue) 5118 if (CONSP (interrupted_kboard->kbd_queue)
5119 && (key = XCONS (interrupted_perdisplay->kbd_queue)->car, 5119 && (key = XCONS (interrupted_kboard->kbd_queue)->car,
5120 !(EVENT_HAS_PARAMETERS (key) 5120 !(EVENT_HAS_PARAMETERS (key)
5121 && EQ (EVENT_HEAD_KIND (EVENT_HEAD (key)), 5121 && EQ (EVENT_HEAD_KIND (EVENT_HEAD (key)),
5122 Qswitch_frame)))) 5122 Qswitch_frame))))
5123 { 5123 {
5124 Lisp_Object frame; 5124 Lisp_Object frame;
5125 XSETFRAME (frame, interrupted_frame); 5125 XSETFRAME (frame, interrupted_frame);
5126 interrupted_perdisplay->kbd_queue 5126 interrupted_kboard->kbd_queue
5127 = Fcons (make_lispy_switch_frame (frame), 5127 = Fcons (make_lispy_switch_frame (frame),
5128 interrupted_perdisplay->kbd_queue); 5128 interrupted_kboard->kbd_queue);
5129 } 5129 }
5130 mock_input = 0; 5130 mock_input = 0;
5131 orig_local_map = get_local_map (PT, current_buffer); 5131 orig_local_map = get_local_map (PT, current_buffer);
5132 goto replay_sequence; 5132 goto replay_sequence;
5133 } 5133 }
6086 DEFUN ("discard-input", Fdiscard_input, Sdiscard_input, 0, 0, 0, 6086 DEFUN ("discard-input", Fdiscard_input, Sdiscard_input, 0, 0, 0,
6087 "Discard the contents of the terminal input buffer.\n\ 6087 "Discard the contents of the terminal input buffer.\n\
6088 Also cancel any kbd macro being defined.") 6088 Also cancel any kbd macro being defined.")
6089 () 6089 ()
6090 { 6090 {
6091 current_perdisplay->defining_kbd_macro = Qnil; 6091 current_kboard->defining_kbd_macro = Qnil;
6092 update_mode_lines++; 6092 update_mode_lines++;
6093 6093
6094 Vunread_command_events = Qnil; 6094 Vunread_command_events = Qnil;
6095 unread_command_char = -1; 6095 unread_command_char = -1;
6096 6096
6184 stuff_char (*p++); 6184 stuff_char (*p++);
6185 stuff_char ('\n'); 6185 stuff_char ('\n');
6186 } 6186 }
6187 /* Anything we have read ahead, put back for the shell to read. */ 6187 /* Anything we have read ahead, put back for the shell to read. */
6188 /* ?? What should this do when we have multiple keyboards?? 6188 /* ?? What should this do when we have multiple keyboards??
6189 Should we ignore anything that was typed in at the "wrong" display? */ 6189 Should we ignore anything that was typed in at the "wrong" kboard? */
6190 for (; kbd_fetch_ptr != kbd_store_ptr; kbd_fetch_ptr++) 6190 for (; kbd_fetch_ptr != kbd_store_ptr; kbd_fetch_ptr++)
6191 { 6191 {
6192 if (kbd_fetch_ptr == kbd_buffer + KBD_BUFFER_SIZE) 6192 if (kbd_fetch_ptr == kbd_buffer + KBD_BUFFER_SIZE)
6193 kbd_fetch_ptr = kbd_buffer; 6193 kbd_fetch_ptr = kbd_buffer;
6194 if (kbd_fetch_ptr->kind == ascii_keystroke) 6194 if (kbd_fetch_ptr->kind == ascii_keystroke)
6456 return Flist (sizeof (val) / sizeof (val[0]), val); 6456 return Flist (sizeof (val) / sizeof (val[0]), val);
6457 } 6457 }
6458 6458
6459 6459
6460 /* 6460 /*
6461 * Set up a perdisplay object with reasonable initial values. 6461 * Set up a new kboard object with reasonable initial values.
6462 */ 6462 */
6463 void 6463 void
6464 init_perdisplay (perd) 6464 init_kboard (kb)
6465 PERDISPLAY *perd; 6465 KBOARD *kb;
6466 { 6466 {
6467 perd->prefix_factor = Qnil; 6467 kb->prefix_factor = Qnil;
6468 perd->prefix_value = Qnil; 6468 kb->prefix_value = Qnil;
6469 perd->prefix_sign = 1; 6469 kb->prefix_sign = 1;
6470 perd->prefix_partial = 0; 6470 kb->prefix_partial = 0;
6471 perd->kbd_queue = Qnil; 6471 kb->kbd_queue = Qnil;
6472 perd->kbd_queue_has_data = 0; 6472 kb->kbd_queue_has_data = 0;
6473 perd->immediate_echo = 0; 6473 kb->immediate_echo = 0;
6474 perd->echoptr = perd->echobuf; 6474 kb->echoptr = kb->echobuf;
6475 perd->echo_after_prompt = -1; 6475 kb->echo_after_prompt = -1;
6476 perd->kbd_macro_buffer = 0; 6476 kb->kbd_macro_buffer = 0;
6477 perd->kbd_macro_bufsize = 0; 6477 kb->kbd_macro_bufsize = 0;
6478 perd->defining_kbd_macro = Qnil; 6478 kb->defining_kbd_macro = Qnil;
6479 perd->Vlast_kbd_macro = Qnil; 6479 kb->Vlast_kbd_macro = Qnil;
6480 kb->reference_count = 0;
6480 } 6481 }
6481 6482
6482 /* 6483 /*
6483 * Destroy the contents of a perdisplay object, but not the object itself. 6484 * Destroy the contents of a kboard object, but not the object itself.
6484 * We use this just before deleteing it, or if we're going to initialize 6485 * We use this just before deleteing it, or if we're going to initialize
6485 * it a second time. 6486 * it a second time.
6486 */ 6487 */
6487 void 6488 void
6488 wipe_perdisplay (perd) 6489 wipe_kboard (kb)
6489 PERDISPLAY *perd; 6490 KBOARD *kb;
6490 { 6491 {
6491 if (perd->kbd_macro_buffer) 6492 if (kb->kbd_macro_buffer)
6492 xfree (perd->kbd_macro_buffer); 6493 xfree (kb->kbd_macro_buffer);
6493 } 6494 }
6494 6495
6495 init_keyboard () 6496 init_keyboard ()
6496 { 6497 {
6497 /* This is correct before outermost invocation of the editor loop */ 6498 /* This is correct before outermost invocation of the editor loop */
6518 Vlast_event_frame = internal_last_event_frame; 6519 Vlast_event_frame = internal_last_event_frame;
6519 #endif 6520 #endif
6520 6521
6521 if (!initialized) 6522 if (!initialized)
6522 { 6523 {
6523 #ifdef MULTI_PERDISPLAY 6524 #ifdef MULTI_KBOARD
6524 current_perdisplay = (PERDISPLAY *)xmalloc (sizeof (PERDISPLAY)); 6525 current_kboard = (KBOARD *)xmalloc (sizeof (KBOARD));
6525 all_perdisplays = current_perdisplay; 6526 all_kboards = current_kboard;
6526 #endif 6527 #endif
6527 current_perdisplay->next_perdisplay = 0; 6528 current_kboard->next_kboard = 0;
6528 } 6529 }
6529 if (initialized) 6530 if (initialized)
6530 wipe_perdisplay (current_perdisplay); 6531 wipe_kboard (current_kboard);
6531 init_perdisplay (current_perdisplay); 6532 init_kboard (current_kboard);
6532 6533
6533 if (initialized) 6534 if (initialized)
6534 Ffillarray (kbd_buffer_frame_or_window, Qnil); 6535 Ffillarray (kbd_buffer_frame_or_window, Qnil);
6535 6536
6536 kbd_buffer_frame_or_window 6537 kbd_buffer_frame_or_window