summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2013-06-16 16:41:47 +0200
committerBram Moolenaar <Bram@vim.org>2013-06-16 16:41:47 +0200
commit5246cd7a9bb514fd5c44f8deaf0b3ed889e1602f (patch)
treeed994eac1c64a83deeade87311a727eade094230 /src
parent03e114b0f2c994d58cd744f9be1b498245bd8c08 (diff)
downloadvim-5246cd7a9bb514fd5c44f8deaf0b3ed889e1602f.zip
updated for version 7.3.1211
Problem: MS-Windows: When 'encoding' differs from the current codepage ":hardcopy" does not work properly. Solution: Use TextOutW() and SetDlgItemTextW(). (Ken Takata)
Diffstat (limited to 'src')
-rw-r--r--src/os_mswin.c70
-rw-r--r--src/version.c2
-rw-r--r--src/vim.rc6
3 files changed, 67 insertions, 11 deletions
diff --git a/src/os_mswin.c b/src/os_mswin.c
index 5af1dee51..96d3448c3 100644
--- a/src/os_mswin.c
+++ b/src/os_mswin.c
@@ -1045,6 +1045,29 @@ static char_u *prt_name = NULL;
#define IDC_PRINTTEXT2 402
#define IDC_PROGRESS 403
+#if !defined(FEAT_MBYTE) || defined(WIN16)
+# define vimSetDlgItemText(h, i, s) SetDlgItemText(h, i, s)
+#else
+ static BOOL
+vimSetDlgItemText(HWND hDlg, int nIDDlgItem, char_u *s)
+{
+ WCHAR *wp = NULL;
+ BOOL ret;
+
+ if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
+ {
+ wp = enc_to_utf16(s, NULL);
+ }
+ if (wp != NULL)
+ {
+ ret = SetDlgItemTextW(hDlg, nIDDlgItem, wp);
+ vim_free(wp);
+ return ret;
+ }
+ return SetDlgItemText(hDlg, nIDDlgItem, s);
+}
+#endif
+
/*
* Convert BGR to RGB for Windows GDI calls
*/
@@ -1096,18 +1119,18 @@ PrintDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
SendDlgItemMessage(hDlg, i, WM_SETFONT, (WPARAM)hfont, 1);
if (GetDlgItemText(hDlg,i, buff, sizeof(buff)))
- SetDlgItemText(hDlg,i, _(buff));
+ vimSetDlgItemText(hDlg,i, _(buff));
}
SendDlgItemMessage(hDlg, IDCANCEL,
WM_SETFONT, (WPARAM)hfont, 1);
if (GetDlgItemText(hDlg,IDCANCEL, buff, sizeof(buff)))
- SetDlgItemText(hDlg,IDCANCEL, _(buff));
+ vimSetDlgItemText(hDlg,IDCANCEL, _(buff));
}
#endif
SetWindowText(hDlg, szAppName);
if (prt_name != NULL)
{
- SetDlgItemText(hDlg, IDC_PRINTTEXT2, (LPSTR)prt_name);
+ vimSetDlgItemText(hDlg, IDC_PRINTTEXT2, (LPSTR)prt_name);
vim_free(prt_name);
prt_name = NULL;
}
@@ -1565,7 +1588,7 @@ mch_print_begin(prt_settings_T *psettings)
SetAbortProc(prt_dlg.hDC, AbortProc);
#endif
wsprintf(szBuffer, _("Printing '%s'"), gettail(psettings->jobname));
- SetDlgItemText(hDlgPrint, IDC_PRINTTEXT1, (LPSTR)szBuffer);
+ vimSetDlgItemText(hDlgPrint, IDC_PRINTTEXT1, (LPSTR)szBuffer);
vim_memset(&di, 0, sizeof(DOCINFO));
di.cbSize = sizeof(DOCINFO);
@@ -1599,7 +1622,7 @@ mch_print_end_page(void)
mch_print_begin_page(char_u *msg)
{
if (msg != NULL)
- SetDlgItemText(hDlgPrint, IDC_PROGRESS, (LPSTR)msg);
+ vimSetDlgItemText(hDlgPrint, IDC_PROGRESS, (LPSTR)msg);
return (StartPage(prt_dlg.hDC) > 0);
}
@@ -1628,10 +1651,41 @@ mch_print_start_line(margin, page_line)
int
mch_print_text_out(char_u *p, int len)
{
-#ifdef FEAT_PROPORTIONAL_FONTS
+#if defined(FEAT_PROPORTIONAL_FONTS) || (defined(FEAT_MBYTE) && !defined(WIN16))
SIZE sz;
#endif
+#if defined(FEAT_MBYTE) && !defined(WIN16)
+ WCHAR *wp = NULL;
+ int wlen = len;
+ if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
+ {
+ wp = enc_to_utf16(p, &wlen);
+ }
+ if (wp != NULL)
+ {
+ int ret = FALSE;
+
+ TextOutW(prt_dlg.hDC, prt_pos_x + prt_left_margin,
+ prt_pos_y + prt_top_margin, wp, wlen);
+ GetTextExtentPoint32W(prt_dlg.hDC, wp, wlen, &sz);
+ vim_free(wp);
+ prt_pos_x += (sz.cx - prt_tm.tmOverhang);
+ /* This is wrong when printing spaces for a TAB. */
+ if (p[len] != NUL)
+ {
+ wlen = MB_PTR2LEN(p + len);
+ wp = enc_to_utf16(p + len, &wlen);
+ if (wp != NULL)
+ {
+ GetTextExtentPoint32W(prt_dlg.hDC, wp, 1, &sz);
+ ret = (prt_pos_x + prt_left_margin + sz.cx > prt_right_margin);
+ vim_free(wp);
+ }
+ }
+ return ret;
+ }
+#endif
TextOut(prt_dlg.hDC, prt_pos_x + prt_left_margin,
prt_pos_y + prt_top_margin, p, len);
#ifndef FEAT_PROPORTIONAL_FONTS
@@ -1947,8 +2001,8 @@ Messaging_WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
reply.cbData = (DWORD)STRLEN(res) + 1;
serverSendEnc(sender);
- retval = (int)SendMessage(sender, WM_COPYDATA, (WPARAM)message_window,
- (LPARAM)(&reply));
+ retval = (int)SendMessage(sender, WM_COPYDATA,
+ (WPARAM)message_window, (LPARAM)(&reply));
vim_free(res);
return retval;
diff --git a/src/version.c b/src/version.c
index abcd2d848..6492078f8 100644
--- a/src/version.c
+++ b/src/version.c
@@ -729,6 +729,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1211,
+/**/
1210,
/**/
1209,
diff --git a/src/vim.rc b/src/vim.rc
index e9ecd64e1..01f1642c8 100644
--- a/src/vim.rc
+++ b/src/vim.rc
@@ -116,8 +116,8 @@ STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
FONT 8, "Helv"
BEGIN
DEFPUSHBUTTON "Cancel", IDCANCEL, 85, 60, 40, 14
- CTEXT "Printing",IDC_PRINTTEXT1,23,15,157,8
- CTEXT " ",IDC_PRINTTEXT2,23,25,157,8
- CTEXT "Initializing...",IDC_PROGRESS,24,38,157,8
+ CTEXT "Printing",IDC_PRINTTEXT1,23,15,157,9
+ CTEXT " ",IDC_PRINTTEXT2,23,25,157,9
+ CTEXT "Initializing...",IDC_PROGRESS,24,38,157,9
GROUPBOX "",IDC_BOX1,19,9,170,47
END