From 5689b8f5a44f126efaeca0c00c3735b5e97053bd Mon Sep 17 00:00:00 2001 From: Kazuki Sakamoto Date: Wed, 29 Nov 2017 22:15:24 -0800 Subject: [PATCH] Fix to call imactivatefunc and imstatusfunc --- src/MacVim/gui_macvim.m | 25 +++++++++++++++++++++++++ src/mbyte.c | 8 ++++++++ src/proto/mbyte.pro | 4 ++++ 3 files changed, 37 insertions(+) diff --git a/src/MacVim/gui_macvim.m b/src/MacVim/gui_macvim.m index 1dd4ded4af..1733c1f7b5 100644 --- a/src/MacVim/gui_macvim.m +++ b/src/MacVim/gui_macvim.m @@ -1290,6 +1290,15 @@ mch_set_mouse_shape(int shape) // -- Input Method ---------------------------------------------------------- #if defined(FEAT_MBYTE) +# if defined(FEAT_EVAL) +# ifdef FEAT_GUI +# define USE_IMACTIVATEFUNC (!gui.in_use && *p_imaf != NUL) +# define USE_IMSTATUSFUNC (!gui.in_use && *p_imsf != NUL) +# else +# define USE_IMACTIVATEFUNC (*p_imaf != NUL) +# define USE_IMSTATUSFUNC (*p_imsf != NUL) +# endif +# endif void im_set_position(int row, int col) @@ -1312,6 +1321,17 @@ im_set_control(int enable) void im_set_active(int active) { +#if defined(FEAT_EVAL) + if (USE_IMACTIVATEFUNC) + { + if (active != im_get_status()) + { + call_imactivatefunc(active); + } + return; + } +#endif + // Tell frontend to enable/disable IM (called e.g. when the mode changes). if (!p_imdisable) { int msgid = active ? ActivateKeyScriptMsgID : DeactivateKeyScriptMsgID; @@ -1324,6 +1344,11 @@ im_set_active(int active) int im_get_status(void) { +# ifdef FEAT_EVAL + if (USE_IMSTATUSFUNC) + return call_imstatusfunc(); +# endif + return [[MMBackend sharedInstance] imState]; } diff --git a/src/mbyte.c b/src/mbyte.c index 9e3919f192..4aba80849c 100644 --- a/src/mbyte.c +++ b/src/mbyte.c @@ -4791,7 +4791,11 @@ iconv_end(void) #endif #if defined(FEAT_EVAL) && defined(FEAT_MBYTE) +# ifdef FEAT_GUI_MACVIM + void +# else static void +# endif call_imactivatefunc(int active) { char_u *argv[1]; @@ -4803,7 +4807,11 @@ call_imactivatefunc(int active) (void)call_func_retnr(p_imaf, 1, argv, FALSE); } +# ifdef FEAT_GUI_MACVIM + int +# else static int +# endif call_imstatusfunc(void) { int is_active; diff --git a/src/proto/mbyte.pro b/src/proto/mbyte.pro index 2ba9f1c9fc..b94f7b85b6 100644 --- a/src/proto/mbyte.pro +++ b/src/proto/mbyte.pro @@ -98,4 +98,8 @@ int convert_input(char_u *ptr, int len, int maxlen); int convert_input_safe(char_u *ptr, int len, int maxlen, char_u **restp, int *restlenp); char_u *string_convert(vimconv_T *vcp, char_u *ptr, int *lenp); char_u *string_convert_ext(vimconv_T *vcp, char_u *ptr, int *lenp, int *unconvlenp); +#ifdef FEAT_GUI_MACVIM +void call_imactivatefunc(int active); +int call_imstatusfunc(void); +#endif /* vim: set ft=c : */