Created
April 11, 2014 07:23
-
-
Save presuku/10446538 to your computer and use it in GitHub Desktop.
ynkdir-imactivatekey patch from [ynkdir's google code](http://code.google.com/r/yukihironakadaira-vim/source/browse/?name=ynkdir-imactivatekey)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff -r 799a3e43b0b5 src/gui.c | |
--- a/src/gui.c Fri Jun 28 11:52:13 2013 +0900 | |
+++ b/src/gui.c Fri Jun 28 12:01:36 2013 +0900 | |
@@ -771,10 +771,6 @@ | |
gui_mch_disable_beval_area(balloonEval); | |
#endif | |
-#if defined(FEAT_XIM) && defined(FEAT_GUI_GTK) | |
- if (!im_xim_isvalid_imactivate()) | |
- EMSG(_("E599: Value of 'imactivatekey' is invalid")); | |
-#endif | |
/* When 'cmdheight' was set during startup it may not have taken | |
* effect yet. */ | |
if (p_ch != 1L) | |
@@ -1131,13 +1127,7 @@ | |
static int iid; | |
guicolor_T fg, bg; | |
- if ( | |
-# if defined(FEAT_GUI_GTK) && !defined(FEAT_HANGULIN) | |
- preedit_get_status() | |
-# else | |
- im_get_status() | |
-# endif | |
- ) | |
+ if (im_get_status()) | |
{ | |
iid = syn_name2id((char_u *)"CursorIM"); | |
if (iid > 0) | |
diff -r 799a3e43b0b5 src/mbyte.c | |
--- a/src/mbyte.c Fri Jun 28 11:52:13 2013 +0900 | |
+++ b/src/mbyte.c Fri Jun 28 12:01:36 2013 +0900 | |
@@ -4439,11 +4439,8 @@ | |
static int xim_has_preediting INIT(= FALSE); /* IM current status */ | |
static int im_is_active = FALSE; /* IM is enabled for current mode */ | |
-static int preedit_is_active = FALSE; | |
static unsigned long im_commit_handler_id = 0; | |
-static unsigned int im_activatekey_keyval = GDK_VoidSymbol; | |
-static unsigned int im_activatekey_state = 0; | |
static GtkWidget *preedit_window = NULL; | |
static GtkWidget *preedit_label = NULL; | |
@@ -4694,11 +4691,6 @@ | |
#ifdef XIM_DEBUG | |
xim_log("im_preedit_start_cb()\n"); | |
#endif | |
- | |
- im_is_active = TRUE; | |
- preedit_is_active = TRUE; | |
- gui_update_cursor(TRUE, FALSE); | |
- im_show_info(); | |
} | |
/* | |
@@ -4714,16 +4706,6 @@ | |
/* Indicate that preediting has finished */ | |
xim_has_preediting = FALSE; | |
- | |
-#if 0 | |
- /* Removal of this line suggested by Takuhiro Nishioka. Fixes that IM was | |
- * switched off unintentionally. We now use preedit_is_active (added by | |
- * SungHyun Nam). */ | |
- im_is_active = FALSE; | |
-#endif | |
- preedit_is_active = FALSE; | |
- gui_update_cursor(TRUE, FALSE); | |
- im_show_info(); | |
} | |
/* | |
@@ -4836,112 +4818,6 @@ | |
xim_has_preediting = FALSE; | |
} | |
-/* | |
- * Convert the string argument to keyval and state for GdkEventKey. | |
- * If str is valid return TRUE, otherwise FALSE. | |
- * | |
- * See 'imactivatekey' for documentation of the format. | |
- */ | |
- static int | |
-im_string_to_keyval(const char *str, unsigned int *keyval, unsigned int *state) | |
-{ | |
- const char *mods_end; | |
- unsigned tmp_keyval; | |
- unsigned tmp_state = 0; | |
- | |
- mods_end = strrchr(str, '-'); | |
- mods_end = (mods_end != NULL) ? mods_end + 1 : str; | |
- | |
- /* Parse modifier keys */ | |
- while (str < mods_end) | |
- switch (*str++) | |
- { | |
- case '-': break; | |
- case 'S': case 's': tmp_state |= (unsigned)GDK_SHIFT_MASK; break; | |
- case 'L': case 'l': tmp_state |= (unsigned)GDK_LOCK_MASK; break; | |
- case 'C': case 'c': tmp_state |= (unsigned)GDK_CONTROL_MASK;break; | |
- case '1': tmp_state |= (unsigned)GDK_MOD1_MASK; break; | |
- case '2': tmp_state |= (unsigned)GDK_MOD2_MASK; break; | |
- case '3': tmp_state |= (unsigned)GDK_MOD3_MASK; break; | |
- case '4': tmp_state |= (unsigned)GDK_MOD4_MASK; break; | |
- case '5': tmp_state |= (unsigned)GDK_MOD5_MASK; break; | |
- default: | |
- return FALSE; | |
- } | |
- | |
- tmp_keyval = gdk_keyval_from_name(str); | |
- | |
- if (tmp_keyval == 0 || tmp_keyval == GDK_VoidSymbol) | |
- return FALSE; | |
- | |
- if (keyval != NULL) | |
- *keyval = tmp_keyval; | |
- if (state != NULL) | |
- *state = tmp_state; | |
- | |
- return TRUE; | |
-} | |
- | |
-/* | |
- * Return TRUE if p_imak is valid, otherwise FALSE. As a special case, an | |
- * empty string is also regarded as valid. | |
- * | |
- * Note: The numerical key value of p_imak is cached if it was valid; thus | |
- * boldly assuming im_xim_isvalid_imactivate() will always be called whenever | |
- * 'imak' changes. This is currently the case but not obvious -- should | |
- * probably rename the function for clarity. | |
- */ | |
- int | |
-im_xim_isvalid_imactivate(void) | |
-{ | |
- if (p_imak[0] == NUL) | |
- { | |
- im_activatekey_keyval = GDK_VoidSymbol; | |
- im_activatekey_state = 0; | |
- return TRUE; | |
- } | |
- | |
- return im_string_to_keyval((const char *)p_imak, | |
- &im_activatekey_keyval, | |
- &im_activatekey_state); | |
-} | |
- | |
- static void | |
-im_synthesize_keypress(unsigned int keyval, unsigned int state) | |
-{ | |
- GdkEventKey *event; | |
- | |
-# ifdef HAVE_GTK_MULTIHEAD | |
- event = (GdkEventKey *)gdk_event_new(GDK_KEY_PRESS); | |
- g_object_ref(gui.drawarea->window); /* unreffed by gdk_event_free() */ | |
-# else | |
- event = (GdkEventKey *)g_malloc0((gulong)sizeof(GdkEvent)); | |
- event->type = GDK_KEY_PRESS; | |
-# endif | |
- event->window = gui.drawarea->window; | |
- event->send_event = TRUE; | |
- event->time = GDK_CURRENT_TIME; | |
- event->state = state; | |
- event->keyval = keyval; | |
- event->hardware_keycode = /* needed for XIM */ | |
- XKeysymToKeycode(GDK_WINDOW_XDISPLAY(event->window), (KeySym)keyval); | |
- event->length = 0; | |
- event->string = NULL; | |
- | |
- gtk_im_context_filter_keypress(xic, event); | |
- | |
- /* For consistency, also send the corresponding release event. */ | |
- event->type = GDK_KEY_RELEASE; | |
- event->send_event = FALSE; | |
- gtk_im_context_filter_keypress(xic, event); | |
- | |
-# ifdef HAVE_GTK_MULTIHEAD | |
- gdk_event_free((GdkEvent *)event); | |
-# else | |
- g_free(event); | |
-# endif | |
-} | |
- | |
void | |
xim_reset(void) | |
{ | |
@@ -4965,22 +4841,6 @@ | |
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) | |
- { | |
- g_signal_handler_block(xic, im_commit_handler_id); | |
- im_synthesize_keypress(im_activatekey_keyval, | |
- im_activatekey_state); | |
- g_signal_handler_unblock(xic, im_commit_handler_id); | |
- } | |
- } | |
- else | |
- { | |
- im_shutdown(); | |
- xim_init(); | |
- xim_set_focus(gui.in_focus); | |
- } | |
} | |
} | |
@@ -5032,75 +4892,17 @@ | |
* gtk_im_context_filter_keypress() in Normal mode. | |
* And while doing :sh too. | |
*/ | |
- if (xic != NULL && !p_imdisable | |
- && (State & (INSERT | CMDLINE | NORMAL | EXTERNCMD)) != 0) | |
+ if (xic != NULL && !p_imdisable) | |
{ | |
- /* | |
- * Filter 'imactivatekey' and map it to CTRL-^. This way, Vim is | |
- * always aware of the current status of IM, and can even emulate | |
- * the activation key for modules that don't support one. | |
- */ | |
- if (event->keyval == im_activatekey_keyval | |
- && (event->state & im_activatekey_state) == im_activatekey_state) | |
- { | |
- unsigned int state_mask; | |
- | |
- /* Require the state of the 3 most used modifiers to match exactly. | |
- * Otherwise e.g. <S-C-space> would be unusable for other purposes | |
- * if the IM activate key is <S-space>. */ | |
- state_mask = im_activatekey_state; | |
- state_mask |= ((int)GDK_SHIFT_MASK | (int)GDK_CONTROL_MASK | |
- | (int)GDK_MOD1_MASK); | |
- | |
- if ((event->state & state_mask) != im_activatekey_state) | |
- return FALSE; | |
- | |
- /* Don't send it a second time on GDK_KEY_RELEASE. */ | |
- if (event->type != GDK_KEY_PRESS) | |
- return TRUE; | |
- | |
- if (map_to_exists_mode((char_u *)"", LANGMAP, FALSE)) | |
- { | |
- im_set_active(FALSE); | |
- | |
- /* ":lmap" mappings exists, toggle use of mappings. */ | |
- State ^= LANGMAP; | |
- if (State & LANGMAP) | |
- { | |
- curbuf->b_p_iminsert = B_IMODE_NONE; | |
- State &= ~LANGMAP; | |
- } | |
- else | |
- { | |
- curbuf->b_p_iminsert = B_IMODE_LMAP; | |
- State |= LANGMAP; | |
- } | |
- return TRUE; | |
- } | |
- | |
- return gtk_im_context_filter_keypress(xic, event); | |
- } | |
- | |
- /* Don't filter events through the IM context if IM isn't active | |
- * right now. Unlike with GTK+ 1.2 we cannot rely on the IM module | |
- * not doing anything before the activation key was sent. */ | |
- if (im_activatekey_keyval == GDK_VoidSymbol || im_is_active) | |
- { | |
- int imresult = gtk_im_context_filter_keypress(xic, event); | |
- | |
- /* If XIM tried to commit a keypad key as a single char., | |
- * ignore it so we can use the keypad key 'raw', for mappings. */ | |
- if (xim_expected_char != NUL && xim_ignored_char) | |
- /* We had a keypad key, and XIM tried to thieve it */ | |
- return FALSE; | |
- | |
- /* This is supposed to fix a problem with iBus, that space | |
- * characters don't work in input mode. */ | |
- xim_expected_char = NUL; | |
- | |
- /* Normal processing */ | |
- return imresult; | |
- } | |
+ int imresult = gtk_im_context_filter_keypress(xic, event); | |
+ | |
+ /* If XIM tried to commit a keypad key as a single char., | |
+ * ignore it so we can use the keypad key 'raw', for mappings. */ | |
+ if (xim_expected_char != NUL && xim_ignored_char) | |
+ /* We had a keypad key, and XIM tried to thieve it */ | |
+ return FALSE; | |
+ | |
+ return imresult; | |
} | |
return FALSE; | |
@@ -5131,12 +4933,6 @@ | |
} | |
int | |
-preedit_get_status(void) | |
-{ | |
- return preedit_is_active; | |
-} | |
- | |
- int | |
im_is_preediting() | |
{ | |
return xim_has_preediting; | |
diff -r 799a3e43b0b5 src/option.c | |
--- a/src/option.c Fri Jun 28 11:52:13 2013 +0900 | |
+++ b/src/option.c Fri Jun 28 12:01:36 2013 +0900 | |
@@ -1477,13 +1477,6 @@ | |
{(char_u *)NULL, (char_u *)0L} | |
# endif | |
SCRIPTID_INIT}, | |
- {"imactivatekey","imak",P_STRING|P_VI_DEF, | |
-#if defined(FEAT_XIM) && defined(FEAT_GUI_GTK) | |
- (char_u *)&p_imak, PV_NONE, | |
-#else | |
- (char_u *)NULL, PV_NONE, | |
-#endif | |
- {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, | |
{"imcmdline", "imc", P_BOOL|P_VI_DEF, | |
#ifdef USE_IM_CONTROL | |
(char_u *)&p_imcmdline, PV_NONE, | |
@@ -6102,14 +6095,6 @@ | |
} | |
#endif | |
-#if defined(FEAT_XIM) && defined(FEAT_GUI_GTK) | |
- else if (varp == &p_imak) | |
- { | |
- if (gui.in_use && !im_xim_isvalid_imactivate()) | |
- errmsg = e_invarg; | |
- } | |
-#endif | |
- | |
#ifdef FEAT_KEYMAP | |
else if (varp == &curbuf->b_p_keymap) | |
{ | |
diff -r 799a3e43b0b5 src/option.h | |
--- a/src/option.h Fri Jun 28 11:52:13 2013 +0900 | |
+++ b/src/option.h Fri Jun 28 12:01:36 2013 +0900 | |
@@ -561,7 +561,6 @@ | |
#endif | |
EXTERN int p_ic; /* 'ignorecase' */ | |
#if defined(FEAT_XIM) && defined(FEAT_GUI_GTK) | |
-EXTERN char_u *p_imak; /* 'imactivatekey' */ | |
EXTERN char_u *p_imaf; /* 'imactivatefunc' */ | |
EXTERN char_u *p_imsf; /* 'imstatusfunc' */ | |
#endif | |
diff -r 799a3e43b0b5 src/proto/mbyte.pro | |
--- a/src/proto/mbyte.pro Fri Jun 28 11:52:13 2013 +0900 | |
+++ b/src/proto/mbyte.pro Fri Jun 28 12:01:36 2013 +0900 | |
@@ -78,11 +78,9 @@ | |
void xim_set_preedit __ARGS((void)); | |
void xim_init __ARGS((void)); | |
void im_shutdown __ARGS((void)); | |
-int im_xim_isvalid_imactivate __ARGS((void)); | |
void xim_reset __ARGS((void)); | |
int xim_queue_key_press_event __ARGS((GdkEventKey *event, int down)); | |
int im_get_status __ARGS((void)); | |
-int preedit_get_status __ARGS((void)); | |
int im_is_preediting __ARGS((void)); | |
void xim_set_status_area __ARGS((void)); | |
int xim_get_status_area_height __ARGS((void)); | |
diff -r 799a3e43b0b5 src/screen.c | |
--- a/src/screen.c Fri Jun 28 11:52:13 2013 +0900 | |
+++ b/src/screen.c Fri Jun 28 12:01:36 2013 +0900 | |
@@ -9531,13 +9531,7 @@ | |
{ | |
MSG_PUTS_ATTR("--", attr); | |
#if defined(FEAT_XIM) | |
- if ( | |
-# ifdef FEAT_GUI_GTK | |
- preedit_get_status() | |
-# else | |
- im_get_status() | |
-# endif | |
- ) | |
+ if (im_get_status()) | |
# ifdef FEAT_GUI_GTK /* most of the time, it's not XIM being used */ | |
MSG_PUTS_ATTR(" IM", attr); | |
# else |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment