From 6315a9ae924d2104b61d1667ea71af3ac7cf48fa Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sat, 25 Nov 2017 15:20:02 +0100 Subject: patch 8.0.1336: cannot use imactivatefunc() unless compiled with +xim Problem: Cannot use imactivatefunc() unless compiled with +xim. Solution: Allow using imactivatefunc() when not compiled with +xim. (Yasuhiro Matsumoto, closes #2349) --- src/mbyte.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 62 insertions(+), 10 deletions(-) (limited to 'src/mbyte.c') 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) -- cgit v1.2.1