public
Created

Vim: use guifontwide for IME when available

  • Download Gist
patch-use_gfw_for_ime.diff
Diff
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
# 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));

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.