2 Subject: Patch 7.2.093 (extra)
4 From: Bram Moolenaar <Bram@moolenaar.net>
6 Content-Type: text/plain; charset=ISO-8859-1
7 Content-Transfer-Encoding: 8bit
11 Problem: Win32: inputdialog() and find/replace dialogs can't handle
13 Solution: Use the wide version of dialog functions when available. (Yanwei
15 Files: src/gui_w32.c, src/gui_w48.c
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
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;
43 /* If the edit box exists, copy the string. */
44 if (s_textfield != NULL)
45 ! GetDlgItemText(hwnd, DLG_NONBUTTON_CONTROL + 2,
49 * Need to check for IDOK because if the user just hits Return to
52 /* If the edit box exists, copy the string. */
53 if (s_textfield != NULL)
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)
61 ! WCHAR *wp = (WCHAR *)alloc(IOSIZE * sizeof(WCHAR));
64 ! GetDlgItemTextW(hwnd, DLG_NONBUTTON_CONTROL + 2, wp, IOSIZE);
65 ! p = utf16_to_enc(wp, NULL);
66 ! vim_strncpy(s_textfield, p, IOSIZE);
72 ! GetDlgItemText(hwnd, DLG_NONBUTTON_CONTROL + 2,
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
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;
89 static HWND s_findrep_hwnd = NULL;
90 static int s_findrep_is_find; /* TRUE for find dialog, FALSE
91 for find/replace dialog */
97 #ifdef MSWIN_FIND_REPLACE
98 + # if defined(FEAT_MBYTE) && defined(WIN3264)
100 + * copy useful data from structure LPFINDREPLACE to structure LPFINDREPLACEW
103 + findrep_atow(LPFINDREPLACEW lpfrw, LPFINDREPLACE lpfr)
107 + lpfrw->hwndOwner = lpfr->hwndOwner;
108 + lpfrw->Flags = lpfr->Flags;
110 + wp = enc_to_utf16(lpfr->lpstrFindWhat, NULL);
111 + wcsncpy(lpfrw->lpstrFindWhat, wp, lpfrw->wFindWhatLen - 1);
114 + /* the field "lpstrReplaceWith" doesn't need to be copied */
118 + * copy useful data from structure LPFINDREPLACEW to structure LPFINDREPLACE
121 + findrep_wtoa(LPFINDREPLACE lpfr, LPFINDREPLACEW lpfrw)
125 + lpfr->Flags = lpfrw->Flags;
127 + p = utf16_to_enc(lpfrw->lpstrFindWhat, NULL);
128 + vim_strncpy(lpfr->lpstrFindWhat, p, lpfr->wFindWhatLen - 1);
131 + p = utf16_to_enc(lpfrw->lpstrReplaceWith, NULL);
132 + vim_strncpy(lpfr->lpstrReplaceWith, p, lpfr->wReplaceWithLen - 1);
138 * Handle a Find/Replace window message.
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)
152 + findrep_wtoa(&s_findrep_struct, &s_findrep_struct_w);
156 if (s_findrep_struct.Flags & FR_DIALOGTERM)
157 /* Give main window the focus back. */
158 (void)SetFocus(s_hwnd);
161 if (!IsWindow(s_findrep_hwnd))
163 initialise_findrep(eap->arg);
164 ! s_findrep_hwnd = FindText((LPFINDREPLACE) &s_findrep_struct);
167 set_window_title(s_findrep_hwnd,
169 if (!IsWindow(s_findrep_hwnd))
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)
178 ! findrep_atow(&s_findrep_struct_w, &s_findrep_struct);
179 ! s_findrep_hwnd = FindTextW(
180 ! (LPFINDREPLACEW) &s_findrep_struct_w);
184 ! s_findrep_hwnd = FindText((LPFINDREPLACE) &s_findrep_struct);
187 set_window_title(s_findrep_hwnd,
190 if (!IsWindow(s_findrep_hwnd))
192 initialise_findrep(eap->arg);
193 ! s_findrep_hwnd = ReplaceText((LPFINDREPLACE) &s_findrep_struct);
196 set_window_title(s_findrep_hwnd,
198 if (!IsWindow(s_findrep_hwnd))
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)
205 ! findrep_atow(&s_findrep_struct_w, &s_findrep_struct);
206 ! s_findrep_hwnd = ReplaceTextW(
207 ! (LPFINDREPLACEW) &s_findrep_struct_w);
211 ! s_findrep_hwnd = ReplaceText(
212 ! (LPFINDREPLACE) &s_findrep_struct);
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
221 { /* Add new patch number below this line */
227 I'm not familiar with this proof, but I'm aware of a significant
228 following of toddlers who believe that peanut butter is the solution
229 to all of life's problems... -- Tim Hammerquist
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 ///