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