mirror of
https://github.com/zoriya/vim.git
synced 2025-12-20 06:05:18 +00:00
patch 8.0.1338: USE_IM_CONTROL is confusing and incomplete
Problem: USE_IM_CONTROL is confusing and incomplete. Solution: Just use FEAT_MBYTE. Call 'imactivatefunc' also without GUI.
This commit is contained in:
12
src/edit.c
12
src/edit.c
@@ -516,7 +516,7 @@ edit(
|
||||
*/
|
||||
if (curbuf->b_p_iminsert == B_IMODE_LMAP)
|
||||
State |= LANGMAP;
|
||||
#ifdef USE_IM_CONTROL
|
||||
#ifdef FEAT_MBYTE
|
||||
im_set_active(curbuf->b_p_iminsert == B_IMODE_IM);
|
||||
#endif
|
||||
|
||||
@@ -8372,7 +8372,7 @@ ins_reg(void)
|
||||
++no_u_sync;
|
||||
if (regname == '=')
|
||||
{
|
||||
# ifdef USE_IM_CONTROL
|
||||
# ifdef FEAT_MBYTE
|
||||
int im_on = im_get_status();
|
||||
# endif
|
||||
/* Sync undo when evaluating the expression calls setline() or
|
||||
@@ -8380,7 +8380,7 @@ ins_reg(void)
|
||||
u_sync_once = 2;
|
||||
|
||||
regname = get_expr_register();
|
||||
# ifdef USE_IM_CONTROL
|
||||
# ifdef FEAT_MBYTE
|
||||
/* Restore the Input Method. */
|
||||
if (im_on)
|
||||
im_set_active(TRUE);
|
||||
@@ -8509,12 +8509,12 @@ ins_ctrl_hat(void)
|
||||
{
|
||||
curbuf->b_p_iminsert = B_IMODE_LMAP;
|
||||
State |= LANGMAP;
|
||||
#ifdef USE_IM_CONTROL
|
||||
#ifdef FEAT_MBYTE
|
||||
im_set_active(FALSE);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#ifdef USE_IM_CONTROL
|
||||
#ifdef FEAT_MBYTE
|
||||
else
|
||||
{
|
||||
/* There are no ":lmap" mappings, toggle IM */
|
||||
@@ -8661,7 +8661,7 @@ ins_esc(
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef USE_IM_CONTROL
|
||||
#ifdef FEAT_MBYTE
|
||||
/* Disable IM to allow typing English directly for Normal mode commands.
|
||||
* When ":lmap" is enabled don't change 'iminsert' (IM can be enabled as
|
||||
* well). */
|
||||
|
||||
@@ -359,11 +359,11 @@ getcmdline(
|
||||
b_im_ptr = &curbuf->b_p_imsearch;
|
||||
if (*b_im_ptr == B_IMODE_LMAP)
|
||||
State |= LANGMAP;
|
||||
#ifdef USE_IM_CONTROL
|
||||
#ifdef FEAT_MBYTE
|
||||
im_set_active(*b_im_ptr == B_IMODE_IM);
|
||||
#endif
|
||||
}
|
||||
#ifdef USE_IM_CONTROL
|
||||
#ifdef FEAT_MBYTE
|
||||
else if (p_imcmdline)
|
||||
im_set_active(TRUE);
|
||||
#endif
|
||||
@@ -1119,7 +1119,7 @@ getcmdline(
|
||||
{
|
||||
/* ":lmap" mappings exists, toggle use of mappings. */
|
||||
State ^= LANGMAP;
|
||||
#ifdef USE_IM_CONTROL
|
||||
#ifdef FEAT_MBYTE
|
||||
im_set_active(FALSE); /* Disable input method */
|
||||
#endif
|
||||
if (b_im_ptr != NULL)
|
||||
@@ -1130,7 +1130,7 @@ getcmdline(
|
||||
*b_im_ptr = B_IMODE_NONE;
|
||||
}
|
||||
}
|
||||
#ifdef USE_IM_CONTROL
|
||||
#ifdef FEAT_MBYTE
|
||||
else
|
||||
{
|
||||
/* There are no ":lmap" mappings, toggle IM. When
|
||||
@@ -2143,7 +2143,7 @@ returncmd:
|
||||
#endif
|
||||
|
||||
State = save_State;
|
||||
#ifdef USE_IM_CONTROL
|
||||
#ifdef FEAT_MBYTE
|
||||
if (b_im_ptr != NULL && *b_im_ptr != B_IMODE_LMAP)
|
||||
im_save_status(b_im_ptr);
|
||||
im_set_active(FALSE);
|
||||
|
||||
@@ -2890,7 +2890,7 @@ vgetorpeek(int advance)
|
||||
+ typebuf.tb_len] != NUL)
|
||||
typebuf.tb_noremap[typebuf.tb_off
|
||||
+ typebuf.tb_len++] = RM_YES;
|
||||
#ifdef USE_IM_CONTROL
|
||||
#ifdef FEAT_MBYTE
|
||||
/* Get IM status right after getting keys, not after the
|
||||
* timeout for a mapping (focus may be lost by then). */
|
||||
vgetc_im_active = im_get_status();
|
||||
|
||||
@@ -1022,7 +1022,7 @@ EXTERN int stop_insert_mode; /* for ":stopinsert" and 'insertmode' */
|
||||
|
||||
EXTERN int KeyTyped; /* TRUE if user typed current char */
|
||||
EXTERN int KeyStuffed; /* TRUE if current char from stuffbuf */
|
||||
#ifdef USE_IM_CONTROL
|
||||
#ifdef FEAT_MBYTE
|
||||
EXTERN int vgetc_im_active; /* Input Method was active for last
|
||||
character obtained from vgetc() */
|
||||
#endif
|
||||
|
||||
@@ -1078,7 +1078,7 @@ gui_update_cursor(
|
||||
gui_undraw_cursor();
|
||||
if (gui.row < 0)
|
||||
return;
|
||||
#ifdef USE_IM_CONTROL
|
||||
#ifdef FEAT_MBYTE
|
||||
if (gui.row != gui.cursor_row || gui.col != gui.cursor_col)
|
||||
im_set_position(gui.row, gui.col);
|
||||
#endif
|
||||
@@ -1136,7 +1136,7 @@ gui_update_cursor(
|
||||
if (id > 0)
|
||||
{
|
||||
cattr = syn_id2colors(id, &cfg, &cbg);
|
||||
#if defined(USE_IM_CONTROL) || defined(FEAT_HANGULIN)
|
||||
#if defined(FEAT_MBYTE) || defined(FEAT_HANGULIN)
|
||||
{
|
||||
static int iid;
|
||||
guicolor_T fg, bg;
|
||||
|
||||
@@ -2024,13 +2024,13 @@ gui_mac_handle_window_activate(
|
||||
switch (eventKind)
|
||||
{
|
||||
case kEventWindowActivated:
|
||||
#if defined(USE_IM_CONTROL)
|
||||
# if defined(FEAT_MBYTE)
|
||||
im_on_window_switch(TRUE);
|
||||
# endif
|
||||
return noErr;
|
||||
|
||||
case kEventWindowDeactivated:
|
||||
#if defined(USE_IM_CONTROL)
|
||||
# if defined(FEAT_MBYTE)
|
||||
im_on_window_switch(FALSE);
|
||||
# endif
|
||||
return noErr;
|
||||
@@ -6230,7 +6230,7 @@ char_u *FullPathFromFSSpec_save(FSSpec file)
|
||||
#endif
|
||||
}
|
||||
|
||||
#if (defined(USE_IM_CONTROL) || defined(PROTO)) && defined(USE_CARBONKEYHANDLER)
|
||||
#if (defined(FEAT_MBYTE) || defined(PROTO)) && defined(USE_CARBONKEYHANDLER)
|
||||
/*
|
||||
* Input Method Control functions.
|
||||
*/
|
||||
@@ -6379,7 +6379,7 @@ im_get_status(void)
|
||||
return im_is_active;
|
||||
}
|
||||
|
||||
#endif /* defined(USE_IM_CONTROL) || defined(PROTO) */
|
||||
#endif /* defined(FEAT_MBYTE) || defined(PROTO) */
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -485,13 +485,11 @@ static void TrackUserActivity(UINT uMsg);
|
||||
* These LOGFONT used for IME.
|
||||
*/
|
||||
#ifdef FEAT_MBYTE
|
||||
# ifdef USE_IM_CONTROL
|
||||
/* holds LOGFONT for 'guifontwide' if available, otherwise 'guifont' */
|
||||
static LOGFONT norm_logfont;
|
||||
/* holds LOGFONT for 'guifont' always. */
|
||||
static LOGFONT sub_logfont;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef FEAT_MBYTE_IME
|
||||
static LRESULT _OnImeNotify(HWND hWnd, DWORD dwCommand, DWORD dwData);
|
||||
|
||||
115
src/mbyte.c
115
src/mbyte.c
@@ -4794,6 +4794,26 @@ call_imactivatefunc(int active)
|
||||
argv[0] = (char_u *)"0";
|
||||
(void)call_func_retnr(p_imaf, 1, argv, FALSE);
|
||||
}
|
||||
|
||||
static int
|
||||
call_imstatusfunc(void)
|
||||
{
|
||||
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
|
||||
|
||||
#if defined(FEAT_XIM) || defined(PROTO)
|
||||
@@ -4838,15 +4858,8 @@ im_set_active(int active)
|
||||
im_is_active = (active && !p_imdisable);
|
||||
|
||||
if (im_is_active != was_active)
|
||||
{
|
||||
#ifdef FEAT_EVAL
|
||||
if (p_imaf[0] != NUL)
|
||||
call_imactivatefunc(im_is_active);
|
||||
else
|
||||
#endif
|
||||
xim_reset();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
xim_set_focus(int focus)
|
||||
@@ -5675,6 +5688,11 @@ im_synthesize_keypress(unsigned int keyval, unsigned int state)
|
||||
void
|
||||
xim_reset(void)
|
||||
{
|
||||
#ifdef FEAT_EVAL
|
||||
if (p_imaf[0] != NUL)
|
||||
call_imactivatefunc(im_is_active);
|
||||
else
|
||||
#endif
|
||||
if (xic != NULL)
|
||||
{
|
||||
gtk_im_context_reset(xic);
|
||||
@@ -5685,11 +5703,6 @@ xim_reset(void)
|
||||
{
|
||||
xim_set_focus(gui.in_focus);
|
||||
|
||||
# ifdef FEAT_EVAL
|
||||
if (p_imaf[0] != NUL)
|
||||
call_imactivatefunc(im_is_active);
|
||||
else
|
||||
# endif
|
||||
if (im_activatekey_keyval != GDK_VoidSymbol)
|
||||
{
|
||||
if (im_is_active)
|
||||
@@ -5856,23 +5869,7 @@ im_get_status(void)
|
||||
{
|
||||
# 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);
|
||||
}
|
||||
return call_imstatusfunc();
|
||||
# endif
|
||||
return im_is_active;
|
||||
}
|
||||
@@ -5901,12 +5898,12 @@ static int status_area_enabled = TRUE;
|
||||
|
||||
/*
|
||||
* Switch using XIM on/off. This is used by the code that changes "State".
|
||||
* When 'imactivatefunc' is defined use that function instead.
|
||||
*/
|
||||
void
|
||||
im_set_active(int active)
|
||||
im_set_active(int active_arg)
|
||||
{
|
||||
if (xic == NULL)
|
||||
return;
|
||||
int active = active_arg;
|
||||
|
||||
/* If 'imdisable' is set, XIM is never active. */
|
||||
if (p_imdisable)
|
||||
@@ -5919,6 +5916,21 @@ im_set_active(int active)
|
||||
active = TRUE;
|
||||
# endif
|
||||
|
||||
# if defined(FEAT_EVAL)
|
||||
if (p_imaf[0] != NUL)
|
||||
{
|
||||
if (active != im_get_status())
|
||||
{
|
||||
call_imactivatefunc(active);
|
||||
im_is_active = active;
|
||||
}
|
||||
return;
|
||||
}
|
||||
# endif
|
||||
|
||||
if (xic == NULL)
|
||||
return;
|
||||
|
||||
/* Remember the active state, it is needed when Vim gets keyboard focus. */
|
||||
xim_is_active = active;
|
||||
xim_set_preedit();
|
||||
@@ -6335,6 +6347,10 @@ xim_real_init(Window x11_window, Display *x11_display)
|
||||
int
|
||||
im_get_status(void)
|
||||
{
|
||||
# ifdef FEAT_EVAL
|
||||
if (p_imsf[0] != NUL)
|
||||
return call_imstatusfunc();
|
||||
# endif
|
||||
return xim_has_focus;
|
||||
}
|
||||
|
||||
@@ -6458,38 +6474,29 @@ xim_get_status_area_height(void)
|
||||
#else /* !defined(FEAT_XIM) */
|
||||
|
||||
# ifndef FEAT_GUI_W32
|
||||
static int im_was_set_active = FALSE;
|
||||
|
||||
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()
|
||||
return call_imstatusfunc();
|
||||
# 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;
|
||||
return im_was_set_active;
|
||||
}
|
||||
|
||||
void
|
||||
im_set_active(int active)
|
||||
im_set_active(int active_arg)
|
||||
{
|
||||
# if defined(USE_IM_CONTROL) && defined(FEAT_EVAL)
|
||||
if (p_imaf[0] != NUL)
|
||||
call_imactivatefunc(p_imdisable ? FALSE : active);
|
||||
# if defined(FEAT_MBYTE) && defined(FEAT_EVAL)
|
||||
int active = !p_imdisable && active_arg;
|
||||
|
||||
if (p_imaf[0] != NUL && active != im_get_status())
|
||||
{
|
||||
call_imactivatefunc(active);
|
||||
im_was_set_active = active;
|
||||
}
|
||||
# endif
|
||||
}
|
||||
# endif
|
||||
|
||||
@@ -892,7 +892,7 @@ getcount:
|
||||
int lit = FALSE; /* get extra character literally */
|
||||
int langmap_active = FALSE; /* using :lmap mappings */
|
||||
int lang; /* getting a text character */
|
||||
#ifdef USE_IM_CONTROL
|
||||
#ifdef FEAT_MBYTE
|
||||
int save_smd; /* saved value of p_smd */
|
||||
#endif
|
||||
|
||||
@@ -957,7 +957,7 @@ getcount:
|
||||
State = LANGMAP;
|
||||
langmap_active = TRUE;
|
||||
}
|
||||
#ifdef USE_IM_CONTROL
|
||||
#ifdef FEAT_MBYTE
|
||||
save_smd = p_smd;
|
||||
p_smd = FALSE; /* Don't let the IM code show the mode here */
|
||||
if (lang && curbuf->b_p_iminsert == B_IMODE_IM)
|
||||
@@ -973,7 +973,7 @@ getcount:
|
||||
++allow_keys;
|
||||
State = NORMAL_BUSY;
|
||||
}
|
||||
#ifdef USE_IM_CONTROL
|
||||
#ifdef FEAT_MBYTE
|
||||
if (lang)
|
||||
{
|
||||
if (curbuf->b_p_iminsert != B_IMODE_LMAP)
|
||||
|
||||
10
src/option.c
10
src/option.c
@@ -1539,7 +1539,7 @@ static struct vimoption options[] =
|
||||
(char_u *)&p_ic, PV_NONE,
|
||||
{(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
|
||||
{"imactivatefunc","imaf",P_STRING|P_VI_DEF|P_SECURE,
|
||||
#if defined(FEAT_EVAL) && defined(USE_IM_CONTROL)
|
||||
#if defined(FEAT_EVAL) && defined(FEAT_MBYTE)
|
||||
(char_u *)&p_imaf, PV_NONE,
|
||||
{(char_u *)"", (char_u *)NULL}
|
||||
# else
|
||||
@@ -1555,14 +1555,14 @@ static struct vimoption options[] =
|
||||
#endif
|
||||
{(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
|
||||
{"imcmdline", "imc", P_BOOL|P_VI_DEF,
|
||||
#ifdef USE_IM_CONTROL
|
||||
#ifdef FEAT_MBYTE
|
||||
(char_u *)&p_imcmdline, PV_NONE,
|
||||
#else
|
||||
(char_u *)NULL, PV_NONE,
|
||||
#endif
|
||||
{(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
|
||||
{"imdisable", "imd", P_BOOL|P_VI_DEF,
|
||||
#ifdef USE_IM_CONTROL
|
||||
#ifdef FEAT_MBYTE
|
||||
(char_u *)&p_imdisable, PV_NONE,
|
||||
#else
|
||||
(char_u *)NULL, PV_NONE,
|
||||
@@ -1582,7 +1582,7 @@ static struct vimoption options[] =
|
||||
{(char_u *)B_IMODE_USE_INSERT, (char_u *)0L}
|
||||
SCRIPTID_INIT},
|
||||
{"imstatusfunc","imsf",P_STRING|P_VI_DEF|P_SECURE,
|
||||
#if defined(FEAT_EVAL) && defined(USE_IM_CONTROL)
|
||||
#if defined(FEAT_EVAL) && defined(FEAT_MBYTE)
|
||||
(char_u *)&p_imsf, PV_NONE,
|
||||
{(char_u *)"", (char_u *)NULL}
|
||||
#else
|
||||
@@ -8469,7 +8469,7 @@ set_bool_option(
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef USE_IM_CONTROL
|
||||
#ifdef FEAT_MBYTE
|
||||
/* 'imdisable' */
|
||||
else if ((int *)varp == &p_imdisable)
|
||||
{
|
||||
|
||||
@@ -585,11 +585,11 @@ EXTERN char_u *p_imak; /* 'imactivatekey' */
|
||||
#define IM_OVER_THE_SPOT 1L
|
||||
EXTERN long p_imst; /* 'imstyle' */
|
||||
#endif
|
||||
#if defined(FEAT_EVAL) && defined(USE_IM_CONTROL)
|
||||
#if defined(FEAT_EVAL) && defined(FEAT_MBYTE)
|
||||
EXTERN char_u *p_imaf; /* 'imactivatefunc' */
|
||||
EXTERN char_u *p_imsf; /* 'imstatusfunc' */
|
||||
#endif
|
||||
#ifdef USE_IM_CONTROL
|
||||
#ifdef FEAT_MBYTE
|
||||
EXTERN int p_imcmdline; /* 'imcmdline' */
|
||||
EXTERN int p_imdisable; /* 'imdisable' */
|
||||
#endif
|
||||
|
||||
2
src/ui.c
2
src/ui.c
@@ -3307,7 +3307,7 @@ ui_focus_change(
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(USE_IM_CONTROL) || defined(PROTO)
|
||||
#if defined(FEAT_MBYTE) || defined(PROTO)
|
||||
/*
|
||||
* Save current Input Method status to specified place.
|
||||
*/
|
||||
|
||||
@@ -771,6 +771,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
1338,
|
||||
/**/
|
||||
1337,
|
||||
/**/
|
||||
|
||||
Reference in New Issue
Block a user