{not in Vi}
{only available when compiled with |+mbyte|}
This option specifies a function that will be called to
- activate/inactivate Input Method.
- Does not work in the MS-Windows GUI version.
+ activate or deactivate the Input Method.
+ It is not used in the GUI.
Example: >
function ImActivateFunc(active)
{only available when compiled with |+mbyte|}
This option specifies a function that is called to obtain the status
of Input Method. It must return a positive number when IME is active.
- Does not work in the MS-Windows GUI version.
+ It is not used in the GUI.
Example: >
function ImStatusFunc()
#endif /* FEAT_MBYTE */
+#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
+
#ifdef FEAT_EVAL
static void
call_imactivatefunc(int active)
xim_reset(void)
{
#ifdef FEAT_EVAL
- if (p_imaf[0] != NUL)
+ if (USE_IMACTIVATEFUNC)
call_imactivatefunc(im_is_active);
else
#endif
im_get_status(void)
{
# ifdef FEAT_EVAL
- if (p_imsf[0] != NUL)
+ if (USE_IMSTATUSFUNC)
return call_imstatusfunc();
# endif
return im_is_active;
/* If 'imdisable' is set, XIM is never active. */
if (p_imdisable)
active = FALSE;
-# if !defined(FEAT_GUI_GTK)
else if (input_style & XIMPreeditPosition)
/* There is a problem in switching XIM off when preediting is used,
* and it is not clear how this can be solved. For now, keep XIM on
* all the time, like it was done in Vim 5.8. */
active = TRUE;
-# endif
# if defined(FEAT_EVAL)
- if (p_imaf[0] != NUL)
+ if (USE_IMACTIVATEFUNC)
{
if (active != im_get_status())
{
}
else
{
- EMSG(_(e_xim));
+ if (!is_not_a_term())
+ EMSG(_(e_xim));
XCloseIM(xim);
return FALSE;
}
im_get_status(void)
{
# ifdef FEAT_EVAL
- if (p_imsf[0] != NUL)
+ if (USE_IMSTATUSFUNC)
return call_imstatusfunc();
# endif
return xim_has_focus;
im_get_status()
{
# ifdef FEAT_EVAL
- if (p_imsf[0] != NUL)
+ if (USE_IMSTATUSFUNC)
return call_imstatusfunc();
# endif
return im_was_set_active;
# if defined(FEAT_MBYTE) && defined(FEAT_EVAL)
int active = !p_imdisable && active_arg;
- if (p_imaf[0] != NUL && active != im_get_status())
+ if (USE_IMACTIVATEFUNC && active != im_get_status())
{
call_imactivatefunc(active);
im_was_set_active = active;
endfunc
func Test_iminsert2()
- if has('gui_win32')
- return
- endif
set imactivatefunc=IM_activatefunc
set imstatusfunc=IM_statusfunc
set iminsert=2
set iminsert=0
set imactivatefunc=
set imstatusfunc=
- call assert_equal(1, s:imactivatefunc_called)
- call assert_equal(1, s:imstatusfunc_called)
+
+ let expected = has('gui_running') ? 0 : 1
+ call assert_equal(expected, s:imactivatefunc_called)
+ call assert_equal(expected, s:imstatusfunc_called)
endfunc