Karsten Hopp b937bf
To: vim_dev@googlegroups.com
Karsten Hopp b937bf
Subject: Patch 7.3.1211
Karsten Hopp b937bf
Fcc: outbox
Karsten Hopp b937bf
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp b937bf
Mime-Version: 1.0
Karsten Hopp b937bf
Content-Type: text/plain; charset=UTF-8
Karsten Hopp b937bf
Content-Transfer-Encoding: 8bit
Karsten Hopp b937bf
------------
Karsten Hopp b937bf
Karsten Hopp b937bf
Patch 7.3.1211
Karsten Hopp b937bf
Problem:    MS-Windows: When 'encoding' differs from the current codepage
Karsten Hopp b937bf
	    ":hardcopy" does not work properly.
Karsten Hopp b937bf
Solution:   Use TextOutW() and SetDlgItemTextW(). (Ken Takata)
Karsten Hopp b937bf
Files:	    src/os_mswin.c, src/vim.rc
Karsten Hopp b937bf
Karsten Hopp b937bf
Karsten Hopp b937bf
*** ../vim-7.3.1210/src/os_mswin.c	2013-06-16 16:01:20.000000000 +0200
Karsten Hopp b937bf
--- src/os_mswin.c	2013-06-16 16:41:11.000000000 +0200
Karsten Hopp b937bf
***************
Karsten Hopp b937bf
*** 1045,1050 ****
Karsten Hopp b937bf
--- 1045,1073 ----
Karsten Hopp b937bf
  #define IDC_PRINTTEXT2		402
Karsten Hopp b937bf
  #define IDC_PROGRESS		403
Karsten Hopp b937bf
  
Karsten Hopp b937bf
+ #if !defined(FEAT_MBYTE) || defined(WIN16)
Karsten Hopp b937bf
+ # define vimSetDlgItemText(h, i, s) SetDlgItemText(h, i, s)
Karsten Hopp b937bf
+ #else
Karsten Hopp b937bf
+     static BOOL
Karsten Hopp b937bf
+ vimSetDlgItemText(HWND hDlg, int nIDDlgItem, char_u *s)
Karsten Hopp b937bf
+ {
Karsten Hopp b937bf
+     WCHAR   *wp = NULL;
Karsten Hopp b937bf
+     BOOL    ret;
Karsten Hopp b937bf
+ 
Karsten Hopp b937bf
+     if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
Karsten Hopp b937bf
+     {
Karsten Hopp b937bf
+ 	wp = enc_to_utf16(s, NULL);
Karsten Hopp b937bf
+     }
Karsten Hopp b937bf
+     if (wp != NULL)
Karsten Hopp b937bf
+     {
Karsten Hopp b937bf
+ 	ret = SetDlgItemTextW(hDlg, nIDDlgItem, wp);
Karsten Hopp b937bf
+ 	vim_free(wp);
Karsten Hopp b937bf
+ 	return ret;
Karsten Hopp b937bf
+     }
Karsten Hopp b937bf
+     return SetDlgItemText(hDlg, nIDDlgItem, s);
Karsten Hopp b937bf
+ }
Karsten Hopp b937bf
+ #endif
Karsten Hopp b937bf
+ 
Karsten Hopp b937bf
  /*
Karsten Hopp b937bf
   * Convert BGR to RGB for Windows GDI calls
Karsten Hopp b937bf
   */
Karsten Hopp b937bf
***************
Karsten Hopp b937bf
*** 1096,1113 ****
Karsten Hopp b937bf
  		{
Karsten Hopp b937bf
  		    SendDlgItemMessage(hDlg, i, WM_SETFONT, (WPARAM)hfont, 1);
Karsten Hopp b937bf
  		    if (GetDlgItemText(hDlg,i, buff, sizeof(buff)))
Karsten Hopp b937bf
! 			SetDlgItemText(hDlg,i, _(buff));
Karsten Hopp b937bf
  		}
Karsten Hopp b937bf
  		SendDlgItemMessage(hDlg, IDCANCEL,
Karsten Hopp b937bf
  						WM_SETFONT, (WPARAM)hfont, 1);
Karsten Hopp b937bf
  		if (GetDlgItemText(hDlg,IDCANCEL, buff, sizeof(buff)))
Karsten Hopp b937bf
! 		    SetDlgItemText(hDlg,IDCANCEL, _(buff));
Karsten Hopp b937bf
  	    }
Karsten Hopp b937bf
  #endif
Karsten Hopp b937bf
  	    SetWindowText(hDlg, szAppName);
Karsten Hopp b937bf
  	    if (prt_name != NULL)
Karsten Hopp b937bf
  	    {
Karsten Hopp b937bf
! 		SetDlgItemText(hDlg, IDC_PRINTTEXT2, (LPSTR)prt_name);
Karsten Hopp b937bf
  		vim_free(prt_name);
Karsten Hopp b937bf
  		prt_name = NULL;
Karsten Hopp b937bf
  	    }
Karsten Hopp b937bf
--- 1119,1136 ----
Karsten Hopp b937bf
  		{
Karsten Hopp b937bf
  		    SendDlgItemMessage(hDlg, i, WM_SETFONT, (WPARAM)hfont, 1);
Karsten Hopp b937bf
  		    if (GetDlgItemText(hDlg,i, buff, sizeof(buff)))
Karsten Hopp b937bf
! 			vimSetDlgItemText(hDlg,i, _(buff));
Karsten Hopp b937bf
  		}
Karsten Hopp b937bf
  		SendDlgItemMessage(hDlg, IDCANCEL,
Karsten Hopp b937bf
  						WM_SETFONT, (WPARAM)hfont, 1);
Karsten Hopp b937bf
  		if (GetDlgItemText(hDlg,IDCANCEL, buff, sizeof(buff)))
Karsten Hopp b937bf
! 		    vimSetDlgItemText(hDlg,IDCANCEL, _(buff));
Karsten Hopp b937bf
  	    }
Karsten Hopp b937bf
  #endif
Karsten Hopp b937bf
  	    SetWindowText(hDlg, szAppName);
Karsten Hopp b937bf
  	    if (prt_name != NULL)
Karsten Hopp b937bf
  	    {
Karsten Hopp b937bf
! 		vimSetDlgItemText(hDlg, IDC_PRINTTEXT2, (LPSTR)prt_name);
Karsten Hopp b937bf
  		vim_free(prt_name);
Karsten Hopp b937bf
  		prt_name = NULL;
Karsten Hopp b937bf
  	    }
Karsten Hopp b937bf
***************
Karsten Hopp b937bf
*** 1565,1571 ****
Karsten Hopp b937bf
      SetAbortProc(prt_dlg.hDC, AbortProc);
Karsten Hopp b937bf
  #endif
Karsten Hopp b937bf
      wsprintf(szBuffer, _("Printing '%s'"), gettail(psettings->jobname));
Karsten Hopp b937bf
!     SetDlgItemText(hDlgPrint, IDC_PRINTTEXT1, (LPSTR)szBuffer);
Karsten Hopp b937bf
  
Karsten Hopp b937bf
      vim_memset(&di, 0, sizeof(DOCINFO));
Karsten Hopp b937bf
      di.cbSize = sizeof(DOCINFO);
Karsten Hopp b937bf
--- 1588,1594 ----
Karsten Hopp b937bf
      SetAbortProc(prt_dlg.hDC, AbortProc);
Karsten Hopp b937bf
  #endif
Karsten Hopp b937bf
      wsprintf(szBuffer, _("Printing '%s'"), gettail(psettings->jobname));
Karsten Hopp b937bf
!     vimSetDlgItemText(hDlgPrint, IDC_PRINTTEXT1, (LPSTR)szBuffer);
Karsten Hopp b937bf
  
Karsten Hopp b937bf
      vim_memset(&di, 0, sizeof(DOCINFO));
Karsten Hopp b937bf
      di.cbSize = sizeof(DOCINFO);
Karsten Hopp b937bf
***************
Karsten Hopp b937bf
*** 1599,1605 ****
Karsten Hopp b937bf
  mch_print_begin_page(char_u *msg)
Karsten Hopp b937bf
  {
Karsten Hopp b937bf
      if (msg != NULL)
Karsten Hopp b937bf
! 	SetDlgItemText(hDlgPrint, IDC_PROGRESS, (LPSTR)msg);
Karsten Hopp b937bf
      return (StartPage(prt_dlg.hDC) > 0);
Karsten Hopp b937bf
  }
Karsten Hopp b937bf
  
Karsten Hopp b937bf
--- 1622,1628 ----
Karsten Hopp b937bf
  mch_print_begin_page(char_u *msg)
Karsten Hopp b937bf
  {
Karsten Hopp b937bf
      if (msg != NULL)
Karsten Hopp b937bf
! 	vimSetDlgItemText(hDlgPrint, IDC_PROGRESS, (LPSTR)msg);
Karsten Hopp b937bf
      return (StartPage(prt_dlg.hDC) > 0);
Karsten Hopp b937bf
  }
Karsten Hopp b937bf
  
Karsten Hopp b937bf
***************
Karsten Hopp b937bf
*** 1628,1637 ****
Karsten Hopp b937bf
      int
Karsten Hopp b937bf
  mch_print_text_out(char_u *p, int len)
Karsten Hopp b937bf
  {
Karsten Hopp b937bf
! #ifdef FEAT_PROPORTIONAL_FONTS
Karsten Hopp b937bf
      SIZE	sz;
Karsten Hopp b937bf
  #endif
Karsten Hopp b937bf
  
Karsten Hopp b937bf
      TextOut(prt_dlg.hDC, prt_pos_x + prt_left_margin,
Karsten Hopp b937bf
  					  prt_pos_y + prt_top_margin, p, len);
Karsten Hopp b937bf
  #ifndef FEAT_PROPORTIONAL_FONTS
Karsten Hopp b937bf
--- 1651,1691 ----
Karsten Hopp b937bf
      int
Karsten Hopp b937bf
  mch_print_text_out(char_u *p, int len)
Karsten Hopp b937bf
  {
Karsten Hopp b937bf
! #if defined(FEAT_PROPORTIONAL_FONTS) || (defined(FEAT_MBYTE) && !defined(WIN16))
Karsten Hopp b937bf
      SIZE	sz;
Karsten Hopp b937bf
  #endif
Karsten Hopp b937bf
+ #if defined(FEAT_MBYTE) && !defined(WIN16)
Karsten Hopp b937bf
+     WCHAR	*wp = NULL;
Karsten Hopp b937bf
+     int		wlen = len;
Karsten Hopp b937bf
  
Karsten Hopp b937bf
+     if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
Karsten Hopp b937bf
+     {
Karsten Hopp b937bf
+ 	wp = enc_to_utf16(p, &wlen);
Karsten Hopp b937bf
+     }
Karsten Hopp b937bf
+     if (wp != NULL)
Karsten Hopp b937bf
+     {
Karsten Hopp b937bf
+ 	int ret = FALSE;
Karsten Hopp b937bf
+ 
Karsten Hopp b937bf
+ 	TextOutW(prt_dlg.hDC, prt_pos_x + prt_left_margin,
Karsten Hopp b937bf
+ 					 prt_pos_y + prt_top_margin, wp, wlen);
Karsten Hopp b937bf
+ 	GetTextExtentPoint32W(prt_dlg.hDC, wp, wlen, &sz);
Karsten Hopp b937bf
+ 	vim_free(wp);
Karsten Hopp b937bf
+ 	prt_pos_x += (sz.cx - prt_tm.tmOverhang);
Karsten Hopp b937bf
+ 	/* This is wrong when printing spaces for a TAB. */
Karsten Hopp b937bf
+ 	if (p[len] != NUL)
Karsten Hopp b937bf
+ 	{
Karsten Hopp b937bf
+ 	    wlen = MB_PTR2LEN(p + len);
Karsten Hopp b937bf
+ 	    wp = enc_to_utf16(p + len, &wlen);
Karsten Hopp b937bf
+ 	    if (wp != NULL)
Karsten Hopp b937bf
+ 	    {
Karsten Hopp b937bf
+ 		GetTextExtentPoint32W(prt_dlg.hDC, wp, 1, &sz);
Karsten Hopp b937bf
+ 		ret = (prt_pos_x + prt_left_margin + sz.cx > prt_right_margin);
Karsten Hopp b937bf
+ 		vim_free(wp);
Karsten Hopp b937bf
+ 	    }
Karsten Hopp b937bf
+ 	}
Karsten Hopp b937bf
+ 	return ret;
Karsten Hopp b937bf
+     }
Karsten Hopp b937bf
+ #endif
Karsten Hopp b937bf
      TextOut(prt_dlg.hDC, prt_pos_x + prt_left_margin,
Karsten Hopp b937bf
  					  prt_pos_y + prt_top_margin, p, len);
Karsten Hopp b937bf
  #ifndef FEAT_PROPORTIONAL_FONTS
Karsten Hopp b937bf
***************
Karsten Hopp b937bf
*** 1947,1954 ****
Karsten Hopp b937bf
  	    reply.cbData = (DWORD)STRLEN(res) + 1;
Karsten Hopp b937bf
  
Karsten Hopp b937bf
  	    serverSendEnc(sender);
Karsten Hopp b937bf
! 	    retval = (int)SendMessage(sender, WM_COPYDATA, (WPARAM)message_window,
Karsten Hopp b937bf
! 							    (LPARAM)(&reply));
Karsten Hopp b937bf
  	    vim_free(res);
Karsten Hopp b937bf
  	    return retval;
Karsten Hopp b937bf
  
Karsten Hopp b937bf
--- 2001,2008 ----
Karsten Hopp b937bf
  	    reply.cbData = (DWORD)STRLEN(res) + 1;
Karsten Hopp b937bf
  
Karsten Hopp b937bf
  	    serverSendEnc(sender);
Karsten Hopp b937bf
! 	    retval = (int)SendMessage(sender, WM_COPYDATA,
Karsten Hopp b937bf
! 				    (WPARAM)message_window, (LPARAM)(&reply));
Karsten Hopp b937bf
  	    vim_free(res);
Karsten Hopp b937bf
  	    return retval;
Karsten Hopp b937bf
  
Karsten Hopp b937bf
*** ../vim-7.3.1210/src/vim.rc	2010-08-15 21:57:30.000000000 +0200
Karsten Hopp b937bf
--- src/vim.rc	2013-06-16 16:37:33.000000000 +0200
Karsten Hopp b937bf
***************
Karsten Hopp b937bf
*** 116,123 ****
Karsten Hopp b937bf
  FONT 8, "Helv"
Karsten Hopp b937bf
  BEGIN
Karsten Hopp b937bf
      DEFPUSHBUTTON   "Cancel", IDCANCEL, 85, 60, 40, 14
Karsten Hopp b937bf
!     CTEXT	    "Printing",IDC_PRINTTEXT1,23,15,157,8
Karsten Hopp b937bf
!     CTEXT	    " ",IDC_PRINTTEXT2,23,25,157,8
Karsten Hopp b937bf
!     CTEXT	    "Initializing...",IDC_PROGRESS,24,38,157,8
Karsten Hopp b937bf
      GROUPBOX	    "",IDC_BOX1,19,9,170,47
Karsten Hopp b937bf
  END
Karsten Hopp b937bf
--- 116,123 ----
Karsten Hopp b937bf
  FONT 8, "Helv"
Karsten Hopp b937bf
  BEGIN
Karsten Hopp b937bf
      DEFPUSHBUTTON   "Cancel", IDCANCEL, 85, 60, 40, 14
Karsten Hopp b937bf
!     CTEXT	    "Printing",IDC_PRINTTEXT1,23,15,157,9
Karsten Hopp b937bf
!     CTEXT	    " ",IDC_PRINTTEXT2,23,25,157,9
Karsten Hopp b937bf
!     CTEXT	    "Initializing...",IDC_PROGRESS,24,38,157,9
Karsten Hopp b937bf
      GROUPBOX	    "",IDC_BOX1,19,9,170,47
Karsten Hopp b937bf
  END
Karsten Hopp b937bf
*** ../vim-7.3.1210/src/version.c	2013-06-16 16:34:53.000000000 +0200
Karsten Hopp b937bf
--- src/version.c	2013-06-16 16:39:19.000000000 +0200
Karsten Hopp b937bf
***************
Karsten Hopp b937bf
*** 730,731 ****
Karsten Hopp b937bf
--- 730,733 ----
Karsten Hopp b937bf
  {   /* Add new patch number below this line */
Karsten Hopp b937bf
+ /**/
Karsten Hopp b937bf
+     1211,
Karsten Hopp b937bf
  /**/
Karsten Hopp b937bf
Karsten Hopp b937bf
-- 
Karsten Hopp b937bf
hundred-and-one symptoms of being an internet addict:
Karsten Hopp b937bf
235. You start naming your kids Pascal, COBOL, Algol and Fortran.
Karsten Hopp b937bf
Karsten Hopp b937bf
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp b937bf
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp b937bf
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp b937bf
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///