diff options
author | Yegappan Lakshmanan <yegappan@yahoo.com> | 2021-12-04 14:02:30 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-12-04 14:02:30 +0000 |
commit | 7645da568c5e3b4ee339a2e99c3b3af790619787 (patch) | |
tree | e922a56be3ad038a67e54ca04a1469d6e1115329 /src/gui_xim.c | |
parent | 01a4dcbceefa99696bd1ef8631c3f7ce9f6e0cc2 (diff) | |
download | vim-git-7645da568c5e3b4ee339a2e99c3b3af790619787.tar.gz |
patch 8.2.3735: cannot use a lambda for 'imactivatefunc'v8.2.3735
Problem: Cannot use a lambda for 'imactivatefunc'.
Solution: Add lambda support for 'imactivatefunc' and 'imstatusfunc'.
(Yegappan Lakshmanan, closes #9275)
Diffstat (limited to 'src/gui_xim.c')
-rw-r--r-- | src/gui_xim.c | 37 |
1 files changed, 33 insertions, 4 deletions
diff --git a/src/gui_xim.c b/src/gui_xim.c index 2a12412da..6d72ef1d6 100644 --- a/src/gui_xim.c +++ b/src/gui_xim.c @@ -67,8 +67,24 @@ xim_log(char *s, ...) # define USE_IMSTATUSFUNC (*p_imsf != NUL) #endif -#if defined(FEAT_EVAL) && \ - (defined(FEAT_XIM) || defined(IME_WITHOUT_XIM) || defined(VIMDLL)) +#if (defined(FEAT_EVAL) && \ + (defined(FEAT_XIM) || defined(IME_WITHOUT_XIM) || defined(VIMDLL))) || \ + defined(PROTO) +static callback_T imaf_cb; // 'imactivatefunc' callback function +static callback_T imsf_cb; // 'imstatusfunc' callback function + + int +set_imactivatefunc_option(void) +{ + return option_set_callback_func(p_imaf, &imaf_cb); +} + + int +set_imstatusfunc_option(void) +{ + return option_set_callback_func(p_imsf, &imsf_cb); +} + static void call_imactivatefunc(int active) { @@ -77,7 +93,7 @@ call_imactivatefunc(int active) argv[0].v_type = VAR_NUMBER; argv[0].vval.v_number = active ? 1 : 0; argv[1].v_type = VAR_UNKNOWN; - (void)call_func_retnr(p_imaf, 1, argv); + (void)call_callback_retnr(&imaf_cb, 1, argv); } static int @@ -91,12 +107,25 @@ call_imstatusfunc(void) // FIXME: :py print 'xxx' is shown duplicate result. // Use silent to avoid it. ++msg_silent; - is_active = call_func_retnr(p_imsf, 0, NULL); + is_active = call_callback_retnr(&imsf_cb, 0, NULL); --msg_silent; return (is_active > 0); } #endif +#if defined(EXITFREE) || defined(PROTO) + void +free_xim_stuff(void) +{ +#if defined(FEAT_EVAL) && \ + (defined(FEAT_XIM) || defined(IME_WITHOUT_XIM) || defined(VIMDLL)) + free_callback(&imaf_cb); + free_callback(&imsf_cb); +# endif +} +#endif + + #if defined(FEAT_XIM) || defined(PROTO) # if defined(FEAT_GUI_GTK) || defined(PROTO) |