]>
Commit | Line | Data |
---|---|---|
48112765 AG |
1 | To: vim-dev@vim.org |
2 | Subject: Patch 6.2.388 | |
3 | Fcc: outbox | |
4 | From: Bram Moolenaar <Bram@moolenaar.net> | |
5 | Mime-Version: 1.0 | |
6 | Content-Type: text/plain; charset=ISO-8859-1 | |
7 | Content-Transfer-Encoding: 8bit | |
8 | ------------ | |
9 | ||
10 | Patch 6.2.388 | |
11 | Problem: GTK: When displaying some double-width characters they are drawn | |
12 | as single-width, because of conversion to UTF-8. | |
13 | Solution: Check the width that GTK uses and add a space if it's one instead | |
14 | of two. | |
15 | Files: src/gui_gtk_x11.c | |
16 | ||
17 | ||
18 | *** ../vim-6.2.387/src/gui_gtk_x11.c Mon Feb 9 18:45:58 2004 | |
19 | --- src/gui_gtk_x11.c Sat Mar 20 13:21:41 2004 | |
20 | *************** | |
21 | *** 5038,5047 **** | |
22 | gui_gtk2_draw_string(int row, int col, char_u *s, int len, int flags) | |
23 | { | |
24 | GdkRectangle area; /* area for clip mask */ | |
25 | - char_u *conv_buf = NULL; /* result of UTF-8 conversion */ | |
26 | PangoGlyphString *glyphs; /* glyphs of current item */ | |
27 | int column_offset = 0; /* column offset in cells */ | |
28 | int i; | |
29 | ||
30 | if (gui.text_context == NULL || gui.drawarea->window == NULL) | |
31 | return len; | |
32 | --- 5045,5058 ---- | |
33 | gui_gtk2_draw_string(int row, int col, char_u *s, int len, int flags) | |
34 | { | |
35 | GdkRectangle area; /* area for clip mask */ | |
36 | PangoGlyphString *glyphs; /* glyphs of current item */ | |
37 | int column_offset = 0; /* column offset in cells */ | |
38 | int i; | |
39 | + char_u *conv_buf = NULL; /* result of UTF-8 conversion */ | |
40 | + char_u *new_conv_buf; | |
41 | + int convlen; | |
42 | + char_u *sp, *bp; | |
43 | + int plen; | |
44 | ||
45 | if (gui.text_context == NULL || gui.drawarea->window == NULL) | |
46 | return len; | |
47 | *************** | |
48 | *** 5054,5063 **** | |
49 | * prohibits changing this to something else than UTF-8 if the GUI is | |
50 | * in use. | |
51 | */ | |
52 | ! conv_buf = string_convert(&output_conv, s, &len); | |
53 | ! s = conv_buf; | |
54 | ! | |
55 | g_return_val_if_fail(conv_buf != NULL, len); | |
56 | } | |
57 | ||
58 | /* | |
59 | --- 5065,5101 ---- | |
60 | * prohibits changing this to something else than UTF-8 if the GUI is | |
61 | * in use. | |
62 | */ | |
63 | ! convlen = len; | |
64 | ! conv_buf = string_convert(&output_conv, s, &convlen); | |
65 | g_return_val_if_fail(conv_buf != NULL, len); | |
66 | + | |
67 | + /* Correct for differences in char width: some chars are | |
68 | + * double-wide in 'encoding' but single-wide in utf-8. Add a space to | |
69 | + * compensate for that. */ | |
70 | + for (sp = s, bp = conv_buf; sp < s + len && bp < conv_buf + convlen; ) | |
71 | + { | |
72 | + plen = utf_ptr2len_check(bp); | |
73 | + if ((*mb_ptr2cells)(sp) == 2 && utf_ptr2cells(bp) == 1) | |
74 | + { | |
75 | + new_conv_buf = alloc(convlen + 2); | |
76 | + if (new_conv_buf == NULL) | |
77 | + return len; | |
78 | + plen += bp - conv_buf; | |
79 | + mch_memmove(new_conv_buf, conv_buf, plen); | |
80 | + new_conv_buf[plen] = ' '; | |
81 | + mch_memmove(new_conv_buf + plen + 1, conv_buf + plen, | |
82 | + convlen - plen + 1); | |
83 | + vim_free(conv_buf); | |
84 | + conv_buf = new_conv_buf; | |
85 | + ++convlen; | |
86 | + bp = conv_buf + plen; | |
87 | + plen = 1; | |
88 | + } | |
89 | + sp += (*mb_ptr2len_check)(sp); | |
90 | + bp += plen; | |
91 | + } | |
92 | + s = conv_buf; | |
93 | + len = convlen; | |
94 | } | |
95 | ||
96 | /* | |
97 | *** ../vim-6.2.387/src/version.c Mon Mar 22 14:33:28 2004 | |
98 | --- src/version.c Mon Mar 22 14:38:38 2004 | |
99 | *************** | |
100 | *** 639,640 **** | |
101 | --- 639,642 ---- | |
102 | { /* Add new patch number below this line */ | |
103 | + /**/ | |
104 | + 388, | |
105 | /**/ | |
106 | ||
107 | -- | |
108 | hundred-and-one symptoms of being an internet addict: | |
109 | 92. It takes you two hours to check all 14 of your mailboxes. | |
110 | ||
111 | /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ | |
112 | /// Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ | |
113 | \\\ Project leader for A-A-P -- http://www.A-A-P.org /// | |
114 | \\\ Buy at Amazon and help AIDS victims -- http://ICCF.nl/click1.html /// |