diff options
| author | Po Lu | 2023-07-21 21:23:35 +0800 |
|---|---|---|
| committer | Po Lu | 2023-07-21 21:23:35 +0800 |
| commit | ae174f266d70f2d722545e77d3f85dd7d3f09a68 (patch) | |
| tree | 5e101bcf2b9836ca4f86108ff24e1ab1b95c4ae7 /src | |
| parent | 2df3f89014a39342c402637296ee88e3749f4918 (diff) | |
| download | emacs-ae174f266d70f2d722545e77d3f85dd7d3f09a68.tar.gz emacs-ae174f266d70f2d722545e77d3f85dd7d3f09a68.zip | |
Improve touch screen and text conversion behavior of many commands
* doc/lispref/commands.texi (Key Sequence Input): Document new
argument to `read-key-sequence' etc.
* lisp/help-macro.el (make-help-screen):
* lisp/subr.el (read-key, read-char-choice-with-read-key):
Disable text conversion and display the OSK before reading a key
sequence.
* lisp/touch-screen.el (touch-screen-window-selection-changed):
Only cancel the minibuffer OSK timer.
(touch-screen-handle-point-up): Update comment accordingly.
* src/keyboard.c (command_loop_1, read_menu_command)
(read_key_sequence, read_key_sequence_vs, Fread_key_sequence)
(Fread_key_sequence_vector): New arg DISABLE_TEXT_CONVERSION.
All callers changed.
Diffstat (limited to 'src')
| -rw-r--r-- | src/callint.c | 6 | ||||
| -rw-r--r-- | src/keyboard.c | 61 |
2 files changed, 50 insertions, 17 deletions
diff --git a/src/callint.c b/src/callint.c index d8d2b278458..00e9a080654 100644 --- a/src/callint.c +++ b/src/callint.c | |||
| @@ -537,7 +537,8 @@ invoke it (via an `interactive' spec that contains, for instance, an | |||
| 537 | make_fixnum (SCHARS (callint_message)), | 537 | make_fixnum (SCHARS (callint_message)), |
| 538 | Qface, Qminibuffer_prompt, callint_message); | 538 | Qface, Qminibuffer_prompt, callint_message); |
| 539 | args[i] = Fread_key_sequence (callint_message, | 539 | args[i] = Fread_key_sequence (callint_message, |
| 540 | Qnil, Qnil, Qnil, Qnil); | 540 | Qnil, Qnil, Qnil, Qnil, |
| 541 | Qnil); | ||
| 541 | unbind_to (speccount1, Qnil); | 542 | unbind_to (speccount1, Qnil); |
| 542 | visargs[i] = Fkey_description (args[i], Qnil); | 543 | visargs[i] = Fkey_description (args[i], Qnil); |
| 543 | 544 | ||
| @@ -567,7 +568,8 @@ invoke it (via an `interactive' spec that contains, for instance, an | |||
| 567 | make_fixnum (SCHARS (callint_message)), | 568 | make_fixnum (SCHARS (callint_message)), |
| 568 | Qface, Qminibuffer_prompt, callint_message); | 569 | Qface, Qminibuffer_prompt, callint_message); |
| 569 | args[i] = Fread_key_sequence_vector (callint_message, | 570 | args[i] = Fread_key_sequence_vector (callint_message, |
| 570 | Qnil, Qt, Qnil, Qnil); | 571 | Qnil, Qt, Qnil, Qnil, |
| 572 | Qnil); | ||
| 571 | visargs[i] = Fkey_description (args[i], Qnil); | 573 | visargs[i] = Fkey_description (args[i], Qnil); |
| 572 | unbind_to (speccount1, Qnil); | 574 | unbind_to (speccount1, Qnil); |
| 573 | 575 | ||
diff --git a/src/keyboard.c b/src/keyboard.c index 97172be8152..f60b5c95654 100644 --- a/src/keyboard.c +++ b/src/keyboard.c | |||
| @@ -1294,7 +1294,7 @@ some_mouse_moved (void) | |||
| 1294 | 1294 | ||
| 1295 | enum { READ_KEY_ELTS = 30 }; | 1295 | enum { READ_KEY_ELTS = 30 }; |
| 1296 | static int read_key_sequence (Lisp_Object *, Lisp_Object, | 1296 | static int read_key_sequence (Lisp_Object *, Lisp_Object, |
| 1297 | bool, bool, bool, bool); | 1297 | bool, bool, bool, bool, bool); |
| 1298 | static void adjust_point_for_property (ptrdiff_t, bool); | 1298 | static void adjust_point_for_property (ptrdiff_t, bool); |
| 1299 | 1299 | ||
| 1300 | static Lisp_Object | 1300 | static Lisp_Object |
| @@ -1405,7 +1405,8 @@ command_loop_1 (void) | |||
| 1405 | /* Read next key sequence; i gets its length. */ | 1405 | /* Read next key sequence; i gets its length. */ |
| 1406 | raw_keybuf_count = 0; | 1406 | raw_keybuf_count = 0; |
| 1407 | Lisp_Object keybuf[READ_KEY_ELTS]; | 1407 | Lisp_Object keybuf[READ_KEY_ELTS]; |
| 1408 | int i = read_key_sequence (keybuf, Qnil, false, true, true, false); | 1408 | int i = read_key_sequence (keybuf, Qnil, false, true, true, false, |
| 1409 | false); | ||
| 1409 | 1410 | ||
| 1410 | /* A filter may have run while we were reading the input. */ | 1411 | /* A filter may have run while we were reading the input. */ |
| 1411 | if (! FRAME_LIVE_P (XFRAME (selected_frame))) | 1412 | if (! FRAME_LIVE_P (XFRAME (selected_frame))) |
| @@ -1680,7 +1681,8 @@ read_menu_command (void) | |||
| 1680 | specbind (Qecho_keystrokes, make_fixnum (0)); | 1681 | specbind (Qecho_keystrokes, make_fixnum (0)); |
| 1681 | 1682 | ||
| 1682 | Lisp_Object keybuf[READ_KEY_ELTS]; | 1683 | Lisp_Object keybuf[READ_KEY_ELTS]; |
| 1683 | int i = read_key_sequence (keybuf, Qnil, false, true, true, true); | 1684 | int i = read_key_sequence (keybuf, Qnil, false, true, true, true, |
| 1685 | false); | ||
| 1684 | 1686 | ||
| 1685 | unbind_to (count, Qnil); | 1687 | unbind_to (count, Qnil); |
| 1686 | 1688 | ||
| @@ -10276,12 +10278,16 @@ restore_reading_key_sequence (int old_reading_key_sequence) | |||
| 10276 | read_char will return it. | 10278 | read_char will return it. |
| 10277 | 10279 | ||
| 10278 | If FIX_CURRENT_BUFFER, we restore current_buffer | 10280 | If FIX_CURRENT_BUFFER, we restore current_buffer |
| 10279 | from the selected window's buffer. */ | 10281 | from the selected window's buffer. |
| 10282 | |||
| 10283 | If DISABLE_TEXT_CONVERSION_P, disable text conversion so the input | ||
| 10284 | method will always send key events. */ | ||
| 10280 | 10285 | ||
| 10281 | static int | 10286 | static int |
| 10282 | read_key_sequence (Lisp_Object *keybuf, Lisp_Object prompt, | 10287 | read_key_sequence (Lisp_Object *keybuf, Lisp_Object prompt, |
| 10283 | bool dont_downcase_last, bool can_return_switch_frame, | 10288 | bool dont_downcase_last, bool can_return_switch_frame, |
| 10284 | bool fix_current_buffer, bool prevent_redisplay) | 10289 | bool fix_current_buffer, bool prevent_redisplay, |
| 10290 | bool disable_text_conversion_p) | ||
| 10285 | { | 10291 | { |
| 10286 | specpdl_ref count = SPECPDL_INDEX (); | 10292 | specpdl_ref count = SPECPDL_INDEX (); |
| 10287 | 10293 | ||
| @@ -10351,7 +10357,7 @@ read_key_sequence (Lisp_Object *keybuf, Lisp_Object prompt, | |||
| 10351 | 10357 | ||
| 10352 | /* Whether or not text conversion has already been disabled. */ | 10358 | /* Whether or not text conversion has already been disabled. */ |
| 10353 | disabled_conversion = false; | 10359 | disabled_conversion = false; |
| 10354 | #endif | 10360 | #endif /* HAVE_TEXT_CONVERSION */ |
| 10355 | 10361 | ||
| 10356 | struct buffer *starting_buffer; | 10362 | struct buffer *starting_buffer; |
| 10357 | 10363 | ||
| @@ -10445,6 +10451,18 @@ read_key_sequence (Lisp_Object *keybuf, Lisp_Object prompt, | |||
| 10445 | if (INTERACTIVE && t < mock_input) | 10451 | if (INTERACTIVE && t < mock_input) |
| 10446 | echo_truncate (echo_start); | 10452 | echo_truncate (echo_start); |
| 10447 | 10453 | ||
| 10454 | /* If text conversion is supposed to be disabled immediately, do it | ||
| 10455 | now. */ | ||
| 10456 | |||
| 10457 | #ifdef HAVE_TEXT_CONVERSION | ||
| 10458 | if (disable_text_conversion_p) | ||
| 10459 | { | ||
| 10460 | disable_text_conversion (); | ||
| 10461 | record_unwind_protect_void (resume_text_conversion); | ||
| 10462 | disabled_conversion = true; | ||
| 10463 | } | ||
| 10464 | #endif /* HAVE_TEXT_CONVERSION */ | ||
| 10465 | |||
| 10448 | /* If the best binding for the current key sequence is a keymap, or | 10466 | /* If the best binding for the current key sequence is a keymap, or |
| 10449 | we may be looking at a function key's escape sequence, keep on | 10467 | we may be looking at a function key's escape sequence, keep on |
| 10450 | reading. */ | 10468 | reading. */ |
| @@ -11279,7 +11297,8 @@ static Lisp_Object | |||
| 11279 | read_key_sequence_vs (Lisp_Object prompt, Lisp_Object continue_echo, | 11297 | read_key_sequence_vs (Lisp_Object prompt, Lisp_Object continue_echo, |
| 11280 | Lisp_Object dont_downcase_last, | 11298 | Lisp_Object dont_downcase_last, |
| 11281 | Lisp_Object can_return_switch_frame, | 11299 | Lisp_Object can_return_switch_frame, |
| 11282 | Lisp_Object cmd_loop, bool allow_string) | 11300 | Lisp_Object cmd_loop, bool allow_string, |
| 11301 | bool disable_text_conversion) | ||
| 11283 | { | 11302 | { |
| 11284 | specpdl_ref count = SPECPDL_INDEX (); | 11303 | specpdl_ref count = SPECPDL_INDEX (); |
| 11285 | 11304 | ||
| @@ -11306,7 +11325,8 @@ read_key_sequence_vs (Lisp_Object prompt, Lisp_Object continue_echo, | |||
| 11306 | raw_keybuf_count = 0; | 11325 | raw_keybuf_count = 0; |
| 11307 | Lisp_Object keybuf[READ_KEY_ELTS]; | 11326 | Lisp_Object keybuf[READ_KEY_ELTS]; |
| 11308 | int i = read_key_sequence (keybuf, prompt, ! NILP (dont_downcase_last), | 11327 | int i = read_key_sequence (keybuf, prompt, ! NILP (dont_downcase_last), |
| 11309 | ! NILP (can_return_switch_frame), false, false); | 11328 | ! NILP (can_return_switch_frame), false, false, |
| 11329 | disable_text_conversion); | ||
| 11310 | 11330 | ||
| 11311 | #if 0 /* The following is fine for code reading a key sequence and | 11331 | #if 0 /* The following is fine for code reading a key sequence and |
| 11312 | then proceeding with a lengthy computation, but it's not good | 11332 | then proceeding with a lengthy computation, but it's not good |
| @@ -11328,7 +11348,7 @@ read_key_sequence_vs (Lisp_Object prompt, Lisp_Object continue_echo, | |||
| 11328 | (i, keybuf))); | 11348 | (i, keybuf))); |
| 11329 | } | 11349 | } |
| 11330 | 11350 | ||
| 11331 | DEFUN ("read-key-sequence", Fread_key_sequence, Sread_key_sequence, 1, 5, 0, | 11351 | DEFUN ("read-key-sequence", Fread_key_sequence, Sread_key_sequence, 1, 6, 0, |
| 11332 | doc: /* Read a sequence of keystrokes and return as a string or vector. | 11352 | doc: /* Read a sequence of keystrokes and return as a string or vector. |
| 11333 | The sequence is sufficient to specify a non-prefix command in the | 11353 | The sequence is sufficient to specify a non-prefix command in the |
| 11334 | current local and global maps. | 11354 | current local and global maps. |
| @@ -11374,20 +11394,31 @@ sequences, where they wouldn't conflict with ordinary bindings. See | |||
| 11374 | The optional fifth argument CMD-LOOP, if non-nil, means | 11394 | The optional fifth argument CMD-LOOP, if non-nil, means |
| 11375 | that this key sequence is being read by something that will | 11395 | that this key sequence is being read by something that will |
| 11376 | read commands one after another. It should be nil if the caller | 11396 | read commands one after another. It should be nil if the caller |
| 11377 | will read just one key sequence. */) | 11397 | will read just one key sequence. |
| 11378 | (Lisp_Object prompt, Lisp_Object continue_echo, Lisp_Object dont_downcase_last, Lisp_Object can_return_switch_frame, Lisp_Object cmd_loop) | 11398 | |
| 11399 | The optional sixth argument DISABLE-TEXT-CONVERSION, if non-nil, means | ||
| 11400 | disable input method text conversion for the duration of reading this | ||
| 11401 | key sequence, and that keyboard input will always result in key events | ||
| 11402 | being sent. */) | ||
| 11403 | (Lisp_Object prompt, Lisp_Object continue_echo, Lisp_Object dont_downcase_last, | ||
| 11404 | Lisp_Object can_return_switch_frame, Lisp_Object cmd_loop, | ||
| 11405 | Lisp_Object disable_text_conversion) | ||
| 11379 | { | 11406 | { |
| 11380 | return read_key_sequence_vs (prompt, continue_echo, dont_downcase_last, | 11407 | return read_key_sequence_vs (prompt, continue_echo, dont_downcase_last, |
| 11381 | can_return_switch_frame, cmd_loop, true); | 11408 | can_return_switch_frame, cmd_loop, true, |
| 11409 | !NILP (disable_text_conversion)); | ||
| 11382 | } | 11410 | } |
| 11383 | 11411 | ||
| 11384 | DEFUN ("read-key-sequence-vector", Fread_key_sequence_vector, | 11412 | DEFUN ("read-key-sequence-vector", Fread_key_sequence_vector, |
| 11385 | Sread_key_sequence_vector, 1, 5, 0, | 11413 | Sread_key_sequence_vector, 1, 6, 0, |
| 11386 | doc: /* Like `read-key-sequence' but always return a vector. */) | 11414 | doc: /* Like `read-key-sequence' but always return a vector. */) |
| 11387 | (Lisp_Object prompt, Lisp_Object continue_echo, Lisp_Object dont_downcase_last, Lisp_Object can_return_switch_frame, Lisp_Object cmd_loop) | 11415 | (Lisp_Object prompt, Lisp_Object continue_echo, Lisp_Object dont_downcase_last, |
| 11416 | Lisp_Object can_return_switch_frame, Lisp_Object cmd_loop, | ||
| 11417 | Lisp_Object disable_text_conversion) | ||
| 11388 | { | 11418 | { |
| 11389 | return read_key_sequence_vs (prompt, continue_echo, dont_downcase_last, | 11419 | return read_key_sequence_vs (prompt, continue_echo, dont_downcase_last, |
| 11390 | can_return_switch_frame, cmd_loop, false); | 11420 | can_return_switch_frame, cmd_loop, false, |
| 11421 | !NILP (disable_text_conversion)); | ||
| 11391 | } | 11422 | } |
| 11392 | 11423 | ||
| 11393 | /* Return true if input events are pending. */ | 11424 | /* Return true if input events are pending. */ |