This file is part of GNU Emacs.
-GNU Emacs is free software; you can redistribute it and/or modify
+GNU Emacs is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 3, or (at your option)
-any later version.
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
GNU Emacs is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
-along with GNU Emacs; see the file COPYING. If not, write to
-the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-Boston, MA 02110-1301, USA. */
+along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include <config.h>
#include <signal.h>
#include "msdos.h"
#include <time.h>
#else /* not MSDOS */
-#ifndef VMS
#include <sys/ioctl.h>
-#endif
#endif /* not MSDOS */
#include "syssignal.h"
#include "w32term.h"
#endif /* HAVE_NTGUI */
-#ifdef MAC_OS
-#include "macterm.h"
+#ifdef HAVE_NS
+#include "nsterm.h"
#endif
#ifndef USE_CRT_DLL
#define KBD_BUFFER_SIZE 4096
-#ifdef MULTI_KBOARD
KBOARD *initial_kboard;
KBOARD *current_kboard;
KBOARD *all_kboards;
int single_kboard;
-#else
-KBOARD the_only_kboard;
-#endif
/* Non-nil disable property on a command means
do not execute it; call disabled-command-function's value instead. */
Lisp_Object Vshow_help_function;
-/* If a string, the message displayed before displaying a help-echo
- in the echo area. */
-
-Lisp_Object Vpre_help_message;
-
/* Nonzero means do menu prompting. */
static int menu_prompting;
/* Symbols to denote kinds of events. */
Lisp_Object Qfunction_key;
Lisp_Object Qmouse_click;
-#if defined (WINDOWSNT) || defined (MAC_OS)
+#if defined (WINDOWSNT)
Lisp_Object Qlanguage_change;
#endif
Lisp_Object Qdrag_n_drop;
Lisp_Object Qsave_session;
-#ifdef MAC_OS
-Lisp_Object Qmac_apple_event;
-#endif
#ifdef HAVE_DBUS
Lisp_Object Qdbus_event;
#endif
Lisp_Object, char **,
Lisp_Object *, unsigned));
static Lisp_Object make_lispy_switch_frame P_ ((Lisp_Object));
-static int parse_solitary_modifier P_ ((Lisp_Object));
-static int parse_solitary_modifier ();
static void save_getcjmp P_ ((jmp_buf));
static void save_getcjmp ();
static void restore_getcjmp P_ ((jmp_buf));
static Lisp_Object apply_modifiers P_ ((int, Lisp_Object));
static void clear_event P_ ((struct input_event *));
-#ifdef MULTI_KBOARD
static Lisp_Object restore_kboard_configuration P_ ((Lisp_Object));
-#endif
static SIGTYPE interrupt_signal P_ ((int signalnum));
static void handle_interrupt P_ ((void));
static void timer_start_idle P_ ((void));
static void
any_kboard_state ()
{
-#ifdef MULTI_KBOARD
#if 0 /* Theory: if there's anything in Vunread_command_events,
it will right away be read by read_key_sequence,
and then if we do switch KBOARDS, it will go into the side
Vunread_command_events = Qnil;
#endif
single_kboard = 0;
-#endif
}
/* Switch to the single-kboard state, making current_kboard
void
single_kboard_state ()
{
-#ifdef MULTI_KBOARD
single_kboard = 1;
-#endif
}
#endif
not_single_kboard_state (kboard)
KBOARD *kboard;
{
-#ifdef MULTI_KBOARD
if (kboard == current_kboard)
single_kboard = 0;
-#endif
}
/* Maintain a stack of kboards, so other parts of Emacs
push_kboard (k)
struct kboard *k;
{
-#ifdef MULTI_KBOARD
struct kboard_stack *p
= (struct kboard_stack *) xmalloc (sizeof (struct kboard_stack));
kboard_stack = p;
current_kboard = k;
-#endif
}
void
pop_kboard ()
{
-#ifdef MULTI_KBOARD
struct terminal *t;
struct kboard_stack *p = kboard_stack;
int found = 0;
}
kboard_stack = p->next;
xfree (p);
-#endif
}
/* Switch to single_kboard mode, making current_kboard the only KBOARD
temporarily_switch_to_single_kboard (f)
struct frame *f;
{
-#ifdef MULTI_KBOARD
int was_locked = single_kboard;
if (was_locked)
{
single_kboard = 1;
record_unwind_protect (restore_kboard_configuration,
(was_locked ? Qt : Qnil));
-#endif
}
#if 0 /* This function is not needed anymore. */
}
#endif
-#ifdef MULTI_KBOARD
static Lisp_Object
restore_kboard_configuration (was_locked)
Lisp_Object was_locked;
}
return Qnil;
}
-#endif
\f
/* Handle errors that are not handled at inner levels
Vinhibit_quit = Qnil;
#if 0 /* This shouldn't be necessary anymore. --lorentey */
-#ifdef MULTI_KBOARD
if (command_loop_level == 0 && minibuf_level == 0)
any_kboard_state ();
-#endif
#endif
return make_number (0);
int prev_modiff = 0;
struct buffer *prev_buffer = NULL;
#if 0 /* This shouldn't be necessary anymore. --lorentey */
-#ifdef MULTI_KBOARD
int was_locked = single_kboard;
-#endif
#endif
int already_adjusted = 0;
&& NILP (current_kboard->Vprefix_arg))
finalize_kbd_macro_chars ();
#if 0 /* This shouldn't be necessary anymore. --lorentey */
-#ifdef MULTI_KBOARD
if (!was_locked)
any_kboard_state ();
-#endif
#endif
}
}
{
if (!NILP (Vshow_help_function))
call1 (Vshow_help_function, help);
- else if (/* Don't overwrite minibuffer contents. */
- !MINI_WINDOW_P (XWINDOW (selected_window))
- /* Don't overwrite a keystroke echo. */
- && (NILP (echo_message_buffer)
- || ok_to_overwrite_keystroke_echo)
- /* Don't overwrite a prompt. */
- && !cursor_in_echo_area)
- {
- if (STRINGP (help))
- {
- int count = SPECPDL_INDEX ();
-
- if (!help_echo_showing_p)
- Vpre_help_message = current_message ();
-
- specbind (Qmessage_truncate_lines, Qt);
- message3_nolog (help, SBYTES (help),
- STRING_MULTIBYTE (help));
- unbind_to (count, Qnil);
- }
- else if (STRINGP (Vpre_help_message))
- {
- message3_nolog (Vpre_help_message,
- SBYTES (Vpre_help_message),
- STRING_MULTIBYTE (Vpre_help_message));
- Vpre_help_message = Qnil;
- }
- else
- message (0);
- }
-
help_echo_showing_p = STRINGP (help);
}
}
if (!NILP (Vinhibit_quit))
Vquit_flag = Qnil;
-#ifdef MULTI_KBOARD
{
KBOARD *kb = FRAME_KBOARD (XFRAME (selected_frame));
if (kb != current_kboard)
return make_number (-2); /* wrong_kboard_jmpbuf */
}
}
-#endif
goto non_reread;
}
}
}
-#ifdef MULTI_KBOARD
/* If current_kboard's side queue is empty check the other kboards.
If one of them has data that we have not yet seen here,
switch to it and process the data waiting for it.
return make_number (-2); /* wrong_kboard_jmpbuf */
}
}
-#endif
wrong_kboard:
c = kbd_buffer_get_event (&kb, used_mouse_menu, end_time);
restore_getcjmp (save_jump);
-#ifdef MULTI_KBOARD
if (! NILP (c) && (kb != current_kboard))
{
Lisp_Object link = kb->kbd_queue;
UNGCPRO;
return make_number (-2);
}
-#endif
}
/* Terminate Emacs in batch mode if at eof. */
/* Set this for debugging, to have a way to get out */
int stop_character;
-#ifdef MULTI_KBOARD
static KBOARD *
event_to_kboard (event)
struct input_event *event;
else
return FRAME_KBOARD (XFRAME (frame));
}
-#endif
Lisp_Object Vthrow_on_input;
if (c == quit_char)
{
-#ifdef MULTI_KBOARD
KBOARD *kb = FRAME_KBOARD (XFRAME (event->frame_or_window));
struct input_event *sp;
}
return;
}
-#endif
if (hold_quit)
{
/* One way or another, wait until input is available; then, if
interrupt handlers have not read it, read it now. */
-#ifdef OLDVMS
- wait_for_kbd_input ();
-#else
/* Note SIGIO has been undef'd if FIONREAD is missing. */
#ifdef SIGIO
gobble_input (0);
if (!interrupt_input && kbd_fetch_ptr == kbd_store_ptr)
/* Pass 1 for EXPECT since we just waited to have input. */
read_avail_input (1);
-#endif /* not VMS */
}
if (CONSP (Vunread_command_events))
last_event_timestamp = event->timestamp;
-#ifdef MULTI_KBOARD
*kbp = event_to_kboard (event);
if (*kbp == 0)
*kbp = current_kboard; /* Better than returning null ptr? */
-#else
- *kbp = &the_only_kboard;
-#endif
obj = Qnil;
#endif
}
-#if defined (HAVE_X11) || defined (HAVE_NTGUI) || defined (MAC_OS)
+#if defined (HAVE_X11) || defined (HAVE_NTGUI) \
+ || defined (HAVE_NS)
else if (event->kind == DELETE_WINDOW_EVENT)
{
/* Make an event (delete-frame (FRAME)). */
kbd_fetch_ptr = event + 1;
}
#endif
-#if defined (HAVE_X11) || defined (HAVE_NTGUI) || defined (MAC_OS)
+#if defined (HAVE_X11) || defined (HAVE_NTGUI) \
+ || defined (HAVE_NS)
else if (event->kind == ICONIFY_EVENT)
{
/* Make an event (iconify-frame (FRAME)). */
XSETBUFFER (obj, current_buffer);
kbd_fetch_ptr = event + 1;
}
-#if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) || defined (MAC_OS) \
- || defined (USE_GTK)
+#if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) \
+ || defined(HAVE_NS) || defined (USE_GTK)
else if (event->kind == MENU_BAR_ACTIVATE_EVENT)
{
kbd_fetch_ptr = event + 1;
x_activate_menubar (XFRAME (event->frame_or_window));
}
#endif
-#if defined (WINDOWSNT) || defined (MAC_OS)
+#if defined (WINDOWSNT)
else if (event->kind == LANGUAGE_CHANGE_EVENT)
{
-#ifdef MAC_OS
- /* Make an event (language-change (KEY_SCRIPT)). */
- obj = Fcons (make_number (event->code), Qnil);
-#else
/* Make an event (language-change (FRAME CHARSET LCID)). */
obj = Fcons (event->frame_or_window, Qnil);
-#endif
obj = Fcons (Qlanguage_change, Fcons (obj, Qnil));
kbd_fetch_ptr = event + 1;
}
{
obj = make_lispy_event (event);
-#if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) || defined(MAC_OS) \
- || defined (USE_GTK)
+#if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) \
+ || defined(HAVE_NS) || defined (USE_GTK)
/* If this was a menu selection, then set the flag to inhibit
writing to last_nonmenu_event. Don't do this if the event
we're returning is (menu-bar), though; that indicates the
if (event->kind == MOUSE_CLICK_EVENT)
{
struct frame *f = XFRAME (event->frame_or_window);
-#if ! defined (USE_X_TOOLKIT) && ! defined (USE_GTK)
+#if ! defined (USE_X_TOOLKIT) && ! defined (USE_GTK) && ! defined (HAVE_NS)
int row, column;
#endif
if (! FRAME_LIVE_P (f))
return Qnil;
-#if ! defined (USE_X_TOOLKIT) && ! defined (USE_GTK)
+#if ! defined (USE_X_TOOLKIT) && ! defined (USE_GTK) && ! defined (HAVE_NS)
/* EVENT->x and EVENT->y are frame-relative pixel
coordinates at this place. Under old redisplay, COLUMN
and ROW are set to frame relative glyph coordinates
return Fcons (item, Fcons (position, Qnil));
}
-#endif /* not USE_X_TOOLKIT && not USE_GTK */
+#endif /* not USE_X_TOOLKIT && not USE_GTK && not HAVE_NS */
position = make_lispy_position (f, &event->x, &event->y,
event->timestamp);
}
#endif /* HAVE_MOUSE */
-#if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) || defined (MAC_OS) \
- || defined (USE_GTK)
+#if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) \
+ || defined(HAVE_NS) || defined (USE_GTK)
case MENU_BAR_EVENT:
if (EQ (event->arg, event->frame_or_window))
/* This is the prefix key. We translate this to
case SAVE_SESSION_EVENT:
return Qsave_session;
-#ifdef MAC_OS
- case MAC_APPLE_EVENT:
- {
- Lisp_Object spec[2];
-
- spec[0] = event->x;
- spec[1] = event->y;
- return Fcons (Qmac_apple_event,
- Fcons (Fvector (2, spec),
- Fcons (event->arg, Qnil)));
- }
-#endif
-
#ifdef HAVE_DBUS
case DBUS_EVENT:
{
/* Try to recognize SYMBOL as a modifier name.
Return the modifier flag bit, or 0 if not recognized. */
-static int
-parse_solitary_modifier (symbol)
- Lisp_Object symbol;
+int
+parse_solitary_modifier (Lisp_Object symbol)
{
Lisp_Object name = SYMBOL_NAME (symbol);
xd_read_queued_messages ();
#endif /* HAVE_DBUS */
-#ifndef VMS
#ifdef SIGIO
if (interrupt_input)
{
sigsetmask (mask);
}
else
-#endif
#endif
read_avail_input (expected);
#endif
}
}
\f
-#ifndef VMS
-
/* Read any terminal input already buffered up by the system
into the kbd_buffer, but do not wait.
EXPECTED should be nonzero if the caller knows there is some input.
- Except on VMS, all input is read by this function.
- If interrupt_input is nonzero, this function MUST be called
- only when SIGIO is blocked.
-
Returns the number of keyboard chars read, or -1 meaning
this is a bad time to try to read input. */
return nread;
}
-#endif /* not VMS */
\f
void
handle_async_input ()
{
-#ifdef BSD4_1
- extern int select_alarmed;
-#endif
-
interrupt_input_pending = 0;
while (1)
0 means there was no keyboard input available. */
if (nread <= 0)
break;
-
-#ifdef BSD4_1
- select_alarmed = 1; /* Force the select emulator back to life */
-#endif
}
}
signal (signo, input_available_signal);
#endif /* USG */
-#ifdef BSD4_1
- sigisheld (SIGIO);
-#endif
-
#ifdef SYNC_INPUT
interrupt_input_pending = 1;
#else
handle_async_input ();
#endif
-#ifdef BSD4_1
- sigfree ();
-#endif
errno = old_errno;
}
#endif /* SIGIO */
if (NILP (cachelist))
{
/* We have to create a cachelist. */
- CHECK_IMPURE (start);
- XSETCDR (start, Fcons (Fcons (Qnil, Qnil), XCDR (start)));
- cachelist = XCAR (XCDR (start));
+ /* With the introduction of where_is_cache, the computation
+ of equivalent key bindings is sufficiently fast that we
+ do not need to cache it here any more. */
+ /* CHECK_IMPURE (start);
+ XSETCDR (start, Fcons (Fcons (Qnil, Qnil), XCDR (start)));
+ cachelist = XCAR (XCDR (start)); */
+ cachelist = Fcons (Qnil, Qnil);
newcache = 1;
tem = AREF (item_properties, ITEM_PROPERTY_KEYEQ);
if (!NILP (keyhint))
if (newcache && !NILP (tem))
{
tem = concat2 (build_string (" "), tem);
- // tem = concat3 (build_string (" ("), tem, build_string (")"));
+ /* tem = concat3 (build_string (" ("), tem, build_string (")")); */
XSETCDR (cachelist, tem);
}
else
{
{
-#ifdef MULTI_KBOARD
KBOARD *interrupted_kboard = current_kboard;
struct frame *interrupted_frame = SELECTED_FRAME ();
-#endif
key = read_char (NILP (prompt), nmaps,
(Lisp_Object *) submaps, last_nonmenu_event,
&used_mouse_menu, NULL);
-#ifdef MULTI_KBOARD
if (INTEGERP (key) && XINT (key) == -2) /* wrong_kboard_jmpbuf */
{
int found = 0;
orig_keymap = get_local_map (PT, current_buffer, Qkeymap);
goto replay_sequence;
}
-#endif
}
/* read_char returns t when it shows a menu and the user rejects it.
*/
sys_suspend ();
#else
-#ifdef VMS
- if (sys_suspend () == -1)
- {
- printf ("Not running as a subprocess;\n");
- printf ("you can continue or abort.\n");
- }
-#else /* not VMS */
/* Perhaps should really fork an inferior shell?
But that would not provide any way to get back
to the original shell, ever. */
printf ("No support for stopping a process on this operating system;\n");
printf ("you can continue or abort.\n");
-#endif /* not VMS */
#endif /* not SIGTSTP */
#ifdef MSDOS
/* We must remain inside the screen area when the internal terminal
#ifdef MSDOS
printf ("\r\nAbort? (y or n) ");
#else /* not MSDOS */
-#ifdef VMS
- printf ("Abort (and enter debugger)? (y or n) ");
-#else /* not VMS */
printf ("Abort (and dump core)? (y or n) ");
-#endif /* not VMS */
#endif /* not MSDOS */
fflush (stdout);
if (((c = getchar ()) & ~040) == 'Y')
new_interrupt_input = 0;
#endif /* not SIGIO */
-/* Our VMS input only works by interrupts, as of now. */
-#ifdef VMS
- new_interrupt_input = 1;
-#endif
-
if (new_interrupt_input != interrupt_input)
{
#ifdef POLL_FOR_INPUT
wipe_kboard (kb)
KBOARD *kb;
{
- if (kb->kbd_macro_buffer)
- xfree (kb->kbd_macro_buffer);
+ xfree (kb->kbd_macro_buffer);
}
-#ifdef MULTI_KBOARD
-
/* Free KB and memory referenced from it. */
void
xfree (kb);
}
-#endif /* MULTI_KBOARD */
-
void
init_keyboard ()
{
internal_last_event_frame = Qnil;
Vlast_event_frame = internal_last_event_frame;
-#ifdef MULTI_KBOARD
current_kboard = initial_kboard;
-#endif
/* Re-initialize the keyboard again. */
wipe_kboard (current_kboard);
init_kboard (current_kboard);
interrupt_input = 0;
#endif
-/* Our VMS input only works by interrupts, as of now. */
-#ifdef VMS
- interrupt_input = 1;
-#endif
-
sigfree ();
dribble = 0;
{
pending_funcalls = Qnil;
- Vpre_help_message = Qnil;
- staticpro (&Vpre_help_message);
-
Vlispy_mouse_stem = build_string ("mouse");
staticpro (&Vlispy_mouse_stem);
staticpro (&Qfunction_key);
Qmouse_click = intern ("mouse-click");
staticpro (&Qmouse_click);
-#if defined (WINDOWSNT) || defined (MAC_OS)
+#if defined (WINDOWSNT)
Qlanguage_change = intern ("language-change");
staticpro (&Qlanguage_change);
#endif
Qsave_session = intern ("save-session");
staticpro (&Qsave_session);
-#ifdef MAC_OS
- Qmac_apple_event = intern ("mac-apple-event");
- staticpro (&Qmac_apple_event);
-#endif
-
#ifdef HAVE_DBUS
Qdbus_event = intern ("dbus-event");
staticpro (&Qdbus_event);
and tool-bar buttons. */);
Venable_disabled_menus_and_buttons = Qnil;
-#ifdef MULTI_KBOARD
/* Create the initial keyboard. */
initial_kboard = (KBOARD *) xmalloc (sizeof (KBOARD));
init_kboard (initial_kboard);
/* Vwindow_system is left at t for now. */
initial_kboard->next_kboard = all_kboards;
all_kboards = initial_kboard;
-#endif
}
void