annotate src/gui_xim.c @ 34034:0794154316d1

runtime(Filelist): remove coveralls, move runtime/lang/Make_mvc.mak (#13790) Commit: https://github.com/vim/vim/commit/53860eb9ce6c5490ded1372607b18bb895bb2461 Author: Restorer <69863286+RestorerZ@users.noreply.github.com> Date: Fri Dec 29 01:11:48 2023 +0300 runtime(Filelist): remove coveralls, move runtime/lang/Make_mvc.mak (https://github.com/vim/vim/issues/13790) - File coveralls.yml removed from $(SRC_ALL), in patch 9.0.1752 (https://github.com/vim/vim/issues/12851) - runtime/lang/Make_mvc.mak moved from $(LANG_DOS) to $(RT_DOS) Signed-off-by: RestorerZ <restorer@mail2k.ru> Signed-off-by: Christian Brabandt <cb@256bit.org>
author Christian Brabandt <cb@256bit.org>
date Thu, 28 Dec 2023 23:15:07 +0100
parents 4545f58c8490
children 1629cc65d78d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
20637
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1 /* vi:set ts=8 sts=4 sw=4 noet:
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2 *
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3 * VIM - Vi IMproved by Bram Moolenaar
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4 *
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5 * Do ":help uganda" in Vim to read copying and usage conditions.
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
6 * Do ":help credits" in Vim to see a list of people who contributed.
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
7 * See README.txt for an overview of the Vim source code.
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
8 */
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
9
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
10 /*
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
11 * gui_xim.c: functions for the X Input Method
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
12 */
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
13
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
14 #include "vim.h"
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
15
31996
ca6bc7c04163 patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents: 31859
diff changeset
16 #if !defined(GTK_CHECK_VERSION)
ca6bc7c04163 patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents: 31859
diff changeset
17 # define GTK_CHECK_VERSION(a, b, c) 0
ca6bc7c04163 patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents: 31859
diff changeset
18 #endif
ca6bc7c04163 patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents: 31859
diff changeset
19 #if !defined(FEAT_GUI_GTK) && defined(PROTO)
ca6bc7c04163 patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents: 31859
diff changeset
20 typedef int GtkWidget;
ca6bc7c04163 patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents: 31859
diff changeset
21 typedef int GtkIMContext;
ca6bc7c04163 patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents: 31859
diff changeset
22 typedef int gchar;
ca6bc7c04163 patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents: 31859
diff changeset
23 typedef int gpointer;
ca6bc7c04163 patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents: 31859
diff changeset
24 typedef int PangoAttrIterator;
ca6bc7c04163 patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents: 31859
diff changeset
25 typedef int GdkEventKey;
ca6bc7c04163 patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents: 31859
diff changeset
26 #endif
ca6bc7c04163 patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents: 31859
diff changeset
27
20637
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
28 #if defined(FEAT_GUI_GTK) && defined(FEAT_XIM)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
29 # if GTK_CHECK_VERSION(3,0,0)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
30 # include <gdk/gdkkeysyms-compat.h>
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
31 # else
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
32 # include <gdk/gdkkeysyms.h>
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
33 # endif
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
34 # ifdef MSWIN
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
35 # include <gdk/gdkwin32.h>
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
36 # else
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
37 # include <gdk/gdkx.h>
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
38 # endif
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
39 #endif
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
40
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
41 /*
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
42 * XIM often causes trouble. Define XIM_DEBUG to get a log of XIM callbacks
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
43 * in the "xim.log" file.
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
44 */
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
45 // #define XIM_DEBUG
25475
038eb6d9003a patch 8.2.3274: macro for printf format check can be simplified
Bram Moolenaar <Bram@vim.org>
parents: 24162
diff changeset
46 #if defined(XIM_DEBUG) && defined(FEAT_GUI_GTK)
038eb6d9003a patch 8.2.3274: macro for printf format check can be simplified
Bram Moolenaar <Bram@vim.org>
parents: 24162
diff changeset
47 static void xim_log(char *s, ...) ATTRIBUTE_FORMAT_PRINTF(1, 2);
038eb6d9003a patch 8.2.3274: macro for printf format check can be simplified
Bram Moolenaar <Bram@vim.org>
parents: 24162
diff changeset
48
20637
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
49 static void
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
50 xim_log(char *s, ...)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
51 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
52 va_list arglist;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
53 static FILE *fd = NULL;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
54
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
55 if (fd == (FILE *)-1)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
56 return;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
57 if (fd == NULL)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
58 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
59 fd = mch_fopen("xim.log", "w");
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
60 if (fd == NULL)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
61 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
62 emsg("Cannot open xim.log");
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
63 fd = (FILE *)-1;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
64 return;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
65 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
66 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
67
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
68 va_start(arglist, s);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
69 vfprintf(fd, s, arglist);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
70 va_end(arglist);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
71 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
72 #endif
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
73
21112
2d3cd9acf853 patch 8.2.1107: 'imactivatefunc' and 'imstatusfunc' are not used in the GUI
Bram Moolenaar <Bram@vim.org>
parents: 20671
diff changeset
74 #if defined(FEAT_GUI_MSWIN)
20637
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
75 # define USE_IMACTIVATEFUNC (!gui.in_use && *p_imaf != NUL)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
76 # define USE_IMSTATUSFUNC (!gui.in_use && *p_imsf != NUL)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
77 #else
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
78 # define USE_IMACTIVATEFUNC (*p_imaf != NUL)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
79 # define USE_IMSTATUSFUNC (*p_imsf != NUL)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
80 #endif
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
81
26408
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 25475
diff changeset
82 #if (defined(FEAT_EVAL) && \
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 25475
diff changeset
83 (defined(FEAT_XIM) || defined(IME_WITHOUT_XIM) || defined(VIMDLL))) || \
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 25475
diff changeset
84 defined(PROTO)
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 25475
diff changeset
85 static callback_T imaf_cb; // 'imactivatefunc' callback function
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 25475
diff changeset
86 static callback_T imsf_cb; // 'imstatusfunc' callback function
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 25475
diff changeset
87
31859
8b15e4161605 patch 9.0.1262: the did_set_string_option function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31651
diff changeset
88 char *
31996
ca6bc7c04163 patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents: 31859
diff changeset
89 did_set_imactivatefunc(optset_T *args UNUSED)
26408
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 25475
diff changeset
90 {
31859
8b15e4161605 patch 9.0.1262: the did_set_string_option function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31651
diff changeset
91 if (option_set_callback_func(p_imaf, &imaf_cb) == FAIL)
8b15e4161605 patch 9.0.1262: the did_set_string_option function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31651
diff changeset
92 return e_invalid_argument;
8b15e4161605 patch 9.0.1262: the did_set_string_option function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31651
diff changeset
93
8b15e4161605 patch 9.0.1262: the did_set_string_option function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31651
diff changeset
94 return NULL;
26408
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 25475
diff changeset
95 }
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 25475
diff changeset
96
31859
8b15e4161605 patch 9.0.1262: the did_set_string_option function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31651
diff changeset
97 char *
31996
ca6bc7c04163 patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents: 31859
diff changeset
98 did_set_imstatusfunc(optset_T *args UNUSED)
26408
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 25475
diff changeset
99 {
31859
8b15e4161605 patch 9.0.1262: the did_set_string_option function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31651
diff changeset
100 if (option_set_callback_func(p_imsf, &imsf_cb) == FAIL)
8b15e4161605 patch 9.0.1262: the did_set_string_option function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31651
diff changeset
101 return e_invalid_argument;
8b15e4161605 patch 9.0.1262: the did_set_string_option function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31651
diff changeset
102
8b15e4161605 patch 9.0.1262: the did_set_string_option function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31651
diff changeset
103 return NULL;
26408
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 25475
diff changeset
104 }
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 25475
diff changeset
105
20637
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
106 static void
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
107 call_imactivatefunc(int active)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
108 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
109 typval_T argv[2];
28996
54247d52bee9 patch 8.2.5020: using 'imstatusfunc' and 'imactivatefunc' breaks 'foldopen'
Bram Moolenaar <Bram@vim.org>
parents: 28773
diff changeset
110 int save_KeyTyped = KeyTyped;
20637
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
111
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
112 argv[0].v_type = VAR_NUMBER;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
113 argv[0].vval.v_number = active ? 1 : 0;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
114 argv[1].v_type = VAR_UNKNOWN;
26408
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 25475
diff changeset
115 (void)call_callback_retnr(&imaf_cb, 1, argv);
28996
54247d52bee9 patch 8.2.5020: using 'imstatusfunc' and 'imactivatefunc' breaks 'foldopen'
Bram Moolenaar <Bram@vim.org>
parents: 28773
diff changeset
116
54247d52bee9 patch 8.2.5020: using 'imstatusfunc' and 'imactivatefunc' breaks 'foldopen'
Bram Moolenaar <Bram@vim.org>
parents: 28773
diff changeset
117 KeyTyped = save_KeyTyped;
20637
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
118 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
119
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
120 static int
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
121 call_imstatusfunc(void)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
122 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
123 int is_active;
28996
54247d52bee9 patch 8.2.5020: using 'imstatusfunc' and 'imactivatefunc' breaks 'foldopen'
Bram Moolenaar <Bram@vim.org>
parents: 28773
diff changeset
124 int save_KeyTyped = KeyTyped;
20637
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
125
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
126 // FIXME: Don't execute user function in unsafe situation.
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
127 if (exiting || is_autocmd_blocked())
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
128 return FALSE;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
129 // FIXME: :py print 'xxx' is shown duplicate result.
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
130 // Use silent to avoid it.
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
131 ++msg_silent;
26408
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 25475
diff changeset
132 is_active = call_callback_retnr(&imsf_cb, 0, NULL);
20637
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
133 --msg_silent;
28996
54247d52bee9 patch 8.2.5020: using 'imstatusfunc' and 'imactivatefunc' breaks 'foldopen'
Bram Moolenaar <Bram@vim.org>
parents: 28773
diff changeset
134
54247d52bee9 patch 8.2.5020: using 'imstatusfunc' and 'imactivatefunc' breaks 'foldopen'
Bram Moolenaar <Bram@vim.org>
parents: 28773
diff changeset
135 KeyTyped = save_KeyTyped;
20637
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
136 return (is_active > 0);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
137 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
138 #endif
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
139
26408
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 25475
diff changeset
140 #if defined(EXITFREE) || defined(PROTO)
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 25475
diff changeset
141 void
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 25475
diff changeset
142 free_xim_stuff(void)
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 25475
diff changeset
143 {
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26408
diff changeset
144 # if defined(FEAT_EVAL) && \
26408
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 25475
diff changeset
145 (defined(FEAT_XIM) || defined(IME_WITHOUT_XIM) || defined(VIMDLL))
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 25475
diff changeset
146 free_callback(&imaf_cb);
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 25475
diff changeset
147 free_callback(&imsf_cb);
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 25475
diff changeset
148 # endif
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 25475
diff changeset
149 }
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 25475
diff changeset
150 #endif
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 25475
diff changeset
151
27018
268f6a3511df patch 8.2.4038: various code not used when features are disabled
Bram Moolenaar <Bram@vim.org>
parents: 26897
diff changeset
152 #if defined(FEAT_EVAL) || defined(PROTO)
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26408
diff changeset
153 /*
31201
b1c66bff0a66 patch 9.0.0934: various code formatting issues
Bram Moolenaar <Bram@vim.org>
parents: 29865
diff changeset
154 * Mark the global 'imactivatefunc' and 'imstatusfunc' callbacks with "copyID"
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26408
diff changeset
155 * so that they are not garbage collected.
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26408
diff changeset
156 */
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26408
diff changeset
157 int
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26408
diff changeset
158 set_ref_in_im_funcs(int copyID UNUSED)
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26408
diff changeset
159 {
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26408
diff changeset
160 int abort = FALSE;
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26408
diff changeset
161
27018
268f6a3511df patch 8.2.4038: various code not used when features are disabled
Bram Moolenaar <Bram@vim.org>
parents: 26897
diff changeset
162 # if defined(FEAT_XIM) || defined(IME_WITHOUT_XIM) || defined(VIMDLL)
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26408
diff changeset
163 abort = set_ref_in_callback(&imaf_cb, copyID);
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26408
diff changeset
164 abort = abort || set_ref_in_callback(&imsf_cb, copyID);
27018
268f6a3511df patch 8.2.4038: various code not used when features are disabled
Bram Moolenaar <Bram@vim.org>
parents: 26897
diff changeset
165 # endif
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26408
diff changeset
166
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26408
diff changeset
167 return abort;
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26408
diff changeset
168 }
27018
268f6a3511df patch 8.2.4038: various code not used when features are disabled
Bram Moolenaar <Bram@vim.org>
parents: 26897
diff changeset
169 #endif
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26408
diff changeset
170
26408
8f17f8f327f3 patch 8.2.3735: cannot use a lambda for 'imactivatefunc'
Bram Moolenaar <Bram@vim.org>
parents: 25475
diff changeset
171
20637
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
172 #if defined(FEAT_XIM) || defined(PROTO)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
173
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
174 # if defined(FEAT_GUI_GTK) || defined(PROTO)
29865
4291eb97e479 patch 9.0.0271: using INIT() in non-header files
Bram Moolenaar <Bram@vim.org>
parents: 28996
diff changeset
175 static int xim_has_preediting = FALSE; // IM current status
20637
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
176
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
177 /*
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
178 * Set preedit_start_col to the current cursor position.
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
179 */
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
180 static void
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
181 init_preedit_start_col(void)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
182 {
28773
d770568e6c98 patch 8.2.4911: the mode #defines are not clearly named
Bram Moolenaar <Bram@vim.org>
parents: 27018
diff changeset
183 if (State & MODE_CMDLINE)
20637
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
184 preedit_start_col = cmdline_getvcol_cursor();
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
185 else if (curwin != NULL && curwin->w_buffer != NULL)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
186 getvcol(curwin, &curwin->w_cursor, &preedit_start_col, NULL, NULL);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
187 // Prevent that preediting marks the buffer as changed.
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
188 xim_changed_while_preediting = curbuf->b_changed;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
189 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
190
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
191 static int im_is_active = FALSE; // IM is enabled for current mode
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
192 static int preedit_is_active = FALSE;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
193 static int im_preedit_cursor = 0; // cursor offset in characters
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
194 static int im_preedit_trailing = 0; // number of characters after cursor
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
195
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
196 static unsigned long im_commit_handler_id = 0;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
197 static unsigned int im_activatekey_keyval = GDK_VoidSymbol;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
198 static unsigned int im_activatekey_state = 0;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
199
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
200 static GtkWidget *preedit_window = NULL;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
201 static GtkWidget *preedit_label = NULL;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
202
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
203 static void im_preedit_window_set_position(void);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
204
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
205 void
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
206 im_set_active(int active)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
207 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
208 int was_active;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
209
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
210 was_active = !!im_get_status();
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
211 im_is_active = (active && !p_imdisable);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
212
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
213 if (im_is_active != was_active)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
214 xim_reset();
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
215 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
216
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
217 void
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
218 xim_set_focus(int focus)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
219 {
31651
e5ee2ffd826a patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31201
diff changeset
220 if (xic == NULL)
e5ee2ffd826a patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31201
diff changeset
221 return;
e5ee2ffd826a patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31201
diff changeset
222
e5ee2ffd826a patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31201
diff changeset
223 if (focus)
e5ee2ffd826a patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31201
diff changeset
224 gtk_im_context_focus_in(xic);
e5ee2ffd826a patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31201
diff changeset
225 else
e5ee2ffd826a patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31201
diff changeset
226 gtk_im_context_focus_out(xic);
20637
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
227 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
228
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
229 void
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
230 im_set_position(int row, int col)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
231 {
31651
e5ee2ffd826a patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31201
diff changeset
232 if (xic == NULL)
e5ee2ffd826a patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31201
diff changeset
233 return;
e5ee2ffd826a patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31201
diff changeset
234
e5ee2ffd826a patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31201
diff changeset
235 GdkRectangle area;
20637
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
236
31651
e5ee2ffd826a patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31201
diff changeset
237 area.x = FILL_X(col);
e5ee2ffd826a patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31201
diff changeset
238 area.y = FILL_Y(row);
e5ee2ffd826a patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31201
diff changeset
239 area.width = gui.char_width * (mb_lefthalve(row, col) ? 2 : 1);
e5ee2ffd826a patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31201
diff changeset
240 area.height = gui.char_height;
20637
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
241
31651
e5ee2ffd826a patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31201
diff changeset
242 gtk_im_context_set_cursor_location(xic, &area);
20637
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
243
31651
e5ee2ffd826a patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31201
diff changeset
244 if (p_imst == IM_OVER_THE_SPOT)
e5ee2ffd826a patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31201
diff changeset
245 im_preedit_window_set_position();
20637
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
246 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
247
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
248 # if 0 || defined(PROTO) // apparently only used in gui_x11.c
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
249 void
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
250 xim_set_preedit(void)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
251 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
252 im_set_position(gui.row, gui.col);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
253 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
254 # endif
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
255
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
256 static void
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
257 im_add_to_input(char_u *str, int len)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
258 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
259 // Convert from 'termencoding' (always "utf-8") to 'encoding'
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
260 if (input_conv.vc_type != CONV_NONE)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
261 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
262 str = string_convert(&input_conv, str, &len);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
263 g_return_if_fail(str != NULL);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
264 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
265
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
266 add_to_input_buf_csi(str, len);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
267
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
268 if (input_conv.vc_type != CONV_NONE)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
269 vim_free(str);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
270
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
271 if (p_mh) // blank out the pointer if necessary
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
272 gui_mch_mousehide(TRUE);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
273 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
274
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
275 static void
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
276 im_preedit_window_set_position(void)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
277 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
278 int x, y, width, height;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
279 int screen_x, screen_y, screen_width, screen_height;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
280
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
281 if (preedit_window == NULL)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
282 return;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
283
24162
cb8b9bf76082 patch 8.2.2622: GTK: error when starting up and -geometry is given
Bram Moolenaar <Bram@vim.org>
parents: 21112
diff changeset
284 gui_gtk_get_screen_geom_of_win(gui.drawarea, 0, 0,
20637
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
285 &screen_x, &screen_y, &screen_width, &screen_height);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
286 gdk_window_get_origin(gtk_widget_get_window(gui.drawarea), &x, &y);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
287 gtk_window_get_size(GTK_WINDOW(preedit_window), &width, &height);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
288 x = x + FILL_X(gui.col);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
289 y = y + FILL_Y(gui.row);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
290 if (x + width > screen_x + screen_width)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
291 x = screen_x + screen_width - width;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
292 if (y + height > screen_y + screen_height)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
293 y = screen_y + screen_height - height;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
294 gtk_window_move(GTK_WINDOW(preedit_window), x, y);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
295 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
296
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
297 static void
32009
4545f58c8490 patch 9.0.1336: functions without arguments are not always declared properly
Bram Moolenaar <Bram@vim.org>
parents: 31996
diff changeset
298 im_preedit_window_open(void)
20637
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
299 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
300 char *preedit_string;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
301 #if !GTK_CHECK_VERSION(3,16,0)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
302 char buf[8];
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
303 #endif
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
304 PangoAttrList *attr_list;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
305 PangoLayout *layout;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
306 #if GTK_CHECK_VERSION(3,0,0)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
307 # if !GTK_CHECK_VERSION(3,16,0)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
308 GdkRGBA color;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
309 # endif
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
310 #else
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
311 GdkColor color;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
312 #endif
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
313 gint w, h;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
314
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
315 if (preedit_window == NULL)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
316 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
317 preedit_window = gtk_window_new(GTK_WINDOW_POPUP);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
318 gtk_window_set_transient_for(GTK_WINDOW(preedit_window),
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
319 GTK_WINDOW(gui.mainwin));
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
320 preedit_label = gtk_label_new("");
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
321 gtk_widget_set_name(preedit_label, "vim-gui-preedit-area");
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
322 gtk_container_add(GTK_CONTAINER(preedit_window), preedit_label);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
323 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
324
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
325 #if GTK_CHECK_VERSION(3,16,0)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
326 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
327 GtkStyleContext * const context
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
328 = gtk_widget_get_style_context(gui.drawarea);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
329 GtkCssProvider * const provider = gtk_css_provider_new();
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
330 gchar *css = NULL;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
331 const char * const fontname
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
332 = pango_font_description_get_family(gui.norm_font);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
333 gint fontsize
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
334 = pango_font_description_get_size(gui.norm_font) / PANGO_SCALE;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
335 gchar *fontsize_propval = NULL;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
336
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
337 if (!pango_font_description_get_size_is_absolute(gui.norm_font))
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
338 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
339 // fontsize was given in points. Convert it into that in pixels
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
340 // to use with CSS.
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
341 GdkScreen * const screen
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
342 = gdk_window_get_screen(gtk_widget_get_window(gui.mainwin));
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
343 const gdouble dpi = gdk_screen_get_resolution(screen);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
344 fontsize = dpi * fontsize / 72;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
345 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
346 if (fontsize > 0)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
347 fontsize_propval = g_strdup_printf("%dpx", fontsize);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
348 else
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
349 fontsize_propval = g_strdup_printf("inherit");
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
350
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
351 css = g_strdup_printf(
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
352 "widget#vim-gui-preedit-area {\n"
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
353 " font-family: %s,monospace;\n"
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
354 " font-size: %s;\n"
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
355 " color: #%.2lx%.2lx%.2lx;\n"
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
356 " background-color: #%.2lx%.2lx%.2lx;\n"
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
357 "}\n",
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
358 fontname != NULL ? fontname : "inherit",
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
359 fontsize_propval,
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
360 (gui.norm_pixel >> 16) & 0xff,
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
361 (gui.norm_pixel >> 8) & 0xff,
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
362 gui.norm_pixel & 0xff,
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
363 (gui.back_pixel >> 16) & 0xff,
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
364 (gui.back_pixel >> 8) & 0xff,
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
365 gui.back_pixel & 0xff);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
366
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
367 gtk_css_provider_load_from_data(provider, css, -1, NULL);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
368 gtk_style_context_add_provider(context,
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
369 GTK_STYLE_PROVIDER(provider), G_MAXUINT);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
370
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
371 g_free(css);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
372 g_free(fontsize_propval);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
373 g_object_unref(provider);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
374 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
375 #elif GTK_CHECK_VERSION(3,0,0)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
376 gtk_widget_override_font(preedit_label, gui.norm_font);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
377
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
378 vim_snprintf(buf, sizeof(buf), "#%06X", gui.norm_pixel);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
379 gdk_rgba_parse(&color, buf);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
380 gtk_widget_override_color(preedit_label, GTK_STATE_FLAG_NORMAL, &color);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
381
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
382 vim_snprintf(buf, sizeof(buf), "#%06X", gui.back_pixel);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
383 gdk_rgba_parse(&color, buf);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
384 gtk_widget_override_background_color(preedit_label, GTK_STATE_FLAG_NORMAL,
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
385 &color);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
386 #else
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
387 gtk_widget_modify_font(preedit_label, gui.norm_font);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
388
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
389 vim_snprintf(buf, sizeof(buf), "#%06X", (unsigned)gui.norm_pixel);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
390 gdk_color_parse(buf, &color);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
391 gtk_widget_modify_fg(preedit_label, GTK_STATE_NORMAL, &color);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
392
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
393 vim_snprintf(buf, sizeof(buf), "#%06X", (unsigned)gui.back_pixel);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
394 gdk_color_parse(buf, &color);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
395 gtk_widget_modify_bg(preedit_window, GTK_STATE_NORMAL, &color);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
396 #endif
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
397
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
398 gtk_im_context_get_preedit_string(xic, &preedit_string, &attr_list, NULL);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
399
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
400 if (preedit_string[0] != NUL)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
401 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
402 gtk_label_set_text(GTK_LABEL(preedit_label), preedit_string);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
403 gtk_label_set_attributes(GTK_LABEL(preedit_label), attr_list);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
404
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
405 layout = gtk_label_get_layout(GTK_LABEL(preedit_label));
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
406 pango_layout_get_pixel_size(layout, &w, &h);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
407 h = MAX(h, gui.char_height);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
408 gtk_window_resize(GTK_WINDOW(preedit_window), w, h);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
409
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
410 gtk_widget_show_all(preedit_window);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
411
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
412 im_preedit_window_set_position();
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
413 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
414
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
415 g_free(preedit_string);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
416 pango_attr_list_unref(attr_list);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
417 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
418
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
419 static void
32009
4545f58c8490 patch 9.0.1336: functions without arguments are not always declared properly
Bram Moolenaar <Bram@vim.org>
parents: 31996
diff changeset
420 im_preedit_window_close(void)
20637
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
421 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
422 if (preedit_window != NULL)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
423 gtk_widget_hide(preedit_window);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
424 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
425
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
426 static void
32009
4545f58c8490 patch 9.0.1336: functions without arguments are not always declared properly
Bram Moolenaar <Bram@vim.org>
parents: 31996
diff changeset
427 im_show_preedit(void)
20637
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
428 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
429 im_preedit_window_open();
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
430
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
431 if (p_mh) // blank out the pointer if necessary
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
432 gui_mch_mousehide(TRUE);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
433 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
434
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
435 static void
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
436 im_delete_preedit(void)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
437 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
438 char_u bskey[] = {CSI, 'k', 'b'};
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
439 char_u delkey[] = {CSI, 'k', 'D'};
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
440
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
441 if (p_imst == IM_OVER_THE_SPOT)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
442 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
443 im_preedit_window_close();
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
444 return;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
445 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
446
28773
d770568e6c98 patch 8.2.4911: the mode #defines are not clearly named
Bram Moolenaar <Bram@vim.org>
parents: 27018
diff changeset
447 if (State & MODE_NORMAL
20637
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
448 #ifdef FEAT_TERMINAL
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
449 && !term_use_loop()
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
450 #endif
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
451 )
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
452 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
453 im_preedit_cursor = 0;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
454 return;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
455 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
456 for (; im_preedit_cursor > 0; --im_preedit_cursor)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
457 add_to_input_buf(bskey, (int)sizeof(bskey));
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
458
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
459 for (; im_preedit_trailing > 0; --im_preedit_trailing)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
460 add_to_input_buf(delkey, (int)sizeof(delkey));
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
461 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
462
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
463 /*
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
464 * Move the cursor left by "num_move_back" characters.
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
465 * Note that ins_left() checks im_is_preediting() to avoid breaking undo for
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
466 * these K_LEFT keys.
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
467 */
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
468 static void
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
469 im_correct_cursor(int num_move_back)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
470 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
471 char_u backkey[] = {CSI, 'k', 'l'};
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
472
28773
d770568e6c98 patch 8.2.4911: the mode #defines are not clearly named
Bram Moolenaar <Bram@vim.org>
parents: 27018
diff changeset
473 if (State & MODE_NORMAL)
20637
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
474 return;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
475 # ifdef FEAT_RIGHTLEFT
28773
d770568e6c98 patch 8.2.4911: the mode #defines are not clearly named
Bram Moolenaar <Bram@vim.org>
parents: 27018
diff changeset
476 if ((State & MODE_CMDLINE) == 0 && curwin != NULL && curwin->w_p_rl)
20637
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
477 backkey[2] = 'r';
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
478 # endif
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
479 for (; num_move_back > 0; --num_move_back)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
480 add_to_input_buf(backkey, (int)sizeof(backkey));
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
481 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
482
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
483 static int xim_expected_char = NUL;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
484 static int xim_ignored_char = FALSE;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
485
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
486 /*
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
487 * Update the mode and cursor while in an IM callback.
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
488 */
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
489 static void
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
490 im_show_info(void)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
491 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
492 int old_vgetc_busy;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
493
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
494 old_vgetc_busy = vgetc_busy;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
495 vgetc_busy = TRUE;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
496 showmode();
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
497 vgetc_busy = old_vgetc_busy;
28773
d770568e6c98 patch 8.2.4911: the mode #defines are not clearly named
Bram Moolenaar <Bram@vim.org>
parents: 27018
diff changeset
498 if ((State & MODE_NORMAL) || (State & MODE_INSERT))
20637
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
499 setcursor();
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
500 out_flush();
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
501 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
502
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
503 /*
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
504 * Callback invoked when the user finished preediting.
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
505 * Put the final string into the input buffer.
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
506 */
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
507 static void
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
508 im_commit_cb(GtkIMContext *context UNUSED,
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
509 const gchar *str,
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
510 gpointer data UNUSED)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
511 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
512 int slen = (int)STRLEN(str);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
513 int add_to_input = TRUE;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
514 int clen;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
515 int len = slen;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
516 int commit_with_preedit = TRUE;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
517 char_u *im_str;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
518
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
519 #ifdef XIM_DEBUG
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
520 xim_log("im_commit_cb(): %s\n", str);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
521 #endif
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
522
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
523 if (p_imst == IM_ON_THE_SPOT)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
524 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
525 // The imhangul module doesn't reset the preedit string before
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
526 // committing. Call im_delete_preedit() to work around that.
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
527 im_delete_preedit();
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
528
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
529 // Indicate that preediting has finished.
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
530 if (preedit_start_col == MAXCOL)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
531 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
532 init_preedit_start_col();
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
533 commit_with_preedit = FALSE;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
534 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
535
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
536 // The thing which setting "preedit_start_col" to MAXCOL means that
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
537 // "preedit_start_col" will be set forcedly when calling
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
538 // preedit_changed_cb() next time.
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
539 // "preedit_start_col" should not reset with MAXCOL on this part. Vim
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
540 // is simulating the preediting by using add_to_input_str(). when
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
541 // preedit begin immediately before committed, the typebuf is not
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
542 // flushed to screen, then it can't get correct "preedit_start_col".
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
543 // Thus, it should calculate the cells by adding cells of the committed
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
544 // string.
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
545 if (input_conv.vc_type != CONV_NONE)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
546 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
547 im_str = string_convert(&input_conv, (char_u *)str, &len);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
548 g_return_if_fail(im_str != NULL);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
549 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
550 else
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
551 im_str = (char_u *)str;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
552
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
553 clen = mb_string2cells(im_str, len);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
554
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
555 if (input_conv.vc_type != CONV_NONE)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
556 vim_free(im_str);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
557 preedit_start_col += clen;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
558 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
559
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
560 // Is this a single character that matches a keypad key that's just
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
561 // been pressed? If so, we don't want it to be entered as such - let
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
562 // us carry on processing the raw keycode so that it may be used in
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
563 // mappings as <kSomething>.
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
564 if (xim_expected_char != NUL)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
565 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
566 // We're currently processing a keypad or other special key
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
567 if (slen == 1 && str[0] == xim_expected_char)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
568 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
569 // It's a match - don't do it here
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
570 xim_ignored_char = TRUE;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
571 add_to_input = FALSE;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
572 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
573 else
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
574 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
575 // Not a match
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
576 xim_ignored_char = FALSE;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
577 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
578 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
579
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
580 if (add_to_input)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
581 im_add_to_input((char_u *)str, slen);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
582
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
583 if (p_imst == IM_ON_THE_SPOT)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
584 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
585 // Inserting chars while "im_is_active" is set does not cause a
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
586 // change of buffer. When the chars are committed the buffer must be
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
587 // marked as changed.
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
588 if (!commit_with_preedit)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
589 preedit_start_col = MAXCOL;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
590
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
591 // This flag is used in changed() at next call.
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
592 xim_changed_while_preediting = TRUE;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
593 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
594
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
595 if (gtk_main_level() > 0)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
596 gtk_main_quit();
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
597 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
598
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
599 /*
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
600 * Callback invoked after start to the preedit.
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
601 */
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
602 static void
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
603 im_preedit_start_cb(GtkIMContext *context UNUSED, gpointer data UNUSED)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
604 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
605 #ifdef XIM_DEBUG
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
606 xim_log("im_preedit_start_cb()\n");
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
607 #endif
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
608
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
609 im_is_active = TRUE;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
610 preedit_is_active = TRUE;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
611 gui_update_cursor(TRUE, FALSE);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
612 im_show_info();
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
613 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
614
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
615 /*
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
616 * Callback invoked after end to the preedit.
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
617 */
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
618 static void
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
619 im_preedit_end_cb(GtkIMContext *context UNUSED, gpointer data UNUSED)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
620 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
621 #ifdef XIM_DEBUG
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
622 xim_log("im_preedit_end_cb()\n");
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
623 #endif
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
624 im_delete_preedit();
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
625
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
626 // Indicate that preediting has finished
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
627 if (p_imst == IM_ON_THE_SPOT)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
628 preedit_start_col = MAXCOL;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
629 xim_has_preediting = FALSE;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
630
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
631 #if 0
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
632 // Removal of this line suggested by Takuhiro Nishioka. Fixes that IM was
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
633 // switched off unintentionally. We now use preedit_is_active (added by
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
634 // SungHyun Nam).
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
635 im_is_active = FALSE;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
636 #endif
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
637 preedit_is_active = FALSE;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
638 gui_update_cursor(TRUE, FALSE);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
639 im_show_info();
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
640 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
641
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
642 /*
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
643 * Callback invoked after changes to the preedit string. If the preedit
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
644 * string was empty before, remember the preedit start column so we know
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
645 * where to apply feedback attributes. Delete the previous preedit string
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
646 * if there was one, save the new preedit cursor offset, and put the new
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
647 * string into the input buffer.
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
648 *
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
649 * TODO: The pragmatic "put into input buffer" approach used here has
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
650 * several fundamental problems:
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
651 *
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
652 * - The characters in the preedit string are subject to remapping.
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
653 * That's broken, only the finally committed string should be remapped.
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
654 *
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
655 * - There is a race condition involved: The retrieved value for the
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
656 * current cursor position will be wrong if any unprocessed characters
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
657 * are still queued in the input buffer.
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
658 *
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
659 * - Due to the lack of synchronization between the file buffer in memory
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
660 * and any typed characters, it's practically impossible to implement the
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
661 * "retrieve_surrounding" and "delete_surrounding" signals reliably. IM
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
662 * modules for languages such as Thai are likely to rely on this feature
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
663 * for proper operation.
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
664 *
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
665 * Conclusions: I think support for preediting needs to be moved to the
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
666 * core parts of Vim. Ideally, until it has been committed, the preediting
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
667 * string should only be displayed and not affect the buffer content at all.
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
668 * The question how to deal with the synchronization issue still remains.
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
669 * Circumventing the input buffer is probably not desirable. Anyway, I think
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
670 * implementing "retrieve_surrounding" is the only hard problem.
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
671 *
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
672 * One way to solve all of this in a clean manner would be to queue all key
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
673 * press/release events "as is" in the input buffer, and apply the IM filtering
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
674 * at the receiving end of the queue. This, however, would have a rather large
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
675 * impact on the code base. If there is an easy way to force processing of all
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
676 * remaining input from within the "retrieve_surrounding" signal handler, this
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
677 * might not be necessary. Gotta ask on vim-dev for opinions.
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
678 */
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
679 static void
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
680 im_preedit_changed_cb(GtkIMContext *context, gpointer data UNUSED)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
681 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
682 char *preedit_string = NULL;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
683 int cursor_index = 0;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
684 int num_move_back = 0;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
685 char_u *str;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
686 char_u *p;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
687 int i;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
688
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
689 if (p_imst == IM_ON_THE_SPOT)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
690 gtk_im_context_get_preedit_string(context,
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
691 &preedit_string, NULL,
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
692 &cursor_index);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
693 else
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
694 gtk_im_context_get_preedit_string(context,
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
695 &preedit_string, NULL,
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
696 NULL);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
697
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
698 #ifdef XIM_DEBUG
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
699 xim_log("im_preedit_changed_cb(): %s\n", preedit_string);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
700 #endif
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
701
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
702 g_return_if_fail(preedit_string != NULL); // just in case
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
703
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
704 if (p_imst == IM_OVER_THE_SPOT)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
705 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
706 if (preedit_string[0] == NUL)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
707 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
708 xim_has_preediting = FALSE;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
709 im_delete_preedit();
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
710 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
711 else
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
712 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
713 xim_has_preediting = TRUE;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
714 im_show_preedit();
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
715 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
716 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
717 else
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
718 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
719 // If preedit_start_col is MAXCOL set it to the current cursor position.
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
720 if (preedit_start_col == MAXCOL && preedit_string[0] != '\0')
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
721 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
722 xim_has_preediting = TRUE;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
723
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
724 // Urgh, this breaks if the input buffer isn't empty now
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
725 init_preedit_start_col();
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
726 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
727 else if (cursor_index == 0 && preedit_string[0] == '\0')
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
728 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
729 xim_has_preediting = FALSE;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
730
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
731 // If at the start position (after typing backspace)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
732 // preedit_start_col must be reset.
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
733 preedit_start_col = MAXCOL;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
734 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
735
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
736 im_delete_preedit();
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
737
20671
ccdd80a6dad7 patch 8.2.0889: using old style comments
Bram Moolenaar <Bram@vim.org>
parents: 20637
diff changeset
738 // Compute the end of the preediting area: "preedit_end_col".
ccdd80a6dad7 patch 8.2.0889: using old style comments
Bram Moolenaar <Bram@vim.org>
parents: 20637
diff changeset
739 // According to the documentation of
ccdd80a6dad7 patch 8.2.0889: using old style comments
Bram Moolenaar <Bram@vim.org>
parents: 20637
diff changeset
740 // gtk_im_context_get_preedit_string(), the cursor_pos output argument
ccdd80a6dad7 patch 8.2.0889: using old style comments
Bram Moolenaar <Bram@vim.org>
parents: 20637
diff changeset
741 // returns the offset in bytes. This is unfortunately not true -- real
ccdd80a6dad7 patch 8.2.0889: using old style comments
Bram Moolenaar <Bram@vim.org>
parents: 20637
diff changeset
742 // life shows the offset is in characters, and the GTK+ source code
ccdd80a6dad7 patch 8.2.0889: using old style comments
Bram Moolenaar <Bram@vim.org>
parents: 20637
diff changeset
743 // agrees with me. Will file a bug later.
20637
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
744 if (preedit_start_col != MAXCOL)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
745 preedit_end_col = preedit_start_col;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
746 str = (char_u *)preedit_string;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
747 for (p = str, i = 0; *p != NUL; p += utf_byte2len(*p), ++i)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
748 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
749 int is_composing;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
750
20671
ccdd80a6dad7 patch 8.2.0889: using old style comments
Bram Moolenaar <Bram@vim.org>
parents: 20637
diff changeset
751 is_composing = ((*p & 0x80) != 0
ccdd80a6dad7 patch 8.2.0889: using old style comments
Bram Moolenaar <Bram@vim.org>
parents: 20637
diff changeset
752 && utf_iscomposing(utf_ptr2char(p)));
ccdd80a6dad7 patch 8.2.0889: using old style comments
Bram Moolenaar <Bram@vim.org>
parents: 20637
diff changeset
753 // These offsets are used as counters when generating <BS> and
ccdd80a6dad7 patch 8.2.0889: using old style comments
Bram Moolenaar <Bram@vim.org>
parents: 20637
diff changeset
754 // <Del> to delete the preedit string. So don't count composing
ccdd80a6dad7 patch 8.2.0889: using old style comments
Bram Moolenaar <Bram@vim.org>
parents: 20637
diff changeset
755 // characters unless 'delcombine' is enabled.
20637
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
756 if (!is_composing || p_deco)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
757 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
758 if (i < cursor_index)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
759 ++im_preedit_cursor;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
760 else
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
761 ++im_preedit_trailing;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
762 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
763 if (!is_composing && i >= cursor_index)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
764 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
765 // This is essentially the same as im_preedit_trailing, except
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
766 // composing characters are not counted even if p_deco is set.
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
767 ++num_move_back;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
768 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
769 if (preedit_start_col != MAXCOL)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
770 preedit_end_col += utf_ptr2cells(p);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
771 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
772
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
773 if (p > str)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
774 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
775 im_add_to_input(str, (int)(p - str));
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
776 im_correct_cursor(num_move_back);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
777 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
778 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
779
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
780 g_free(preedit_string);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
781
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
782 if (gtk_main_level() > 0)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
783 gtk_main_quit();
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
784 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
785
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
786 /*
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
787 * Translate the Pango attributes at iter to Vim highlighting attributes.
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
788 * Ignore attributes not supported by Vim highlighting. This shouldn't have
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
789 * too much impact -- right now we handle even more attributes than necessary
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
790 * for the IM modules I tested with.
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
791 */
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
792 static int
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
793 translate_pango_attributes(PangoAttrIterator *iter)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
794 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
795 PangoAttribute *attr;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
796 int char_attr = HL_NORMAL;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
797
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
798 attr = pango_attr_iterator_get(iter, PANGO_ATTR_UNDERLINE);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
799 if (attr != NULL && ((PangoAttrInt *)attr)->value
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
800 != (int)PANGO_UNDERLINE_NONE)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
801 char_attr |= HL_UNDERLINE;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
802
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
803 attr = pango_attr_iterator_get(iter, PANGO_ATTR_WEIGHT);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
804 if (attr != NULL && ((PangoAttrInt *)attr)->value >= (int)PANGO_WEIGHT_BOLD)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
805 char_attr |= HL_BOLD;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
806
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
807 attr = pango_attr_iterator_get(iter, PANGO_ATTR_STYLE);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
808 if (attr != NULL && ((PangoAttrInt *)attr)->value
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
809 != (int)PANGO_STYLE_NORMAL)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
810 char_attr |= HL_ITALIC;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
811
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
812 attr = pango_attr_iterator_get(iter, PANGO_ATTR_BACKGROUND);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
813 if (attr != NULL)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
814 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
815 const PangoColor *color = &((PangoAttrColor *)attr)->color;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
816
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
817 // Assume inverse if black background is requested
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
818 if ((color->red | color->green | color->blue) == 0)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
819 char_attr |= HL_INVERSE;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
820 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
821
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
822 return char_attr;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
823 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
824
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
825 /*
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
826 * Retrieve the highlighting attributes at column col in the preedit string.
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
827 * Return -1 if not in preediting mode or if col is out of range.
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
828 */
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
829 int
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
830 im_get_feedback_attr(int col)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
831 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
832 char *preedit_string = NULL;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
833 PangoAttrList *attr_list = NULL;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
834 int char_attr = -1;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
835
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
836 if (xic == NULL)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
837 return char_attr;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
838
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
839 gtk_im_context_get_preedit_string(xic, &preedit_string, &attr_list, NULL);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
840
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
841 if (preedit_string != NULL && attr_list != NULL)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
842 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
843 int idx;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
844
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
845 // Get the byte index as used by PangoAttrIterator
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
846 for (idx = 0; col > 0 && preedit_string[idx] != '\0'; --col)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
847 idx += utfc_ptr2len((char_u *)preedit_string + idx);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
848
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
849 if (preedit_string[idx] != '\0')
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
850 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
851 PangoAttrIterator *iter;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
852 int start, end;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
853
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
854 char_attr = HL_NORMAL;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
855 iter = pango_attr_list_get_iterator(attr_list);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
856
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
857 // Extract all relevant attributes from the list.
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
858 do
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
859 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
860 pango_attr_iterator_range(iter, &start, &end);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
861
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
862 if (idx >= start && idx < end)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
863 char_attr |= translate_pango_attributes(iter);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
864 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
865 while (pango_attr_iterator_next(iter));
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
866
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
867 pango_attr_iterator_destroy(iter);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
868 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
869 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
870
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
871 if (attr_list != NULL)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
872 pango_attr_list_unref(attr_list);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
873 g_free(preedit_string);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
874
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
875 return char_attr;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
876 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
877
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
878 void
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
879 xim_init(void)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
880 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
881 #ifdef XIM_DEBUG
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
882 xim_log("xim_init()\n");
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
883 #endif
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
884
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
885 g_return_if_fail(gui.drawarea != NULL);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
886 g_return_if_fail(gtk_widget_get_window(gui.drawarea) != NULL);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
887
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
888 xic = gtk_im_multicontext_new();
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
889 g_object_ref(xic);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
890
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
891 im_commit_handler_id = g_signal_connect(G_OBJECT(xic), "commit",
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
892 G_CALLBACK(&im_commit_cb), NULL);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
893 g_signal_connect(G_OBJECT(xic), "preedit_changed",
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
894 G_CALLBACK(&im_preedit_changed_cb), NULL);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
895 g_signal_connect(G_OBJECT(xic), "preedit_start",
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
896 G_CALLBACK(&im_preedit_start_cb), NULL);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
897 g_signal_connect(G_OBJECT(xic), "preedit_end",
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
898 G_CALLBACK(&im_preedit_end_cb), NULL);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
899
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
900 gtk_im_context_set_client_window(xic, gtk_widget_get_window(gui.drawarea));
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
901 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
902
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
903 void
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
904 im_shutdown(void)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
905 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
906 #ifdef XIM_DEBUG
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
907 xim_log("im_shutdown()\n");
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
908 #endif
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
909
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
910 if (xic != NULL)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
911 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
912 gtk_im_context_focus_out(xic);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
913 g_object_unref(xic);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
914 xic = NULL;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
915 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
916 im_is_active = FALSE;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
917 im_commit_handler_id = 0;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
918 if (p_imst == IM_ON_THE_SPOT)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
919 preedit_start_col = MAXCOL;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
920 xim_has_preediting = FALSE;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
921 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
922
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
923 /*
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
924 * Convert the string argument to keyval and state for GdkEventKey.
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
925 * If str is valid return TRUE, otherwise FALSE.
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
926 *
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
927 * See 'imactivatekey' for documentation of the format.
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
928 */
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
929 static int
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
930 im_string_to_keyval(const char *str, unsigned int *keyval, unsigned int *state)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
931 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
932 const char *mods_end;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
933 unsigned tmp_keyval;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
934 unsigned tmp_state = 0;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
935
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
936 mods_end = strrchr(str, '-');
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
937 mods_end = (mods_end != NULL) ? mods_end + 1 : str;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
938
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
939 // Parse modifier keys
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
940 while (str < mods_end)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
941 switch (*str++)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
942 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
943 case '-': break;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
944 case 'S': case 's': tmp_state |= (unsigned)GDK_SHIFT_MASK; break;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
945 case 'L': case 'l': tmp_state |= (unsigned)GDK_LOCK_MASK; break;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
946 case 'C': case 'c': tmp_state |= (unsigned)GDK_CONTROL_MASK;break;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
947 case '1': tmp_state |= (unsigned)GDK_MOD1_MASK; break;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
948 case '2': tmp_state |= (unsigned)GDK_MOD2_MASK; break;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
949 case '3': tmp_state |= (unsigned)GDK_MOD3_MASK; break;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
950 case '4': tmp_state |= (unsigned)GDK_MOD4_MASK; break;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
951 case '5': tmp_state |= (unsigned)GDK_MOD5_MASK; break;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
952 default:
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
953 return FALSE;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
954 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
955
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
956 tmp_keyval = gdk_keyval_from_name(str);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
957
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
958 if (tmp_keyval == 0 || tmp_keyval == GDK_VoidSymbol)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
959 return FALSE;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
960
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
961 if (keyval != NULL)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
962 *keyval = tmp_keyval;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
963 if (state != NULL)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
964 *state = tmp_state;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
965
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
966 return TRUE;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
967 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
968
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
969 /*
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
970 * Return TRUE if p_imak is valid, otherwise FALSE. As a special case, an
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
971 * empty string is also regarded as valid.
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
972 *
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
973 * Note: The numerical key value of p_imak is cached if it was valid; thus
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
974 * boldly assuming im_xim_isvalid_imactivate() will always be called whenever
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
975 * 'imak' changes. This is currently the case but not obvious -- should
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
976 * probably rename the function for clarity.
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
977 */
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
978 int
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
979 im_xim_isvalid_imactivate(void)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
980 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
981 if (p_imak[0] == NUL)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
982 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
983 im_activatekey_keyval = GDK_VoidSymbol;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
984 im_activatekey_state = 0;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
985 return TRUE;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
986 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
987
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
988 return im_string_to_keyval((const char *)p_imak,
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
989 &im_activatekey_keyval,
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
990 &im_activatekey_state);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
991 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
992
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
993 static void
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
994 im_synthesize_keypress(unsigned int keyval, unsigned int state)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
995 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
996 GdkEventKey *event;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
997
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
998 event = (GdkEventKey *)gdk_event_new(GDK_KEY_PRESS);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
999 g_object_ref(gtk_widget_get_window(gui.drawarea));
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1000 // unreffed by gdk_event_free()
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1001 event->window = gtk_widget_get_window(gui.drawarea);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1002 event->send_event = TRUE;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1003 event->time = GDK_CURRENT_TIME;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1004 event->state = state;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1005 event->keyval = keyval;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1006 event->hardware_keycode = // needed for XIM
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1007 XKeysymToKeycode(GDK_WINDOW_XDISPLAY(event->window), (KeySym)keyval);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1008 event->length = 0;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1009 event->string = NULL;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1010
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1011 gtk_im_context_filter_keypress(xic, event);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1012
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1013 // For consistency, also send the corresponding release event.
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1014 event->type = GDK_KEY_RELEASE;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1015 event->send_event = FALSE;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1016 gtk_im_context_filter_keypress(xic, event);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1017
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1018 gdk_event_free((GdkEvent *)event);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1019 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1020
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1021 void
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1022 xim_reset(void)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1023 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1024 # ifdef FEAT_EVAL
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1025 if (USE_IMACTIVATEFUNC)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1026 call_imactivatefunc(im_is_active);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1027 else
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1028 # endif
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1029 if (xic != NULL)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1030 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1031 gtk_im_context_reset(xic);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1032
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1033 if (p_imdisable)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1034 im_shutdown();
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1035 else
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1036 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1037 xim_set_focus(gui.in_focus);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1038
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1039 if (im_activatekey_keyval != GDK_VoidSymbol)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1040 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1041 if (im_is_active)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1042 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1043 g_signal_handler_block(xic, im_commit_handler_id);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1044 im_synthesize_keypress(im_activatekey_keyval,
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1045 im_activatekey_state);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1046 g_signal_handler_unblock(xic, im_commit_handler_id);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1047 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1048 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1049 else
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1050 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1051 im_shutdown();
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1052 xim_init();
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1053 xim_set_focus(gui.in_focus);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1054 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1055 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1056 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1057
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1058 if (p_imst == IM_ON_THE_SPOT)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1059 preedit_start_col = MAXCOL;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1060 xim_has_preediting = FALSE;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1061 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1062
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1063 int
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1064 xim_queue_key_press_event(GdkEventKey *event, int down)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1065 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1066 if (down)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1067 {
20671
ccdd80a6dad7 patch 8.2.0889: using old style comments
Bram Moolenaar <Bram@vim.org>
parents: 20637
diff changeset
1068 // Workaround GTK2 XIM 'feature' that always converts keypad keys to
ccdd80a6dad7 patch 8.2.0889: using old style comments
Bram Moolenaar <Bram@vim.org>
parents: 20637
diff changeset
1069 // chars., even when not part of an IM sequence (ref. feature of
ccdd80a6dad7 patch 8.2.0889: using old style comments
Bram Moolenaar <Bram@vim.org>
parents: 20637
diff changeset
1070 // gdk/gdkkeyuni.c).
ccdd80a6dad7 patch 8.2.0889: using old style comments
Bram Moolenaar <Bram@vim.org>
parents: 20637
diff changeset
1071 // Flag any keypad keys that might represent a single char.
ccdd80a6dad7 patch 8.2.0889: using old style comments
Bram Moolenaar <Bram@vim.org>
parents: 20637
diff changeset
1072 // If this (on its own - i.e., not part of an IM sequence) is
ccdd80a6dad7 patch 8.2.0889: using old style comments
Bram Moolenaar <Bram@vim.org>
parents: 20637
diff changeset
1073 // committed while we're processing one of these keys, we can ignore
ccdd80a6dad7 patch 8.2.0889: using old style comments
Bram Moolenaar <Bram@vim.org>
parents: 20637
diff changeset
1074 // that commit and go ahead & process it ourselves. That way we can
ccdd80a6dad7 patch 8.2.0889: using old style comments
Bram Moolenaar <Bram@vim.org>
parents: 20637
diff changeset
1075 // still distinguish keypad keys for use in mappings.
ccdd80a6dad7 patch 8.2.0889: using old style comments
Bram Moolenaar <Bram@vim.org>
parents: 20637
diff changeset
1076 // Also add GDK_space to make <S-Space> work.
20637
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1077 switch (event->keyval)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1078 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1079 case GDK_KP_Add: xim_expected_char = '+'; break;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1080 case GDK_KP_Subtract: xim_expected_char = '-'; break;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1081 case GDK_KP_Divide: xim_expected_char = '/'; break;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1082 case GDK_KP_Multiply: xim_expected_char = '*'; break;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1083 case GDK_KP_Decimal: xim_expected_char = '.'; break;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1084 case GDK_KP_Equal: xim_expected_char = '='; break;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1085 case GDK_KP_0: xim_expected_char = '0'; break;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1086 case GDK_KP_1: xim_expected_char = '1'; break;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1087 case GDK_KP_2: xim_expected_char = '2'; break;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1088 case GDK_KP_3: xim_expected_char = '3'; break;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1089 case GDK_KP_4: xim_expected_char = '4'; break;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1090 case GDK_KP_5: xim_expected_char = '5'; break;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1091 case GDK_KP_6: xim_expected_char = '6'; break;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1092 case GDK_KP_7: xim_expected_char = '7'; break;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1093 case GDK_KP_8: xim_expected_char = '8'; break;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1094 case GDK_KP_9: xim_expected_char = '9'; break;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1095 case GDK_space: xim_expected_char = ' '; break;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1096 default: xim_expected_char = NUL;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1097 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1098 xim_ignored_char = FALSE;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1099 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1100
20671
ccdd80a6dad7 patch 8.2.0889: using old style comments
Bram Moolenaar <Bram@vim.org>
parents: 20637
diff changeset
1101 // When typing fFtT, XIM may be activated. Thus it must pass
ccdd80a6dad7 patch 8.2.0889: using old style comments
Bram Moolenaar <Bram@vim.org>
parents: 20637
diff changeset
1102 // gtk_im_context_filter_keypress() in Normal mode.
ccdd80a6dad7 patch 8.2.0889: using old style comments
Bram Moolenaar <Bram@vim.org>
parents: 20637
diff changeset
1103 // And while doing :sh too.
20637
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1104 if (xic != NULL && !p_imdisable
28773
d770568e6c98 patch 8.2.4911: the mode #defines are not clearly named
Bram Moolenaar <Bram@vim.org>
parents: 27018
diff changeset
1105 && (State & (MODE_INSERT | MODE_CMDLINE
d770568e6c98 patch 8.2.4911: the mode #defines are not clearly named
Bram Moolenaar <Bram@vim.org>
parents: 27018
diff changeset
1106 | MODE_NORMAL | MODE_EXTERNCMD)))
20637
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1107 {
20671
ccdd80a6dad7 patch 8.2.0889: using old style comments
Bram Moolenaar <Bram@vim.org>
parents: 20637
diff changeset
1108 // Filter 'imactivatekey' and map it to CTRL-^. This way, Vim is
ccdd80a6dad7 patch 8.2.0889: using old style comments
Bram Moolenaar <Bram@vim.org>
parents: 20637
diff changeset
1109 // always aware of the current status of IM, and can even emulate
ccdd80a6dad7 patch 8.2.0889: using old style comments
Bram Moolenaar <Bram@vim.org>
parents: 20637
diff changeset
1110 // the activation key for modules that don't support one.
20637
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1111 if (event->keyval == im_activatekey_keyval
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1112 && (event->state & im_activatekey_state) == im_activatekey_state)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1113 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1114 unsigned int state_mask;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1115
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1116 // Require the state of the 3 most used modifiers to match exactly.
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1117 // Otherwise e.g. <S-C-space> would be unusable for other purposes
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1118 // if the IM activate key is <S-space>.
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1119 state_mask = im_activatekey_state;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1120 state_mask |= ((int)GDK_SHIFT_MASK | (int)GDK_CONTROL_MASK
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1121 | (int)GDK_MOD1_MASK);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1122
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1123 if ((event->state & state_mask) != im_activatekey_state)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1124 return FALSE;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1125
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1126 // Don't send it a second time on GDK_KEY_RELEASE.
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1127 if (event->type != GDK_KEY_PRESS)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1128 return TRUE;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1129
28773
d770568e6c98 patch 8.2.4911: the mode #defines are not clearly named
Bram Moolenaar <Bram@vim.org>
parents: 27018
diff changeset
1130 if (map_to_exists_mode((char_u *)"", MODE_LANGMAP, FALSE))
20637
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1131 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1132 im_set_active(FALSE);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1133
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1134 // ":lmap" mappings exists, toggle use of mappings.
28773
d770568e6c98 patch 8.2.4911: the mode #defines are not clearly named
Bram Moolenaar <Bram@vim.org>
parents: 27018
diff changeset
1135 State ^= MODE_LANGMAP;
d770568e6c98 patch 8.2.4911: the mode #defines are not clearly named
Bram Moolenaar <Bram@vim.org>
parents: 27018
diff changeset
1136 if (State & MODE_LANGMAP)
20637
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1137 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1138 curbuf->b_p_iminsert = B_IMODE_NONE;
28773
d770568e6c98 patch 8.2.4911: the mode #defines are not clearly named
Bram Moolenaar <Bram@vim.org>
parents: 27018
diff changeset
1139 State &= ~MODE_LANGMAP;
20637
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1140 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1141 else
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1142 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1143 curbuf->b_p_iminsert = B_IMODE_LMAP;
28773
d770568e6c98 patch 8.2.4911: the mode #defines are not clearly named
Bram Moolenaar <Bram@vim.org>
parents: 27018
diff changeset
1144 State |= MODE_LANGMAP;
20637
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1145 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1146 return TRUE;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1147 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1148
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1149 return gtk_im_context_filter_keypress(xic, event);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1150 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1151
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1152 // Don't filter events through the IM context if IM isn't active
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1153 // right now. Unlike with GTK+ 1.2 we cannot rely on the IM module
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1154 // not doing anything before the activation key was sent.
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1155 if (im_activatekey_keyval == GDK_VoidSymbol || im_is_active)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1156 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1157 int imresult = gtk_im_context_filter_keypress(xic, event);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1158
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1159 if (p_imst == IM_ON_THE_SPOT)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1160 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1161 // Some XIM send following sequence:
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1162 // 1. preedited string.
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1163 // 2. committed string.
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1164 // 3. line changed key.
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1165 // 4. preedited string.
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1166 // 5. remove preedited string.
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1167 // if 3, Vim can't move back the above line for 5.
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1168 // thus, this part should not parse the key.
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1169 if (!imresult && preedit_start_col != MAXCOL
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1170 && event->keyval == GDK_Return)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1171 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1172 im_synthesize_keypress(GDK_Return, 0U);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1173 return FALSE;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1174 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1175 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1176
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1177 // If XIM tried to commit a keypad key as a single char.,
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1178 // ignore it so we can use the keypad key 'raw', for mappings.
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1179 if (xim_expected_char != NUL && xim_ignored_char)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1180 // We had a keypad key, and XIM tried to thieve it
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1181 return FALSE;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1182
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1183 // This is supposed to fix a problem with iBus, that space
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1184 // characters don't work in input mode.
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1185 xim_expected_char = NUL;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1186
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1187 // Normal processing
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1188 return imresult;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1189 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1190 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1191
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1192 return FALSE;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1193 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1194
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1195 int
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1196 im_get_status(void)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1197 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1198 # ifdef FEAT_EVAL
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1199 if (USE_IMSTATUSFUNC)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1200 return call_imstatusfunc();
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1201 # endif
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1202 return im_is_active;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1203 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1204
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1205 int
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1206 preedit_get_status(void)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1207 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1208 return preedit_is_active;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1209 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1210
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1211 int
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1212 im_is_preediting(void)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1213 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1214 return xim_has_preediting;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1215 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1216
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1217 # else // !FEAT_GUI_GTK
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1218
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1219 static int xim_is_active = FALSE; // XIM should be active in the current
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1220 // mode
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1221 static int xim_has_focus = FALSE; // XIM is really being used for Vim
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1222 # ifdef FEAT_GUI_X11
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1223 static XIMStyle input_style;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1224 static int status_area_enabled = TRUE;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1225 # endif
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1226
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1227 /*
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1228 * Switch using XIM on/off. This is used by the code that changes "State".
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1229 * When 'imactivatefunc' is defined use that function instead.
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1230 */
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1231 void
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1232 im_set_active(int active_arg)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1233 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1234 int active = active_arg;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1235
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1236 // If 'imdisable' is set, XIM is never active.
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1237 if (p_imdisable)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1238 active = FALSE;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1239 else if (input_style & XIMPreeditPosition)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1240 // There is a problem in switching XIM off when preediting is used,
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1241 // and it is not clear how this can be solved. For now, keep XIM on
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1242 // all the time, like it was done in Vim 5.8.
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1243 active = TRUE;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1244
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1245 # if defined(FEAT_EVAL)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1246 if (USE_IMACTIVATEFUNC)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1247 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1248 if (active != im_get_status())
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1249 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1250 call_imactivatefunc(active);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1251 xim_has_focus = active;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1252 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1253 return;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1254 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1255 # endif
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1256
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1257 if (xic == NULL)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1258 return;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1259
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1260 // Remember the active state, it is needed when Vim gets keyboard focus.
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1261 xim_is_active = active;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1262 xim_set_preedit();
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1263 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1264
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1265 /*
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1266 * Adjust using XIM for gaining or losing keyboard focus. Also called when
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1267 * "xim_is_active" changes.
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1268 */
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1269 void
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1270 xim_set_focus(int focus)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1271 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1272 if (xic == NULL)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1273 return;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1274
20671
ccdd80a6dad7 patch 8.2.0889: using old style comments
Bram Moolenaar <Bram@vim.org>
parents: 20637
diff changeset
1275 // XIM only gets focus when the Vim window has keyboard focus and XIM has
ccdd80a6dad7 patch 8.2.0889: using old style comments
Bram Moolenaar <Bram@vim.org>
parents: 20637
diff changeset
1276 // been set active for the current mode.
20637
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1277 if (focus && xim_is_active)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1278 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1279 if (!xim_has_focus)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1280 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1281 xim_has_focus = TRUE;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1282 XSetICFocus(xic);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1283 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1284 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1285 else
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1286 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1287 if (xim_has_focus)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1288 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1289 xim_has_focus = FALSE;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1290 XUnsetICFocus(xic);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1291 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1292 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1293 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1294
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1295 void
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1296 im_set_position(int row UNUSED, int col UNUSED)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1297 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1298 xim_set_preedit();
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1299 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1300
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1301 /*
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1302 * Set the XIM to the current cursor position.
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1303 */
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1304 void
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1305 xim_set_preedit(void)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1306 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1307 XVaNestedList attr_list;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1308 XRectangle spot_area;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1309 XPoint over_spot;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1310 int line_space;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1311
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1312 if (xic == NULL)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1313 return;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1314
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1315 xim_set_focus(TRUE);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1316
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1317 if (!xim_has_focus)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1318 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1319 // hide XIM cursor
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1320 over_spot.x = 0;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1321 over_spot.y = -100; // arbitrary invisible position
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1322 attr_list = (XVaNestedList) XVaCreateNestedList(0,
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1323 XNSpotLocation,
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1324 &over_spot,
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1325 NULL);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1326 XSetICValues(xic, XNPreeditAttributes, attr_list, NULL);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1327 XFree(attr_list);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1328 return;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1329 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1330
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1331 if (input_style & XIMPreeditPosition)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1332 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1333 if (xim_fg_color == INVALCOLOR)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1334 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1335 xim_fg_color = gui.def_norm_pixel;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1336 xim_bg_color = gui.def_back_pixel;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1337 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1338 over_spot.x = TEXT_X(gui.col);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1339 over_spot.y = TEXT_Y(gui.row);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1340 spot_area.x = 0;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1341 spot_area.y = 0;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1342 spot_area.height = gui.char_height * Rows;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1343 spot_area.width = gui.char_width * Columns;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1344 line_space = gui.char_height;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1345 attr_list = (XVaNestedList) XVaCreateNestedList(0,
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1346 XNSpotLocation, &over_spot,
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1347 XNForeground, (Pixel) xim_fg_color,
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1348 XNBackground, (Pixel) xim_bg_color,
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1349 XNArea, &spot_area,
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1350 XNLineSpace, line_space,
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1351 NULL);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1352 if (XSetICValues(xic, XNPreeditAttributes, attr_list, NULL))
26897
d02d40f0261c patch 8.2.3977: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1353 emsg(_(e_cannot_set_ic_values));
20637
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1354 XFree(attr_list);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1355 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1356 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1357
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1358 # if defined(FEAT_GUI_X11) || defined(PROTO)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1359 # if defined(XtSpecificationRelease) && XtSpecificationRelease >= 6 && !defined(SUN_SYSTEM)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1360 # define USE_X11R6_XIM
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1361 # endif
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1362
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1363 static int xim_real_init(Window x11_window, Display *x11_display);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1364
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1365
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1366 # ifdef USE_X11R6_XIM
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1367 static void
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1368 xim_instantiate_cb(
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1369 Display *display,
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1370 XPointer client_data UNUSED,
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1371 XPointer call_data UNUSED)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1372 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1373 Window x11_window;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1374 Display *x11_display;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1375
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1376 # ifdef XIM_DEBUG
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1377 xim_log("xim_instantiate_cb()\n");
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1378 # endif
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1379
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1380 gui_get_x11_windis(&x11_window, &x11_display);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1381 if (display != x11_display)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1382 return;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1383
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1384 xim_real_init(x11_window, x11_display);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1385 gui_set_shellsize(FALSE, FALSE, RESIZE_BOTH);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1386 if (xic != NULL)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1387 XUnregisterIMInstantiateCallback(x11_display, NULL, NULL, NULL,
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1388 xim_instantiate_cb, NULL);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1389 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1390
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1391 static void
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1392 xim_destroy_cb(
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1393 XIM im UNUSED,
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1394 XPointer client_data UNUSED,
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1395 XPointer call_data UNUSED)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1396 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1397 Window x11_window;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1398 Display *x11_display;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1399
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1400 # ifdef XIM_DEBUG
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1401 xim_log("xim_destroy_cb()\n");
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1402 #endif
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1403 gui_get_x11_windis(&x11_window, &x11_display);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1404
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1405 xic = NULL;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1406 status_area_enabled = FALSE;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1407
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1408 gui_set_shellsize(FALSE, FALSE, RESIZE_BOTH);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1409
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1410 XRegisterIMInstantiateCallback(x11_display, NULL, NULL, NULL,
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1411 xim_instantiate_cb, NULL);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1412 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1413 # endif
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1414
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1415 void
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1416 xim_init(void)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1417 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1418 Window x11_window;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1419 Display *x11_display;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1420
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1421 # ifdef XIM_DEBUG
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1422 xim_log("xim_init()\n");
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1423 # endif
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1424
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1425 gui_get_x11_windis(&x11_window, &x11_display);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1426
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1427 xic = NULL;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1428
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1429 if (xim_real_init(x11_window, x11_display))
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1430 return;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1431
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1432 gui_set_shellsize(FALSE, FALSE, RESIZE_BOTH);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1433
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1434 # ifdef USE_X11R6_XIM
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1435 XRegisterIMInstantiateCallback(x11_display, NULL, NULL, NULL,
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1436 xim_instantiate_cb, NULL);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1437 # endif
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1438 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1439
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1440 static int
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1441 xim_real_init(Window x11_window, Display *x11_display)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1442 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1443 int i;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1444 char *p,
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1445 *s,
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1446 *ns,
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1447 *end,
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1448 tmp[1024];
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1449 # define IMLEN_MAX 40
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1450 char buf[IMLEN_MAX + 7];
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1451 XIM xim = NULL;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1452 XIMStyles *xim_styles;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1453 XIMStyle this_input_style = 0;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1454 Boolean found;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1455 XPoint over_spot;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1456 XVaNestedList preedit_list, status_list;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1457
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1458 input_style = 0;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1459 status_area_enabled = FALSE;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1460
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1461 if (xic != NULL)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1462 return FALSE;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1463
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1464 if (gui.rsrc_input_method != NULL && *gui.rsrc_input_method != NUL)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1465 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1466 strcpy(tmp, gui.rsrc_input_method);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1467 for (ns = s = tmp; ns != NULL && *s != NUL;)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1468 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1469 s = (char *)skipwhite((char_u *)s);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1470 if (*s == NUL)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1471 break;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1472 if ((ns = end = strchr(s, ',')) == NULL)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1473 end = s + strlen(s);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1474 while (isspace(((char_u *)end)[-1]))
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1475 end--;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1476 *end = NUL;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1477
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1478 if (strlen(s) <= IMLEN_MAX)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1479 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1480 strcpy(buf, "@im=");
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1481 strcat(buf, s);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1482 if ((p = XSetLocaleModifiers(buf)) != NULL && *p != NUL
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1483 && (xim = XOpenIM(x11_display, NULL, NULL, NULL))
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1484 != NULL)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1485 break;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1486 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1487
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1488 s = ns + 1;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1489 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1490 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1491
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1492 if (xim == NULL && (p = XSetLocaleModifiers("")) != NULL && *p != NUL)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1493 xim = XOpenIM(x11_display, NULL, NULL, NULL);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1494
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1495 // This is supposed to be useful to obtain characters through
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1496 // XmbLookupString() without really using a XIM.
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1497 if (xim == NULL && (p = XSetLocaleModifiers("@im=none")) != NULL
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1498 && *p != NUL)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1499 xim = XOpenIM(x11_display, NULL, NULL, NULL);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1500
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1501 if (xim == NULL)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1502 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1503 // Only give this message when verbose is set, because too many people
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1504 // got this message when they didn't want to use a XIM.
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1505 if (p_verbose > 0)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1506 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1507 verbose_enter();
26897
d02d40f0261c patch 8.2.3977: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1508 emsg(_(e_failed_to_open_input_method));
20637
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1509 verbose_leave();
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1510 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1511 return FALSE;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1512 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1513
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1514 # ifdef USE_X11R6_XIM
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1515 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1516 XIMCallback destroy_cb;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1517
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1518 destroy_cb.callback = xim_destroy_cb;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1519 destroy_cb.client_data = NULL;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1520 if (XSetIMValues(xim, XNDestroyCallback, &destroy_cb, NULL))
26897
d02d40f0261c patch 8.2.3977: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1521 emsg(_(e_warning_could_not_set_destroy_callback_to_im));
20637
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1522 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1523 # endif
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1524
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1525 if (XGetIMValues(xim, XNQueryInputStyle, &xim_styles, NULL) || !xim_styles)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1526 {
26897
d02d40f0261c patch 8.2.3977: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1527 emsg(_(e_input_method_doesnt_support_any_style));
20637
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1528 XCloseIM(xim);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1529 return FALSE;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1530 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1531
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1532 found = False;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1533 strcpy(tmp, gui.rsrc_preedit_type_name);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1534 for (s = tmp; s && !found; )
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1535 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1536 while (*s && isspace((unsigned char)*s))
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1537 s++;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1538 if (!*s)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1539 break;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1540 if ((ns = end = strchr(s, ',')) != 0)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1541 ns++;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1542 else
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1543 end = s + strlen(s);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1544 while (isspace((unsigned char)*end))
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1545 end--;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1546 *end = '\0';
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1547
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1548 if (!strcmp(s, "OverTheSpot"))
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1549 this_input_style = (XIMPreeditPosition | XIMStatusArea);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1550 else if (!strcmp(s, "OffTheSpot"))
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1551 this_input_style = (XIMPreeditArea | XIMStatusArea);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1552 else if (!strcmp(s, "Root"))
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1553 this_input_style = (XIMPreeditNothing | XIMStatusNothing);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1554
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1555 for (i = 0; (unsigned short)i < xim_styles->count_styles; i++)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1556 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1557 if (this_input_style == xim_styles->supported_styles[i])
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1558 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1559 found = True;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1560 break;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1561 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1562 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1563 if (!found)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1564 for (i = 0; (unsigned short)i < xim_styles->count_styles; i++)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1565 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1566 if ((xim_styles->supported_styles[i] & this_input_style)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1567 == (this_input_style & ~XIMStatusArea))
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1568 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1569 this_input_style &= ~XIMStatusArea;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1570 found = True;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1571 break;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1572 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1573 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1574
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1575 s = ns;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1576 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1577 XFree(xim_styles);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1578
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1579 if (!found)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1580 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1581 // Only give this message when verbose is set, because too many people
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1582 // got this message when they didn't want to use a XIM.
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1583 if (p_verbose > 0)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1584 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1585 verbose_enter();
26897
d02d40f0261c patch 8.2.3977: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1586 emsg(_(e_input_method_doesnt_support_my_preedit_type));
20637
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1587 verbose_leave();
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1588 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1589 XCloseIM(xim);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1590 return FALSE;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1591 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1592
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1593 over_spot.x = TEXT_X(gui.col);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1594 over_spot.y = TEXT_Y(gui.row);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1595 input_style = this_input_style;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1596
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1597 // A crash was reported when trying to pass gui.norm_font as XNFontSet,
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1598 // thus that has been removed. Hopefully the default works...
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1599 # ifdef FEAT_XFONTSET
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1600 if (gui.fontset != NOFONTSET)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1601 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1602 preedit_list = XVaCreateNestedList(0,
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1603 XNSpotLocation, &over_spot,
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1604 XNForeground, (Pixel)gui.def_norm_pixel,
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1605 XNBackground, (Pixel)gui.def_back_pixel,
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1606 XNFontSet, (XFontSet)gui.fontset,
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1607 NULL);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1608 status_list = XVaCreateNestedList(0,
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1609 XNForeground, (Pixel)gui.def_norm_pixel,
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1610 XNBackground, (Pixel)gui.def_back_pixel,
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1611 XNFontSet, (XFontSet)gui.fontset,
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1612 NULL);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1613 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1614 else
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1615 # endif
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1616 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1617 preedit_list = XVaCreateNestedList(0,
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1618 XNSpotLocation, &over_spot,
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1619 XNForeground, (Pixel)gui.def_norm_pixel,
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1620 XNBackground, (Pixel)gui.def_back_pixel,
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1621 NULL);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1622 status_list = XVaCreateNestedList(0,
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1623 XNForeground, (Pixel)gui.def_norm_pixel,
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1624 XNBackground, (Pixel)gui.def_back_pixel,
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1625 NULL);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1626 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1627
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1628 xic = XCreateIC(xim,
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1629 XNInputStyle, input_style,
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1630 XNClientWindow, x11_window,
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1631 XNFocusWindow, gui.wid,
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1632 XNPreeditAttributes, preedit_list,
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1633 XNStatusAttributes, status_list,
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1634 NULL);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1635 XFree(status_list);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1636 XFree(preedit_list);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1637 if (xic != NULL)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1638 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1639 if (input_style & XIMStatusArea)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1640 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1641 xim_set_status_area();
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1642 status_area_enabled = TRUE;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1643 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1644 else
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1645 gui_set_shellsize(FALSE, FALSE, RESIZE_BOTH);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1646 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1647 else
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1648 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1649 if (!is_not_a_term())
26897
d02d40f0261c patch 8.2.3977: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1650 emsg(_(e_failed_to_create_input_context));
20637
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1651 XCloseIM(xim);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1652 return FALSE;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1653 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1654
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1655 return TRUE;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1656 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1657
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1658 # endif // FEAT_GUI_X11
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1659
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1660 /*
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1661 * Get IM status. When IM is on, return TRUE. Else return FALSE.
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1662 * FIXME: This doesn't work correctly: Having focus doesn't always mean XIM is
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1663 * active, when not having focus XIM may still be active (e.g., when using a
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1664 * tear-off menu item).
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1665 */
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1666 int
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1667 im_get_status(void)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1668 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1669 # ifdef FEAT_EVAL
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1670 if (USE_IMSTATUSFUNC)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1671 return call_imstatusfunc();
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1672 # endif
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1673 return xim_has_focus;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1674 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1675
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1676 # endif // !FEAT_GUI_GTK
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1677
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1678 # if !defined(FEAT_GUI_GTK) || defined(PROTO)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1679 /*
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1680 * Set up the status area.
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1681 *
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1682 * This should use a separate Widget, but that seems not possible, because
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1683 * preedit_area and status_area should be set to the same window as for the
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1684 * text input. Unfortunately this means the status area pollutes the text
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1685 * window...
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1686 */
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1687 void
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1688 xim_set_status_area(void)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1689 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1690 XVaNestedList preedit_list = 0, status_list = 0, list = 0;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1691 XRectangle pre_area, status_area;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1692
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1693 if (xic == NULL)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1694 return;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1695
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1696 if (input_style & XIMStatusArea)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1697 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1698 if (input_style & XIMPreeditArea)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1699 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1700 XRectangle *needed_rect;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1701
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1702 // to get status_area width
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1703 status_list = XVaCreateNestedList(0, XNAreaNeeded,
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1704 &needed_rect, NULL);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1705 XGetICValues(xic, XNStatusAttributes, status_list, NULL);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1706 XFree(status_list);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1707
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1708 status_area.width = needed_rect->width;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1709 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1710 else
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1711 status_area.width = gui.char_width * Columns;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1712
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1713 status_area.x = 0;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1714 status_area.y = gui.char_height * Rows + gui.border_offset;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1715 if (gui.which_scrollbars[SBAR_BOTTOM])
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1716 status_area.y += gui.scrollbar_height;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1717 #ifdef FEAT_MENU
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1718 if (gui.menu_is_active)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1719 status_area.y += gui.menu_height;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1720 #endif
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1721 status_area.height = gui.char_height;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1722 status_list = XVaCreateNestedList(0, XNArea, &status_area, NULL);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1723 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1724 else
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1725 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1726 status_area.x = 0;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1727 status_area.y = gui.char_height * Rows + gui.border_offset;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1728 if (gui.which_scrollbars[SBAR_BOTTOM])
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1729 status_area.y += gui.scrollbar_height;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1730 #ifdef FEAT_MENU
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1731 if (gui.menu_is_active)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1732 status_area.y += gui.menu_height;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1733 #endif
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1734 status_area.width = 0;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1735 status_area.height = gui.char_height;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1736 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1737
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1738 if (input_style & XIMPreeditArea) // off-the-spot
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1739 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1740 pre_area.x = status_area.x + status_area.width;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1741 pre_area.y = gui.char_height * Rows + gui.border_offset;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1742 pre_area.width = gui.char_width * Columns - pre_area.x;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1743 if (gui.which_scrollbars[SBAR_BOTTOM])
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1744 pre_area.y += gui.scrollbar_height;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1745 #ifdef FEAT_MENU
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1746 if (gui.menu_is_active)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1747 pre_area.y += gui.menu_height;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1748 #endif
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1749 pre_area.height = gui.char_height;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1750 preedit_list = XVaCreateNestedList(0, XNArea, &pre_area, NULL);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1751 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1752 else if (input_style & XIMPreeditPosition) // over-the-spot
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1753 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1754 pre_area.x = 0;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1755 pre_area.y = 0;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1756 pre_area.height = gui.char_height * Rows;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1757 pre_area.width = gui.char_width * Columns;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1758 preedit_list = XVaCreateNestedList(0, XNArea, &pre_area, NULL);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1759 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1760
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1761 if (preedit_list && status_list)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1762 list = XVaCreateNestedList(0, XNPreeditAttributes, preedit_list,
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1763 XNStatusAttributes, status_list, NULL);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1764 else if (preedit_list)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1765 list = XVaCreateNestedList(0, XNPreeditAttributes, preedit_list,
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1766 NULL);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1767 else if (status_list)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1768 list = XVaCreateNestedList(0, XNStatusAttributes, status_list,
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1769 NULL);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1770 else
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1771 list = NULL;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1772
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1773 if (list)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1774 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1775 XSetICValues(xic, XNVaNestedList, list, NULL);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1776 XFree(list);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1777 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1778 if (status_list)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1779 XFree(status_list);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1780 if (preedit_list)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1781 XFree(preedit_list);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1782 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1783
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1784 int
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1785 xim_get_status_area_height(void)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1786 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1787 if (status_area_enabled)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1788 return gui.char_height;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1789 return 0;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1790 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1791 # endif
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1792
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1793 #else // !defined(FEAT_XIM)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1794
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1795 # if defined(IME_WITHOUT_XIM) || defined(VIMDLL) || defined(PROTO)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1796 static int im_was_set_active = FALSE;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1797
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1798 int
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1799 # ifdef VIMDLL
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1800 mbyte_im_get_status(void)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1801 # else
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1802 im_get_status(void)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1803 # endif
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1804 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1805 # if defined(FEAT_EVAL)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1806 if (USE_IMSTATUSFUNC)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1807 return call_imstatusfunc();
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1808 # endif
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1809 return im_was_set_active;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1810 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1811
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1812 void
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1813 # ifdef VIMDLL
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1814 mbyte_im_set_active(int active_arg)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1815 # else
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1816 im_set_active(int active_arg)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1817 # endif
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1818 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1819 # if defined(FEAT_EVAL)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1820 int active = !p_imdisable && active_arg;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1821
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1822 if (USE_IMACTIVATEFUNC && active != im_get_status())
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1823 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1824 call_imactivatefunc(active);
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1825 im_was_set_active = active;
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1826 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1827 # endif
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1828 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1829
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1830 # if defined(FEAT_GUI) && !defined(FEAT_GUI_HAIKU) && !defined(VIMDLL)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1831 void
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1832 im_set_position(int row UNUSED, int col UNUSED)
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1833 {
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1834 }
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1835 # endif
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1836 # endif
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1837
6c5b11458f31 patch 8.2.0872: XIM code is mixed with multi-byte code
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1838 #endif // FEAT_XIM