Blob Blame History Raw
To: vim-dev@vim.org
Subject: Patch 7.0.161
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
------------

Patch 7.0.161
Problem:    Win32: Tab pages line popup menu isn't using the right encoding.
            (Yongwei Wu)
Solution:   Convert the text when necessary.  Also fixes the Find/Replace
	    dialog title. (Yegappan Lakshmanan)
Files:	    src/gui_w48.c


*** ../vim-7.0.160/src/gui_w48.c	Tue Aug 29 21:30:15 2006
--- src/gui_w48.c	Tue Nov  7 19:03:52 2006
***************
*** 2217,2226 ****
  
  #if defined(FEAT_GUI_TABLINE) || defined(PROTO)
      static void
  show_tabline_popup_menu(void)
  {
      HMENU	    tab_pmenu;
-     MENUITEMINFO    minfo;
      long	    rval;
      POINT	    pt;
  
--- 2217,2270 ----
  
  #if defined(FEAT_GUI_TABLINE) || defined(PROTO)
      static void
+ add_tabline_popup_menu_entry(HMENU pmenu, UINT item_id, char_u *item_text)
+ {
+ #ifdef FEAT_MBYTE
+     WCHAR	*wn = NULL;
+     int		n;
+ 
+     if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
+     {
+ 	/* 'encoding' differs from active codepage: convert menu name
+ 	 * and use wide function */
+ 	wn = enc_to_ucs2(item_text, NULL);
+ 	if (wn != NULL)
+ 	{
+ 	    MENUITEMINFOW	infow;
+ 
+ 	    infow.cbSize = sizeof(infow);
+ 	    infow.fMask = MIIM_TYPE | MIIM_ID;
+ 	    infow.wID = item_id;
+ 	    infow.fType = MFT_STRING;
+ 	    infow.dwTypeData = wn;
+ 	    infow.cch = (UINT)wcslen(wn);
+ 	    n = InsertMenuItemW(pmenu, item_id, FALSE, &infow);
+ 	    vim_free(wn);
+ 	    if (n == 0 && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
+ 		/* Failed, try using non-wide function. */
+ 		wn = NULL;
+ 	}
+     }
+ 
+     if (wn == NULL)
+ #endif
+     {
+ 	MENUITEMINFO	info;
+ 
+ 	info.cbSize = sizeof(info);
+ 	info.fMask = MIIM_TYPE | MIIM_ID;
+ 	info.wID = item_id;
+ 	info.fType = MFT_STRING;
+ 	info.dwTypeData = item_text;
+ 	info.cch = (UINT)STRLEN(item_text);
+ 	InsertMenuItem(pmenu, item_id, FALSE, &info);
+     }
+ }
+ 
+     static void
  show_tabline_popup_menu(void)
  {
      HMENU	    tab_pmenu;
      long	    rval;
      POINT	    pt;
  
***************
*** 2236,2256 ****
      if (tab_pmenu == NULL)
  	return;
  
!     minfo.cbSize = sizeof(MENUITEMINFO);
!     minfo.fMask = MIIM_TYPE|MIIM_ID;
!     minfo.fType = MFT_STRING;
! 
!     minfo.dwTypeData = _("Close tab");
!     minfo.wID = TABLINE_MENU_CLOSE;
!     InsertMenuItem(tab_pmenu, TABLINE_MENU_CLOSE, FALSE, &minfo);
! 
!     minfo.dwTypeData = _("New tab");
!     minfo.wID = TABLINE_MENU_NEW;
!     InsertMenuItem(tab_pmenu, TABLINE_MENU_NEW, FALSE, &minfo);
! 
!     minfo.dwTypeData = _("Open tab...");
!     minfo.wID = TABLINE_MENU_OPEN;
!     InsertMenuItem(tab_pmenu, TABLINE_MENU_OPEN, FALSE, &minfo);
  
      GetCursorPos(&pt);
      rval = TrackPopupMenuEx(tab_pmenu, TPM_RETURNCMD, pt.x, pt.y, s_tabhwnd,
--- 2280,2289 ----
      if (tab_pmenu == NULL)
  	return;
  
!     add_tabline_popup_menu_entry(tab_pmenu, TABLINE_MENU_CLOSE, _("Close tab"));
!     add_tabline_popup_menu_entry(tab_pmenu, TABLINE_MENU_NEW, _("New tab"));
!     add_tabline_popup_menu_entry(tab_pmenu, TABLINE_MENU_OPEN,
! 				 _("Open tab..."));
  
      GetCursorPos(&pt);
      rval = TrackPopupMenuEx(tab_pmenu, TPM_RETURNCMD, pt.x, pt.y, s_tabhwnd,
***************
*** 2455,2460 ****
--- 2488,2517 ----
  }
  #endif
  
+     static void
+ set_window_title(HWND hwnd, char *title)
+ {
+ #ifdef FEAT_MBYTE
+     if (title != NULL && enc_codepage >= 0 && enc_codepage != (int)GetACP())
+     {
+ 	WCHAR	*wbuf;
+ 	int	n;
+ 
+ 	/* Convert the title from 'encoding' to ucs2. */
+ 	wbuf = (WCHAR *)enc_to_ucs2((char_u *)title, NULL);
+ 	if (wbuf != NULL)
+ 	{
+ 	    n = SetWindowTextW(hwnd, wbuf);
+ 	    vim_free(wbuf);
+ 	    if (n != 0 || GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
+ 		return;
+ 	    /* Retry with non-wide function (for Windows 98). */
+ 	}
+     }
+ #endif
+     (void)SetWindowText(hwnd, (LPCSTR)title);
+ }
+ 
      void
  gui_mch_find_dialog(exarg_T *eap)
  {
***************
*** 2470,2477 ****
  	    s_findrep_hwnd = FindText((LPFINDREPLACE) &s_findrep_struct);
  	}
  
! 	(void)SetWindowText(s_findrep_hwnd,
! 		       (LPCSTR)_("Find string (use '\\\\' to find  a '\\')"));
  	(void)SetFocus(s_findrep_hwnd);
  
  	s_findrep_is_find = TRUE;
--- 2527,2534 ----
  	    s_findrep_hwnd = FindText((LPFINDREPLACE) &s_findrep_struct);
  	}
  
! 	set_window_title(s_findrep_hwnd,
! 			       _("Find string (use '\\\\' to find  a '\\')"));
  	(void)SetFocus(s_findrep_hwnd);
  
  	s_findrep_is_find = TRUE;
***************
*** 2495,2502 ****
  	    s_findrep_hwnd = ReplaceText((LPFINDREPLACE) &s_findrep_struct);
  	}
  
! 	(void)SetWindowText(s_findrep_hwnd,
! 		    (LPCSTR)_("Find & Replace (use '\\\\' to find  a '\\')"));
  	(void)SetFocus(s_findrep_hwnd);
  
  	s_findrep_is_find = FALSE;
--- 2552,2559 ----
  	    s_findrep_hwnd = ReplaceText((LPFINDREPLACE) &s_findrep_struct);
  	}
  
! 	set_window_title(s_findrep_hwnd,
! 			    _("Find & Replace (use '\\\\' to find  a '\\')"));
  	(void)SetFocus(s_findrep_hwnd);
  
  	s_findrep_is_find = FALSE;
***************
*** 3015,3039 ****
      char_u  *title,
      char_u  *icon)
  {
! #ifdef FEAT_MBYTE
!     if (title != NULL && enc_codepage >= 0 && enc_codepage != (int)GetACP())
!     {
! 	WCHAR	*wbuf;
! 	int	n;
! 
! 	/* Convert the title from 'encoding' to ucs2. */
! 	wbuf = (WCHAR *)enc_to_ucs2(title, NULL);
! 	if (wbuf != NULL)
! 	{
! 	    n = SetWindowTextW(s_hwnd, wbuf);
! 	    vim_free(wbuf);
! 	    if (n != 0 || GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
! 		return;
! 	    /* Retry with non-wide function (for Windows 98). */
! 	}
!     }
! #endif
!     SetWindowText(s_hwnd, (LPCSTR)(title == NULL ? "VIM" : (char *)title));
  }
  
  #ifdef FEAT_MOUSESHAPE
--- 3072,3078 ----
      char_u  *title,
      char_u  *icon)
  {
!     set_window_title(s_hwnd, (title == NULL ? "VIM" : (char *)title));
  }
  
  #ifdef FEAT_MOUSESHAPE
*** ../vim-7.0.160/src/version.c	Tue Nov  7 18:43:10 2006
--- src/version.c	Tue Nov  7 18:57:42 2006
***************
*** 668,669 ****
--- 668,671 ----
  {   /* Add new patch number below this line */
+ /**/
+     161,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
174. You know what a listserv is.

 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\        download, build and distribute -- http://www.A-A-P.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///