char evalargs;
};
-PERD the_only_perd;
+PERDISPLAY the_only_perdisplay;
/* Non-nil disable property on a command means
do not execute it; call disabled-command-hook's value instead. */
extern char *pending_malloc_warning;
-/* Vector to GCPRO the frames and windows mentioned in kbd_buffer.
-
- The interrupt-level event handlers will never enqueue an event on a
- frame which is not in Vframe_list, and once an event is dequeued,
- internal_last_event_frame or the event itself points to the frame.
- So that's all fine.
-
- But while the event is sitting in the queue, it's completely
- unprotected. Suppose the user types one command which will run for
- a while and then delete a frame, and then types another event at
- the frame that will be deleted, before the command gets around to
- it. Suppose there are no references to this frame elsewhere in
- Emacs, and a GC occurs before the second event is dequeued. Now we
- have an event referring to a freed frame, which will crash Emacs
- when it is dequeued.
-
- Similar things happen when an event on a scroll bar is enqueued; the
- window may be deleted while the event is in the queue.
-
- So, we use this vector to protect the frame_or_window field in the
- event queue. That way, they'll be dequeued as dead frames or
- windows, but still valid lisp objects.
-
- If perd->kbd_buffer[i].kind != no_event, then
- (XVECTOR (kbd_buffer_frame_or_window)->contents[i]
- == perd->kbd_buffer[i].frame_or_window. */
-static Lisp_Object kbd_buffer_frame_or_window;
-
#ifdef HAVE_MOUSE
/* If this flag is a frame, we check mouse_moved to see when the
mouse moves, and motion events will appear in the input stream.
/* > 0 if we are to echo keystrokes. */
static int echo_keystrokes;
-/* Nonzero means echo each character as typed. */
-static int immediate_echo;
-
-/* The text we're echoing in the modeline - partial key sequences,
- usually. '\0'-terminated. This really shouldn't have a fixed size. */
-static char echobuf[300];
-
-/* Where to append more text to echobuf if we want to. */
-static char *echoptr;
-
-/* If we have echoed a prompt string specified by the user,
- this is its length. Otherwise this is -1. */
-static int echo_after_prompt;
-
/* Nonzero means don't try to suspend even if the operating system seems
to support it. */
static int cannot_suspend;
echo_prompt (str)
char *str;
{
+ PERDISPLAY *perd = get_perdisplay (selected_frame);
int len = strlen (str);
- if (len > sizeof echobuf - 4)
- len = sizeof echobuf - 4;
- bcopy (str, echobuf, len);
- echoptr = echobuf + len;
- *echoptr = '\0';
+ if (len > ECHOBUFSIZE - 4)
+ len = ECHOBUFSIZE - 4;
+ bcopy (str, perd->echobuf, len);
+ perd->echoptr = perd->echobuf + len;
+ *perd->echoptr = '\0';
- echo_after_prompt = len;
+ perd->echo_after_prompt = len;
echo ();
}
Lisp_Object c;
{
extern char *push_key_description ();
+ PERDISPLAY *perd = get_perdisplay (selected_frame);
- if (immediate_echo)
+ if (perd->immediate_echo)
{
- char *ptr = echoptr;
+ char *ptr = perd->echoptr;
- if (ptr != echobuf)
+ if (ptr != perd->echobuf)
*ptr++ = ' ';
/* If someone has passed us a composite event, use its head symbol. */
if (INTEGERP (c))
{
- if (ptr - echobuf > sizeof echobuf - 6)
+ if (ptr - perd->echobuf > ECHOBUFSIZE - 6)
return;
ptr = push_key_description (XINT (c), ptr);
else if (SYMBOLP (c))
{
struct Lisp_String *name = XSYMBOL (c)->name;
- if (((ptr - echobuf) + name->size + 4) > sizeof echobuf)
+ if (((ptr - perd->echobuf) + name->size + 4) > ECHOBUFSIZE)
return;
bcopy (name->data, ptr, name->size);
ptr += name->size;
}
- if (echoptr == echobuf && EQ (c, Vhelp_char))
+ if (perd->echoptr == perd->echobuf && EQ (c, Vhelp_char))
{
strcpy (ptr, " (Type ? for further options)");
ptr += strlen (ptr);
}
*ptr = 0;
- echoptr = ptr;
+ perd->echoptr = ptr;
echo ();
}
echo_dash ()
{
- if (!immediate_echo && echoptr == echobuf)
+ PERDISPLAY *perd = get_perdisplay (selected_frame);
+ if (!perd->immediate_echo && perd->echoptr == perd->echobuf)
return;
/* Do nothing if we just printed a prompt. */
- if (echo_after_prompt == echoptr - echobuf)
+ if (perd->echo_after_prompt == perd->echoptr - perd->echobuf)
return;
/* Do nothing if not echoing at all. */
- if (echoptr == 0)
+ if (perd->echoptr == 0)
return;
/* Put a dash at the end of the buffer temporarily,
but make it go away when the next character is added. */
- echoptr[0] = '-';
- echoptr[1] = 0;
+ perd->echoptr[0] = '-';
+ perd->echoptr[1] = 0;
echo ();
}
echo ()
{
- if (!immediate_echo)
+ PERDISPLAY *perd = get_perdisplay (selected_frame);
+ if (!perd->immediate_echo)
{
int i;
- immediate_echo = 1;
+ perd->immediate_echo = 1;
for (i = 0; i < this_command_key_count; i++)
{
}
echoing = 1;
- message2_nolog (echobuf, strlen (echobuf));
+ message2_nolog (perd->echobuf, strlen (perd->echobuf));
echoing = 0;
if (waiting_for_input && !NILP (Vquit_flag))
cancel_echoing ()
{
- immediate_echo = 0;
- echoptr = echobuf;
- echo_after_prompt = -1;
+ PERDISPLAY *perd = get_perdisplay (selected_frame);
+ perd->immediate_echo = 0;
+ perd->echoptr = perd->echobuf;
+ perd->echo_after_prompt = -1;
}
/* Return the length of the current echo string. */
static int
echo_length ()
{
- return echoptr - echobuf;
+ PERDISPLAY *perd = get_perdisplay (selected_frame);
+ return perd->echoptr - perd->echobuf;
}
/* Truncate the current echo message to its first LEN chars.
echo_truncate (len)
int len;
{
- echobuf[len] = '\0';
- echoptr = echobuf + len;
+ PERDISPLAY *perd = get_perdisplay (selected_frame);
+ perd->echobuf[len] = '\0';
+ perd->echoptr = perd->echobuf + len;
truncate_echo_area (len);
}
int count;
jmp_buf save_jump;
int key_already_recorded = 0;
+ PERDISPLAY *perd = get_perdisplay (selected_frame);
Lisp_Object also_record;
also_record = Qnil;
}
/* Message turns off echoing unless more keystrokes turn it on again. */
- if (echo_area_glyphs && *echo_area_glyphs && echo_area_glyphs != echobuf)
+ if (echo_area_glyphs && *echo_area_glyphs && echo_area_glyphs != perd->echobuf)
cancel_echoing ();
else
/* If already echoing, continue. */
/* If in middle of key sequence and minibuffer not active,
start echoing if enough time elapses. */
- if (minibuf_level == 0 && !immediate_echo && this_command_key_count > 0
+ if (minibuf_level == 0 && !perd->immediate_echo && this_command_key_count > 0
&& ! noninteractive
&& echo_keystrokes > 0
&& (echo_area_glyphs == 0 || *echo_area_glyphs == 0))
mouse_moved indicates when the mouse has moved again, and
*mouse_position_hook provides the mouse position. */
-static PERD *
+static PERDISPLAY *
find_active_event_queue ()
{
- PERD *perd;
- perd = &the_only_perd;
- /* FOR_ALL_PERDS (perd) */
+ PERDISPLAY *perd;
+ perd = &the_only_perdisplay;
+ /* FOR_ALL_PERDISPLAYS (perd) */
{
if (perd->kbd_fetch_ptr != perd->kbd_store_ptr)
return perd;
kbd_buffer_store_event (event)
register struct input_event *event;
{
- PERD *perd = get_perd (XFRAME (event->frame_or_window));
+ PERDISPLAY *perd = get_perdisplay (XFRAME (event->frame_or_window));
if (event->kind == no_event)
abort ();
sp->y = event->y;
sp->timestamp = event->timestamp;
}
- (XVECTOR (kbd_buffer_frame_or_window)->contents[perd->kbd_store_ptr
- - perd->kbd_buffer]
+ (XVECTOR (perd->kbd_buffer_frame_or_window)->contents[perd->kbd_store_ptr
+ - perd->kbd_buffer]
= event->frame_or_window);
perd->kbd_store_ptr++;
static Lisp_Object
kbd_buffer_get_event ()
{
- PERD *perd;
+ PERDISPLAY *perd;
register int c;
Lisp_Object obj;
/* Wipe out this event, to catch bugs. */
event->kind = no_event;
- (XVECTOR (kbd_buffer_frame_or_window)->contents[event - perd->kbd_buffer]
- = Qnil);
+ XVECTOR (perd->kbd_buffer_frame_or_window)->contents[event - perd->kbd_buffer] = Qnil;
perd->kbd_fetch_ptr = event + 1;
}
void
swallow_events ()
{
- PERD *perd;
+ PERDISPLAY *perd;
while ((perd = find_active_event_queue ()) != NULL)
{
struct input_event *event;
Also cancel any kbd macro being defined.")
()
{
- PERD *perd = &the_only_perd;
+ PERDISPLAY *perd = &the_only_perdisplay;
defining_kbd_macro = 0;
update_mode_lines++;
volatile qualifier of kbd_store_ptr. Is there anything wrong
with that? */
perd->kbd_fetch_ptr = (struct input_event *) perd->kbd_store_ptr;
- Ffillarray (kbd_buffer_frame_or_window, Qnil);
+ Ffillarray (perd->kbd_buffer_frame_or_window, Qnil);
input_pending = 0;
return Qnil;
#ifdef BSD
#ifndef BSD4_1
register unsigned char *p;
- PERD *perd = &the_only_perd; /* We really want the primary display's perd */
+ PERDISPLAY *perd = &the_only_perdisplay; /* We really want the primary display's perd */
if (STRINGP (stuffstring))
{
if (perd->kbd_fetch_ptr->kind == ascii_keystroke)
stuff_char (perd->kbd_fetch_ptr->code);
perd->kbd_fetch_ptr->kind = no_event;
- (XVECTOR (kbd_buffer_frame_or_window)->contents[perd->kbd_fetch_ptr
- - perd->kbd_buffer]
+ (XVECTOR (perd->kbd_buffer_frame_or_window)->contents[perd->kbd_fetch_ptr
+ - perd->kbd_buffer]
= Qnil);
perd->kbd_fetch_ptr++;
}
unread_command_char = -1;
total_keys = 0;
recent_keys_index = 0;
- the_only_perd.kbd_buffer
+ the_only_perdisplay.kbd_buffer
= (struct input_event *)xmalloc (KBD_BUFFER_SIZE
* sizeof (struct input_event));
- the_only_perd.kbd_fetch_ptr = the_only_perd.kbd_buffer;
- the_only_perd.kbd_store_ptr = the_only_perd.kbd_buffer;
+ 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
do_mouse_tracking = Qnil;
#endif
If we're running an undumped Emacs, it hasn't been initialized by
syms_of_keyboard yet. */
if (initialized)
- Ffillarray (kbd_buffer_frame_or_window, Qnil);
+ {
+ PERDISPLAY *perd;
+ perd = &the_only_perdisplay;
+ /* FOR_ALL_PERDISPLAYS (perd) */
+ {
+ Ffillarray (perd->kbd_buffer_frame_or_window, Qnil);
+ }
+ }
if (!noninteractive && !read_socket_hook && NILP (Vwindow_system))
{
Fset (Qextended_command_history, Qnil);
staticpro (&Qextended_command_history);
- kbd_buffer_frame_or_window
+ the_only_perdisplay.kbd_buffer_frame_or_window
= Fmake_vector (make_number (KBD_BUFFER_SIZE), Qnil);
- staticpro (&kbd_buffer_frame_or_window);
+ staticpro (&the_only_perdisplay.kbd_buffer_frame_or_window);
accent_key_syms = Qnil;
staticpro (&accent_key_syms);