aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKarl Heuer1995-02-04 01:11:55 +0000
committerKarl Heuer1995-02-04 01:11:55 +0000
commit6c6083a932a1a2c3294f8f89d92d0943695fb8c3 (patch)
treeadd0de4da80c71ce05ac471b761121b057bc09be /src
parenteebf4ec9ce15b03c7dcae4d69206925b130097d1 (diff)
downloademacs-6c6083a932a1a2c3294f8f89d92d0943695fb8c3.tar.gz
emacs-6c6083a932a1a2c3294f8f89d92d0943695fb8c3.zip
(syms_of_keyboard): Move DEFVAR_DISPLAY's here from callint.c.
[MULTI_PERDISPLAY] (current_perdisplay): New var. (find_active_event_queue): Search all perdisplays. (init_perdisplay, wipe_perdisplay): New functions. (init_keyboard): Move perdisplay initialization to init_perdisplay. (syms_of_keyboard): Likewise. (echo_prompt, echo_char, echo_dash, echo, cancel_echoing, echo_length) (read_char, Fdiscard_input, stuff_buffered_input): Use current_perdisplay, not get_perdisplay.
Diffstat (limited to 'src')
-rw-r--r--src/keyboard.c167
1 files changed, 103 insertions, 64 deletions
diff --git a/src/keyboard.c b/src/keyboard.c
index fca3d3a1599..54b470f2eac 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -95,7 +95,11 @@ struct backtrace
95 char evalargs; 95 char evalargs;
96 }; 96 };
97 97
98#ifdef MULTI_PERDISPLAY
99PERDISPLAY *current_perdisplay;
100#else
98PERDISPLAY the_only_perdisplay; 101PERDISPLAY the_only_perdisplay;
102#endif
99 103
100/* Non-nil disable property on a command means 104/* Non-nil disable property on a command means
101 do not execute it; call disabled-command-hook's value instead. */ 105 do not execute it; call disabled-command-hook's value instead. */
@@ -456,16 +460,15 @@ static int cannot_suspend;
456echo_prompt (str) 460echo_prompt (str)
457 char *str; 461 char *str;
458{ 462{
459 PERDISPLAY *perd = get_perdisplay (selected_frame);
460 int len = strlen (str); 463 int len = strlen (str);
461 464
462 if (len > ECHOBUFSIZE - 4) 465 if (len > ECHOBUFSIZE - 4)
463 len = ECHOBUFSIZE - 4; 466 len = ECHOBUFSIZE - 4;
464 bcopy (str, perd->echobuf, len); 467 bcopy (str, current_perdisplay->echobuf, len);
465 perd->echoptr = perd->echobuf + len; 468 current_perdisplay->echoptr = current_perdisplay->echobuf + len;
466 *perd->echoptr = '\0'; 469 *current_perdisplay->echoptr = '\0';
467 470
468 perd->echo_after_prompt = len; 471 current_perdisplay->echo_after_prompt = len;
469 472
470 echo (); 473 echo ();
471} 474}
@@ -478,13 +481,12 @@ echo_char (c)
478 Lisp_Object c; 481 Lisp_Object c;
479{ 482{
480 extern char *push_key_description (); 483 extern char *push_key_description ();
481 PERDISPLAY *perd = get_perdisplay (selected_frame);
482 484
483 if (perd->immediate_echo) 485 if (current_perdisplay->immediate_echo)
484 { 486 {
485 char *ptr = perd->echoptr; 487 char *ptr = current_perdisplay->echoptr;
486 488
487 if (ptr != perd->echobuf) 489 if (ptr != current_perdisplay->echobuf)
488 *ptr++ = ' '; 490 *ptr++ = ' ';
489 491
490 /* If someone has passed us a composite event, use its head symbol. */ 492 /* If someone has passed us a composite event, use its head symbol. */
@@ -492,7 +494,7 @@ echo_char (c)
492 494
493 if (INTEGERP (c)) 495 if (INTEGERP (c))
494 { 496 {
495 if (ptr - perd->echobuf > ECHOBUFSIZE - 6) 497 if (ptr - current_perdisplay->echobuf > ECHOBUFSIZE - 6)
496 return; 498 return;
497 499
498 ptr = push_key_description (XINT (c), ptr); 500 ptr = push_key_description (XINT (c), ptr);
@@ -500,20 +502,22 @@ echo_char (c)
500 else if (SYMBOLP (c)) 502 else if (SYMBOLP (c))
501 { 503 {
502 struct Lisp_String *name = XSYMBOL (c)->name; 504 struct Lisp_String *name = XSYMBOL (c)->name;
503 if (((ptr - perd->echobuf) + name->size + 4) > ECHOBUFSIZE) 505 if (((ptr - current_perdisplay->echobuf) + name->size + 4)
506 > ECHOBUFSIZE)
504 return; 507 return;
505 bcopy (name->data, ptr, name->size); 508 bcopy (name->data, ptr, name->size);
506 ptr += name->size; 509 ptr += name->size;
507 } 510 }
508 511
509 if (perd->echoptr == perd->echobuf && EQ (c, Vhelp_char)) 512 if (current_perdisplay->echoptr == current_perdisplay->echobuf
513 && EQ (c, Vhelp_char))
510 { 514 {
511 strcpy (ptr, " (Type ? for further options)"); 515 strcpy (ptr, " (Type ? for further options)");
512 ptr += strlen (ptr); 516 ptr += strlen (ptr);
513 } 517 }
514 518
515 *ptr = 0; 519 *ptr = 0;
516 perd->echoptr = ptr; 520 current_perdisplay->echoptr = ptr;
517 521
518 echo (); 522 echo ();
519 } 523 }
@@ -524,20 +528,21 @@ echo_char (c)
524 528
525echo_dash () 529echo_dash ()
526{ 530{
527 PERDISPLAY *perd = get_perdisplay (selected_frame); 531 if (!current_perdisplay->immediate_echo
528 if (!perd->immediate_echo && perd->echoptr == perd->echobuf) 532 && current_perdisplay->echoptr == current_perdisplay->echobuf)
529 return; 533 return;
530 /* Do nothing if we just printed a prompt. */ 534 /* Do nothing if we just printed a prompt. */
531 if (perd->echo_after_prompt == perd->echoptr - perd->echobuf) 535 if (current_perdisplay->echo_after_prompt
536 == current_perdisplay->echoptr - current_perdisplay->echobuf)
532 return; 537 return;
533 /* Do nothing if not echoing at all. */ 538 /* Do nothing if not echoing at all. */
534 if (perd->echoptr == 0) 539 if (current_perdisplay->echoptr == 0)
535 return; 540 return;
536 541
537 /* Put a dash at the end of the buffer temporarily, 542 /* Put a dash at the end of the buffer temporarily,
538 but make it go away when the next character is added. */ 543 but make it go away when the next character is added. */
539 perd->echoptr[0] = '-'; 544 current_perdisplay->echoptr[0] = '-';
540 perd->echoptr[1] = 0; 545 current_perdisplay->echoptr[1] = 0;
541 546
542 echo (); 547 echo ();
543} 548}
@@ -547,11 +552,10 @@ echo_dash ()
547 552
548echo () 553echo ()
549{ 554{
550 PERDISPLAY *perd = get_perdisplay (selected_frame); 555 if (!current_perdisplay->immediate_echo)
551 if (!perd->immediate_echo)
552 { 556 {
553 int i; 557 int i;
554 perd->immediate_echo = 1; 558 current_perdisplay->immediate_echo = 1;
555 559
556 for (i = 0; i < this_command_key_count; i++) 560 for (i = 0; i < this_command_key_count; i++)
557 { 561 {
@@ -565,7 +569,7 @@ echo ()
565 } 569 }
566 570
567 echoing = 1; 571 echoing = 1;
568 message2_nolog (perd->echobuf, strlen (perd->echobuf)); 572 message1_nolog (current_perdisplay->echobuf);
569 echoing = 0; 573 echoing = 0;
570 574
571 if (waiting_for_input && !NILP (Vquit_flag)) 575 if (waiting_for_input && !NILP (Vquit_flag))
@@ -576,10 +580,9 @@ echo ()
576 580
577cancel_echoing () 581cancel_echoing ()
578{ 582{
579 PERDISPLAY *perd = get_perdisplay (selected_frame); 583 current_perdisplay->immediate_echo = 0;
580 perd->immediate_echo = 0; 584 current_perdisplay->echoptr = current_perdisplay->echobuf;
581 perd->echoptr = perd->echobuf; 585 current_perdisplay->echo_after_prompt = -1;
582 perd->echo_after_prompt = -1;
583} 586}
584 587
585/* Return the length of the current echo string. */ 588/* Return the length of the current echo string. */
@@ -587,8 +590,7 @@ cancel_echoing ()
587static int 590static int
588echo_length () 591echo_length ()
589{ 592{
590 PERDISPLAY *perd = get_perdisplay (selected_frame); 593 return current_perdisplay->echoptr - current_perdisplay->echobuf;
591 return perd->echoptr - perd->echobuf;
592} 594}
593 595
594/* Truncate the current echo message to its first LEN chars. 596/* Truncate the current echo message to its first LEN chars.
@@ -599,9 +601,8 @@ static void
599echo_truncate (len) 601echo_truncate (len)
600 int len; 602 int len;
601{ 603{
602 PERDISPLAY *perd = get_perdisplay (selected_frame); 604 current_perdisplay->echobuf[len] = '\0';
603 perd->echobuf[len] = '\0'; 605 current_perdisplay->echoptr = current_perdisplay->echobuf + len;
604 perd->echoptr = perd->echobuf + len;
605 truncate_echo_area (len); 606 truncate_echo_area (len);
606} 607}
607 608
@@ -1449,7 +1450,6 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu)
1449 int count; 1450 int count;
1450 jmp_buf save_jump; 1451 jmp_buf save_jump;
1451 int key_already_recorded = 0; 1452 int key_already_recorded = 0;
1452 PERDISPLAY *perd = get_perdisplay (selected_frame);
1453 Lisp_Object also_record; 1453 Lisp_Object also_record;
1454 also_record = Qnil; 1454 also_record = Qnil;
1455 1455
@@ -1551,7 +1551,8 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu)
1551 } 1551 }
1552 1552
1553 /* Message turns off echoing unless more keystrokes turn it on again. */ 1553 /* Message turns off echoing unless more keystrokes turn it on again. */
1554 if (echo_area_glyphs && *echo_area_glyphs && echo_area_glyphs != perd->echobuf) 1554 if (echo_area_glyphs && *echo_area_glyphs
1555 && echo_area_glyphs != current_perdisplay->echobuf)
1555 cancel_echoing (); 1556 cancel_echoing ();
1556 else 1557 else
1557 /* If already echoing, continue. */ 1558 /* If already echoing, continue. */
@@ -1580,7 +1581,8 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu)
1580 1581
1581 /* If in middle of key sequence and minibuffer not active, 1582 /* If in middle of key sequence and minibuffer not active,
1582 start echoing if enough time elapses. */ 1583 start echoing if enough time elapses. */
1583 if (minibuf_level == 0 && !perd->immediate_echo && this_command_key_count > 0 1584 if (minibuf_level == 0 && !current_perdisplay->immediate_echo
1585 && this_command_key_count > 0
1584 && ! noninteractive 1586 && ! noninteractive
1585 && echo_keystrokes > 0 1587 && echo_keystrokes > 0
1586 && (echo_area_glyphs == 0 || *echo_area_glyphs == 0)) 1588 && (echo_area_glyphs == 0 || *echo_area_glyphs == 0))
@@ -1953,8 +1955,8 @@ static PERDISPLAY *
1953find_active_event_queue () 1955find_active_event_queue ()
1954{ 1956{
1955 PERDISPLAY *perd; 1957 PERDISPLAY *perd;
1956 perd = &the_only_perdisplay; 1958
1957 /* FOR_ALL_PERDISPLAYS (perd) */ 1959 for (perd = all_perdisplays; perd; perd = perd->next_perdisplay)
1958 { 1960 {
1959 if (perd->kbd_fetch_ptr != perd->kbd_store_ptr) 1961 if (perd->kbd_fetch_ptr != perd->kbd_store_ptr)
1960 return perd; 1962 return perd;
@@ -5651,7 +5653,6 @@ DEFUN ("discard-input", Fdiscard_input, Sdiscard_input, 0, 0, 0,
5651Also cancel any kbd macro being defined.") 5653Also cancel any kbd macro being defined.")
5652 () 5654 ()
5653{ 5655{
5654 PERDISPLAY *perd = &the_only_perdisplay;
5655 defining_kbd_macro = 0; 5656 defining_kbd_macro = 0;
5656 update_mode_lines++; 5657 update_mode_lines++;
5657 5658
@@ -5663,8 +5664,9 @@ Also cancel any kbd macro being defined.")
5663 /* Without the cast, GCC complains that this assignment loses the 5664 /* Without the cast, GCC complains that this assignment loses the
5664 volatile qualifier of kbd_store_ptr. Is there anything wrong 5665 volatile qualifier of kbd_store_ptr. Is there anything wrong
5665 with that? */ 5666 with that? */
5666 perd->kbd_fetch_ptr = (struct input_event *) perd->kbd_store_ptr; 5667 current_perdisplay->kbd_fetch_ptr
5667 Ffillarray (perd->kbd_buffer_frame_or_window, Qnil); 5668 = (struct input_event *) current_perdisplay->kbd_store_ptr;
5669 Ffillarray (current_perdisplay->kbd_buffer_frame_or_window, Qnil);
5668 input_pending = 0; 5670 input_pending = 0;
5669 5671
5670 return Qnil; 5672 return Qnil;
@@ -5737,7 +5739,7 @@ stuff_buffered_input (stuffstring)
5737#ifdef BSD 5739#ifdef BSD
5738#ifndef BSD4_1 5740#ifndef BSD4_1
5739 register unsigned char *p; 5741 register unsigned char *p;
5740 PERDISPLAY *perd = &the_only_perdisplay; /* We really want the primary display's perd */ 5742 PERDISPLAY *perd;
5741 5743
5742 if (STRINGP (stuffstring)) 5744 if (STRINGP (stuffstring))
5743 { 5745 {
@@ -5750,6 +5752,14 @@ stuff_buffered_input (stuffstring)
5750 stuff_char ('\n'); 5752 stuff_char ('\n');
5751 } 5753 }
5752 /* Anything we have read ahead, put back for the shell to read. */ 5754 /* Anything we have read ahead, put back for the shell to read. */
5755#ifndef MULTI_PERDISPLAY
5756 perd = &the_only_perdisplay;
5757#else
5758 /* ?? What should this do when we have multiple keyboards?? */
5759 perd = current_perdisplay;
5760 if (!perd)
5761 return;
5762#endif
5753 while (perd->kbd_fetch_ptr != perd->kbd_store_ptr) 5763 while (perd->kbd_fetch_ptr != perd->kbd_store_ptr)
5754 { 5764 {
5755 if (perd->kbd_fetch_ptr == perd->kbd_buffer + KBD_BUFFER_SIZE) 5765 if (perd->kbd_fetch_ptr == perd->kbd_buffer + KBD_BUFFER_SIZE)
@@ -6020,6 +6030,36 @@ The elements of this list correspond to the arguments of\n\
6020} 6030}
6021 6031
6022 6032
6033/*
6034 * Set up a perdisplay object with reasonable initial values.
6035 */
6036void
6037init_perdisplay (perd)
6038 PERDISPLAY *perd;
6039{
6040 perd->Vprefix_arg = Qnil;
6041 perd->Vcurrent_prefix_arg = Qnil;
6042 perd->kbd_buffer
6043 = (struct input_event *)xmalloc (KBD_BUFFER_SIZE
6044 * sizeof (struct input_event));
6045 perd->kbd_fetch_ptr = perd->kbd_buffer;
6046 perd->kbd_store_ptr = perd->kbd_buffer;
6047 perd->kbd_buffer_frame_or_window
6048 = Fmake_vector (make_number (KBD_BUFFER_SIZE), Qnil);
6049}
6050
6051/*
6052 * Destroy the contents of a perdisplay object, but not the object itself.
6053 * We use this just before deleteing it, or if we're going to initialize
6054 * it a second time.
6055 */
6056void
6057wipe_perdisplay (perd)
6058 PERDISPLAY *perd;
6059{
6060 xfree (perd->kbd_buffer);
6061}
6062
6023init_keyboard () 6063init_keyboard ()
6024{ 6064{
6025 /* This is correct before outermost invocation of the editor loop */ 6065 /* This is correct before outermost invocation of the editor loop */
@@ -6030,11 +6070,6 @@ init_keyboard ()
6030 unread_command_char = -1; 6070 unread_command_char = -1;
6031 total_keys = 0; 6071 total_keys = 0;
6032 recent_keys_index = 0; 6072 recent_keys_index = 0;
6033 the_only_perdisplay.kbd_buffer
6034 = (struct input_event *)xmalloc (KBD_BUFFER_SIZE
6035 * sizeof (struct input_event));
6036 the_only_perdisplay.kbd_fetch_ptr = the_only_perdisplay.kbd_buffer;
6037 the_only_perdisplay.kbd_store_ptr = the_only_perdisplay.kbd_buffer;
6038#ifdef HAVE_MOUSE 6073#ifdef HAVE_MOUSE
6039 do_mouse_tracking = Qnil; 6074 do_mouse_tracking = Qnil;
6040#endif 6075#endif
@@ -6047,21 +6082,11 @@ init_keyboard ()
6047 Vlast_event_frame = internal_last_event_frame; 6082 Vlast_event_frame = internal_last_event_frame;
6048#endif 6083#endif
6049 6084
6050 /* If we're running a dumped Emacs, we need to clear out 6085#ifndef MULTI_PERDISPLAY
6051 kbd_buffer_frame_or_window, in case some events got into it
6052 before we dumped.
6053
6054 If we're running an undumped Emacs, it hasn't been initialized by
6055 syms_of_keyboard yet. */
6056 if (initialized) 6086 if (initialized)
6057 { 6087 wipe_perdisplay (&the_only_perdisplay);
6058 PERDISPLAY *perd; 6088 init_perdisplay (&the_only_perdisplay);
6059 perd = &the_only_perdisplay; 6089#endif
6060 /* FOR_ALL_PERDISPLAYS (perd) */
6061 {
6062 Ffillarray (perd->kbd_buffer_frame_or_window, Qnil);
6063 }
6064 }
6065 6090
6066 if (!noninteractive && !read_socket_hook && NILP (Vwindow_system)) 6091 if (!noninteractive && !read_socket_hook && NILP (Vwindow_system))
6067 { 6092 {
@@ -6232,10 +6257,6 @@ syms_of_keyboard ()
6232 Fset (Qextended_command_history, Qnil); 6257 Fset (Qextended_command_history, Qnil);
6233 staticpro (&Qextended_command_history); 6258 staticpro (&Qextended_command_history);
6234 6259
6235 the_only_perdisplay.kbd_buffer_frame_or_window
6236 = Fmake_vector (make_number (KBD_BUFFER_SIZE), Qnil);
6237 staticpro (&the_only_perdisplay.kbd_buffer_frame_or_window);
6238
6239 accent_key_syms = Qnil; 6260 accent_key_syms = Qnil;
6240 staticpro (&accent_key_syms); 6261 staticpro (&accent_key_syms);
6241 6262
@@ -6503,6 +6524,24 @@ The precise format isn't relevant here; we just check whether it is nil.");
6503This function is called with no arguments after each command\n\ 6524This function is called with no arguments after each command\n\
6504whenever `deferred-action-list' is non-nil."); 6525whenever `deferred-action-list' is non-nil.");
6505 Vdeferred_action_function = Qnil; 6526 Vdeferred_action_function = Qnil;
6527
6528 DEFVAR_DISPLAY ("prefix-arg", Vprefix_arg,
6529 "The value of the prefix argument for the next editing command.\n\
6530It may be a number, or the symbol `-' for just a minus sign as arg,\n\
6531or a list whose car is a number for just one or more C-U's\n\
6532or nil if no argument has been specified.\n\
6533\n\
6534You cannot examine this variable to find the argument for this command\n\
6535since it has been set to nil by the time you can look.\n\
6536Instead, you should use the variable `current-prefix-arg', although\n\
6537normally commands can get this prefix argument with (interactive \"P\").");
6538
6539 DEFVAR_DISPLAY ("current-prefix-arg", Vcurrent_prefix_arg,
6540 "The value of the prefix argument for this editing command.\n\
6541It may be a number, or the symbol `-' for just a minus sign as arg,\n\
6542or a list whose car is a number for just one or more C-U's\n\
6543or nil if no argument has been specified.\n\
6544This is what `(interactive \"P\")' returns.");
6506} 6545}
6507 6546
6508keys_of_keyboard () 6547keys_of_keyboard ()