]> git.pld-linux.org Git - packages/vim.git/blame - 7.2.093
- updated to 7.2.102
[packages/vim.git] / 7.2.093
CommitLineData
3e524028
AG
1To: vim-dev@vim.org
2Subject: Patch 7.2.093 (extra)
3Fcc: outbox
4From: Bram Moolenaar <Bram@moolenaar.net>
5Mime-Version: 1.0
6Content-Type: text/plain; charset=ISO-8859-1
7Content-Transfer-Encoding: 8bit
8------------
9
10Patch 7.2.093 (extra)
11Problem: Win32: inputdialog() and find/replace dialogs can't handle
12 multi-byte text.
13Solution: Use the wide version of dialog functions when available. (Yanwei
14 Jia)
15Files: src/gui_w32.c, src/gui_w48.c
16
17
18*** ../vim-7.2.092/src/gui_w32.c Thu Nov 20 17:09:09 2008
19--- src/gui_w32.c Wed Jan 28 21:15:29 2009
20***************
21*** 1582,1587 ****
22--- 1582,1598 ----
23 s_findrep_struct.lpstrReplaceWith[0] = NUL;
24 s_findrep_struct.wFindWhatLen = MSWIN_FR_BUFSIZE;
25 s_findrep_struct.wReplaceWithLen = MSWIN_FR_BUFSIZE;
26+ # if defined(FEAT_MBYTE) && defined(WIN3264)
27+ s_findrep_struct_w.lStructSize = sizeof(s_findrep_struct_w);
28+ s_findrep_struct_w.lpstrFindWhat =
29+ (LPWSTR)alloc(MSWIN_FR_BUFSIZE * sizeof(WCHAR));
30+ s_findrep_struct_w.lpstrFindWhat[0] = NUL;
31+ s_findrep_struct_w.lpstrReplaceWith =
32+ (LPWSTR)alloc(MSWIN_FR_BUFSIZE * sizeof(WCHAR));
33+ s_findrep_struct_w.lpstrReplaceWith[0] = NUL;
34+ s_findrep_struct_w.wFindWhatLen = MSWIN_FR_BUFSIZE;
35+ s_findrep_struct_w.wReplaceWithLen = MSWIN_FR_BUFSIZE;
36+ # endif
37 #endif
38
39 theend:
40***************
41*** 2938,2945 ****
42
43 /* If the edit box exists, copy the string. */
44 if (s_textfield != NULL)
45! GetDlgItemText(hwnd, DLG_NONBUTTON_CONTROL + 2,
46 s_textfield, IOSIZE);
47
48 /*
49 * Need to check for IDOK because if the user just hits Return to
50--- 2949,2975 ----
51
52 /* If the edit box exists, copy the string. */
53 if (s_textfield != NULL)
54! {
55! # if defined(FEAT_MBYTE) && defined(WIN3264)
56! /* If the OS is Windows NT, and 'encoding' differs from active
57! * codepage: use wide function and convert text. */
58! if (os_version.dwPlatformId == VER_PLATFORM_WIN32_NT
59! && enc_codepage >= 0 && (int)GetACP() != enc_codepage)
60! {
61! WCHAR *wp = (WCHAR *)alloc(IOSIZE * sizeof(WCHAR));
62! char_u *p;
63!
64! GetDlgItemTextW(hwnd, DLG_NONBUTTON_CONTROL + 2, wp, IOSIZE);
65! p = utf16_to_enc(wp, NULL);
66! vim_strncpy(s_textfield, p, IOSIZE);
67! vim_free(p);
68! vim_free(wp);
69! }
70! else
71! # endif
72! GetDlgItemText(hwnd, DLG_NONBUTTON_CONTROL + 2,
73 s_textfield, IOSIZE);
74+ }
75
76 /*
77 * Need to check for IDOK because if the user just hits Return to
78*** ../vim-7.2.092/src/gui_w48.c Wed Jan 28 14:17:21 2009
79--- src/gui_w48.c Wed Jan 28 21:10:26 2009
80***************
81*** 153,158 ****
82--- 153,161 ----
83 #ifdef MSWIN_FIND_REPLACE
84 static UINT s_findrep_msg = 0; /* set in gui_w[16/32].c */
85 static FINDREPLACE s_findrep_struct;
86+ # if defined(FEAT_MBYTE) && defined(WIN3264)
87+ static FINDREPLACEW s_findrep_struct_w;
88+ # endif
89 static HWND s_findrep_hwnd = NULL;
90 static int s_findrep_is_find; /* TRUE for find dialog, FALSE
91 for find/replace dialog */
92***************
93*** 884,889 ****
94--- 887,931 ----
95 #endif
96
97 #ifdef MSWIN_FIND_REPLACE
98+ # if defined(FEAT_MBYTE) && defined(WIN3264)
99+ /*
100+ * copy useful data from structure LPFINDREPLACE to structure LPFINDREPLACEW
101+ */
102+ static void
103+ findrep_atow(LPFINDREPLACEW lpfrw, LPFINDREPLACE lpfr)
104+ {
105+ WCHAR *wp;
106+
107+ lpfrw->hwndOwner = lpfr->hwndOwner;
108+ lpfrw->Flags = lpfr->Flags;
109+
110+ wp = enc_to_utf16(lpfr->lpstrFindWhat, NULL);
111+ wcsncpy(lpfrw->lpstrFindWhat, wp, lpfrw->wFindWhatLen - 1);
112+ vim_free(wp);
113+
114+ /* the field "lpstrReplaceWith" doesn't need to be copied */
115+ }
116+
117+ /*
118+ * copy useful data from structure LPFINDREPLACEW to structure LPFINDREPLACE
119+ */
120+ static void
121+ findrep_wtoa(LPFINDREPLACE lpfr, LPFINDREPLACEW lpfrw)
122+ {
123+ char_u *p;
124+
125+ lpfr->Flags = lpfrw->Flags;
126+
127+ p = utf16_to_enc(lpfrw->lpstrFindWhat, NULL);
128+ vim_strncpy(lpfr->lpstrFindWhat, p, lpfr->wFindWhatLen - 1);
129+ vim_free(p);
130+
131+ p = utf16_to_enc(lpfrw->lpstrReplaceWith, NULL);
132+ vim_strncpy(lpfr->lpstrReplaceWith, p, lpfr->wReplaceWithLen - 1);
133+ vim_free(p);
134+ }
135+ # endif
136+
137 /*
138 * Handle a Find/Replace window message.
139 */
140***************
141*** 893,898 ****
142--- 935,950 ----
143 int flags = 0;
144 int down;
145
146+ # if defined(FEAT_MBYTE) && defined(WIN3264)
147+ /* If the OS is Windows NT, and 'encoding' differs from active codepage:
148+ * convert text from wide string. */
149+ if (os_version.dwPlatformId == VER_PLATFORM_WIN32_NT
150+ && enc_codepage >= 0 && (int)GetACP() != enc_codepage)
151+ {
152+ findrep_wtoa(&s_findrep_struct, &s_findrep_struct_w);
153+ }
154+ # endif
155+
156 if (s_findrep_struct.Flags & FR_DIALOGTERM)
157 /* Give main window the focus back. */
158 (void)SetFocus(s_hwnd);
159***************
160*** 2562,2568 ****
161 if (!IsWindow(s_findrep_hwnd))
162 {
163 initialise_findrep(eap->arg);
164! s_findrep_hwnd = FindText((LPFINDREPLACE) &s_findrep_struct);
165 }
166
167 set_window_title(s_findrep_hwnd,
168--- 2614,2632 ----
169 if (!IsWindow(s_findrep_hwnd))
170 {
171 initialise_findrep(eap->arg);
172! # if defined(FEAT_MBYTE) && defined(WIN3264)
173! /* If the OS is Windows NT, and 'encoding' differs from active
174! * codepage: convert text and use wide function. */
175! if (os_version.dwPlatformId == VER_PLATFORM_WIN32_NT
176! && enc_codepage >= 0 && (int)GetACP() != enc_codepage)
177! {
178! findrep_atow(&s_findrep_struct_w, &s_findrep_struct);
179! s_findrep_hwnd = FindTextW(
180! (LPFINDREPLACEW) &s_findrep_struct_w);
181! }
182! else
183! # endif
184! s_findrep_hwnd = FindText((LPFINDREPLACE) &s_findrep_struct);
185 }
186
187 set_window_title(s_findrep_hwnd,
188***************
189*** 2587,2593 ****
190 if (!IsWindow(s_findrep_hwnd))
191 {
192 initialise_findrep(eap->arg);
193! s_findrep_hwnd = ReplaceText((LPFINDREPLACE) &s_findrep_struct);
194 }
195
196 set_window_title(s_findrep_hwnd,
197--- 2651,2668 ----
198 if (!IsWindow(s_findrep_hwnd))
199 {
200 initialise_findrep(eap->arg);
201! # if defined(FEAT_MBYTE) && defined(WIN3264)
202! if (os_version.dwPlatformId == VER_PLATFORM_WIN32_NT
203! && enc_codepage >= 0 && (int)GetACP() != enc_codepage)
204! {
205! findrep_atow(&s_findrep_struct_w, &s_findrep_struct);
206! s_findrep_hwnd = ReplaceTextW(
207! (LPFINDREPLACEW) &s_findrep_struct_w);
208! }
209! else
210! # endif
211! s_findrep_hwnd = ReplaceText(
212! (LPFINDREPLACE) &s_findrep_struct);
213 }
214
215 set_window_title(s_findrep_hwnd,
216*** ../vim-7.2.092/src/version.c Wed Jan 28 19:08:31 2009
217--- src/version.c Wed Jan 28 21:19:56 2009
218***************
219*** 678,679 ****
220--- 678,681 ----
221 { /* Add new patch number below this line */
222+ /**/
223+ 93,
224 /**/
225
226--
227I'm not familiar with this proof, but I'm aware of a significant
228following of toddlers who believe that peanut butter is the solution
229to all of life's problems... -- Tim Hammerquist
230
231 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
232/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
233\\\ download, build and distribute -- http://www.A-A-P.org ///
234 \\\ help me help AIDS victims -- http://ICCF-Holland.org ///
This page took 0.09645 seconds and 4 git commands to generate.