#include "dispextern.h"
#include "syntax.h"
#include "intervals.h"
+#include "keymap.h"
#include "blockinput.h"
#include "puresize.h"
#include "systime.h"
exists, and echo_message_buffer is eq to the current message
buffer, we know that the message comes from echo_kboard. */
-static struct kboard *echo_kboard;
+struct kboard *echo_kboard;
/* The buffer used for echoing. Set in echo_now, reset in
cancel_echoing. */
static void restore_getcjmp P_ ((jmp_buf));
static Lisp_Object apply_modifiers P_ ((int, Lisp_Object));
static void clear_event P_ ((struct input_event *));
+static void any_kboard_state P_ ((void));
/* Nonzero means don't try to suspend even if the operating system seems
to support it. */
static int cannot_suspend;
-#define min(a,b) ((a)<(b)?(a):(b))
-#define max(a,b) ((a)>(b)?(a):(b))
-
/* Install the string STR as the beginning of the string of echoing,
so that it serves as a prompt for the next character.
Also start echoing. */
()
{
int count = specpdl_ptr - specpdl;
+ Lisp_Object buffer;
command_loop_level++;
update_mode_lines = 1;
+ if (command_loop_level
+ && current_buffer != XBUFFER (XWINDOW (selected_window)->buffer))
+ buffer = Fcurrent_buffer ();
+ else
+ buffer = Qnil;
+
+ /* If we leave recursive_edit_1 below with a `throw' for instance,
+ like it is done in the splash screen display, we have to
+ make sure that we restore single_kboard as command_loop_1
+ would have done if it were left normally. */
record_unwind_protect (recursive_edit_unwind,
- (command_loop_level
- && current_buffer != XBUFFER (XWINDOW (selected_window)->buffer))
- ? Fcurrent_buffer ()
- : Qnil);
+ Fcons (buffer, single_kboard ? Qt : Qnil));
+
recursive_edit_1 ();
return unbind_to (count, Qnil);
}
Lisp_Object
-recursive_edit_unwind (buffer)
- Lisp_Object buffer;
+recursive_edit_unwind (info)
+ Lisp_Object info;
{
- if (!NILP (buffer))
- Fset_buffer (buffer);
-
+ if (BUFFERP (XCAR (info)))
+ Fset_buffer (XCAR (info));
+
+ if (NILP (XCDR (info)))
+ any_kboard_state ();
+ else
+ single_kboard_state ();
+
command_loop_level--;
update_mode_lines = 1;
return Qnil;
}
+
\f
static void
any_kboard_state ()
/* This is the actual command reading loop,
sans error-handling encapsulation. */
-EXFUN (Fcommand_execute, 4);
static int read_key_sequence P_ ((Lisp_Object *, int, Lisp_Object,
int, int, int));
void safe_run_hooks P_ ((Lisp_Object));
KBOARD *kb = FRAME_KBOARD (XFRAME (selected_frame));
if (kb != current_kboard)
{
- Lisp_Object *tailp = &kb->kbd_queue;
+ Lisp_Object link = kb->kbd_queue;
/* We shouldn't get here if we were in single-kboard mode! */
if (single_kboard)
abort ();
- while (CONSP (*tailp))
- tailp = &XCDR (*tailp);
- if (!NILP (*tailp))
- abort ();
- *tailp = Fcons (c, Qnil);
+ if (CONSP (link))
+ {
+ while (CONSP (XCDR (link)))
+ link = XCDR (link);
+ if (!NILP (XCDR (link)))
+ abort ();
+ }
+ if (!CONSP (link))
+ kb->kbd_queue = Fcons (c, Qnil);
+ else
+ XSETCDR (link, Fcons (c, Qnil));
kb->kbd_queue_has_data = 1;
current_kboard = kb;
/* This is going to exit from read_char
#ifdef MULTI_KBOARD
if (! NILP (c) && (kb != current_kboard))
{
- Lisp_Object *tailp = &kb->kbd_queue;
- while (CONSP (*tailp))
- tailp = &XCDR (*tailp);
- if (!NILP (*tailp))
- abort ();
- *tailp = Fcons (c, Qnil);
+ Lisp_Object link = kb->kbd_queue;
+ if (CONSP (link))
+ {
+ while (CONSP (XCDR (link)))
+ link = XCDR (link);
+ if (!NILP (XCDR (link)))
+ abort ();
+ }
+ if (!CONSP (link))
+ kb->kbd_queue = Fcons (c, Qnil);
+ else
+ XSETCDR (link, Fcons (c, Qnil));
kb->kbd_queue_has_data = 1;
c = Qnil;
if (single_kboard)
if (EQ (posn, Qmenu_bar) || EQ (posn, Qtool_bar))
{
/* Change menu-bar to (menu-bar) as the event "position". */
- POSN_BUFFER_POSN (EVENT_START (c)) = Fcons (posn, Qnil);
+ POSN_BUFFER_SET_POSN (EVENT_START (c), Fcons (posn, Qnil));
also_record = c;
Vunread_command_events = Fcons (c, Vunread_command_events);
/* Now wipe the echo area, except for help events which do their
own stuff with the echo area. */
- if (!CONSP (c) || !(EQ (Qhelp_echo, XCAR (c))))
+ if (!CONSP (c)
+ || (!(EQ (Qhelp_echo, XCAR (c)))
+ && !(EQ (Qswitch_frame, XCAR (c)))))
{
if (!NILP (echo_area_buffer[0]))
safe_run_hooks (Qecho_area_clear_hook);
/ sizeof (iso_lispy_function_keys[0])));
else
#endif
- return modify_event_symbol (event->code - FUNCTION_KEY_OFFSET,
- event->modifiers,
- Qfunction_key, Qnil,
- lispy_function_keys, &func_key_syms,
- (sizeof (lispy_function_keys)
- / sizeof (lispy_function_keys[0])));
+
+#ifdef HAVE_X_WINDOWS
+ if (event->code - FUNCTION_KEY_OFFSET < 0
+ || (event->code - FUNCTION_KEY_OFFSET
+ >= sizeof lispy_function_keys / sizeof *lispy_function_keys))
+ {
+ /* EVENT->code is an unknown keysym, for example someone
+ assigned `ccaron' to a key in a locale where
+ XmbLookupString doesn't return a translation for it. */
+ char *name;
+ Lisp_Object symbol;
+
+ BLOCK_INPUT;
+ /* This returns a pointer to a static area. Don't free it. */
+ name = XKeysymToString (event->code);
+ symbol = name ? intern (name) : Qnil;
+ UNBLOCK_INPUT;
+
+ if (!NILP (symbol))
+ return apply_modifiers (event->modifiers, symbol);
+ }
+#endif /* HAVE_X_WINDOWS */
+
+ return modify_event_symbol (event->code - FUNCTION_KEY_OFFSET,
+ event->modifiers,
+ Qfunction_key, Qnil,
+ lispy_function_keys, &func_key_syms,
+ (sizeof (lispy_function_keys)
+ / sizeof (lispy_function_keys[0])));
#ifdef HAVE_MOUSE
/* A mouse click. Figure out where it is, decide whether it's
STRING_BYTES (XSYMBOL (symbol)->name) - end),
Qnil);
- if (modifiers & ~(((EMACS_INT)1 << VALBITS) - 1))
+ if (modifiers & ~VALMASK)
abort ();
XSETFASTINT (mask, modifiers);
elements = Fcons (unmodified, Fcons (mask, Qnil));
Lisp_Object cache, index, entry, new_symbol;
/* Mask out upper bits. We don't know where this value's been. */
- modifiers &= ((EMACS_INT)1 << VALBITS) - 1;
+ modifiers &= VALMASK;
/* The click modifier never figures into cache indices. */
cache = Fget (base, Qmodifier_cache);
\f
-/* Return the prompt-string of a sparse keymap.
- This is the first element which is a string.
- Return nil if there is none. */
-
-Lisp_Object
-map_prompt (map)
- Lisp_Object map;
-{
- while (CONSP (map))
- {
- register Lisp_Object tem;
- tem = Fcar (map);
- if (STRINGP (tem))
- return tem;
- map = Fcdr (map);
- }
- return Qnil;
-}
-
static void menu_bar_item P_ ((Lisp_Object, Lisp_Object));
static void menu_bar_one_keymap P_ ((Lisp_Object));
{
/* We have to create a cachelist. */
CHECK_IMPURE (start);
- XCDR (start) = Fcons (Fcons (Qnil, Qnil), XCDR (start));
+ XSETCDR (start, Fcons (Fcons (Qnil, Qnil), XCDR (start)));
cachelist = XCAR (XCDR (start));
newcache = 1;
tem = AREF (item_properties, ITEM_PROPERTY_KEYEQ);
if (!NILP (keyhint))
{
- XCAR (cachelist) = XCAR (keyhint);
+ XSETCAR (cachelist, XCAR (keyhint));
newcache = 0;
}
else if (STRINGP (tem))
{
- XCDR (cachelist) = Fsubstitute_command_keys (tem);
- XCAR (cachelist) = Qt;
+ XSETCDR (cachelist, Fsubstitute_command_keys (tem));
+ XSETCAR (cachelist, Qt);
}
}
&& ! NILP (Fget (def, Qmenu_alias)))
def = XSYMBOL (def)->function;
tem = Fwhere_is_internal (def, Qnil, Qt, Qnil);
- XCAR (cachelist) = tem;
+ XSETCAR (cachelist, tem);
if (NILP (tem))
{
- XCDR (cachelist) = Qnil;
+ XSETCDR (cachelist, Qnil);
chkcache = 0;
}
}
if (STRINGP (XCDR (prefix)))
tem = concat2 (tem, XCDR (prefix));
}
- XCDR (cachelist) = tem;
+ XSETCDR (cachelist, tem);
}
}
if (newcache && !NILP (tem))
{
tem = concat3 (build_string (" ("), tem, build_string (")"));
- XCDR (cachelist) = tem;
+ XSETCDR (cachelist, tem);
}
/* If we only want to precompute equivalent key bindings, stop here. */
/* Get the menu name from the first map that has one (a prompt string). */
for (mapno = 0; mapno < nmaps; mapno++)
{
- name = map_prompt (maps[mapno]);
+ name = Fkeymap_prompt (maps[mapno]);
if (!NILP (name))
break;
}
record_menu_key (XCAR (tem));
if (SYMBOLP (XCAR (tem))
|| INTEGERP (XCAR (tem)))
- XCAR (tem) = Fcons (XCAR (tem), Qdisabled);
+ XSETCAR (tem, Fcons (XCAR (tem), Qdisabled));
}
/* If we got more than one event, put all but the first
/* Get the menu name from the first map that has one (a prompt string). */
for (mapno = 0; mapno < nmaps; mapno++)
{
- name = map_prompt (maps[mapno]);
+ name = Fkeymap_prompt (maps[mapno]);
if (!NILP (name))
break;
}
/* Zap the position in key, so we know that we've
expanded it, and don't try to do so again. */
- POSN_BUFFER_POSN (EVENT_START (key))
- = Fcons (posn, Qnil);
+ POSN_BUFFER_SET_POSN (EVENT_START (key),
+ Fcons (posn, Qnil));
mock_input = t + 2;
goto replay_sequence;
{
tem = Fnthcdr (Vhistory_length, Vcommand_history);
if (CONSP (tem))
- XCDR (tem) = Qnil;
+ XSETCDR (tem, Qnil);
}
}
"Normal hook run when clearing the echo area.");
#endif
Qecho_area_clear_hook = intern ("echo-area-clear-hook");
- XSYMBOL (Qecho_area_clear_hook)->value = Qnil;
+ SET_SYMBOL_VALUE (Qecho_area_clear_hook, Qnil);
DEFVAR_LISP ("lucid-menu-bar-dirty-flag", &Vlucid_menu_bar_dirty_flag,
"t means menu bar, specified Lucid style, needs to be recomputed.");