comparison src/gui_xim.c @ 20671:ccdd80a6dad7 v8.2.0889

patch 8.2.0889: using old style comments Commit: https://github.com/vim/vim/commit/791fb1bcda7cd1a388ad948cdef469a2744d6dff Author: Bram Moolenaar <Bram@vim.org> Date: Tue Jun 2 22:24:36 2020 +0200 patch 8.2.0889: using old style comments Problem: Using old style comments. Solution: Use // comments. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/6190)
author Bram Moolenaar <Bram@vim.org>
date Tue, 02 Jun 2020 22:30:04 +0200
parents 6c5b11458f31
children 2d3cd9acf853
comparison
equal deleted inserted replaced
20670:acdeafd06233 20671:ccdd80a6dad7
659 preedit_start_col = MAXCOL; 659 preedit_start_col = MAXCOL;
660 } 660 }
661 661
662 im_delete_preedit(); 662 im_delete_preedit();
663 663
664 /* 664 // Compute the end of the preediting area: "preedit_end_col".
665 * Compute the end of the preediting area: "preedit_end_col". 665 // According to the documentation of
666 * According to the documentation of gtk_im_context_get_preedit_string(), 666 // gtk_im_context_get_preedit_string(), the cursor_pos output argument
667 * the cursor_pos output argument returns the offset in bytes. This is 667 // returns the offset in bytes. This is unfortunately not true -- real
668 * unfortunately not true -- real life shows the offset is in characters, 668 // life shows the offset is in characters, and the GTK+ source code
669 * and the GTK+ source code agrees with me. Will file a bug later. 669 // agrees with me. Will file a bug later.
670 */
671 if (preedit_start_col != MAXCOL) 670 if (preedit_start_col != MAXCOL)
672 preedit_end_col = preedit_start_col; 671 preedit_end_col = preedit_start_col;
673 str = (char_u *)preedit_string; 672 str = (char_u *)preedit_string;
674 for (p = str, i = 0; *p != NUL; p += utf_byte2len(*p), ++i) 673 for (p = str, i = 0; *p != NUL; p += utf_byte2len(*p), ++i)
675 { 674 {
676 int is_composing; 675 int is_composing;
677 676
678 is_composing = ((*p & 0x80) != 0 && utf_iscomposing(utf_ptr2char(p))); 677 is_composing = ((*p & 0x80) != 0
679 /* 678 && utf_iscomposing(utf_ptr2char(p)));
680 * These offsets are used as counters when generating <BS> and <Del> 679 // These offsets are used as counters when generating <BS> and
681 * to delete the preedit string. So don't count composing characters 680 // <Del> to delete the preedit string. So don't count composing
682 * unless 'delcombine' is enabled. 681 // characters unless 'delcombine' is enabled.
683 */
684 if (!is_composing || p_deco) 682 if (!is_composing || p_deco)
685 { 683 {
686 if (i < cursor_index) 684 if (i < cursor_index)
687 ++im_preedit_cursor; 685 ++im_preedit_cursor;
688 else 686 else
991 int 989 int
992 xim_queue_key_press_event(GdkEventKey *event, int down) 990 xim_queue_key_press_event(GdkEventKey *event, int down)
993 { 991 {
994 if (down) 992 if (down)
995 { 993 {
996 /* 994 // Workaround GTK2 XIM 'feature' that always converts keypad keys to
997 * Workaround GTK2 XIM 'feature' that always converts keypad keys to 995 // chars., even when not part of an IM sequence (ref. feature of
998 * chars., even when not part of an IM sequence (ref. feature of 996 // gdk/gdkkeyuni.c).
999 * gdk/gdkkeyuni.c). 997 // Flag any keypad keys that might represent a single char.
1000 * Flag any keypad keys that might represent a single char. 998 // If this (on its own - i.e., not part of an IM sequence) is
1001 * If this (on its own - i.e., not part of an IM sequence) is 999 // committed while we're processing one of these keys, we can ignore
1002 * committed while we're processing one of these keys, we can ignore 1000 // that commit and go ahead & process it ourselves. That way we can
1003 * that commit and go ahead & process it ourselves. That way we can 1001 // still distinguish keypad keys for use in mappings.
1004 * still distinguish keypad keys for use in mappings. 1002 // Also add GDK_space to make <S-Space> work.
1005 * Also add GDK_space to make <S-Space> work.
1006 */
1007 switch (event->keyval) 1003 switch (event->keyval)
1008 { 1004 {
1009 case GDK_KP_Add: xim_expected_char = '+'; break; 1005 case GDK_KP_Add: xim_expected_char = '+'; break;
1010 case GDK_KP_Subtract: xim_expected_char = '-'; break; 1006 case GDK_KP_Subtract: xim_expected_char = '-'; break;
1011 case GDK_KP_Divide: xim_expected_char = '/'; break; 1007 case GDK_KP_Divide: xim_expected_char = '/'; break;
1026 default: xim_expected_char = NUL; 1022 default: xim_expected_char = NUL;
1027 } 1023 }
1028 xim_ignored_char = FALSE; 1024 xim_ignored_char = FALSE;
1029 } 1025 }
1030 1026
1031 /* 1027 // When typing fFtT, XIM may be activated. Thus it must pass
1032 * When typing fFtT, XIM may be activated. Thus it must pass 1028 // gtk_im_context_filter_keypress() in Normal mode.
1033 * gtk_im_context_filter_keypress() in Normal mode. 1029 // And while doing :sh too.
1034 * And while doing :sh too.
1035 */
1036 if (xic != NULL && !p_imdisable 1030 if (xic != NULL && !p_imdisable
1037 && (State & (INSERT | CMDLINE | NORMAL | EXTERNCMD)) != 0) 1031 && (State & (INSERT | CMDLINE | NORMAL | EXTERNCMD)) != 0)
1038 { 1032 {
1039 /* 1033 // Filter 'imactivatekey' and map it to CTRL-^. This way, Vim is
1040 * Filter 'imactivatekey' and map it to CTRL-^. This way, Vim is 1034 // always aware of the current status of IM, and can even emulate
1041 * always aware of the current status of IM, and can even emulate 1035 // the activation key for modules that don't support one.
1042 * the activation key for modules that don't support one.
1043 */
1044 if (event->keyval == im_activatekey_keyval 1036 if (event->keyval == im_activatekey_keyval
1045 && (event->state & im_activatekey_state) == im_activatekey_state) 1037 && (event->state & im_activatekey_state) == im_activatekey_state)
1046 { 1038 {
1047 unsigned int state_mask; 1039 unsigned int state_mask;
1048 1040
1203 xim_set_focus(int focus) 1195 xim_set_focus(int focus)
1204 { 1196 {
1205 if (xic == NULL) 1197 if (xic == NULL)
1206 return; 1198 return;
1207 1199
1208 /* 1200 // XIM only gets focus when the Vim window has keyboard focus and XIM has
1209 * XIM only gets focus when the Vim window has keyboard focus and XIM has 1201 // been set active for the current mode.
1210 * been set active for the current mode.
1211 */
1212 if (focus && xim_is_active) 1202 if (focus && xim_is_active)
1213 { 1203 {
1214 if (!xim_has_focus) 1204 if (!xim_has_focus)
1215 { 1205 {
1216 xim_has_focus = TRUE; 1206 xim_has_focus = TRUE;