Commit 6c6083a9 authored by Karl Heuer's avatar Karl Heuer
Browse files

(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.
parent eebf4ec9
...@@ -95,7 +95,11 @@ struct backtrace ...@@ -95,7 +95,11 @@ struct backtrace
char evalargs; char evalargs;
}; };
#ifdef MULTI_PERDISPLAY
PERDISPLAY *current_perdisplay;
#else
PERDISPLAY the_only_perdisplay; PERDISPLAY the_only_perdisplay;
#endif
/* Non-nil disable property on a command means /* Non-nil disable property on a command means
do not execute it; call disabled-command-hook's value instead. */ do not execute it; call disabled-command-hook's value instead. */
...@@ -456,16 +460,15 @@ static int cannot_suspend; ...@@ -456,16 +460,15 @@ static int cannot_suspend;
echo_prompt (str) echo_prompt (str)
char *str; char *str;
{ {
PERDISPLAY *perd = get_perdisplay (selected_frame);
int len = strlen (str); int len = strlen (str);
if (len > ECHOBUFSIZE - 4) if (len > ECHOBUFSIZE - 4)
len = ECHOBUFSIZE - 4; len = ECHOBUFSIZE - 4;
bcopy (str, perd->echobuf, len); bcopy (str, current_perdisplay->echobuf, len);
perd->echoptr = perd->echobuf + len; current_perdisplay->echoptr = current_perdisplay->echobuf + len;
*perd->echoptr = '\0'; *current_perdisplay->echoptr = '\0';
perd->echo_after_prompt = len; current_perdisplay->echo_after_prompt = len;
echo (); echo ();
} }
...@@ -478,13 +481,12 @@ echo_char (c) ...@@ -478,13 +481,12 @@ echo_char (c)
Lisp_Object c; Lisp_Object c;
{ {
extern char *push_key_description (); extern char *push_key_description ();
PERDISPLAY *perd = get_perdisplay (selected_frame);
if (perd->immediate_echo) if (current_perdisplay->immediate_echo)
{ {
char *ptr = perd->echoptr; char *ptr = current_perdisplay->echoptr;
if (ptr != perd->echobuf) if (ptr != current_perdisplay->echobuf)
*ptr++ = ' '; *ptr++ = ' ';
/* If someone has passed us a composite event, use its head symbol. */ /* If someone has passed us a composite event, use its head symbol. */
...@@ -492,7 +494,7 @@ echo_char (c) ...@@ -492,7 +494,7 @@ echo_char (c)
if (INTEGERP (c)) if (INTEGERP (c))
{ {
if (ptr - perd->echobuf > ECHOBUFSIZE - 6) if (ptr - current_perdisplay->echobuf > ECHOBUFSIZE - 6)
return; return;
ptr = push_key_description (XINT (c), ptr); ptr = push_key_description (XINT (c), ptr);
...@@ -500,20 +502,22 @@ echo_char (c) ...@@ -500,20 +502,22 @@ echo_char (c)
else if (SYMBOLP (c)) else if (SYMBOLP (c))
{ {
struct Lisp_String *name = XSYMBOL (c)->name; struct Lisp_String *name = XSYMBOL (c)->name;
if (((ptr - perd->echobuf) + name->size + 4) > ECHOBUFSIZE) if (((ptr - current_perdisplay->echobuf) + name->size + 4)
> ECHOBUFSIZE)
return; return;
bcopy (name->data, ptr, name->size); bcopy (name->data, ptr, name->size);
ptr += name->size; ptr += name->size;
} }
if (perd->echoptr == perd->echobuf && EQ (c, Vhelp_char)) if (current_perdisplay->echoptr == current_perdisplay->echobuf
&& EQ (c, Vhelp_char))
{ {
strcpy (ptr, " (Type ? for further options)"); strcpy (ptr, " (Type ? for further options)");
ptr += strlen (ptr); ptr += strlen (ptr);
} }
*ptr = 0; *ptr = 0;
perd->echoptr = ptr; current_perdisplay->echoptr = ptr;
echo (); echo ();
} }
...@@ -524,20 +528,21 @@ echo_char (c) ...@@ -524,20 +528,21 @@ echo_char (c)
echo_dash () echo_dash ()
{ {
PERDISPLAY *perd = get_perdisplay (selected_frame); if (!current_perdisplay->immediate_echo
if (!perd->immediate_echo && perd->echoptr == perd->echobuf) && current_perdisplay->echoptr == current_perdisplay->echobuf)
return; return;
/* Do nothing if we just printed a prompt. */ /* Do nothing if we just printed a prompt. */
if (perd->echo_after_prompt == perd->echoptr - perd->echobuf) if (current_perdisplay->echo_after_prompt
== current_perdisplay->echoptr - current_perdisplay->echobuf)
return; return;
/* Do nothing if not echoing at all. */ /* Do nothing if not echoing at all. */
if (perd->echoptr == 0) if (current_perdisplay->echoptr == 0)
return; return;
/* Put a dash at the end of the buffer temporarily, /* Put a dash at the end of the buffer temporarily,
but make it go away when the next character is added. */ but make it go away when the next character is added. */
perd->echoptr[0] = '-'; current_perdisplay->echoptr[0] = '-';
perd->echoptr[1] = 0; current_perdisplay->echoptr[1] = 0;
echo (); echo ();
} }
...@@ -547,11 +552,10 @@ echo_dash () ...@@ -547,11 +552,10 @@ echo_dash ()
echo () echo ()
{ {
PERDISPLAY *perd = get_perdisplay (selected_frame); if (!current_perdisplay->immediate_echo)
if (!perd->immediate_echo)
{ {
int i; int i;
perd->immediate_echo = 1; current_perdisplay->immediate_echo = 1;
for (i = 0; i < this_command_key_count; i++) for (i = 0; i < this_command_key_count; i++)
{ {
...@@ -565,7 +569,7 @@ echo () ...@@ -565,7 +569,7 @@ echo ()
} }
echoing = 1; echoing = 1;
message2_nolog (perd->echobuf, strlen (perd->echobuf)); message1_nolog (current_perdisplay->echobuf);
echoing = 0; echoing = 0;
if (waiting_for_input && !NILP (Vquit_flag)) if (waiting_for_input && !NILP (Vquit_flag))
...@@ -576,10 +580,9 @@ echo () ...@@ -576,10 +580,9 @@ echo ()
cancel_echoing () cancel_echoing ()
{ {
PERDISPLAY *perd = get_perdisplay (selected_frame); current_perdisplay->immediate_echo = 0;
perd->immediate_echo = 0; current_perdisplay->echoptr = current_perdisplay->echobuf;
perd->echoptr = perd->echobuf; current_perdisplay->echo_after_prompt = -1;
perd->echo_after_prompt = -1;
} }
/* Return the length of the current echo string. */ /* Return the length of the current echo string. */
...@@ -587,8 +590,7 @@ cancel_echoing () ...@@ -587,8 +590,7 @@ cancel_echoing ()
static int static int
echo_length () echo_length ()
{ {
PERDISPLAY *perd = get_perdisplay (selected_frame); return current_perdisplay->echoptr - current_perdisplay->echobuf;
return perd->echoptr - perd->echobuf;
} }
/* Truncate the current echo message to its first LEN chars. /* Truncate the current echo message to its first LEN chars.
...@@ -599,9 +601,8 @@ static void ...@@ -599,9 +601,8 @@ static void
echo_truncate (len) echo_truncate (len)
int len; int len;
{ {
PERDISPLAY *perd = get_perdisplay (selected_frame); current_perdisplay->echobuf[len] = '\0';
perd->echobuf[len] = '\0'; current_perdisplay->echoptr = current_perdisplay->echobuf + len;
perd->echoptr = perd->echobuf + len;
truncate_echo_area (len); truncate_echo_area (len);
} }
...@@ -1449,7 +1450,6 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu) ...@@ -1449,7 +1450,6 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu)
int count; int count;
jmp_buf save_jump; jmp_buf save_jump;
int key_already_recorded = 0; int key_already_recorded = 0;
PERDISPLAY *perd = get_perdisplay (selected_frame);
Lisp_Object also_record; Lisp_Object also_record;
also_record = Qnil; also_record = Qnil;
...@@ -1551,7 +1551,8 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu) ...@@ -1551,7 +1551,8 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu)
} }
/* Message turns off echoing unless more keystrokes turn it on again. */ /* Message turns off echoing unless more keystrokes turn it on again. */
if (echo_area_glyphs && *echo_area_glyphs && echo_area_glyphs != perd->echobuf) if (echo_area_glyphs && *echo_area_glyphs
&& echo_area_glyphs != current_perdisplay->echobuf)
cancel_echoing (); cancel_echoing ();
else else
/* If already echoing, continue. */ /* If already echoing, continue. */
...@@ -1580,7 +1581,8 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu) ...@@ -1580,7 +1581,8 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu)
/* If in middle of key sequence and minibuffer not active, /* If in middle of key sequence and minibuffer not active,
start echoing if enough time elapses. */ start echoing if enough time elapses. */
if (minibuf_level == 0 && !perd->immediate_echo && this_command_key_count > 0 if (minibuf_level == 0 && !current_perdisplay->immediate_echo
&& this_command_key_count > 0
&& ! noninteractive && ! noninteractive
&& echo_keystrokes > 0 && echo_keystrokes > 0
&& (echo_area_glyphs == 0 || *echo_area_glyphs == 0)) && (echo_area_glyphs == 0 || *echo_area_glyphs == 0))
...@@ -1953,8 +1955,8 @@ static PERDISPLAY * ...@@ -1953,8 +1955,8 @@ static PERDISPLAY *
find_active_event_queue () find_active_event_queue ()
{ {
PERDISPLAY *perd; PERDISPLAY *perd;
perd = &the_only_perdisplay;
/* FOR_ALL_PERDISPLAYS (perd) */ for (perd = all_perdisplays; perd; perd = perd->next_perdisplay)
{ {
if (perd->kbd_fetch_ptr != perd->kbd_store_ptr) if (perd->kbd_fetch_ptr != perd->kbd_store_ptr)
return perd; return perd;
...@@ -5651,7 +5653,6 @@ DEFUN ("discard-input", Fdiscard_input, Sdiscard_input, 0, 0, 0, ...@@ -5651,7 +5653,6 @@ DEFUN ("discard-input", Fdiscard_input, Sdiscard_input, 0, 0, 0,
Also cancel any kbd macro being defined.") Also cancel any kbd macro being defined.")
() ()
{ {
PERDISPLAY *perd = &the_only_perdisplay;
defining_kbd_macro = 0; defining_kbd_macro = 0;
update_mode_lines++; update_mode_lines++;
...@@ -5663,8 +5664,9 @@ Also cancel any kbd macro being defined.") ...@@ -5663,8 +5664,9 @@ Also cancel any kbd macro being defined.")
/* Without the cast, GCC complains that this assignment loses the /* Without the cast, GCC complains that this assignment loses the
volatile qualifier of kbd_store_ptr. Is there anything wrong volatile qualifier of kbd_store_ptr. Is there anything wrong
with that? */ with that? */
perd->kbd_fetch_ptr = (struct input_event *) perd->kbd_store_ptr; current_perdisplay->kbd_fetch_ptr
Ffillarray (perd->kbd_buffer_frame_or_window, Qnil); = (struct input_event *) current_perdisplay->kbd_store_ptr;
Ffillarray (current_perdisplay->kbd_buffer_frame_or_window, Qnil);
input_pending = 0; input_pending = 0;
return Qnil; return Qnil;
...@@ -5737,7 +5739,7 @@ stuff_buffered_input (stuffstring) ...@@ -5737,7 +5739,7 @@ stuff_buffered_input (stuffstring)
#ifdef BSD #ifdef BSD
#ifndef BSD4_1 #ifndef BSD4_1
register unsigned char *p; register unsigned char *p;
PERDISPLAY *perd = &the_only_perdisplay; /* We really want the primary display's perd */ PERDISPLAY *perd;
if (STRINGP (stuffstring)) if (STRINGP (stuffstring))
{ {
...@@ -5750,6 +5752,14 @@ stuff_buffered_input (stuffstring) ...@@ -5750,6 +5752,14 @@ stuff_buffered_input (stuffstring)
stuff_char ('\n'); stuff_char ('\n');
} }
/* Anything we have read ahead, put back for the shell to read. */ /* Anything we have read ahead, put back for the shell to read. */
#ifndef MULTI_PERDISPLAY
perd = &the_only_perdisplay;
#else
/* ?? What should this do when we have multiple keyboards?? */
perd = current_perdisplay;
if (!perd)
return;
#endif
while (perd->kbd_fetch_ptr != perd->kbd_store_ptr) while (perd->kbd_fetch_ptr != perd->kbd_store_ptr)
{ {
if (perd->kbd_fetch_ptr == perd->kbd_buffer + KBD_BUFFER_SIZE) 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,6 +6030,36 @@ The elements of this list correspond to the arguments of\n\
} }
/*
* Set up a perdisplay object with reasonable initial values.
*/
void
init_perdisplay (perd)
PERDISPLAY *perd;
{
perd->Vprefix_arg = Qnil;
perd->Vcurrent_prefix_arg = Qnil;
perd->kbd_buffer
= (struct input_event *)xmalloc (KBD_BUFFER_SIZE
* sizeof (struct input_event));
perd->kbd_fetch_ptr = perd->kbd_buffer;
perd->kbd_store_ptr = perd->kbd_buffer;
perd->kbd_buffer_frame_or_window
= Fmake_vector (make_number (KBD_BUFFER_SIZE), Qnil);
}
/*
* Destroy the contents of a perdisplay object, but not the object itself.
* We use this just before deleteing it, or if we're going to initialize
* it a second time.
*/
void
wipe_perdisplay (perd)
PERDISPLAY *perd;
{
xfree (perd->kbd_buffer);
}
init_keyboard () init_keyboard ()
{ {
/* This is correct before outermost invocation of the editor loop */ /* This is correct before outermost invocation of the editor loop */
...@@ -6030,11 +6070,6 @@ init_keyboard () ...@@ -6030,11 +6070,6 @@ init_keyboard ()
unread_command_char = -1; unread_command_char = -1;
total_keys = 0; total_keys = 0;
recent_keys_index = 0; recent_keys_index = 0;
the_only_perdisplay.kbd_buffer
= (struct input_event *)xmalloc (KBD_BUFFER_SIZE
* sizeof (struct input_event));
the_only_perdisplay.kbd_fetch_ptr = the_only_perdisplay.kbd_buffer;
the_only_perdisplay.kbd_store_ptr = the_only_perdisplay.kbd_buffer;
#ifdef HAVE_MOUSE #ifdef HAVE_MOUSE
do_mouse_tracking = Qnil; do_mouse_tracking = Qnil;
#endif #endif
...@@ -6047,21 +6082,11 @@ init_keyboard () ...@@ -6047,21 +6082,11 @@ init_keyboard ()
Vlast_event_frame = internal_last_event_frame; Vlast_event_frame = internal_last_event_frame;
#endif #endif
/* If we're running a dumped Emacs, we need to clear out #ifndef MULTI_PERDISPLAY
kbd_buffer_frame_or_window, in case some events got into it
before we dumped.
If we're running an undumped Emacs, it hasn't been initialized by
syms_of_keyboard yet. */
if (initialized) if (initialized)
{ wipe_perdisplay (&the_only_perdisplay);
PERDISPLAY *perd; init_perdisplay (&the_only_perdisplay);
perd = &the_only_perdisplay; #endif
/* FOR_ALL_PERDISPLAYS (perd) */
{
Ffillarray (perd->kbd_buffer_frame_or_window, Qnil);
}
}
if (!noninteractive && !read_socket_hook && NILP (Vwindow_system)) if (!noninteractive && !read_socket_hook && NILP (Vwindow_system))
{ {
...@@ -6232,10 +6257,6 @@ syms_of_keyboard () ...@@ -6232,10 +6257,6 @@ syms_of_keyboard ()
Fset (Qextended_command_history, Qnil); Fset (Qextended_command_history, Qnil);
staticpro (&Qextended_command_history); staticpro (&Qextended_command_history);
the_only_perdisplay.kbd_buffer_frame_or_window
= Fmake_vector (make_number (KBD_BUFFER_SIZE), Qnil);
staticpro (&the_only_perdisplay.kbd_buffer_frame_or_window);
accent_key_syms = Qnil; accent_key_syms = Qnil;
staticpro (&accent_key_syms); staticpro (&accent_key_syms);
...@@ -6503,6 +6524,24 @@ The precise format isn't relevant here; we just check whether it is nil."); ...@@ -6503,6 +6524,24 @@ The precise format isn't relevant here; we just check whether it is nil.");
This function is called with no arguments after each command\n\ This function is called with no arguments after each command\n\
whenever `deferred-action-list' is non-nil."); whenever `deferred-action-list' is non-nil.");
Vdeferred_action_function = Qnil; Vdeferred_action_function = Qnil;
DEFVAR_DISPLAY ("prefix-arg", Vprefix_arg,
"The value of the prefix argument for the next editing command.\n\
It may be a number, or the symbol `-' for just a minus sign as arg,\n\
or a list whose car is a number for just one or more C-U's\n\
or nil if no argument has been specified.\n\
\n\
You cannot examine this variable to find the argument for this command\n\
since it has been set to nil by the time you can look.\n\
Instead, you should use the variable `current-prefix-arg', although\n\
normally commands can get this prefix argument with (interactive \"P\").");
DEFVAR_DISPLAY ("current-prefix-arg", Vcurrent_prefix_arg,
"The value of the prefix argument for this editing command.\n\
It may be a number, or the symbol `-' for just a minus sign as arg,\n\
or a list whose car is a number for just one or more C-U's\n\
or nil if no argument has been specified.\n\
This is what `(interactive \"P\")' returns.");
} }
keys_of_keyboard () keys_of_keyboard ()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment