Skip to content

Commit 594349b

Browse files
authored
Merge pull request #606 from macvim-dev/fix/im_funcs
Fix to call imactivatefunc and imstatusfunc
2 parents 28c6e2f + 5689b8f commit 594349b

3 files changed

Lines changed: 37 additions & 0 deletions

File tree

src/MacVim/gui_macvim.m

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1290,6 +1290,15 @@
12901290
// -- Input Method ----------------------------------------------------------
12911291

12921292
#if defined(FEAT_MBYTE)
1293+
# if defined(FEAT_EVAL)
1294+
# ifdef FEAT_GUI
1295+
# define USE_IMACTIVATEFUNC (!gui.in_use && *p_imaf != NUL)
1296+
# define USE_IMSTATUSFUNC (!gui.in_use && *p_imsf != NUL)
1297+
# else
1298+
# define USE_IMACTIVATEFUNC (*p_imaf != NUL)
1299+
# define USE_IMSTATUSFUNC (*p_imsf != NUL)
1300+
# endif
1301+
# endif
12931302

12941303
void
12951304
im_set_position(int row, int col)
@@ -1312,6 +1321,17 @@
13121321
void
13131322
im_set_active(int active)
13141323
{
1324+
#if defined(FEAT_EVAL)
1325+
if (USE_IMACTIVATEFUNC)
1326+
{
1327+
if (active != im_get_status())
1328+
{
1329+
call_imactivatefunc(active);
1330+
}
1331+
return;
1332+
}
1333+
#endif
1334+
13151335
// Tell frontend to enable/disable IM (called e.g. when the mode changes).
13161336
if (!p_imdisable) {
13171337
int msgid = active ? ActivateKeyScriptMsgID : DeactivateKeyScriptMsgID;
@@ -1324,6 +1344,11 @@
13241344
int
13251345
im_get_status(void)
13261346
{
1347+
# ifdef FEAT_EVAL
1348+
if (USE_IMSTATUSFUNC)
1349+
return call_imstatusfunc();
1350+
# endif
1351+
13271352
return [[MMBackend sharedInstance] imState];
13281353
}
13291354

src/mbyte.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4791,7 +4791,11 @@ iconv_end(void)
47914791
#endif
47924792

47934793
#if defined(FEAT_EVAL) && defined(FEAT_MBYTE)
4794+
# ifdef FEAT_GUI_MACVIM
4795+
void
4796+
# else
47944797
static void
4798+
# endif
47954799
call_imactivatefunc(int active)
47964800
{
47974801
char_u *argv[1];
@@ -4803,7 +4807,11 @@ call_imactivatefunc(int active)
48034807
(void)call_func_retnr(p_imaf, 1, argv, FALSE);
48044808
}
48054809

4810+
# ifdef FEAT_GUI_MACVIM
4811+
int
4812+
# else
48064813
static int
4814+
# endif
48074815
call_imstatusfunc(void)
48084816
{
48094817
int is_active;

src/proto/mbyte.pro

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,4 +98,8 @@ int convert_input(char_u *ptr, int len, int maxlen);
9898
int convert_input_safe(char_u *ptr, int len, int maxlen, char_u **restp, int *restlenp);
9999
char_u *string_convert(vimconv_T *vcp, char_u *ptr, int *lenp);
100100
char_u *string_convert_ext(vimconv_T *vcp, char_u *ptr, int *lenp, int *unconvlenp);
101+
#ifdef FEAT_GUI_MACVIM
102+
void call_imactivatefunc(int active);
103+
int call_imstatusfunc(void);
104+
#endif
101105
/* vim: set ft=c : */

0 commit comments

Comments
 (0)