lkundrak / rpms / vim

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