#include "dispextern.h"
#include "keyboard.h"
#include "intervals.h"
+#include "blockinput.h"
#include <setjmp.h>
#include <errno.h>
extern int errno;
+/* Variables for blockinput.h: */
+
+/* Non-zero if interrupt input is blocked right now. */
+int interrupt_input_blocked;
+
+/* Nonzero means an input interrupt has arrived
+ during the current critical section. */
+int interrupt_input_pending;
+
+
#ifdef HAVE_X_WINDOWS
extern Lisp_Object Vmouse_grabbed;
/* Non-nil means deactivate the mark at end of this command. */
Lisp_Object Vdeactivate_mark;
+/* Menu bar specified in Lucid Emacs fashion. */
+
+Lisp_Object Vlucid_menu_bar_dirty_flag;
+Lisp_Object Qrecompute_lucid_menubar, Qactivate_menubar_hook;
+
/* Hooks to run before and after each command. */
Lisp_Object Qpre_command_hook, Qpost_command_hook;
Lisp_Object Vpre_command_hook, Vpost_command_hook;
/* Nonzero if input is available. */
int input_pending;
-/* Nonzero if should obey 0200 bit in input chars as "Meta". */
+/* 1 if should obey 0200 bit in input chars as "Meta", 2 if should
+ keep 0200 bit in input chars. 0 to ignore the 0200 bit. */
+
int meta_key;
extern char *pending_malloc_warning;
dequeuing functions? Such a flag could be screwed up by interrupts
at inopportune times. */
-/* If this flag is non-zero, we will check mouse_moved to see when the
+/* If this flag is non-zero, we check mouse_moved to see when the
mouse moves, and motion events will appear in the input stream. If
- it is zero, mouse motion will be ignored. */
-int do_mouse_tracking;
+ it is zero, mouse motion is ignored. */
+static int do_mouse_tracking;
/* The window system handling code should set this if the mouse has
moved since the last call to the mouse_position_hook. Calling that
/* Symbols to head events. */
Lisp_Object Qmouse_movement;
Lisp_Object Qscroll_bar_movement;
-
Lisp_Object Qswitch_frame;
/* Symbols to denote kinds of events. */
Lisp_Object Qevent_kind;
Lisp_Object Qevent_symbol_elements;
+Lisp_Object Qmenu_enable;
+
/* An event header symbol HEAD may have a property named
Qevent_symbol_element_mask, which is of the form (BASE MODIFIERS);
BASE is the base, unmodified version of HEAD, and MODIFIERS is the
apply_modifiers. */
Lisp_Object Qmodifier_cache;
-/* Symbols to use for non-text mouse positions. */
+/* Symbols to use for parts of windows. */
Lisp_Object Qmode_line;
Lisp_Object Qvertical_line;
Lisp_Object Qvertical_scroll_bar;
+Lisp_Object Qmenu_bar;
+
+extern Lisp_Object Qmenu_enable;
Lisp_Object recursive_edit_unwind (), command_loop ();
Lisp_Object Fthis_command_keys ();
{
if (!immediate_echo && echoptr == echobuf)
return;
+ /* Do nothing if not echoing at all. */
+ if (echoptr == 0)
+ return;
/* Put a dash at the end of the buffer temporarily,
but make it go away when the next character is added. */
Lisp_Object
command_loop_1 ()
{
- Lisp_Object cmd;
+ Lisp_Object cmd, tem;
int lose;
int nonundocount;
Lisp_Object keybuf[30];
Fselect_frame (internal_last_event_frame, Qnil);
#endif
#endif
+ /* If it has changed current-menubar from previous value,
+ really recompute the menubar from the value. */
+ if (! NILP (Vlucid_menu_bar_dirty_flag))
+ call0 (Qrecompute_lucid_menubar);
+
+#if 0 /* This is done in xdisp.c now. */
+#ifdef MULTI_FRAME
+ for (tem = Vframe_list; CONSP (tem); tem = XCONS (tem)->cdr)
+ {
+ struct frame *f = XFRAME (XCONS (tem)->car);
+ struct window *w = XWINDOW (FRAME_SELECTED_WINDOW (f));
+
+ /* If the user has switched buffers or windows, we need to
+ recompute to reflect the new bindings. But we'll
+ recompute when update_mode_lines is set too; that means
+ that people can use force-mode-line-update to request
+ that the menu bar be recomputed. The adverse effect on
+ the rest of the redisplay algorithm is about the same as
+ windows_or_buffers_changed anyway. */
+ if (windows_or_buffers_changed
+ || update_mode_lines
+ || (XFASTINT (w->last_modified) < MODIFF
+ && (XFASTINT (w->last_modified)
+ <= XBUFFER (w->buffer)->save_modified)))
+ {
+ struct buffer *prev = current_buffer;
+ current_buffer = XBUFFER (w->buffer);
+ FRAME_MENU_BAR_ITEMS (f) = menu_bar_items ();
+ current_buffer = prev;
+ }
+ }
+#endif /* MULTI_FRAME */
+#endif /* 0 */
/* Read next key sequence; i gets its length. */
i = read_key_sequence (keybuf, (sizeof keybuf / sizeof (keybuf[0])), 0);
last_command_char = keybuf[i - 1];
+ /* If the previous command tried to force a specific window-start,
+ forget about that, in case this command moves point far away
+ from that position. */
+ XWINDOW (selected_window)->force_start = Qnil;
+
cmd = read_key_sequence_cmd;
if (!NILP (Vexecuting_macro))
{
SIGTYPE
input_poll_signal ()
{
-#ifdef HAVE_X_WINDOWS
- extern int x_input_blocked;
- if (x_input_blocked == 0)
-#endif
- if (!waiting_for_input)
- read_avail_input (0);
+ if (interrupt_input_blocked == 0
+ && !waiting_for_input)
+ read_avail_input (0);
signal (SIGALRM, input_poll_signal);
alarm (polling_period);
}
Vlast_event_frame = internal_last_event_frame = Qmacro;
#endif
- if (executing_macro_index >= XFASTINT (Flength (Vexecuting_macro)))
+ /* Exit the macro if we are at the end.
+ Also, some things replace the macro with t
+ to force an early exit. */
+ if (EQ (Vexecuting_macro, Qt)
+ || executing_macro_index >= XFASTINT (Flength (Vexecuting_macro)))
{
XSET (c, Lisp_Int, -1);
return c;
XSET (internal_last_event_frame, Lisp_Frame, selected_frame);
Vlast_event_frame = internal_last_event_frame;
#endif
+ /* If we report the quit char as an event,
+ don't do so more than once. */
+ if (!NILP (Vinhibit_quit))
+ Vquit_flag = Qnil;
goto non_reread;
}
if (noninteractive && XTYPE (c) == Lisp_Int && XINT (c) < 0)
Fkill_emacs (make_number (1));
- /* Test for ControlMask and Mod1Mask. */
- if (extra_keyboard_modifiers & 4)
- c &= ~0140;
- if (extra_keyboard_modifiers & 8)
- c |= 0200;
+ if (XTYPE (c) == Lisp_Int)
+ {
+ /* Add in any extra modifiers, where appropriate. */
+ if ((extra_keyboard_modifiers & CHAR_CTL)
+ || ((extra_keyboard_modifiers & 0177) < ' '
+ && (extra_keyboard_modifiers & 0177) != 0))
+ {
+ /* If it's already a control character, don't mess with it. */
+ if ((c & 0177) == 0)
+ ;
+
+ /* Making ? a control character should result in DEL. */
+ else if ((c & 0177) == '?')
+ c |= 0177;
+
+ /* ASCII control chars are made from letters (both cases),
+ as well as the non-letters within 0100...0137. */
+ else if ((c & 0137) >= 0101 && (c & 0137) <= 0132)
+ c = (c & (037 | ~0177));
+ else if ((c & 0177) >= 0100 && (c & 0177) <= 0137)
+ c = (c & (037 | ~0177));
+
+ /* Anything else must get its high control bit set. */
+ else
+ c = c | ctrl_modifier;
+ }
+
+ /* Transfer any other modifier bits directly from
+ extra_keyboard_modifiers to c. Ignore the actual character code
+ in the low 16 bits of extra_keyboard_modifiers. */
+ c |= (extra_keyboard_modifiers & ~0xff7f & ~CHAR_CTL);
+ }
non_reread:
return obj;
}
+ retry:
/* Wait until there is input available. */
for (;;)
{
obj = Qnil;
+ /* These two kinds of events get special handling
+ and don't actually appear to the command loop. */
+ if (event->kind == selection_request_event)
+ {
+#ifdef HAVE_X11
+ x_handle_selection_request (event);
+ kbd_fetch_ptr = event + 1;
+ goto retry;
+#else
+ /* We're getting selection request events, but we don't have
+ a window system. */
+ abort ();
+#endif
+ }
+
+ if (event->kind == selection_clear_event)
+ {
+#ifdef HAVE_X11
+ x_handle_selection_clear (event);
+ kbd_fetch_ptr = event + 1;
+ goto retry;
+#else
+ /* We're getting selection request events, but we don't have
+ a window system. */
+ abort ();
+#endif
+ }
+
#ifdef MULTI_FRAME
/* If this event is on a different frame, return a switch-frame this
time, and leave the event in the queue for next time. */
if (! NILP (focus))
frame = focus;
- if (! EQ (frame, internal_last_event_frame))
- {
- internal_last_event_frame = frame;
- obj = make_lispy_switch_frame (frame);
- }
+ if (! EQ (frame, internal_last_event_frame)
+ && XFRAME (frame) != selected_frame)
+ obj = make_lispy_switch_frame (frame);
+ internal_last_event_frame = frame;
}
#endif
if (NILP (frame))
XSET (frame, Lisp_Frame, f);
- if (! EQ (frame, internal_last_event_frame))
- {
- XSET (internal_last_event_frame, Lisp_Frame, frame);
- obj = make_lispy_switch_frame (internal_last_event_frame);
- }
+ if (! EQ (frame, internal_last_event_frame)
+ && XFRAME (frame) != selected_frame)
+ obj = make_lispy_switch_frame (internal_last_event_frame);
+ internal_last_event_frame = frame;
}
#endif
something for us to read! */
abort ();
+ /* If something gave back nil as the Lispy event,
+ it means the event was discarded, so try again. */
+ if (NILP (obj))
+ goto retry;
+
input_pending = readable_events ();
#ifdef MULTI_FRAME
if ((event->modifiers & ctrl_modifier)
&& c >= 040)
c |= ctrl_modifier;
- if (XFASTINT (event->code) < 040
+ /* Set the shift modifier for a control char
+ made from a shifted letter. But only for letters! */
+ if (XFASTINT (event->code) >= 'A' - 0100
+ && XFASTINT (event->code) <= 'Z' - 0100
&& (event->modifiers & shift_modifier))
c |= shift_modifier;
c |= (event->modifiers
if (event->kind == mouse_click)
{
int part;
- Lisp_Object window =
- window_from_coordinates (XFRAME (event->frame_or_window),
- XINT (event->x), XINT (event->y),
- &part);
+ FRAME_PTR f = XFRAME (event->frame_or_window);
+ Lisp_Object window
+ = window_from_coordinates (f, XINT (event->x), XINT (event->y),
+ &part);
Lisp_Object posn;
- if (XTYPE (window) != Lisp_Window)
+ if (XINT (event->y) < FRAME_MENU_BAR_LINES (f))
+ {
+ int hpos;
+ Lisp_Object items;
+ items = FRAME_MENU_BAR_ITEMS (f);
+ for (; CONSP (items); items = XCONS (items)->cdr)
+ {
+ Lisp_Object pos, string;
+ pos = Fcdr (Fcdr (Fcar (items)));
+ string = Fcar (Fcdr (Fcar (items)));
+ if (XINT (event->x) > XINT (pos)
+ && XINT (event->x) <= XINT (pos) + XSTRING (string)->size)
+ break;
+ }
+ position
+ = Fcons (event->frame_or_window,
+ Fcons (Qmenu_bar,
+ Fcons (Fcons (event->x, event->y),
+ Fcons (make_number (event->timestamp),
+ Qnil))));
+
+ if (CONSP (items))
+ return Fcons (Fcar (Fcar (items)),
+ Fcons (position, Qnil));
+ else
+ return Fcons (Qnil, Fcons (position, Qnil));
+ }
+ else if (XTYPE (window) != Lisp_Window)
posn = Qnil;
else
{
XINT (event->y)));
}
- position =
- Fcons (window,
- Fcons (posn,
- Fcons (Fcons (event->x, event->y),
- Fcons (make_number (event->timestamp),
- Qnil))));
+ position
+ = Fcons (window,
+ Fcons (posn,
+ Fcons (Fcons (event->x, event->y),
+ Fcons (make_number (event->timestamp),
+ Qnil))));
}
else
{
see if this was a click or a drag. */
else if (event->modifiers & up_modifier)
{
- /* Is there a start position stored at all for this
- button?
-
- It would be nice if we could assume that if we're
- getting a button release, we must therefore have gotten
- a button press. Unfortunately, the X menu code thwarts
- this assumption, so we'll have to be more robust. We
- treat a button release with no stored start position as
- a click. */
+ /* If we did not see a down before this up,
+ ignore the up. Probably this happened because
+ the down event chose a menu item.
+ It would be an annoyance to treat the release
+ of the button that chose the menu item
+ as a separate event. */
+
+ if (XTYPE (start_pos) != Lisp_Cons)
+ return Qnil;
+
event->modifiers &= ~up_modifier;
+#if 0 /* Formerly we treated an up with no down as a click event. */
if (XTYPE (start_pos) != Lisp_Cons)
event->modifiers |= click_modifier;
else
+#endif
{
/* The third element of every position should be the (x,y)
pair. */
{
/* Get the symbol we should use for the mouse click. */
- Lisp_Object head =
- modify_event_symbol (button,
- event->modifiers,
- Qmouse_click,
- lispy_mouse_names, &mouse_syms,
- (sizeof (lispy_mouse_names)
- / sizeof (lispy_mouse_names[0])));
+ Lisp_Object head
+ = modify_event_symbol (button,
+ event->modifiers,
+ Qmouse_click,
+ lispy_mouse_names, &mouse_syms,
+ (sizeof (lispy_mouse_names)
+ / sizeof (lispy_mouse_names[0])));
if (event->modifiers & drag_modifier)
return Fcons (head,
/* The 'kind' field of the event is something we don't recognize. */
default:
- abort();
+ abort ();
}
}
}
}
-
/* Construct a switch frame event. */
static Lisp_Object
make_lispy_switch_frame (frame)
{
return Fcons (Qswitch_frame, Fcons (frame, Qnil));
}
-
\f
/* Manipulating modifiers. */
"drag", "click", 0, 0, 0, 0, 0, 0,
0, 0, "alt", "super", "hyper", "shift", "control", "meta"
};
+#define NUM_MOD_NAMES (sizeof (modifier_names) / sizeof (modifier_names[0]))
static Lisp_Object modifier_symbols;
int i;
modifier_list = Qnil;
- for (i = 0; (1<<i) <= modifiers; i++)
+ for (i = 0; (1<<i) <= modifiers && i < NUM_MOD_NAMES; i++)
if (modifiers & (1<<i))
- {
- if (i >= XVECTOR (modifier_symbols)->size)
- abort ();
- modifier_list = Fcons (XVECTOR (modifier_symbols)->contents[i],
- modifier_list);
- }
+ modifier_list = Fcons (XVECTOR (modifier_symbols)->contents[i],
+ modifier_list);
return modifier_list;
}
Qnil);
Lisp_Object mask;
+ if (modifiers & ~((1<<VALBITS) - 1))
+ abort ();
XFASTINT (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 &= (1<<VALBITS) - 1;
+
/* The click modifier never figures into cache indices. */
cache = Fget (base, Qmodifier_cache);
XFASTINT (index) = (modifiers & ~click_modifier);
You'd think we could just set this once and for all when we
intern the symbol above, but reorder_modifiers may call us when
BASE's property isn't set right; we can't assume that just
- because we found something in the cache it must have its kind set
- right. */
+ because it has a Qmodifier_cache property it must have its
+ Qevent_kind set right as well. */
if (NILP (Fget (new_symbol, Qevent_kind)))
{
Lisp_Object kind = Fget (base, Qevent_kind);
{
buf[i].kind = ascii_keystroke;
buf[i].modifiers = 0;
- if (meta_key && (cbuf[i] & 0x80))
+ if (meta_key == 1 && (cbuf[i] & 0x80))
buf[i].modifiers = meta_modifier;
- cbuf[i] &= ~0x80;
+ if (meta_key != 2)
+ cbuf[i] &= ~0x80;
XSET (buf[i].code, Lisp_Int, cbuf[i]);
#ifdef MULTI_FRAME
errno = old_errno;
}
#endif /* SIGIO */
+
+/* Send ourselves a SIGIO.
+
+ This function exists so that the UNBLOCK_INPUT macro in
+ blockinput.h can have some way to take care of input we put off
+ dealing with, without assuming that every file which uses
+ UNBLOCK_INPUT also has #included the files necessary to get SIGIO. */
+void
+reinvoke_input_signal ()
+{
+#ifdef SIGIO
+ kill (0, SIGIO);
+#endif
+}
+
+
\f
/* Return the prompt-string of a sparse keymap.
This is the first element which is a string.
return Qnil;
}
+static Lisp_Object menu_bar_item ();
+static Lisp_Object menu_bar_one_keymap ();
+
+/* Return a list of menu items for a menu bar, appropriate
+ to the current buffer.
+ The elements have the form (KEY STRING . nil). */
+
+Lisp_Object
+menu_bar_items ()
+{
+ /* The number of keymaps we're scanning right now, and the number of
+ keymaps we have allocated space for. */
+ int nmaps;
+
+ /* maps[0..nmaps-1] are the prefix definitions of KEYBUF[0..t-1]
+ in the current keymaps, or nil where it is not a prefix. */
+ Lisp_Object *maps;
+
+ Lisp_Object def, tem;
+
+ Lisp_Object result;
+
+ int mapno;
+
+ /* Build our list of keymaps.
+ If we recognize a function key and replace its escape sequence in
+ keybuf with its symbol, or if the sequence starts with a mouse
+ click and we need to switch buffers, we jump back here to rebuild
+ the initial keymaps from the current buffer. */
+ {
+ Lisp_Object *tmaps;
+
+ nmaps = current_minor_maps (0, &tmaps) + 2;
+ maps = (Lisp_Object *) alloca (nmaps * sizeof (maps[0]));
+ bcopy (tmaps, maps, (nmaps - 2) * sizeof (maps[0]));
+#ifdef USE_TEXT_PROPERTIES
+ maps[nmaps-2] = get_local_map (PT, current_buffer);
+#else
+ maps[nmaps-2] = current_buffer->local_map;
+#endif
+ maps[nmaps-1] = global_map;
+ }
+
+ /* Look up in each map the dummy prefix key `menu-bar'. */
+
+ result = Qnil;
+
+ for (mapno = 0; mapno < nmaps; mapno++)
+ {
+ if (! NILP (maps[mapno]))
+ def = get_keyelt (access_keymap (maps[mapno], Qmenu_bar, 1));
+ else
+ def = Qnil;
+
+ tem = Fkeymapp (def);
+ if (!NILP (tem))
+ result = menu_bar_one_keymap (def, result);
+ }
+
+ return Fnreverse (result);
+}
+\f
+/* Scan one map KEYMAP, accumulating any menu items it defines
+ that have not yet been seen in RESULT. Return the updated RESULT. */
+
+static Lisp_Object
+menu_bar_one_keymap (keymap, result)
+ Lisp_Object keymap, result;
+{
+ Lisp_Object tail, item, key, binding, item_string, table;
+
+ /* Loop over all keymap entries that have menu strings. */
+ for (tail = keymap; XTYPE (tail) == Lisp_Cons; tail = XCONS (tail)->cdr)
+ {
+ item = XCONS (tail)->car;
+ if (XTYPE (item) == Lisp_Cons)
+ {
+ key = XCONS (item)->car;
+ binding = XCONS (item)->cdr;
+ if (XTYPE (binding) == Lisp_Cons)
+ {
+ item_string = XCONS (binding)->car;
+ if (XTYPE (item_string) == Lisp_String)
+ result = menu_bar_item (key, item_string,
+ Fcdr (binding), result);
+ }
+ }
+ else if (XTYPE (item) == Lisp_Vector)
+ {
+ /* Loop over the char values represented in the vector. */
+ int len = XVECTOR (item)->size;
+ int c;
+ for (c = 0; c < len; c++)
+ {
+ Lisp_Object character;
+ XFASTINT (character) = c;
+ binding = XVECTOR (item)->contents[c];
+ if (XTYPE (binding) == Lisp_Cons)
+ {
+ item_string = XCONS (binding)->car;
+ if (XTYPE (item_string) == Lisp_String)
+ result = menu_bar_item (key, item_string,
+ Fcdr (binding), result);
+ }
+ }
+ }
+ }
+
+ return result;
+}
+
+static Lisp_Object
+menu_bar_item (key, item_string, def, result)
+ Lisp_Object key, item_string, def, result;
+{
+ Lisp_Object tem, elt;
+ Lisp_Object enabled;
+
+ /* See if this entry is enabled. */
+ enabled = Qt;
+
+ if (XTYPE (def) == Lisp_Symbol)
+ {
+ /* No property, or nil, means enable.
+ Otherwise, enable if value is not nil. */
+ tem = Fget (def, Qmenu_enable);
+ if (!NILP (tem))
+ enabled = Feval (tem);
+ }
+
+ /* Add an entry for this key and string
+ if there is none yet. */
+ elt = Fassq (key, result);
+ if (!NILP (enabled) && NILP (elt))
+ result = Fcons (Fcons (key, Fcons (item_string, Qnil)), result);
+
+ return result;
+}
+\f
static int echo_flag;
static int echo_now;
realmaps[nmaps1++] = maps[mapno];
value = Fx_popup_menu (prev_event, Flist (nmaps1, realmaps));
+ if (CONSP (value))
+ {
+ /* If we got more than one event, put all but the first
+ onto this list to be read later.
+ Return just the first event now. */
+ unread_command_events
+ = nconc2 (XCONS (value)->cdr, unread_command_events);
+ value = XCONS (value)->car;
+ }
if (NILP (value))
XSET (value, Lisp_Int, quit_char);
if (used_mouse_menu)
If the user switches frames in the midst of a key sequence, we put
off the switch-frame event until later; the next call to
read_char will return it. */
+
static int
read_key_sequence (keybuf, bufsize, prompt)
Lisp_Object *keybuf;
goto replay_key;
}
}
+ else
+ {
+ Lisp_Object posn = POSN_BUFFER_POSN (EVENT_START (key));
+
+ /* Handle menu-bar events:
+ insert the dummy prefix char `menu-bar'. */
+ if (EQ (posn, Qmenu_bar))
+ {
+ if (t + 1 >= bufsize)
+ error ("key sequence too long");
+ /* Run the Lucid hook. */
+ call1 (Vrun_hooks, Qactivate_menubar_hook);
+ /* If it has changed current-menubar from previous value,
+ really recompute the menubar from the value. */
+ if (! NILP (Vlucid_menu_bar_dirty_flag))
+ call0 (Qrecompute_lucid_menubar);
+ keybuf[t] = posn;
+ keybuf[t+1] = key;
+ mock_input = t + 2;
+ goto replay_sequence;
+ }
+ }
}
}
if (XTYPE (head) == Lisp_Symbol)
{
Lisp_Object breakdown = parse_modifiers (head);
- Lisp_Object modifiers =
- XINT (XCONS (XCONS (breakdown)->cdr)->car);
+ int modifiers = XINT (XCONS (XCONS (breakdown)->cdr)->car);
/* We drop unbound `down-' events altogether. */
if (modifiers & down_modifier)
}
DEFUN ("this-command-keys", Fthis_command_keys, Sthis_command_keys, 0, 0, 0,
- "Return string of the keystrokes that invoked this command.")
+ "Return the key sequence that invoked this command.\n\
+The value is a string or a vector.")
()
{
return make_event_array (this_command_key_count,
If optional arg STUFFSTRING is non-nil, its characters are stuffed\n\
to be read as terminal input by Emacs's parent, after suspension.\n\
\n\
-Before suspending, call the functions in `suspend-hooks' with no args.\n\
+Before suspending, call the functions in `suspend-hook' with no args.\n\
If any of them returns nil, don't call the rest and don't suspend.\n\
Otherwise, suspend normally and after resumption run the normal hook\n\
`suspend-resume-hook' if that is bound and non-nil.\n\
if (!NILP (stuffstring))
CHECK_STRING (stuffstring, 0);
- /* Run the functions in suspend-hooks. */
- tem = Fsymbol_value (intern ("suspend-hooks"));
- while (CONSP (tem))
- {
- Lisp_Object val;
- GCPRO2 (stuffstring, tem);
- val = call0 (Fcar (tem));
- UNGCPRO;
- tem = Fcdr (tem);
- if (!EQ (val, Qnil)) return Qnil;
- }
+ /* Run the functions in suspend-hook. */
+ if (!NILP (Vrun_hooks))
+ call1 (Vrun_hooks, intern ("suspend-hook"));
GCPRO1 (stuffstring);
get_frame_size (&old_width, &old_height);
if (width != old_width || height != old_height)
change_frame_size (0, height, width, 0, 0);
- /* Call value of suspend-resume-hook
- if it is bound and value is non-nil. */
+ /* Run suspend-resume-hook. */
if (!NILP (Vrun_hooks))
call1 (Vrun_hooks, intern ("suspend-resume-hook"));
char c;
/* Must preserve main program's value of errno. */
int old_errno = errno;
- extern Lisp_Object Vwindow_system;
#ifdef USG
/* USG systems forget handlers when they are used;
unread_command_events = Qnil;
unread_command_char = -1;
+#ifdef POLL_FOR_INPUT
+ /* May be > 1 if in recursive minibuffer. */
+ if (poll_suppress_count == 0)
+ abort ();
+#endif
+
_longjmp (getcjmp, 1);
}
\f
nil means use CBREAK mode.\n\
Second arg FLOW non-nil means use ^S/^Q flow control for output to terminal\n\
(no effect except in CBREAK mode).\n\
-Third arg META non-nil means accept 8-bit input (for a Meta key).\n\
- Otherwise, the top bit is ignored, on the assumption it is parity.\n\
+Third arg META t means accept 8-bit input (for a Meta key).\n\
+ META nil means ignore the top bit, on the assumption it is parity.\n\
+ Otherwise, accept 8-bit input and don't use the top bit for Meta.\n\
Optional fourth arg QUIT if non-nil specifies character to use for quitting.")
(interrupt, flow, meta, quit)
Lisp_Object interrupt, flow, meta, quit;
interrupt_input = 1;
#endif
flow_control = !NILP (flow);
- meta_key = !NILP (meta);
+ if (NILP (meta))
+ meta_key = 0;
+ else if (EQ (meta, Qt))
+ meta_key = 1;
+ else
+ meta_key = 2;
if (!NILP (quit))
/* Don't let this value be out of range. */
quit_char = XINT (quit) & (meta_key ? 0377 : 0177);
init_sys_modes ();
return Qnil;
}
+
+DEFUN ("current-input-mode", Fcurrent_input_mode, Scurrent_input_mode, 0, 0, 0,
+ "Return information about the way Emacs currently reads keyboard input.\n\
+The value is a list of the form (INTERRUPT FLOW META QUIT), where\n\
+ INTERRUPT is non-nil if Emacs is using interrupt-driven input; if\n\
+ nil, Emacs is using CBREAK mode.\n\
+ FLOW is non-nil if Emacs uses ^S/^Q flow control for output to the\n\
+ terminal; this does not apply if Emacs uses interrupt-driven input.\n\
+ META is non-nil if Emacs is accepting 8-bit input; otherwise, Emacs\n\
+ clears the eighth bit of every input character.\n\
+ QUIT is the character Emacs currently uses to quit.\n\
+The elements of this list correspond to the arguments of\n\
+set-input-mode.")
+ ()
+{
+ Lisp_Object val[4];
+
+ val[0] = interrupt_input ? Qt : Qnil;
+ val[1] = flow_control ? Qt : Qnil;
+ val[2] = meta_key ? Qt : Qnil;
+ XSETINT (val[3], quit_char);
+
+ return Flist (val, sizeof (val) / sizeof (val[0]));
+}
+
\f
init_keyboard ()
{
Qmouse_click = intern ("mouse-click");
staticpro (&Qmouse_click);
+ Qmenu_enable = intern ("menu-enable");
+ staticpro (&Qmenu_enable);
+
Qmode_line = intern ("mode-line");
staticpro (&Qmode_line);
Qvertical_line = intern ("vertical-line");
staticpro (&Qvertical_line);
Qvertical_scroll_bar = intern ("vertical-scroll-bar");
staticpro (&Qvertical_scroll_bar);
+ Qmenu_bar = intern ("menu-bar");
+ staticpro (&Qmenu_bar);
Qabove_handle = intern ("above-handle");
staticpro (&Qabove_handle);
Qmodifier_cache = intern ("modifier-cache");
staticpro (&Qmodifier_cache);
+ Qrecompute_lucid_menubar = intern ("recompute-lucid-menubar");
+ staticpro (&Qrecompute_lucid_menubar);
+ Qactivate_menubar_hook = intern ("activate-menubar-hook");
+ staticpro (&Qactivate_menubar_hook);
+
{
struct event_head *p;
defsubr (&Sdiscard_input);
defsubr (&Sopen_dribble_file);
defsubr (&Sset_input_mode);
+ defsubr (&Scurrent_input_mode);
defsubr (&Sexecute_extended_command);
DEFVAR_LISP ("disabled-command-hook", &Vdisabled_command_hook,
DEFVAR_INT ("extra-keyboard-modifiers", &extra_keyboard_modifiers,
"A mask of additional modifier keys to use with every keyboard character.\n\
-These bits follow the convention for X windows,\n\
-but the control and meta bits work even when you are not using X:\n\
- 1 -- shift bit 2 -- lock bit\n\
- 4 -- control bit 8 -- meta bit.");
+Emacs applies the modifiers of the character stored here to each keyboard\n\
+character it reads. For example, after evaluating the expression\n\
+ (setq extra-keyboard-modifiers ?\C-x)\n\
+all input characters will have the control modifier applied to them.\n\
+\n\
+Note that the character ?\C-@, equivalent to the integer zero, does\n\
+not count as a control character; rather, it counts as a character\n\
+with no modifiers; thus, setting extra_keyboard_modifiers to zero\n\
+cancels any modification.");
extra_keyboard_modifiers = 0;
DEFVAR_LISP ("deactivate-mark", &Vdeactivate_mark,
DEFVAR_LISP ("post-command-hook", &Vpost_command_hook,
"Normal hook run before each command is executed.");
Vpost_command_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.");
+ Vlucid_menu_bar_dirty_flag = Qnil;
}
keys_of_keyboard ()