mirror of
https://github.com/vim/vim.git
synced 2025-09-23 03:43:49 -04:00
updated for version 7.3.1248
Problem: Still have old hacking code for Input Method. Solution: Add 'imactivatefunc' and 'imstatusfunc' as a generic solution to Input Method activation. (Yukihiro Nakadaira)
This commit is contained in:
57
src/mbyte.c
57
src/mbyte.c
@@ -4447,7 +4447,7 @@ im_set_active(int active)
|
||||
{
|
||||
int was_active;
|
||||
|
||||
was_active = !!im_is_active;
|
||||
was_active = !!im_get_status();
|
||||
im_is_active = (active && !p_imdisable);
|
||||
|
||||
if (im_is_active != was_active)
|
||||
@@ -5071,44 +5071,25 @@ xim_reset(void)
|
||||
{
|
||||
if (xic != NULL)
|
||||
{
|
||||
/*
|
||||
* The third-party imhangul module (and maybe others too) ignores
|
||||
* gtk_im_context_reset() or at least doesn't reset the active state.
|
||||
* Thus sending imactivatekey would turn it off if it was on before,
|
||||
* which is clearly not what we want. Fortunately we can work around
|
||||
* that for imhangul by sending GDK_Escape, but I don't know if it
|
||||
* works with all IM modules that support an activation key :/
|
||||
*
|
||||
* An alternative approach would be to destroy the IM context and
|
||||
* recreate it. But that means loading/unloading the IM module on
|
||||
* every mode switch, which causes a quite noticeable delay even on
|
||||
* my rather fast box...
|
||||
* *
|
||||
* Moreover, there are some XIM which cannot respond to
|
||||
* im_synthesize_keypress(). we hope that they reset by
|
||||
* xim_shutdown().
|
||||
*/
|
||||
if (im_activatekey_keyval != GDK_VoidSymbol && im_is_active)
|
||||
im_synthesize_keypress(GDK_Escape, 0U);
|
||||
|
||||
gtk_im_context_reset(xic);
|
||||
|
||||
/*
|
||||
* HACK for Ami: This sequence of function calls makes Ami handle
|
||||
* the IM reset graciously, without breaking loads of other stuff.
|
||||
* It seems to force English mode as well, which is exactly what we
|
||||
* want because it makes the Ami status display work reliably.
|
||||
*/
|
||||
gtk_im_context_set_use_preedit(xic, FALSE);
|
||||
|
||||
if (p_imdisable)
|
||||
im_shutdown();
|
||||
else
|
||||
{
|
||||
gtk_im_context_set_use_preedit(xic, TRUE);
|
||||
xim_set_focus(gui.in_focus);
|
||||
|
||||
if (im_activatekey_keyval != GDK_VoidSymbol)
|
||||
if (p_imaf[0] != NUL)
|
||||
{
|
||||
char_u *argv[1];
|
||||
|
||||
if (im_is_active)
|
||||
argv[0] = (char_u *)"1";
|
||||
else
|
||||
argv[0] = (char_u *)"0";
|
||||
(void)call_func_retnr(p_imaf, 1, argv, FALSE);
|
||||
}
|
||||
else if (im_activatekey_keyval != GDK_VoidSymbol)
|
||||
{
|
||||
if (im_is_active)
|
||||
{
|
||||
@@ -5268,6 +5249,20 @@ xim_queue_key_press_event(GdkEventKey *event, int down)
|
||||
int
|
||||
im_get_status(void)
|
||||
{
|
||||
if (p_imsf[0] != NUL)
|
||||
{
|
||||
int is_active;
|
||||
|
||||
/* FIXME: Don't execute user function in unsafe situation. */
|
||||
if (exiting || is_autocmd_blocked())
|
||||
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 im_is_active;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user