X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/39eb0cb563f5287270f3946804456dc766386638..e686f4760ca8e4fe3fb414cfeac0948e0f99a4ec:/src/keyboard.h diff --git a/src/keyboard.h b/src/keyboard.h index 1ee4a97c5c..387378750c 100644 --- a/src/keyboard.h +++ b/src/keyboard.h @@ -1,13 +1,13 @@ /* Declarations useful when processing input. - Copyright (C) 1985-1987, 1993, 2001-2013 Free Software Foundation, + Copyright (C) 1985-1987, 1993, 2001-2016 Free Software Foundation, Inc. This file is part of GNU Emacs. 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 of the License, 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 @@ -17,18 +17,21 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Emacs. If not, see . */ -#include "systime.h" /* for struct timespec, Time */ +#ifndef EMACS_KEYBOARD_H +#define EMACS_KEYBOARD_H + #include "coding.h" /* for ENCODE_UTF_8 and ENCODE_SYSTEM */ #include "termhooks.h" -INLINE_HEADER_BEGIN -#ifndef KEYBOARD_INLINE -# define KEYBOARD_INLINE INLINE +#ifdef HAVE_X11 +# include "xterm.h" /* for struct selection_input_event */ #endif +INLINE_HEADER_BEGIN + /* Most code should use this macro to access Lisp fields in struct kboard. */ -#define KVAR(kboard, field) ((kboard)->INTERNAL_FIELD (field)) +#define KVAR(kboard, field) ((kboard)->field ## _) /* Each KBOARD represents one logical input stream from which Emacs gets input. If we are using ordinary terminals, it has one KBOARD @@ -81,32 +84,32 @@ struct kboard can effectively wait for input in the any-kboard state, and hence avoid blocking out the other KBOARDs. See universal-argument in lisp/simple.el for an example. */ - Lisp_Object INTERNAL_FIELD (Voverriding_terminal_local_map); + Lisp_Object Voverriding_terminal_local_map_; /* Last command executed by the editor command loop, not counting commands that set the prefix argument. */ - Lisp_Object INTERNAL_FIELD (Vlast_command); + Lisp_Object Vlast_command_; /* Normally same as last-command, but never modified by other commands. */ - Lisp_Object INTERNAL_FIELD (Vreal_last_command); + Lisp_Object Vreal_last_command_; /* User-supplied table to translate input characters through. */ - Lisp_Object INTERNAL_FIELD (Vkeyboard_translate_table); + Lisp_Object Vkeyboard_translate_table_; /* Last command that may be repeated by `repeat'. */ - Lisp_Object INTERNAL_FIELD (Vlast_repeatable_command); + Lisp_Object Vlast_repeatable_command_; /* The prefix argument for the next command, in raw form. */ - Lisp_Object INTERNAL_FIELD (Vprefix_arg); + Lisp_Object Vprefix_arg_; /* Saved prefix argument for the last command, in raw form. */ - Lisp_Object INTERNAL_FIELD (Vlast_prefix_arg); + Lisp_Object Vlast_prefix_arg_; /* Unread events specific to this kboard. */ - Lisp_Object INTERNAL_FIELD (kbd_queue); + Lisp_Object kbd_queue_; /* Non-nil while a kbd macro is being defined. */ - Lisp_Object INTERNAL_FIELD (defining_kbd_macro); + Lisp_Object defining_kbd_macro_; /* The start of storage for the current keyboard macro. */ Lisp_Object *kbd_macro_buffer; @@ -128,28 +131,28 @@ struct kboard ptrdiff_t kbd_macro_bufsize; /* Last anonymous kbd macro defined. */ - Lisp_Object INTERNAL_FIELD (Vlast_kbd_macro); + Lisp_Object Vlast_kbd_macro_; /* Alist of system-specific X windows key symbols. */ - Lisp_Object INTERNAL_FIELD (Vsystem_key_alist); + Lisp_Object Vsystem_key_alist_; /* Cache for modify_event_symbol. */ - Lisp_Object INTERNAL_FIELD (system_key_syms); + Lisp_Object system_key_syms_; /* The kind of display: x, w32, ... */ - Lisp_Object INTERNAL_FIELD (Vwindow_system); + Lisp_Object Vwindow_system_; /* Keymap mapping keys to alternative preferred forms. See the DEFVAR for more documentation. */ - Lisp_Object INTERNAL_FIELD (Vlocal_function_key_map); + Lisp_Object Vlocal_function_key_map_; /* Keymap mapping ASCII function key sequences onto their preferred forms. Initialized by the terminal-specific lisp files. See the DEFVAR for more documentation. */ - Lisp_Object INTERNAL_FIELD (Vinput_decode_map); + Lisp_Object Vinput_decode_map_; /* Minibufferless frames on this display use this frame's minibuffer. */ - Lisp_Object INTERNAL_FIELD (Vdefault_minibuffer_frame); + Lisp_Object Vdefault_minibuffer_frame_; /* Number of displays using this KBOARD. Normally 1, but can be larger when you have multiple screens on a single X display. */ @@ -157,7 +160,7 @@ struct kboard /* The text we're echoing in the modeline - partial key sequences, usually. This is nil when not echoing. */ - Lisp_Object INTERNAL_FIELD (echo_string); + Lisp_Object echo_string_; /* This flag indicates that events were put into kbd_queue while Emacs was running for some other KBOARD. @@ -169,57 +172,65 @@ struct kboard kbd_queue_has_data is 0. When we push back an incomplete command, then this flag is 0, meaning we don't want to try reading from this KBOARD again until more input arrives. */ - char kbd_queue_has_data; + bool_bf kbd_queue_has_data; /* True means echo each character as typed. */ - unsigned immediate_echo : 1; + bool_bf immediate_echo : 1; - /* If we have echoed a prompt string specified by the user, - this is its length in characters. Otherwise this is -1. */ - ptrdiff_t echo_after_prompt; + /* If we have a prompt string specified by the user, this is it. */ + Lisp_Object echo_prompt_; }; -KEYBOARD_INLINE void +INLINE void kset_default_minibuffer_frame (struct kboard *kb, Lisp_Object val) { - kb->INTERNAL_FIELD (Vdefault_minibuffer_frame) = val; + kb->Vdefault_minibuffer_frame_ = val; } -KEYBOARD_INLINE void +INLINE void kset_defining_kbd_macro (struct kboard *kb, Lisp_Object val) { - kb->INTERNAL_FIELD (defining_kbd_macro) = val; + kb->defining_kbd_macro_ = val; } -KEYBOARD_INLINE void +INLINE void kset_input_decode_map (struct kboard *kb, Lisp_Object val) { - kb->INTERNAL_FIELD (Vinput_decode_map) = val; + kb->Vinput_decode_map_ = val; } -KEYBOARD_INLINE void +INLINE void kset_last_command (struct kboard *kb, Lisp_Object val) { - kb->INTERNAL_FIELD (Vlast_command) = val; + kb->Vlast_command_ = val; } -KEYBOARD_INLINE void +INLINE void kset_last_kbd_macro (struct kboard *kb, Lisp_Object val) { - kb->INTERNAL_FIELD (Vlast_kbd_macro) = val; + kb->Vlast_kbd_macro_ = val; } -KEYBOARD_INLINE void +INLINE void kset_prefix_arg (struct kboard *kb, Lisp_Object val) { - kb->INTERNAL_FIELD (Vprefix_arg) = val; + kb->Vprefix_arg_ = val; } -KEYBOARD_INLINE void +INLINE void kset_system_key_alist (struct kboard *kb, Lisp_Object val) { - kb->INTERNAL_FIELD (Vsystem_key_alist) = val; + kb->Vsystem_key_alist_ = val; } -KEYBOARD_INLINE void +INLINE void kset_window_system (struct kboard *kb, Lisp_Object val) { - kb->INTERNAL_FIELD (Vwindow_system) = val; + kb->Vwindow_system_ = val; } +union buffered_input_event +{ + ENUM_BF (event_kind) kind : EVENT_KIND_WIDTH; + struct input_event ie; +#ifdef HAVE_X11 + struct selection_input_event sie; +#endif +}; + /* Temporarily used before a frame has been opened. */ extern KBOARD *initial_kboard; @@ -230,13 +241,22 @@ extern KBOARD *initial_kboard; right now considering input. We can consider input from another kboard, but doing so requires throwing to wrong_kboard_jmpbuf. */ extern KBOARD *current_kboard; - -/* A list of all kboard objects, linked through next_kboard. */ -extern KBOARD *all_kboards; /* Total number of times read_char has returned, modulo UINTMAX_MAX + 1. */ extern uintmax_t num_input_events; +/* The location of point immediately before the last command was + executed, or the last time the undo-boundary command added a + boundary.*/ +extern ptrdiff_t point_before_last_command_or_undo; + +/* The value of current_buffer immediately before the last command was + executed, or the last time the undo-boundary command added a + boundary.*/ +extern struct buffer *buffer_before_last_command_or_undo; + +extern struct buffer *prev_buffer; + /* Nonzero means polling for input is temporarily suppressed. */ extern int poll_suppress_count; @@ -254,8 +274,6 @@ extern ptrdiff_t this_command_key_count; generated by the next character. */ extern Lisp_Object internal_last_event_frame; -extern Lisp_Object Qrecompute_lucid_menubar, Qactivate_menubar_hook; - /* This holds a Lisp vector that holds the properties of a single menu item while decoding it in parse_menu_item. Using a Lisp vector to hold this information while we decode it @@ -311,9 +329,7 @@ extern Lisp_Object menu_items; /* If non-nil, means that the global vars defined here are already in use. Used to detect cases where we try to re-enter this non-reentrant code. */ -#if defined USE_GTK || defined USE_MOTIF extern Lisp_Object menu_items_inuse; -#endif /* Number of slots currently allocated in menu_items. */ extern int menu_items_allocated; @@ -360,57 +376,6 @@ extern void unuse_menu_items (void); #define ENCODE_MENU_STRING(str) (str) #endif -#if defined (HAVE_NS) || defined (HAVE_NTGUI) || defined (USE_GTK) - -/* Definitions copied from lwlib.h */ - -enum button_type -{ - BUTTON_TYPE_NONE, - BUTTON_TYPE_TOGGLE, - BUTTON_TYPE_RADIO -}; - -/* This structure is based on the one in ../lwlib/lwlib.h, with unused portions - removed. No term uses these. */ -typedef struct _widget_value -{ - /* name of widget */ - Lisp_Object lname; - const char* name; - /* value (meaning depend on widget type) */ - const char* value; - /* keyboard equivalent. no implications for XtTranslations */ - Lisp_Object lkey; - const char* key; - /* Help string or nil if none. - GC finds this string through the frame's menu_bar_vector - or through menu_items. */ - Lisp_Object help; - /* true if enabled */ - unsigned char enabled; - /* true if selected */ - unsigned char selected; - /* The type of a button. */ - enum button_type button_type; -#if defined (HAVE_NTGUI) - /* true if menu title */ - unsigned char title; -#endif - /* Contents of the sub-widgets, also selected slot for checkbox */ - struct _widget_value* contents; - /* data passed to callback */ - void *call_data; - /* next one in the list */ - struct _widget_value* next; -#ifdef USE_GTK - struct _widget_value *free_list; -#endif -} widget_value; - -#endif /* HAVE_NS || HAVE_NTGUI */ - - /* Macros for dealing with lispy events. */ /* True if EVENT has data fields describing it (i.e. a mouse click). */ @@ -446,24 +411,10 @@ typedef struct _widget_value #define POSN_INBUFFER_P(posn) (NILP (POSN_STRING (posn))) #define POSN_BUFFER_POSN(posn) (Fnth (make_number (5), (posn))) -/* Some of the event heads. */ -extern Lisp_Object Qswitch_frame; - -/* Properties on event heads. */ -extern Lisp_Object Qevent_kind; - -/* The values of Qevent_kind properties. */ -extern Lisp_Object Qmouse_click; - -extern Lisp_Object Qhelp_echo; - /* Getting the kind of an event head. */ #define EVENT_HEAD_KIND(event_head) \ (Fget ((event_head), Qevent_kind)) -/* Symbols to use for non-text mouse positions. */ -extern Lisp_Object Qmode_line, Qvertical_line, Qheader_line; - /* True while doing kbd input. */ extern bool waiting_for_input; @@ -471,12 +422,7 @@ extern bool waiting_for_input; happens. */ extern struct timespec *input_available_clear_time; -#if defined HAVE_WINDOW_SYSTEM && !defined USE_GTK && !defined HAVE_NS extern bool ignore_mouse_drag_p; -#endif - -/* The primary selection. */ -extern Lisp_Object QPRIMARY; extern Lisp_Object parse_modifiers (Lisp_Object); extern Lisp_Object reorder_modifiers (Lisp_Object); @@ -488,21 +434,6 @@ extern int parse_solitary_modifier (Lisp_Object symbol); /* This is like Vthis_command, except that commands never set it. */ extern Lisp_Object real_this_command; -/* Non-nil disable property on a command means - do not execute it; call disabled-command-function's value instead. */ -extern Lisp_Object QCtoggle, QCradio; - -/* 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 - mask of modifiers applied to it. If present, this is used to help - speed up parse_modifiers. */ -extern Lisp_Object Qevent_symbol_element_mask; - -/* The timestamp of the last input event we received from the X server. - X Windows wants this for selection ownership. */ -extern Time last_event_timestamp; - extern int quit_char; extern unsigned int timers_run; @@ -510,7 +441,7 @@ extern unsigned int timers_run; extern bool menu_separator_name_p (const char *); extern bool parse_menu_item (Lisp_Object, int); -extern void init_kboard (KBOARD *); +extern KBOARD *allocate_kboard (Lisp_Object); extern void delete_kboard (KBOARD *); extern void not_single_kboard_state (KBOARD *); extern void push_kboard (struct kboard *); @@ -533,9 +464,20 @@ extern void clear_waiting_for_input (void); extern void swallow_events (bool); extern bool lucid_event_type_list_p (Lisp_Object); extern void kbd_buffer_store_event (struct input_event *); -extern void kbd_buffer_store_event_hold (struct input_event *, - struct input_event *); -extern void kbd_buffer_unget_event (struct input_event *); +extern void kbd_buffer_store_buffered_event (union buffered_input_event *, + struct input_event *); +INLINE void +kbd_buffer_store_event_hold (struct input_event *event, + struct input_event *hold_quit) +{ + verify (alignof (struct input_event) == alignof (union buffered_input_event) + && sizeof (struct input_event) == sizeof (union buffered_input_event)); + kbd_buffer_store_buffered_event ((union buffered_input_event *) event, + hold_quit); +} +#ifdef HAVE_X11 +extern void kbd_buffer_unget_event (struct selection_input_event *); +#endif extern void poll_for_input_1 (void); extern void show_help_echo (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object); @@ -555,3 +497,5 @@ extern const char *const lispy_function_keys[]; #endif INLINE_HEADER_END + +#endif /* EMACS_KEYBOARD_H */