summaryrefslogtreecommitdiff
path: root/src/mbyte.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2017-11-25 15:20:02 +0100
committerBram Moolenaar <Bram@vim.org>2017-11-25 15:20:02 +0100
commit6315a9ae924d2104b61d1667ea71af3ac7cf48fa (patch)
treede56592e8f6642707a93414b79c66586faea052d /src/mbyte.c
parent291a9d15ed1eb1094edc8ad6dda00a6da3bd7072 (diff)
downloadvim-git-6315a9ae924d2104b61d1667ea71af3ac7cf48fa.tar.gz
patch 8.0.1336: cannot use imactivatefunc() unless compiled with +ximv8.0.1336
Problem: Cannot use imactivatefunc() unless compiled with +xim. Solution: Allow using imactivatefunc() when not compiled with +xim. (Yasuhiro Matsumoto, closes #2349)
Diffstat (limited to 'src/mbyte.c')
-rw-r--r--src/mbyte.c72
1 files changed, 62 insertions, 10 deletions
diff --git a/src/mbyte.c b/src/mbyte.c
index 3592ddbdd..54186d9c2 100644
--- a/src/mbyte.c
+++ b/src/mbyte.c
@@ -4782,6 +4782,20 @@ iconv_end(void)
#endif /* FEAT_MBYTE */
+#ifdef FEAT_EVAL
+ static void
+call_imactivatefunc(int active)
+{
+ char_u *argv[1];
+
+ if (active)
+ argv[0] = (char_u *)"1";
+ else
+ argv[0] = (char_u *)"0";
+ (void)call_func_retnr(p_imaf, 1, argv, FALSE);
+}
+#endif
+
#if defined(FEAT_XIM) || defined(PROTO)
# if defined(FEAT_GUI_GTK) || defined(PROTO)
@@ -4824,7 +4838,14 @@ im_set_active(int active)
im_is_active = (active && !p_imdisable);
if (im_is_active != was_active)
- xim_reset();
+ {
+#ifdef FEAT_EVAL
+ if (p_imaf[0] != NUL)
+ call_imactivatefunc(im_is_active);
+ else
+#endif
+ xim_reset();
+ }
}
void
@@ -5666,15 +5687,7 @@ xim_reset(void)
# ifdef FEAT_EVAL
if (p_imaf[0] != NUL)
- {
- char_u *argv[1];
-
- if (im_is_active)
- argv[0] = (char_u *)"1";
- else
- argv[0] = (char_u *)"0";
- (void)call_func_retnr(p_imaf, 1, argv, FALSE);
- }
+ call_imactivatefunc(im_is_active);
else
# endif
if (im_activatekey_keyval != GDK_VoidSymbol)
@@ -6442,6 +6455,45 @@ xim_get_status_area_height(void)
}
# endif
+#else /* !defined(FEAT_XIM) */
+
+# ifndef FEAT_GUI_W32
+ int
+im_get_status()
+{
+# ifdef FEAT_EVAL
+ if (p_imsf[0] != NUL)
+ {
+ int is_active;
+
+ /* FIXME: Don't execute user function in unsafe situation. */
+ if (exiting
+# ifdef FEAT_AUTOCMD
+ || is_autocmd_blocked()
+# endif
+ )
+ return FALSE;
+ /* FIXME: :py print 'xxx' is shown duplicate result.
+ * Use silent to avoid it. */
+ ++msg_silent;
+ is_active = call_func_retnr(p_imsf, 0, NULL, FALSE);
+ --msg_silent;
+ return (is_active > 0);
+ }
+# endif
+ return FALSE;
+}
+
+ void
+im_set_active(int active)
+{
+# ifdef(USE_IM_CONTROL) && defined(FEAT_EVAL)
+ if (p_imaf[0] != NUL)
+ call_imactivatefunc(p_imdisable ? FALSE : active);
+# endif
+}
+# endif
+
#endif /* FEAT_XIM */
#if defined(FEAT_MBYTE) || defined(PROTO)