Karsten Hopp e5aea6
To: vim-dev@vim.org
Karsten Hopp e5aea6
Subject: Patch 7.2.093 (extra)
Karsten Hopp e5aea6
Fcc: outbox
Karsten Hopp e5aea6
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp e5aea6
Mime-Version: 1.0
Karsten Hopp e5aea6
Content-Type: text/plain; charset=ISO-8859-1
Karsten Hopp e5aea6
Content-Transfer-Encoding: 8bit
Karsten Hopp e5aea6
------------
Karsten Hopp e5aea6
Karsten Hopp e5aea6
Patch 7.2.093 (extra)
Karsten Hopp e5aea6
Problem:    Win32: inputdialog() and find/replace dialogs can't handle
Karsten Hopp e5aea6
	    multi-byte text.
Karsten Hopp e5aea6
Solution:   Use the wide version of dialog functions when available. (Yanwei
Karsten Hopp e5aea6
	    Jia)
Karsten Hopp e5aea6
Files:	    src/gui_w32.c, src/gui_w48.c
Karsten Hopp e5aea6
Karsten Hopp e5aea6
Karsten Hopp e5aea6
*** ../vim-7.2.092/src/gui_w32.c	Thu Nov 20 17:09:09 2008
Karsten Hopp e5aea6
--- src/gui_w32.c	Wed Jan 28 21:15:29 2009
Karsten Hopp e5aea6
***************
Karsten Hopp e5aea6
*** 1582,1587 ****
Karsten Hopp e5aea6
--- 1582,1598 ----
Karsten Hopp e5aea6
      s_findrep_struct.lpstrReplaceWith[0] = NUL;
Karsten Hopp e5aea6
      s_findrep_struct.wFindWhatLen = MSWIN_FR_BUFSIZE;
Karsten Hopp e5aea6
      s_findrep_struct.wReplaceWithLen = MSWIN_FR_BUFSIZE;
Karsten Hopp e5aea6
+ # if defined(FEAT_MBYTE) && defined(WIN3264)
Karsten Hopp e5aea6
+     s_findrep_struct_w.lStructSize = sizeof(s_findrep_struct_w);
Karsten Hopp e5aea6
+     s_findrep_struct_w.lpstrFindWhat =
Karsten Hopp e5aea6
+ 			      (LPWSTR)alloc(MSWIN_FR_BUFSIZE * sizeof(WCHAR));
Karsten Hopp e5aea6
+     s_findrep_struct_w.lpstrFindWhat[0] = NUL;
Karsten Hopp e5aea6
+     s_findrep_struct_w.lpstrReplaceWith =
Karsten Hopp e5aea6
+ 			      (LPWSTR)alloc(MSWIN_FR_BUFSIZE * sizeof(WCHAR));
Karsten Hopp e5aea6
+     s_findrep_struct_w.lpstrReplaceWith[0] = NUL;
Karsten Hopp e5aea6
+     s_findrep_struct_w.wFindWhatLen = MSWIN_FR_BUFSIZE;
Karsten Hopp e5aea6
+     s_findrep_struct_w.wReplaceWithLen = MSWIN_FR_BUFSIZE;
Karsten Hopp e5aea6
+ # endif
Karsten Hopp e5aea6
  #endif
Karsten Hopp e5aea6
  
Karsten Hopp e5aea6
  theend:
Karsten Hopp e5aea6
***************
Karsten Hopp e5aea6
*** 2938,2945 ****
Karsten Hopp e5aea6
  
Karsten Hopp e5aea6
  	/* If the edit box exists, copy the string. */
Karsten Hopp e5aea6
  	if (s_textfield != NULL)
Karsten Hopp e5aea6
! 	    GetDlgItemText(hwnd, DLG_NONBUTTON_CONTROL + 2,
Karsten Hopp e5aea6
  							 s_textfield, IOSIZE);
Karsten Hopp e5aea6
  
Karsten Hopp e5aea6
  	/*
Karsten Hopp e5aea6
  	 * Need to check for IDOK because if the user just hits Return to
Karsten Hopp e5aea6
--- 2949,2975 ----
Karsten Hopp e5aea6
  
Karsten Hopp e5aea6
  	/* If the edit box exists, copy the string. */
Karsten Hopp e5aea6
  	if (s_textfield != NULL)
Karsten Hopp e5aea6
! 	{
Karsten Hopp e5aea6
! # if defined(FEAT_MBYTE) && defined(WIN3264)
Karsten Hopp e5aea6
! 	    /* If the OS is Windows NT, and 'encoding' differs from active
Karsten Hopp e5aea6
! 	     * codepage: use wide function and convert text. */
Karsten Hopp e5aea6
! 	    if (os_version.dwPlatformId == VER_PLATFORM_WIN32_NT
Karsten Hopp e5aea6
! 		    && enc_codepage >= 0 && (int)GetACP() != enc_codepage)
Karsten Hopp e5aea6
!             {
Karsten Hopp e5aea6
! 	       WCHAR  *wp = (WCHAR *)alloc(IOSIZE * sizeof(WCHAR));
Karsten Hopp e5aea6
! 	       char_u *p;
Karsten Hopp e5aea6
! 
Karsten Hopp e5aea6
! 	       GetDlgItemTextW(hwnd, DLG_NONBUTTON_CONTROL + 2, wp, IOSIZE);
Karsten Hopp e5aea6
! 	       p = utf16_to_enc(wp, NULL);
Karsten Hopp e5aea6
! 	       vim_strncpy(s_textfield, p, IOSIZE);
Karsten Hopp e5aea6
! 	       vim_free(p);
Karsten Hopp e5aea6
! 	       vim_free(wp);
Karsten Hopp e5aea6
! 	    }
Karsten Hopp e5aea6
! 	    else
Karsten Hopp e5aea6
! # endif
Karsten Hopp e5aea6
! 		GetDlgItemText(hwnd, DLG_NONBUTTON_CONTROL + 2,
Karsten Hopp e5aea6
  							 s_textfield, IOSIZE);
Karsten Hopp e5aea6
+ 	}
Karsten Hopp e5aea6
  
Karsten Hopp e5aea6
  	/*
Karsten Hopp e5aea6
  	 * Need to check for IDOK because if the user just hits Return to
Karsten Hopp e5aea6
*** ../vim-7.2.092/src/gui_w48.c	Wed Jan 28 14:17:21 2009
Karsten Hopp e5aea6
--- src/gui_w48.c	Wed Jan 28 21:10:26 2009
Karsten Hopp e5aea6
***************
Karsten Hopp e5aea6
*** 153,158 ****
Karsten Hopp e5aea6
--- 153,161 ----
Karsten Hopp e5aea6
  #ifdef MSWIN_FIND_REPLACE
Karsten Hopp e5aea6
  static UINT		s_findrep_msg = 0;	/* set in gui_w[16/32].c */
Karsten Hopp e5aea6
  static FINDREPLACE	s_findrep_struct;
Karsten Hopp e5aea6
+ # if defined(FEAT_MBYTE) && defined(WIN3264)
Karsten Hopp e5aea6
+ static FINDREPLACEW	s_findrep_struct_w;
Karsten Hopp e5aea6
+ # endif
Karsten Hopp e5aea6
  static HWND		s_findrep_hwnd = NULL;
Karsten Hopp e5aea6
  static int		s_findrep_is_find;	/* TRUE for find dialog, FALSE
Karsten Hopp e5aea6
  						   for find/replace dialog */
Karsten Hopp e5aea6
***************
Karsten Hopp e5aea6
*** 884,889 ****
Karsten Hopp e5aea6
--- 887,931 ----
Karsten Hopp e5aea6
  #endif
Karsten Hopp e5aea6
  
Karsten Hopp e5aea6
  #ifdef MSWIN_FIND_REPLACE
Karsten Hopp e5aea6
+ # if defined(FEAT_MBYTE) && defined(WIN3264)
Karsten Hopp e5aea6
+ /*
Karsten Hopp e5aea6
+  * copy useful data from structure LPFINDREPLACE to structure LPFINDREPLACEW
Karsten Hopp e5aea6
+  */
Karsten Hopp e5aea6
+     static void
Karsten Hopp e5aea6
+ findrep_atow(LPFINDREPLACEW lpfrw, LPFINDREPLACE lpfr)
Karsten Hopp e5aea6
+ {
Karsten Hopp e5aea6
+     WCHAR *wp;
Karsten Hopp e5aea6
+ 
Karsten Hopp e5aea6
+     lpfrw->hwndOwner = lpfr->hwndOwner;
Karsten Hopp e5aea6
+     lpfrw->Flags = lpfr->Flags;
Karsten Hopp e5aea6
+ 
Karsten Hopp e5aea6
+     wp = enc_to_utf16(lpfr->lpstrFindWhat, NULL);
Karsten Hopp e5aea6
+     wcsncpy(lpfrw->lpstrFindWhat, wp, lpfrw->wFindWhatLen - 1);
Karsten Hopp e5aea6
+     vim_free(wp);
Karsten Hopp e5aea6
+ 
Karsten Hopp e5aea6
+     /* the field "lpstrReplaceWith" doesn't need to be copied */
Karsten Hopp e5aea6
+ }
Karsten Hopp e5aea6
+ 
Karsten Hopp e5aea6
+ /*
Karsten Hopp e5aea6
+  * copy useful data from structure LPFINDREPLACEW to structure LPFINDREPLACE
Karsten Hopp e5aea6
+  */
Karsten Hopp e5aea6
+     static void
Karsten Hopp e5aea6
+ findrep_wtoa(LPFINDREPLACE lpfr, LPFINDREPLACEW lpfrw)
Karsten Hopp e5aea6
+ {
Karsten Hopp e5aea6
+     char_u *p;
Karsten Hopp e5aea6
+ 
Karsten Hopp e5aea6
+     lpfr->Flags = lpfrw->Flags;
Karsten Hopp e5aea6
+ 
Karsten Hopp e5aea6
+     p = utf16_to_enc(lpfrw->lpstrFindWhat, NULL);
Karsten Hopp e5aea6
+     vim_strncpy(lpfr->lpstrFindWhat, p, lpfr->wFindWhatLen - 1);
Karsten Hopp e5aea6
+     vim_free(p);
Karsten Hopp e5aea6
+ 
Karsten Hopp e5aea6
+     p = utf16_to_enc(lpfrw->lpstrReplaceWith, NULL);
Karsten Hopp e5aea6
+     vim_strncpy(lpfr->lpstrReplaceWith, p, lpfr->wReplaceWithLen - 1);
Karsten Hopp e5aea6
+     vim_free(p);
Karsten Hopp e5aea6
+ }
Karsten Hopp e5aea6
+ # endif
Karsten Hopp e5aea6
+ 
Karsten Hopp e5aea6
  /*
Karsten Hopp e5aea6
   * Handle a Find/Replace window message.
Karsten Hopp e5aea6
   */
Karsten Hopp e5aea6
***************
Karsten Hopp e5aea6
*** 893,898 ****
Karsten Hopp e5aea6
--- 935,950 ----
Karsten Hopp e5aea6
      int	    flags = 0;
Karsten Hopp e5aea6
      int	    down;
Karsten Hopp e5aea6
  
Karsten Hopp e5aea6
+ # if defined(FEAT_MBYTE) && defined(WIN3264)
Karsten Hopp e5aea6
+     /* If the OS is Windows NT, and 'encoding' differs from active codepage:
Karsten Hopp e5aea6
+      * convert text from wide string. */
Karsten Hopp e5aea6
+     if (os_version.dwPlatformId == VER_PLATFORM_WIN32_NT
Karsten Hopp e5aea6
+ 			&& enc_codepage >= 0 && (int)GetACP() != enc_codepage)
Karsten Hopp e5aea6
+     {
Karsten Hopp e5aea6
+         findrep_wtoa(&s_findrep_struct, &s_findrep_struct_w);
Karsten Hopp e5aea6
+     }
Karsten Hopp e5aea6
+ # endif
Karsten Hopp e5aea6
+ 
Karsten Hopp e5aea6
      if (s_findrep_struct.Flags & FR_DIALOGTERM)
Karsten Hopp e5aea6
  	/* Give main window the focus back. */
Karsten Hopp e5aea6
  	(void)SetFocus(s_hwnd);
Karsten Hopp e5aea6
***************
Karsten Hopp e5aea6
*** 2562,2568 ****
Karsten Hopp e5aea6
  	if (!IsWindow(s_findrep_hwnd))
Karsten Hopp e5aea6
  	{
Karsten Hopp e5aea6
  	    initialise_findrep(eap->arg);
Karsten Hopp e5aea6
! 	    s_findrep_hwnd = FindText((LPFINDREPLACE) &s_findrep_struct);
Karsten Hopp e5aea6
  	}
Karsten Hopp e5aea6
  
Karsten Hopp e5aea6
  	set_window_title(s_findrep_hwnd,
Karsten Hopp e5aea6
--- 2614,2632 ----
Karsten Hopp e5aea6
  	if (!IsWindow(s_findrep_hwnd))
Karsten Hopp e5aea6
  	{
Karsten Hopp e5aea6
  	    initialise_findrep(eap->arg);
Karsten Hopp e5aea6
! # if defined(FEAT_MBYTE) && defined(WIN3264)
Karsten Hopp e5aea6
! 	    /* If the OS is Windows NT, and 'encoding' differs from active
Karsten Hopp e5aea6
! 	     * codepage: convert text and use wide function. */
Karsten Hopp e5aea6
! 	    if (os_version.dwPlatformId == VER_PLATFORM_WIN32_NT
Karsten Hopp e5aea6
! 		    && enc_codepage >= 0 && (int)GetACP() != enc_codepage)
Karsten Hopp e5aea6
! 	    {
Karsten Hopp e5aea6
! 	        findrep_atow(&s_findrep_struct_w, &s_findrep_struct);
Karsten Hopp e5aea6
! 		s_findrep_hwnd = FindTextW(
Karsten Hopp e5aea6
! 					(LPFINDREPLACEW) &s_findrep_struct_w);
Karsten Hopp e5aea6
! 	    }
Karsten Hopp e5aea6
! 	    else
Karsten Hopp e5aea6
! # endif
Karsten Hopp e5aea6
! 		s_findrep_hwnd = FindText((LPFINDREPLACE) &s_findrep_struct);
Karsten Hopp e5aea6
  	}
Karsten Hopp e5aea6
  
Karsten Hopp e5aea6
  	set_window_title(s_findrep_hwnd,
Karsten Hopp e5aea6
***************
Karsten Hopp e5aea6
*** 2587,2593 ****
Karsten Hopp e5aea6
  	if (!IsWindow(s_findrep_hwnd))
Karsten Hopp e5aea6
  	{
Karsten Hopp e5aea6
  	    initialise_findrep(eap->arg);
Karsten Hopp e5aea6
! 	    s_findrep_hwnd = ReplaceText((LPFINDREPLACE) &s_findrep_struct);
Karsten Hopp e5aea6
  	}
Karsten Hopp e5aea6
  
Karsten Hopp e5aea6
  	set_window_title(s_findrep_hwnd,
Karsten Hopp e5aea6
--- 2651,2668 ----
Karsten Hopp e5aea6
  	if (!IsWindow(s_findrep_hwnd))
Karsten Hopp e5aea6
  	{
Karsten Hopp e5aea6
  	    initialise_findrep(eap->arg);
Karsten Hopp e5aea6
! # if defined(FEAT_MBYTE) && defined(WIN3264)
Karsten Hopp e5aea6
! 	    if (os_version.dwPlatformId == VER_PLATFORM_WIN32_NT
Karsten Hopp e5aea6
! 		    && enc_codepage >= 0 && (int)GetACP() != enc_codepage)
Karsten Hopp e5aea6
! 	    {
Karsten Hopp e5aea6
! 		findrep_atow(&s_findrep_struct_w, &s_findrep_struct);
Karsten Hopp e5aea6
! 		s_findrep_hwnd = ReplaceTextW(
Karsten Hopp e5aea6
! 					(LPFINDREPLACEW) &s_findrep_struct_w);
Karsten Hopp e5aea6
! 	    }
Karsten Hopp e5aea6
! 	    else
Karsten Hopp e5aea6
! # endif
Karsten Hopp e5aea6
! 		s_findrep_hwnd = ReplaceText(
Karsten Hopp e5aea6
! 					   (LPFINDREPLACE) &s_findrep_struct);
Karsten Hopp e5aea6
  	}
Karsten Hopp e5aea6
  
Karsten Hopp e5aea6
  	set_window_title(s_findrep_hwnd,
Karsten Hopp e5aea6
*** ../vim-7.2.092/src/version.c	Wed Jan 28 19:08:31 2009
Karsten Hopp e5aea6
--- src/version.c	Wed Jan 28 21:19:56 2009
Karsten Hopp e5aea6
***************
Karsten Hopp e5aea6
*** 678,679 ****
Karsten Hopp e5aea6
--- 678,681 ----
Karsten Hopp e5aea6
  {   /* Add new patch number below this line */
Karsten Hopp e5aea6
+ /**/
Karsten Hopp e5aea6
+     93,
Karsten Hopp e5aea6
  /**/
Karsten Hopp e5aea6
Karsten Hopp e5aea6
-- 
Karsten Hopp e5aea6
I'm not familiar with this proof, but I'm aware of a significant
Karsten Hopp e5aea6
following of toddlers who believe that peanut butter is the solution
Karsten Hopp e5aea6
to all of life's problems... 		-- Tim Hammerquist
Karsten Hopp e5aea6
Karsten Hopp e5aea6
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp e5aea6
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp e5aea6
\\\        download, build and distribute -- http://www.A-A-P.org        ///
Karsten Hopp e5aea6
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///