Karsten Hopp 112b35
To: vim-dev@vim.org
Karsten Hopp 112b35
Subject: Patch 7.0.074 (extra)
Karsten Hopp 112b35
Fcc: outbox
Karsten Hopp 112b35
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 112b35
Mime-Version: 1.0
Karsten Hopp 112b35
Content-Type: text/plain; charset=ISO-8859-1
Karsten Hopp 112b35
Content-Transfer-Encoding: 8bit
Karsten Hopp 112b35
------------
Karsten Hopp 112b35
Karsten Hopp 112b35
Patch 7.0.074 (extra)
Karsten Hopp 112b35
Problem:    Win32: tooltips were not converted from 'encoding' to Unicode.
Karsten Hopp 112b35
Solution:   Set the tooltip to use Unicode and do the conversion.  Also
Karsten Hopp 112b35
	    cleanup the code for the tab pages tooltips. (Yukihiro Nakadaira)
Karsten Hopp 112b35
Files:	    src/gui_w32.c, src/gui_w48.c
Karsten Hopp 112b35
Karsten Hopp 112b35
Karsten Hopp 112b35
*** ../vim-7.0.073/src/gui_w32.c	Sat May  6 23:43:11 2006
Karsten Hopp 112b35
--- src/gui_w32.c	Tue Aug 29 21:16:58 2006
Karsten Hopp 112b35
***************
Karsten Hopp 112b35
*** 889,1005 ****
Karsten Hopp 112b35
  # ifdef FEAT_MBYTE
Karsten Hopp 112b35
  	    case TTN_GETDISPINFOW:
Karsten Hopp 112b35
  # endif
Karsten Hopp 112b35
! 	    case TTN_NEEDTEXT:
Karsten Hopp 112b35
! # ifdef FEAT_GUI_TABLINE
Karsten Hopp 112b35
! 		if (gui_mch_showing_tabline()
Karsten Hopp 112b35
! 			&& ((LPNMHDR)lParam)->hwndFrom ==
Karsten Hopp 112b35
! 					       TabCtrl_GetToolTips(s_tabhwnd))
Karsten Hopp 112b35
  		{
Karsten Hopp 112b35
! 		    LPNMTTDISPINFO	lpdi;
Karsten Hopp 112b35
! 		    POINT		pt;
Karsten Hopp 112b35
! 		    static char		*tt_text = NULL;
Karsten Hopp 112b35
! 		    static int		tt_text_len = 0;
Karsten Hopp 112b35
! 
Karsten Hopp 112b35
! 		    /*
Karsten Hopp 112b35
! 		     * Mouse is over the GUI tabline. Display the tooltip
Karsten Hopp 112b35
! 		     * for the tab under the cursor
Karsten Hopp 112b35
! 		     */
Karsten Hopp 112b35
! 		    lpdi = (LPNMTTDISPINFO)lParam;
Karsten Hopp 112b35
! 		    lpdi->hinst = NULL;
Karsten Hopp 112b35
! 		    lpdi->szText[0] = '\0';
Karsten Hopp 112b35
! 
Karsten Hopp 112b35
! 		    /*
Karsten Hopp 112b35
! 		     * Get the cursor position within the tab control
Karsten Hopp 112b35
! 		     */
Karsten Hopp 112b35
! 		    GetCursorPos(&pt;;
Karsten Hopp 112b35
! 		    if (ScreenToClient(s_tabhwnd, &pt) != 0)
Karsten Hopp 112b35
! 		    {
Karsten Hopp 112b35
! 			TCHITTESTINFO htinfo;
Karsten Hopp 112b35
! 			int idx;
Karsten Hopp 112b35
  
Karsten Hopp 112b35
  			/*
Karsten Hopp 112b35
! 			 * Get the tab under the cursor
Karsten Hopp 112b35
  			 */
Karsten Hopp 112b35
! 			htinfo.pt.x = pt.x;
Karsten Hopp 112b35
! 			htinfo.pt.y = pt.y;
Karsten Hopp 112b35
! 			idx = TabCtrl_HitTest(s_tabhwnd, &htinfo);
Karsten Hopp 112b35
! 			if (idx != -1)
Karsten Hopp 112b35
  			{
Karsten Hopp 112b35
! 			    tabpage_T *tp;
Karsten Hopp 112b35
  
Karsten Hopp 112b35
! 			    tp = find_tabpage(idx + 1);
Karsten Hopp 112b35
! 			    if (tp != NULL)
Karsten Hopp 112b35
  			    {
Karsten Hopp 112b35
! #  ifdef FEAT_MBYTE
Karsten Hopp 112b35
! 				WCHAR	*wstr = NULL;
Karsten Hopp 112b35
! #  endif
Karsten Hopp 112b35
! 				get_tabline_label(tp, TRUE);
Karsten Hopp 112b35
! #  ifdef FEAT_MBYTE
Karsten Hopp 112b35
! 				if (enc_codepage >= 0
Karsten Hopp 112b35
! 					     && (int)GetACP() != enc_codepage)
Karsten Hopp 112b35
! 				{
Karsten Hopp 112b35
! 				    wstr = enc_to_ucs2(NameBuff, NULL);
Karsten Hopp 112b35
! 				    if (wstr != NULL)
Karsten Hopp 112b35
! 				    {
Karsten Hopp 112b35
! 					int wlen;
Karsten Hopp 112b35
! 
Karsten Hopp 112b35
! 					wlen = ((int)wcslen(wstr) + 1)
Karsten Hopp 112b35
! 							      * sizeof(WCHAR);
Karsten Hopp 112b35
! 					if (tt_text_len < wlen)
Karsten Hopp 112b35
! 					{
Karsten Hopp 112b35
! 					    tt_text = vim_realloc(tt_text,
Karsten Hopp 112b35
! 									wlen);
Karsten Hopp 112b35
! 					    if (tt_text != NULL)
Karsten Hopp 112b35
! 						tt_text_len = wlen;
Karsten Hopp 112b35
! 					}
Karsten Hopp 112b35
! 					if (tt_text != NULL)
Karsten Hopp 112b35
! 					    wcscpy((WCHAR *)tt_text, wstr);
Karsten Hopp 112b35
! 					lpdi->lpszText = tt_text;
Karsten Hopp 112b35
! 					vim_free(wstr);
Karsten Hopp 112b35
! 				    }
Karsten Hopp 112b35
! 				}
Karsten Hopp 112b35
! 				if (wstr == NULL)
Karsten Hopp 112b35
! #  endif
Karsten Hopp 112b35
! 				{
Karsten Hopp 112b35
! 				    int len;
Karsten Hopp 112b35
  
Karsten Hopp 112b35
! 				    len = (int)STRLEN(NameBuff) + 1;
Karsten Hopp 112b35
! 				    if (tt_text_len < len)
Karsten Hopp 112b35
! 				    {
Karsten Hopp 112b35
! 					tt_text = vim_realloc(tt_text, len);
Karsten Hopp 112b35
! 					if (tt_text != NULL)
Karsten Hopp 112b35
! 					    tt_text_len = len;
Karsten Hopp 112b35
! 				    }
Karsten Hopp 112b35
! 				    if (tt_text != NULL)
Karsten Hopp 112b35
! 					STRCPY(tt_text, NameBuff);
Karsten Hopp 112b35
! 				    lpdi->lpszText = tt_text;
Karsten Hopp 112b35
  				}
Karsten Hopp 112b35
  			    }
Karsten Hopp 112b35
  			}
Karsten Hopp 112b35
  		    }
Karsten Hopp 112b35
- 		}
Karsten Hopp 112b35
- 		else
Karsten Hopp 112b35
  # endif
Karsten Hopp 112b35
- 		{
Karsten Hopp 112b35
  # ifdef FEAT_TOOLBAR
Karsten Hopp 112b35
! 		    LPTOOLTIPTEXT	lpttt;
Karsten Hopp 112b35
! 		    UINT		idButton;
Karsten Hopp 112b35
! 		    int			idx;
Karsten Hopp 112b35
! 		    vimmenu_T		*pMenu;
Karsten Hopp 112b35
! 
Karsten Hopp 112b35
! 		    lpttt = (LPTOOLTIPTEXT)lParam;
Karsten Hopp 112b35
! 		    idButton = (UINT) lpttt->hdr.idFrom;
Karsten Hopp 112b35
! 		    pMenu = gui_mswin_find_menu(root_menu, idButton);
Karsten Hopp 112b35
! 		    if (pMenu)
Karsten Hopp 112b35
  		    {
Karsten Hopp 112b35
! 			idx = MENU_INDEX_TIP;
Karsten Hopp 112b35
! 			if (pMenu->strings[idx])
Karsten Hopp 112b35
  			{
Karsten Hopp 112b35
! 			    lpttt->hinst = NULL;  /* string, not resource */
Karsten Hopp 112b35
! 			    lpttt->lpszText = pMenu->strings[idx];
Karsten Hopp 112b35
  			}
Karsten Hopp 112b35
! 		    }
Karsten Hopp 112b35
  # endif
Karsten Hopp 112b35
  		}
Karsten Hopp 112b35
  		break;
Karsten Hopp 112b35
  # ifdef FEAT_GUI_TABLINE
Karsten Hopp 112b35
--- 889,978 ----
Karsten Hopp 112b35
  # ifdef FEAT_MBYTE
Karsten Hopp 112b35
  	    case TTN_GETDISPINFOW:
Karsten Hopp 112b35
  # endif
Karsten Hopp 112b35
! 	    case TTN_GETDISPINFO:
Karsten Hopp 112b35
  		{
Karsten Hopp 112b35
! 		    LPNMHDR		hdr = (LPNMHDR)lParam;
Karsten Hopp 112b35
! 		    char_u		*str = NULL;
Karsten Hopp 112b35
! 		    static void		*tt_text = NULL;
Karsten Hopp 112b35
! 
Karsten Hopp 112b35
! 		    vim_free(tt_text);
Karsten Hopp 112b35
! 		    tt_text = NULL;
Karsten Hopp 112b35
  
Karsten Hopp 112b35
+ # ifdef FEAT_GUI_TABLINE
Karsten Hopp 112b35
+ 		    if (gui_mch_showing_tabline()
Karsten Hopp 112b35
+ 			   && hdr->hwndFrom == TabCtrl_GetToolTips(s_tabhwnd))
Karsten Hopp 112b35
+ 		    {
Karsten Hopp 112b35
+ 			POINT		pt;
Karsten Hopp 112b35
  			/*
Karsten Hopp 112b35
! 			 * Mouse is over the GUI tabline. Display the
Karsten Hopp 112b35
! 			 * tooltip for the tab under the cursor
Karsten Hopp 112b35
! 			 *
Karsten Hopp 112b35
! 			 * Get the cursor position within the tab control
Karsten Hopp 112b35
  			 */
Karsten Hopp 112b35
! 			GetCursorPos(&pt;;
Karsten Hopp 112b35
! 			if (ScreenToClient(s_tabhwnd, &pt) != 0)
Karsten Hopp 112b35
  			{
Karsten Hopp 112b35
! 			    TCHITTESTINFO htinfo;
Karsten Hopp 112b35
! 			    int idx;
Karsten Hopp 112b35
  
Karsten Hopp 112b35
! 			    /*
Karsten Hopp 112b35
! 			     * Get the tab under the cursor
Karsten Hopp 112b35
! 			     */
Karsten Hopp 112b35
! 			    htinfo.pt.x = pt.x;
Karsten Hopp 112b35
! 			    htinfo.pt.y = pt.y;
Karsten Hopp 112b35
! 			    idx = TabCtrl_HitTest(s_tabhwnd, &htinfo);
Karsten Hopp 112b35
! 			    if (idx != -1)
Karsten Hopp 112b35
  			    {
Karsten Hopp 112b35
! 				tabpage_T *tp;
Karsten Hopp 112b35
  
Karsten Hopp 112b35
! 				tp = find_tabpage(idx + 1);
Karsten Hopp 112b35
! 				if (tp != NULL)
Karsten Hopp 112b35
! 				{
Karsten Hopp 112b35
! 				    get_tabline_label(tp, TRUE);
Karsten Hopp 112b35
! 				    str = NameBuff;
Karsten Hopp 112b35
  				}
Karsten Hopp 112b35
  			    }
Karsten Hopp 112b35
  			}
Karsten Hopp 112b35
  		    }
Karsten Hopp 112b35
  # endif
Karsten Hopp 112b35
  # ifdef FEAT_TOOLBAR
Karsten Hopp 112b35
! #  ifdef FEAT_GUI_TABLINE
Karsten Hopp 112b35
! 		    else
Karsten Hopp 112b35
! #  endif
Karsten Hopp 112b35
! 		    {
Karsten Hopp 112b35
! 			UINT		idButton;
Karsten Hopp 112b35
! 			vimmenu_T	*pMenu;
Karsten Hopp 112b35
! 
Karsten Hopp 112b35
! 			idButton = (UINT) hdr->idFrom;
Karsten Hopp 112b35
! 			pMenu = gui_mswin_find_menu(root_menu, idButton);
Karsten Hopp 112b35
! 			if (pMenu)
Karsten Hopp 112b35
! 			    str = pMenu->strings[MENU_INDEX_TIP];
Karsten Hopp 112b35
! 		    }
Karsten Hopp 112b35
! # endif
Karsten Hopp 112b35
! 		    if (str != NULL)
Karsten Hopp 112b35
  		    {
Karsten Hopp 112b35
! # ifdef FEAT_MBYTE
Karsten Hopp 112b35
! 			if (hdr->code == TTN_GETDISPINFOW)
Karsten Hopp 112b35
  			{
Karsten Hopp 112b35
! 			    LPNMTTDISPINFOW	lpdi = (LPNMTTDISPINFOW)lParam;
Karsten Hopp 112b35
! 
Karsten Hopp 112b35
! 			    tt_text = enc_to_ucs2(str, NULL);
Karsten Hopp 112b35
! 			    lpdi->lpszText = tt_text;
Karsten Hopp 112b35
! 			    /* can't show tooltip if failed */
Karsten Hopp 112b35
  			}
Karsten Hopp 112b35
! 			else
Karsten Hopp 112b35
  # endif
Karsten Hopp 112b35
+ 			{
Karsten Hopp 112b35
+ 			    LPNMTTDISPINFO	lpdi = (LPNMTTDISPINFO)lParam;
Karsten Hopp 112b35
+ 
Karsten Hopp 112b35
+ 			    if (STRLEN(str) < sizeof(lpdi->szText)
Karsten Hopp 112b35
+ 				    || ((tt_text = vim_strsave(str)) == NULL))
Karsten Hopp 112b35
+ 				vim_strncpy(lpdi->szText, str,
Karsten Hopp 112b35
+ 						sizeof(lpdi->szText) - 1);
Karsten Hopp 112b35
+ 			    else
Karsten Hopp 112b35
+ 				lpdi->lpszText = tt_text;
Karsten Hopp 112b35
+ 			}
Karsten Hopp 112b35
+ 		    }
Karsten Hopp 112b35
  		}
Karsten Hopp 112b35
  		break;
Karsten Hopp 112b35
  # ifdef FEAT_GUI_TABLINE
Karsten Hopp 112b35
*** ../vim-7.0.073/src/gui_w48.c	Fri Jun 23 16:44:32 2006
Karsten Hopp 112b35
--- src/gui_w48.c	Tue Aug 29 21:14:31 2006
Karsten Hopp 112b35
***************
Karsten Hopp 112b35
*** 2194,2200 ****
Karsten Hopp 112b35
--- 2194,2211 ----
Karsten Hopp 112b35
  	return;
Karsten Hopp 112b35
  
Karsten Hopp 112b35
      if (showit)
Karsten Hopp 112b35
+     {
Karsten Hopp 112b35
+ # ifdef FEAT_MBYTE
Karsten Hopp 112b35
+ #  ifndef TB_SETUNICODEFORMAT
Karsten Hopp 112b35
+     /* For older compilers.  We assume this never changes. */
Karsten Hopp 112b35
+ #   define TB_SETUNICODEFORMAT 0x2005
Karsten Hopp 112b35
+ #  endif
Karsten Hopp 112b35
+ 	/* Enable/disable unicode support */
Karsten Hopp 112b35
+ 	int uu = (enc_codepage >= 0 && (int)GetACP() != enc_codepage);
Karsten Hopp 112b35
+ 	SendMessage(s_toolbarhwnd, TB_SETUNICODEFORMAT, (WPARAM)uu, (LPARAM)0);
Karsten Hopp 112b35
+ # endif
Karsten Hopp 112b35
  	ShowWindow(s_toolbarhwnd, SW_SHOW);
Karsten Hopp 112b35
+     }
Karsten Hopp 112b35
      else
Karsten Hopp 112b35
  	ShowWindow(s_toolbarhwnd, SW_HIDE);
Karsten Hopp 112b35
  }
Karsten Hopp 112b35
*** ../vim-7.0.073/src/version.c	Tue Aug 29 18:36:55 2006
Karsten Hopp 112b35
--- src/version.c	Tue Aug 29 21:28:00 2006
Karsten Hopp 112b35
***************
Karsten Hopp 112b35
*** 668,669 ****
Karsten Hopp 112b35
--- 668,671 ----
Karsten Hopp 112b35
  {   /* Add new patch number below this line */
Karsten Hopp 112b35
+ /**/
Karsten Hopp 112b35
+     74,
Karsten Hopp 112b35
  /**/
Karsten Hopp 112b35
Karsten Hopp 112b35
-- 
Karsten Hopp 112b35
hundred-and-one symptoms of being an internet addict:
Karsten Hopp 112b35
271. You collect hilarious signatures from all 250 mailing lists you
Karsten Hopp 112b35
     are subscribed to.
Karsten Hopp 112b35
Karsten Hopp 112b35
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 112b35
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 112b35
\\\        download, build and distribute -- http://www.A-A-P.org        ///
Karsten Hopp 112b35
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///