34e4685
To: vim-dev@vim.org
34e4685
Subject: Patch 7.0.161
34e4685
Fcc: outbox
34e4685
From: Bram Moolenaar <Bram@moolenaar.net>
34e4685
Mime-Version: 1.0
34e4685
Content-Type: text/plain; charset=ISO-8859-1
34e4685
Content-Transfer-Encoding: 8bit
34e4685
------------
34e4685
34e4685
Patch 7.0.161
34e4685
Problem:    Win32: Tab pages line popup menu isn't using the right encoding.
34e4685
            (Yongwei Wu)
34e4685
Solution:   Convert the text when necessary.  Also fixes the Find/Replace
34e4685
	    dialog title. (Yegappan Lakshmanan)
34e4685
Files:	    src/gui_w48.c
34e4685
34e4685
34e4685
*** ../vim-7.0.160/src/gui_w48.c	Tue Aug 29 21:30:15 2006
34e4685
--- src/gui_w48.c	Tue Nov  7 19:03:52 2006
34e4685
***************
34e4685
*** 2217,2226 ****
34e4685
  
34e4685
  #if defined(FEAT_GUI_TABLINE) || defined(PROTO)
34e4685
      static void
34e4685
  show_tabline_popup_menu(void)
34e4685
  {
34e4685
      HMENU	    tab_pmenu;
34e4685
-     MENUITEMINFO    minfo;
34e4685
      long	    rval;
34e4685
      POINT	    pt;
34e4685
  
34e4685
--- 2217,2270 ----
34e4685
  
34e4685
  #if defined(FEAT_GUI_TABLINE) || defined(PROTO)
34e4685
      static void
34e4685
+ add_tabline_popup_menu_entry(HMENU pmenu, UINT item_id, char_u *item_text)
34e4685
+ {
34e4685
+ #ifdef FEAT_MBYTE
34e4685
+     WCHAR	*wn = NULL;
34e4685
+     int		n;
34e4685
+ 
34e4685
+     if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
34e4685
+     {
34e4685
+ 	/* 'encoding' differs from active codepage: convert menu name
34e4685
+ 	 * and use wide function */
34e4685
+ 	wn = enc_to_ucs2(item_text, NULL);
34e4685
+ 	if (wn != NULL)
34e4685
+ 	{
34e4685
+ 	    MENUITEMINFOW	infow;
34e4685
+ 
34e4685
+ 	    infow.cbSize = sizeof(infow);
34e4685
+ 	    infow.fMask = MIIM_TYPE | MIIM_ID;
34e4685
+ 	    infow.wID = item_id;
34e4685
+ 	    infow.fType = MFT_STRING;
34e4685
+ 	    infow.dwTypeData = wn;
34e4685
+ 	    infow.cch = (UINT)wcslen(wn);
34e4685
+ 	    n = InsertMenuItemW(pmenu, item_id, FALSE, &infow);
34e4685
+ 	    vim_free(wn);
34e4685
+ 	    if (n == 0 && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
34e4685
+ 		/* Failed, try using non-wide function. */
34e4685
+ 		wn = NULL;
34e4685
+ 	}
34e4685
+     }
34e4685
+ 
34e4685
+     if (wn == NULL)
34e4685
+ #endif
34e4685
+     {
34e4685
+ 	MENUITEMINFO	info;
34e4685
+ 
34e4685
+ 	info.cbSize = sizeof(info);
34e4685
+ 	info.fMask = MIIM_TYPE | MIIM_ID;
34e4685
+ 	info.wID = item_id;
34e4685
+ 	info.fType = MFT_STRING;
34e4685
+ 	info.dwTypeData = item_text;
34e4685
+ 	info.cch = (UINT)STRLEN(item_text);
34e4685
+ 	InsertMenuItem(pmenu, item_id, FALSE, &info;;
34e4685
+     }
34e4685
+ }
34e4685
+ 
34e4685
+     static void
34e4685
  show_tabline_popup_menu(void)
34e4685
  {
34e4685
      HMENU	    tab_pmenu;
34e4685
      long	    rval;
34e4685
      POINT	    pt;
34e4685
  
34e4685
***************
34e4685
*** 2236,2256 ****
34e4685
      if (tab_pmenu == NULL)
34e4685
  	return;
34e4685
  
34e4685
!     minfo.cbSize = sizeof(MENUITEMINFO);
34e4685
!     minfo.fMask = MIIM_TYPE|MIIM_ID;
34e4685
!     minfo.fType = MFT_STRING;
34e4685
! 
34e4685
!     minfo.dwTypeData = _("Close tab");
34e4685
!     minfo.wID = TABLINE_MENU_CLOSE;
34e4685
!     InsertMenuItem(tab_pmenu, TABLINE_MENU_CLOSE, FALSE, &minfo);
34e4685
! 
34e4685
!     minfo.dwTypeData = _("New tab");
34e4685
!     minfo.wID = TABLINE_MENU_NEW;
34e4685
!     InsertMenuItem(tab_pmenu, TABLINE_MENU_NEW, FALSE, &minfo);
34e4685
! 
34e4685
!     minfo.dwTypeData = _("Open tab...");
34e4685
!     minfo.wID = TABLINE_MENU_OPEN;
34e4685
!     InsertMenuItem(tab_pmenu, TABLINE_MENU_OPEN, FALSE, &minfo);
34e4685
  
34e4685
      GetCursorPos(&pt;;
34e4685
      rval = TrackPopupMenuEx(tab_pmenu, TPM_RETURNCMD, pt.x, pt.y, s_tabhwnd,
34e4685
--- 2280,2289 ----
34e4685
      if (tab_pmenu == NULL)
34e4685
  	return;
34e4685
  
34e4685
!     add_tabline_popup_menu_entry(tab_pmenu, TABLINE_MENU_CLOSE, _("Close tab"));
34e4685
!     add_tabline_popup_menu_entry(tab_pmenu, TABLINE_MENU_NEW, _("New tab"));
34e4685
!     add_tabline_popup_menu_entry(tab_pmenu, TABLINE_MENU_OPEN,
34e4685
! 				 _("Open tab..."));
34e4685
  
34e4685
      GetCursorPos(&pt;;
34e4685
      rval = TrackPopupMenuEx(tab_pmenu, TPM_RETURNCMD, pt.x, pt.y, s_tabhwnd,
34e4685
***************
34e4685
*** 2455,2460 ****
34e4685
--- 2488,2517 ----
34e4685
  }
34e4685
  #endif
34e4685
  
34e4685
+     static void
34e4685
+ set_window_title(HWND hwnd, char *title)
34e4685
+ {
34e4685
+ #ifdef FEAT_MBYTE
34e4685
+     if (title != NULL && enc_codepage >= 0 && enc_codepage != (int)GetACP())
34e4685
+     {
34e4685
+ 	WCHAR	*wbuf;
34e4685
+ 	int	n;
34e4685
+ 
34e4685
+ 	/* Convert the title from 'encoding' to ucs2. */
34e4685
+ 	wbuf = (WCHAR *)enc_to_ucs2((char_u *)title, NULL);
34e4685
+ 	if (wbuf != NULL)
34e4685
+ 	{
34e4685
+ 	    n = SetWindowTextW(hwnd, wbuf);
34e4685
+ 	    vim_free(wbuf);
34e4685
+ 	    if (n != 0 || GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
34e4685
+ 		return;
34e4685
+ 	    /* Retry with non-wide function (for Windows 98). */
34e4685
+ 	}
34e4685
+     }
34e4685
+ #endif
34e4685
+     (void)SetWindowText(hwnd, (LPCSTR)title);
34e4685
+ }
34e4685
+ 
34e4685
      void
34e4685
  gui_mch_find_dialog(exarg_T *eap)
34e4685
  {
34e4685
***************
34e4685
*** 2470,2477 ****
34e4685
  	    s_findrep_hwnd = FindText((LPFINDREPLACE) &s_findrep_struct);
34e4685
  	}
34e4685
  
34e4685
! 	(void)SetWindowText(s_findrep_hwnd,
34e4685
! 		       (LPCSTR)_("Find string (use '\\\\' to find  a '\\')"));
34e4685
  	(void)SetFocus(s_findrep_hwnd);
34e4685
  
34e4685
  	s_findrep_is_find = TRUE;
34e4685
--- 2527,2534 ----
34e4685
  	    s_findrep_hwnd = FindText((LPFINDREPLACE) &s_findrep_struct);
34e4685
  	}
34e4685
  
34e4685
! 	set_window_title(s_findrep_hwnd,
34e4685
! 			       _("Find string (use '\\\\' to find  a '\\')"));
34e4685
  	(void)SetFocus(s_findrep_hwnd);
34e4685
  
34e4685
  	s_findrep_is_find = TRUE;
34e4685
***************
34e4685
*** 2495,2502 ****
34e4685
  	    s_findrep_hwnd = ReplaceText((LPFINDREPLACE) &s_findrep_struct);
34e4685
  	}
34e4685
  
34e4685
! 	(void)SetWindowText(s_findrep_hwnd,
34e4685
! 		    (LPCSTR)_("Find & Replace (use '\\\\' to find  a '\\')"));
34e4685
  	(void)SetFocus(s_findrep_hwnd);
34e4685
  
34e4685
  	s_findrep_is_find = FALSE;
34e4685
--- 2552,2559 ----
34e4685
  	    s_findrep_hwnd = ReplaceText((LPFINDREPLACE) &s_findrep_struct);
34e4685
  	}
34e4685
  
34e4685
! 	set_window_title(s_findrep_hwnd,
34e4685
! 			    _("Find & Replace (use '\\\\' to find  a '\\')"));
34e4685
  	(void)SetFocus(s_findrep_hwnd);
34e4685
  
34e4685
  	s_findrep_is_find = FALSE;
34e4685
***************
34e4685
*** 3015,3039 ****
34e4685
      char_u  *title,
34e4685
      char_u  *icon)
34e4685
  {
34e4685
! #ifdef FEAT_MBYTE
34e4685
!     if (title != NULL && enc_codepage >= 0 && enc_codepage != (int)GetACP())
34e4685
!     {
34e4685
! 	WCHAR	*wbuf;
34e4685
! 	int	n;
34e4685
! 
34e4685
! 	/* Convert the title from 'encoding' to ucs2. */
34e4685
! 	wbuf = (WCHAR *)enc_to_ucs2(title, NULL);
34e4685
! 	if (wbuf != NULL)
34e4685
! 	{
34e4685
! 	    n = SetWindowTextW(s_hwnd, wbuf);
34e4685
! 	    vim_free(wbuf);
34e4685
! 	    if (n != 0 || GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
34e4685
! 		return;
34e4685
! 	    /* Retry with non-wide function (for Windows 98). */
34e4685
! 	}
34e4685
!     }
34e4685
! #endif
34e4685
!     SetWindowText(s_hwnd, (LPCSTR)(title == NULL ? "VIM" : (char *)title));
34e4685
  }
34e4685
  
34e4685
  #ifdef FEAT_MOUSESHAPE
34e4685
--- 3072,3078 ----
34e4685
      char_u  *title,
34e4685
      char_u  *icon)
34e4685
  {
34e4685
!     set_window_title(s_hwnd, (title == NULL ? "VIM" : (char *)title));
34e4685
  }
34e4685
  
34e4685
  #ifdef FEAT_MOUSESHAPE
34e4685
*** ../vim-7.0.160/src/version.c	Tue Nov  7 18:43:10 2006
34e4685
--- src/version.c	Tue Nov  7 18:57:42 2006
34e4685
***************
34e4685
*** 668,669 ****
34e4685
--- 668,671 ----
34e4685
  {   /* Add new patch number below this line */
34e4685
+ /**/
34e4685
+     161,
34e4685
  /**/
34e4685
34e4685
-- 
34e4685
hundred-and-one symptoms of being an internet addict:
34e4685
174. You know what a listserv is.
34e4685
34e4685
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
34e4685
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
34e4685
\\\        download, build and distribute -- http://www.A-A-P.org        ///
34e4685
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///