aboutsummaryrefslogtreecommitdiffstats
path: root/src/keyboard.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/keyboard.c')
-rw-r--r--src/keyboard.c180
1 files changed, 73 insertions, 107 deletions
diff --git a/src/keyboard.c b/src/keyboard.c
index a2f772dea8a..5996986bfb4 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -425,7 +425,9 @@ static Lisp_Object modify_event_symbol (ptrdiff_t, int, Lisp_Object,
425 Lisp_Object *, ptrdiff_t); 425 Lisp_Object *, ptrdiff_t);
426static Lisp_Object make_lispy_switch_frame (Lisp_Object); 426static Lisp_Object make_lispy_switch_frame (Lisp_Object);
427static Lisp_Object make_lispy_focus_in (Lisp_Object); 427static Lisp_Object make_lispy_focus_in (Lisp_Object);
428#ifdef HAVE_WINDOW_SYSTEM
428static Lisp_Object make_lispy_focus_out (Lisp_Object); 429static Lisp_Object make_lispy_focus_out (Lisp_Object);
430#endif /* HAVE_WINDOW_SYSTEM */
429static bool help_char_p (Lisp_Object); 431static bool help_char_p (Lisp_Object);
430static void save_getcjmp (sys_jmp_buf); 432static void save_getcjmp (sys_jmp_buf);
431static void restore_getcjmp (sys_jmp_buf); 433static void restore_getcjmp (sys_jmp_buf);
@@ -3213,6 +3215,8 @@ read_char (int commandflag, Lisp_Object map,
3213 RETURN_UNGCPRO (c); 3215 RETURN_UNGCPRO (c);
3214} 3216}
3215 3217
3218#ifdef HAVE_MENUS
3219
3216/* Record a key that came from a mouse menu. 3220/* Record a key that came from a mouse menu.
3217 Record it for echoing, for this-command-keys, and so on. */ 3221 Record it for echoing, for this-command-keys, and so on. */
3218 3222
@@ -3248,6 +3252,8 @@ record_menu_key (Lisp_Object c)
3248 num_input_events++; 3252 num_input_events++;
3249} 3253}
3250 3254
3255#endif /* HAVE_MENUS */
3256
3251/* Return true if should recognize C as "the help character". */ 3257/* Return true if should recognize C as "the help character". */
3252 3258
3253static bool 3259static bool
@@ -6095,12 +6101,17 @@ make_lispy_focus_in (Lisp_Object frame)
6095{ 6101{
6096 return list2 (Qfocus_in, frame); 6102 return list2 (Qfocus_in, frame);
6097} 6103}
6104
6105#ifdef HAVE_WINDOW_SYSTEM
6106
6098static Lisp_Object 6107static Lisp_Object
6099make_lispy_focus_out (Lisp_Object frame) 6108make_lispy_focus_out (Lisp_Object frame)
6100{ 6109{
6101 return list2 (Qfocus_out, frame); 6110 return list2 (Qfocus_out, frame);
6102} 6111}
6103 6112
6113#endif /* HAVE_WINDOW_SYSTEM */
6114
6104/* Manipulating modifiers. */ 6115/* Manipulating modifiers. */
6105 6116
6106/* Parse the name of SYMBOL, and return the set of modifiers it contains. 6117/* Parse the name of SYMBOL, and return the set of modifiers it contains.
@@ -9738,54 +9749,11 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
9738 return t; 9749 return t;
9739} 9750}
9740 9751
9741DEFUN ("read-key-sequence", Fread_key_sequence, Sread_key_sequence, 1, 5, 0, 9752static Lisp_Object
9742 doc: /* Read a sequence of keystrokes and return as a string or vector. 9753read_key_sequence_vs (Lisp_Object prompt, Lisp_Object continue_echo,
9743The sequence is sufficient to specify a non-prefix command in the 9754 Lisp_Object dont_downcase_last,
9744current local and global maps. 9755 Lisp_Object can_return_switch_frame,
9745 9756 Lisp_Object cmd_loop, bool allow_string)
9746First arg PROMPT is a prompt string. If nil, do not prompt specially.
9747Second (optional) arg CONTINUE-ECHO, if non-nil, means this key echos
9748as a continuation of the previous key.
9749
9750The third (optional) arg DONT-DOWNCASE-LAST, if non-nil, means do not
9751convert the last event to lower case. (Normally any upper case event
9752is converted to lower case if the original event is undefined and the lower
9753case equivalent is defined.) A non-nil value is appropriate for reading
9754a key sequence to be defined.
9755
9756A C-g typed while in this function is treated like any other character,
9757and `quit-flag' is not set.
9758
9759If the key sequence starts with a mouse click, then the sequence is read
9760using the keymaps of the buffer of the window clicked in, not the buffer
9761of the selected window as normal.
9762
9763`read-key-sequence' drops unbound button-down events, since you normally
9764only care about the click or drag events which follow them. If a drag
9765or multi-click event is unbound, but the corresponding click event would
9766be bound, `read-key-sequence' turns the event into a click event at the
9767drag's starting position. This means that you don't have to distinguish
9768between click and drag, double, or triple events unless you want to.
9769
9770`read-key-sequence' prefixes mouse events on mode lines, the vertical
9771lines separating windows, and scroll bars with imaginary keys
9772`mode-line', `vertical-line', and `vertical-scroll-bar'.
9773
9774Optional fourth argument CAN-RETURN-SWITCH-FRAME non-nil means that this
9775function will process a switch-frame event if the user switches frames
9776before typing anything. If the user switches frames in the middle of a
9777key sequence, or at the start of the sequence but CAN-RETURN-SWITCH-FRAME
9778is nil, then the event will be put off until after the current key sequence.
9779
9780`read-key-sequence' checks `function-key-map' for function key
9781sequences, where they wouldn't conflict with ordinary bindings. See
9782`function-key-map' for more details.
9783
9784The optional fifth argument CMD-LOOP, if non-nil, means
9785that this key sequence is being read by something that will
9786read commands one after another. It should be nil if the caller
9787will read just one key sequence. */)
9788 (Lisp_Object prompt, Lisp_Object continue_echo, Lisp_Object dont_downcase_last, Lisp_Object can_return_switch_frame, Lisp_Object cmd_loop)
9789{ 9757{
9790 Lisp_Object keybuf[30]; 9758 Lisp_Object keybuf[30];
9791 register int i; 9759 register int i;
@@ -9836,60 +9804,71 @@ will read just one key sequence. */)
9836 QUIT; 9804 QUIT;
9837 } 9805 }
9838 UNGCPRO; 9806 UNGCPRO;
9839 return unbind_to (count, make_event_array (i, keybuf)); 9807 return unbind_to (count,
9808 ((allow_string ? make_event_array : Fvector)
9809 (i, keybuf)));
9840} 9810}
9841 9811
9842DEFUN ("read-key-sequence-vector", Fread_key_sequence_vector, 9812DEFUN ("read-key-sequence", Fread_key_sequence, Sread_key_sequence, 1, 5, 0,
9843 Sread_key_sequence_vector, 1, 5, 0, 9813 doc: /* Read a sequence of keystrokes and return as a string or vector.
9844 doc: /* Like `read-key-sequence' but always return a vector. */) 9814The sequence is sufficient to specify a non-prefix command in the
9845 (Lisp_Object prompt, Lisp_Object continue_echo, Lisp_Object dont_downcase_last, Lisp_Object can_return_switch_frame, Lisp_Object cmd_loop) 9815current local and global maps.
9846{
9847 Lisp_Object keybuf[30];
9848 register int i;
9849 struct gcpro gcpro1;
9850 ptrdiff_t count = SPECPDL_INDEX ();
9851 9816
9852 if (!NILP (prompt)) 9817First arg PROMPT is a prompt string. If nil, do not prompt specially.
9853 CHECK_STRING (prompt); 9818Second (optional) arg CONTINUE-ECHO, if non-nil, means this key echos
9854 QUIT; 9819as a continuation of the previous key.
9855 9820
9856 specbind (Qinput_method_exit_on_first_char, 9821The third (optional) arg DONT-DOWNCASE-LAST, if non-nil, means do not
9857 (NILP (cmd_loop) ? Qt : Qnil)); 9822convert the last event to lower case. (Normally any upper case event
9858 specbind (Qinput_method_use_echo_area, 9823is converted to lower case if the original event is undefined and the lower
9859 (NILP (cmd_loop) ? Qt : Qnil)); 9824case equivalent is defined.) A non-nil value is appropriate for reading
9825a key sequence to be defined.
9860 9826
9861 memset (keybuf, 0, sizeof keybuf); 9827A C-g typed while in this function is treated like any other character,
9862 GCPRO1 (keybuf[0]); 9828and `quit-flag' is not set.
9863 gcpro1.nvars = (sizeof keybuf / sizeof (keybuf[0]));
9864 9829
9865 if (NILP (continue_echo)) 9830If the key sequence starts with a mouse click, then the sequence is read
9866 { 9831using the keymaps of the buffer of the window clicked in, not the buffer
9867 this_command_key_count = 0; 9832of the selected window as normal.
9868 this_command_key_count_reset = 0;
9869 this_single_command_key_start = 0;
9870 }
9871 9833
9872#ifdef HAVE_WINDOW_SYSTEM 9834`read-key-sequence' drops unbound button-down events, since you normally
9873 if (display_hourglass_p) 9835only care about the click or drag events which follow them. If a drag
9874 cancel_hourglass (); 9836or multi-click event is unbound, but the corresponding click event would
9875#endif 9837be bound, `read-key-sequence' turns the event into a click event at the
9838drag's starting position. This means that you don't have to distinguish
9839between click and drag, double, or triple events unless you want to.
9876 9840
9877 i = read_key_sequence (keybuf, (sizeof keybuf / sizeof (keybuf[0])), 9841`read-key-sequence' prefixes mouse events on mode lines, the vertical
9878 prompt, ! NILP (dont_downcase_last), 9842lines separating windows, and scroll bars with imaginary keys
9879 ! NILP (can_return_switch_frame), 0); 9843`mode-line', `vertical-line', and `vertical-scroll-bar'.
9880 9844
9881#ifdef HAVE_WINDOW_SYSTEM 9845Optional fourth argument CAN-RETURN-SWITCH-FRAME non-nil means that this
9882 if (display_hourglass_p) 9846function will process a switch-frame event if the user switches frames
9883 start_hourglass (); 9847before typing anything. If the user switches frames in the middle of a
9884#endif 9848key sequence, or at the start of the sequence but CAN-RETURN-SWITCH-FRAME
9849is nil, then the event will be put off until after the current key sequence.
9885 9850
9886 if (i == -1) 9851`read-key-sequence' checks `function-key-map' for function key
9887 { 9852sequences, where they wouldn't conflict with ordinary bindings. See
9888 Vquit_flag = Qt; 9853`function-key-map' for more details.
9889 QUIT; 9854
9890 } 9855The optional fifth argument CMD-LOOP, if non-nil, means
9891 UNGCPRO; 9856that this key sequence is being read by something that will
9892 return unbind_to (count, Fvector (i, keybuf)); 9857read commands one after another. It should be nil if the caller
9858will read just one key sequence. */)
9859 (Lisp_Object prompt, Lisp_Object continue_echo, Lisp_Object dont_downcase_last, Lisp_Object can_return_switch_frame, Lisp_Object cmd_loop)
9860{
9861 return read_key_sequence_vs (prompt, continue_echo, dont_downcase_last,
9862 can_return_switch_frame, cmd_loop, true);
9863}
9864
9865DEFUN ("read-key-sequence-vector", Fread_key_sequence_vector,
9866 Sread_key_sequence_vector, 1, 5, 0,
9867 doc: /* Like `read-key-sequence' but always return a vector. */)
9868 (Lisp_Object prompt, Lisp_Object continue_echo, Lisp_Object dont_downcase_last, Lisp_Object can_return_switch_frame, Lisp_Object cmd_loop)
9869{
9870 return read_key_sequence_vs (prompt, continue_echo, dont_downcase_last,
9871 can_return_switch_frame, cmd_loop, false);
9893} 9872}
9894 9873
9895/* Return true if input events are pending. */ 9874/* Return true if input events are pending. */
@@ -9920,20 +9899,7 @@ detect_input_pending_run_timers (bool do_display)
9920 get_input_pending (READABLE_EVENTS_DO_TIMERS_NOW); 9899 get_input_pending (READABLE_EVENTS_DO_TIMERS_NOW);
9921 9900
9922 if (old_timers_run != timers_run && do_display) 9901 if (old_timers_run != timers_run && do_display)
9923 { 9902 redisplay_preserve_echo_area (8);
9924 redisplay_preserve_echo_area (8);
9925 /* The following fixes a bug when using lazy-lock with
9926 lazy-lock-defer-on-the-fly set to t, i.e. when fontifying
9927 from an idle timer function. The symptom of the bug is that
9928 the cursor sometimes doesn't become visible until the next X
9929 event is processed. --gerd. */
9930 {
9931 Lisp_Object tail, frame;
9932 FOR_EACH_FRAME (tail, frame)
9933 if (FRAME_RIF (XFRAME (frame)))
9934 FRAME_RIF (XFRAME (frame))->flush_display (XFRAME (frame));
9935 }
9936 }
9937 9903
9938 return input_pending; 9904 return input_pending;
9939} 9905}