Created
September 30, 2012 04:35
-
-
Save koron/3805843 to your computer and use it in GitHub Desktop.
Vim: use guifontwide for IME when available
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
# HG changeset patch | |
# Parent 90260c4de57396c83532cf99babecbc8f7473c16 | |
use guifontwide for IME when available | |
diff -r 90260c4de573 runtime/doc/options.txt | |
--- a/runtime/doc/options.txt Wed Sep 26 21:55:52 2012 +0900 | |
+++ b/runtime/doc/options.txt Tue Oct 02 10:30:19 2012 +0900 | |
@@ -3567,6 +3567,10 @@ | |
to set 'guifontwide' at all unless you want to override the choice | |
made by Pango/Xft. | |
+ Windows +multibyte only: *guifontwide_win_mbyte* | |
+ | |
+ If set and vaild, 'guifontwide' is used for IME instead of 'guifont'. | |
+ | |
*'guiheadroom'* *'ghr'* | |
'guiheadroom' 'ghr' number (default 50) | |
global | |
diff -r 90260c4de573 src/gui.c | |
--- a/src/gui.c Wed Sep 26 21:55:52 2012 +0900 | |
+++ b/src/gui.c Tue Oct 02 10:30:19 2012 +0900 | |
@@ -1008,6 +1008,9 @@ | |
else | |
#endif | |
gui.wide_font = font; | |
+#ifdef FEAT_GUI_MSWIN | |
+ gui_mch_wide_font_changed(); | |
+#endif | |
return OK; | |
} | |
#endif | |
diff -r 90260c4de573 src/gui_w48.c | |
--- a/src/gui_w48.c Wed Sep 26 21:55:52 2012 +0900 | |
+++ b/src/gui_w48.c Tue Oct 02 10:30:19 2012 +0900 | |
@@ -318,10 +318,15 @@ | |
/* | |
* For control IME. | |
+ * | |
+ * 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 | |
@@ -3078,6 +3083,39 @@ | |
return res; | |
} | |
+ | |
+#ifdef FEAT_MBYTE_IME | |
+/* | |
+ * Set correct LOGFONT to IME. Use 'guifontwide' if available, otherwise use | |
+ * 'guifont' | |
+ */ | |
+ static void | |
+update_im_font() | |
+{ | |
+ LOGFONT lf_wide; | |
+ | |
+ if (p_guifontwide != NULL && *p_guifontwide != NUL | |
+ && get_logfont(&lf_wide, p_guifontwide, NULL, TRUE) == OK) | |
+ norm_logfont = lf_wide; | |
+ else | |
+ norm_logfont = sub_logfont; | |
+ im_set_font(&norm_logfont); | |
+} | |
+#endif | |
+ | |
+#ifdef FEAT_MBYTE | |
+/* | |
+ * Handler of gui.wide_font (p_guifontwide) changed notification. | |
+ */ | |
+ void | |
+gui_mch_wide_font_changed() | |
+{ | |
+#ifdef FEAT_MBYTE_IME | |
+ update_im_font(); | |
+#endif | |
+} | |
+#endif | |
+ | |
/* | |
* Initialise vim to use the font with the given name. | |
* Return FAIL if the font could not be loaded, OK otherwise. | |
@@ -3100,9 +3138,10 @@ | |
font_name = lf.lfFaceName; | |
#if defined(FEAT_MBYTE_IME) || defined(GLOBAL_IME) | |
norm_logfont = lf; | |
+ sub_logfont = lf; | |
#endif | |
#ifdef FEAT_MBYTE_IME | |
- im_set_font(&lf); | |
+ update_im_font(); | |
#endif | |
gui_mch_free_font(gui.norm_font); | |
gui.norm_font = font; | |
diff -r 90260c4de573 src/proto/gui_w16.pro | |
--- a/src/proto/gui_w16.pro Wed Sep 26 21:55:52 2012 +0900 | |
+++ b/src/proto/gui_w16.pro Tue Oct 02 10:30:19 2012 +0900 | |
@@ -50,6 +50,7 @@ | |
void gui_mch_insert_lines __ARGS((int row, int num_lines)); | |
void gui_mch_exit __ARGS((int rc)); | |
int gui_mch_init_font __ARGS((char_u *font_name, int fontset)); | |
+void gui_mch_wide_font_changed __ARGS((void)); | |
int gui_mch_maximized __ARGS((void)); | |
void gui_mch_newfont __ARGS((void)); | |
void gui_mch_settitle __ARGS((char_u *title, char_u *icon)); | |
diff -r 90260c4de573 src/proto/gui_w32.pro | |
--- a/src/proto/gui_w32.pro Wed Sep 26 21:55:52 2012 +0900 | |
+++ b/src/proto/gui_w32.pro Tue Oct 02 10:30:19 2012 +0900 | |
@@ -50,6 +50,7 @@ | |
void gui_mch_insert_lines __ARGS((int row, int num_lines)); | |
void gui_mch_exit __ARGS((int rc)); | |
int gui_mch_init_font __ARGS((char_u *font_name, int fontset)); | |
+void gui_mch_wide_font_changed __ARGS((void)); | |
int gui_mch_maximized __ARGS((void)); | |
void gui_mch_newfont __ARGS((void)); | |
void gui_mch_settitle __ARGS((char_u *title, char_u *icon)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment