Mercurial > vim
comparison src/os_mswin.c @ 15603:639b8318472c v8.1.0809
patch 8.1.0809: too many #ifdefs
commit https://github.com/vim/vim/commit/a12a161b8ce09d024ed71c2134149fa323f8ee8e
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Jan 24 16:39:02 2019 +0100
patch 8.1.0809: too many #ifdefs
Problem: Too many #ifdefs.
Solution: Graduate FEAT_MBYTE, part 3.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 24 Jan 2019 16:45:06 +0100 |
parents | 55ccc2d353bd |
children | c4efa095f323 |
comparison
equal
deleted
inserted
replaced
15602:2ef2028868e2 | 15603:639b8318472c |
---|---|
280 # ifdef FEAT_GUI_MSWIN | 280 # ifdef FEAT_GUI_MSWIN |
281 gui_mch_settitle(title, icon); | 281 gui_mch_settitle(title, icon); |
282 # else | 282 # else |
283 if (title != NULL) | 283 if (title != NULL) |
284 { | 284 { |
285 # ifdef FEAT_MBYTE | |
286 if (enc_codepage >= 0 && (int)GetACP() != enc_codepage) | 285 if (enc_codepage >= 0 && (int)GetACP() != enc_codepage) |
287 { | 286 { |
288 /* Convert the title from 'encoding' to the active codepage. */ | 287 /* Convert the title from 'encoding' to the active codepage. */ |
289 WCHAR *wp = enc_to_utf16(title, NULL); | 288 WCHAR *wp = enc_to_utf16(title, NULL); |
290 | 289 |
293 SetConsoleTitleW(wp); | 292 SetConsoleTitleW(wp); |
294 vim_free(wp); | 293 vim_free(wp); |
295 return; | 294 return; |
296 } | 295 } |
297 } | 296 } |
298 # endif | |
299 SetConsoleTitle((LPCSTR)title); | 297 SetConsoleTitle((LPCSTR)title); |
300 } | 298 } |
301 # endif | 299 # endif |
302 } | 300 } |
303 | 301 |
359 if (*fname == NUL) /* Borland behaves badly here - make it consistent */ | 357 if (*fname == NUL) /* Borland behaves badly here - make it consistent */ |
360 nResult = mch_dirname(buf, len); | 358 nResult = mch_dirname(buf, len); |
361 else | 359 else |
362 #endif | 360 #endif |
363 { | 361 { |
364 #ifdef FEAT_MBYTE | |
365 if (enc_codepage >= 0 && (int)GetACP() != enc_codepage) | 362 if (enc_codepage >= 0 && (int)GetACP() != enc_codepage) |
366 { | 363 { |
367 WCHAR *wname; | 364 WCHAR *wname; |
368 WCHAR wbuf[MAX_PATH]; | 365 WCHAR wbuf[MAX_PATH]; |
369 char_u *cname = NULL; | 366 char_u *cname = NULL; |
385 } | 382 } |
386 vim_free(wname); | 383 vim_free(wname); |
387 vim_free(cname); | 384 vim_free(cname); |
388 } | 385 } |
389 if (nResult == FAIL) /* fall back to non-wide function */ | 386 if (nResult == FAIL) /* fall back to non-wide function */ |
390 #endif | |
391 { | 387 { |
392 if (_fullpath((char *)buf, (const char *)fname, len - 1) == NULL) | 388 if (_fullpath((char *)buf, (const char *)fname, len - 1) == NULL) |
393 { | 389 { |
394 /* failed, use relative path name */ | 390 /* failed, use relative path name */ |
395 vim_strncpy(buf, fname, len - 1); | 391 vim_strncpy(buf, fname, len - 1); |
413 * Return TRUE if "fname" does not depend on the current directory. | 409 * Return TRUE if "fname" does not depend on the current directory. |
414 */ | 410 */ |
415 int | 411 int |
416 mch_isFullName(char_u *fname) | 412 mch_isFullName(char_u *fname) |
417 { | 413 { |
418 #ifdef FEAT_MBYTE | |
419 /* WinNT and later can use _MAX_PATH wide characters for a pathname, which | 414 /* WinNT and later can use _MAX_PATH wide characters for a pathname, which |
420 * means that the maximum pathname is _MAX_PATH * 3 bytes when 'enc' is | 415 * means that the maximum pathname is _MAX_PATH * 3 bytes when 'enc' is |
421 * UTF-8. */ | 416 * UTF-8. */ |
422 char szName[_MAX_PATH * 3 + 1]; | 417 char szName[_MAX_PATH * 3 + 1]; |
423 #else | |
424 char szName[_MAX_PATH + 1]; | |
425 #endif | |
426 | 418 |
427 /* A name like "d:/foo" and "//server/share" is absolute */ | 419 /* A name like "d:/foo" and "//server/share" is absolute */ |
428 if ((fname[0] && fname[1] == ':' && (fname[2] == '/' || fname[2] == '\\')) | 420 if ((fname[0] && fname[1] == ':' && (fname[2] == '/' || fname[2] == '\\')) |
429 || (fname[0] == fname[1] && (fname[0] == '/' || fname[0] == '\\'))) | 421 || (fname[0] == fname[1] && (fname[0] == '/' || fname[0] == '\\'))) |
430 return TRUE; | 422 return TRUE; |
536 } | 528 } |
537 #endif | 529 #endif |
538 return stat(name, stp); | 530 return stat(name, stp); |
539 } | 531 } |
540 | 532 |
541 #ifdef FEAT_MBYTE | |
542 static int | 533 static int |
543 wstat_symlink_aware(const WCHAR *name, stat_T *stp) | 534 wstat_symlink_aware(const WCHAR *name, stat_T *stp) |
544 { | 535 { |
545 # if (defined(_MSC_VER) && (_MSC_VER < 1900)) || defined(__MINGW32__) | 536 #if (defined(_MSC_VER) && (_MSC_VER < 1900)) || defined(__MINGW32__) |
546 /* Work around for VC12 or earlier (and MinGW). _wstat() can't handle | 537 /* Work around for VC12 or earlier (and MinGW). _wstat() can't handle |
547 * symlinks properly. | 538 * symlinks properly. |
548 * VC9 or earlier: _wstat() doesn't support a symlink at all. It retrieves | 539 * VC9 or earlier: _wstat() doesn't support a symlink at all. It retrieves |
549 * status of a symlink itself. | 540 * status of a symlink itself. |
550 * VC10: _wstat() supports a symlink to a normal file, but it doesn't | 541 * VC10: _wstat() supports a symlink to a normal file, but it doesn't |
585 stp->st_mode = (stp->st_mode & ~S_IFREG) | S_IFDIR; | 576 stp->st_mode = (stp->st_mode & ~S_IFREG) | S_IFDIR; |
586 _close(fd); | 577 _close(fd); |
587 return n; | 578 return n; |
588 } | 579 } |
589 } | 580 } |
590 # endif | 581 #endif |
591 return _wstat(name, (struct _stat *)stp); | 582 return _wstat(name, (struct _stat *)stp); |
592 } | 583 } |
593 #endif | |
594 | 584 |
595 /* | 585 /* |
596 * stat() can't handle a trailing '/' or '\', remove it first. | 586 * stat() can't handle a trailing '/' or '\', remove it first. |
597 */ | 587 */ |
598 int | 588 int |
599 vim_stat(const char *name, stat_T *stp) | 589 vim_stat(const char *name, stat_T *stp) |
600 { | 590 { |
601 #ifdef FEAT_MBYTE | |
602 /* WinNT and later can use _MAX_PATH wide characters for a pathname, which | 591 /* WinNT and later can use _MAX_PATH wide characters for a pathname, which |
603 * means that the maximum pathname is _MAX_PATH * 3 bytes when 'enc' is | 592 * means that the maximum pathname is _MAX_PATH * 3 bytes when 'enc' is |
604 * UTF-8. */ | 593 * UTF-8. */ |
605 char_u buf[_MAX_PATH * 3 + 1]; | 594 char_u buf[_MAX_PATH * 3 + 1]; |
606 #else | |
607 char_u buf[_MAX_PATH + 1]; | |
608 #endif | |
609 char_u *p; | 595 char_u *p; |
610 | 596 |
611 vim_strncpy((char_u *)buf, (char_u *)name, sizeof(buf) - 1); | 597 vim_strncpy((char_u *)buf, (char_u *)name, sizeof(buf) - 1); |
612 p = buf + STRLEN(buf); | 598 p = buf + STRLEN(buf); |
613 if (p > buf) | 599 if (p > buf) |
626 p = vim_strpbrk(p + 1, (char_u *)"\\/"); | 612 p = vim_strpbrk(p + 1, (char_u *)"\\/"); |
627 if (p == NULL) | 613 if (p == NULL) |
628 STRCAT(buf, "\\"); | 614 STRCAT(buf, "\\"); |
629 } | 615 } |
630 } | 616 } |
631 #ifdef FEAT_MBYTE | |
632 if (enc_codepage >= 0 && (int)GetACP() != enc_codepage) | 617 if (enc_codepage >= 0 && (int)GetACP() != enc_codepage) |
633 { | 618 { |
634 WCHAR *wp = enc_to_utf16(buf, NULL); | 619 WCHAR *wp = enc_to_utf16(buf, NULL); |
635 int n; | 620 int n; |
636 | 621 |
639 n = wstat_symlink_aware(wp, stp); | 624 n = wstat_symlink_aware(wp, stp); |
640 vim_free(wp); | 625 vim_free(wp); |
641 return n; | 626 return n; |
642 } | 627 } |
643 } | 628 } |
644 #endif | |
645 return stat_symlink_aware((char *)buf, stp); | 629 return stat_symlink_aware((char *)buf, stp); |
646 } | 630 } |
647 | 631 |
648 #if defined(FEAT_GUI_MSWIN) || defined(PROTO) | 632 #if defined(FEAT_GUI_MSWIN) || defined(PROTO) |
649 void | 633 void |
789 } | 773 } |
790 | 774 |
791 if (*path == NUL) /* drive name only */ | 775 if (*path == NUL) /* drive name only */ |
792 return 0; | 776 return 0; |
793 | 777 |
794 #ifdef FEAT_MBYTE | |
795 if (enc_codepage >= 0 && (int)GetACP() != enc_codepage) | 778 if (enc_codepage >= 0 && (int)GetACP() != enc_codepage) |
796 { | 779 { |
797 WCHAR *p = enc_to_utf16((char_u *)path, NULL); | 780 WCHAR *p = enc_to_utf16((char_u *)path, NULL); |
798 int n; | 781 int n; |
799 | 782 |
802 n = _wchdir(p); | 785 n = _wchdir(p); |
803 vim_free(p); | 786 vim_free(p); |
804 return n; | 787 return n; |
805 } | 788 } |
806 } | 789 } |
807 #endif | |
808 | 790 |
809 return chdir(path); /* let the normal chdir() do the rest */ | 791 return chdir(path); /* let the normal chdir() do the rest */ |
810 } | 792 } |
811 | 793 |
812 | 794 |
1143 #define IDC_BOX1 400 | 1125 #define IDC_BOX1 400 |
1144 #define IDC_PRINTTEXT1 401 | 1126 #define IDC_PRINTTEXT1 401 |
1145 #define IDC_PRINTTEXT2 402 | 1127 #define IDC_PRINTTEXT2 402 |
1146 #define IDC_PROGRESS 403 | 1128 #define IDC_PROGRESS 403 |
1147 | 1129 |
1148 #if !defined(FEAT_MBYTE) | |
1149 # define vimSetDlgItemText(h, i, s) SetDlgItemText(h, i, s) | |
1150 #else | |
1151 static BOOL | 1130 static BOOL |
1152 vimSetDlgItemText(HWND hDlg, int nIDDlgItem, char_u *s) | 1131 vimSetDlgItemText(HWND hDlg, int nIDDlgItem, char_u *s) |
1153 { | 1132 { |
1154 WCHAR *wp = NULL; | 1133 WCHAR *wp = NULL; |
1155 BOOL ret; | 1134 BOOL ret; |
1164 vim_free(wp); | 1143 vim_free(wp); |
1165 return ret; | 1144 return ret; |
1166 } | 1145 } |
1167 return SetDlgItemText(hDlg, nIDDlgItem, (LPCSTR)s); | 1146 return SetDlgItemText(hDlg, nIDDlgItem, (LPCSTR)s); |
1168 } | 1147 } |
1169 #endif | |
1170 | 1148 |
1171 /* | 1149 /* |
1172 * Convert BGR to RGB for Windows GDI calls | 1150 * Convert BGR to RGB for Windows GDI calls |
1173 */ | 1151 */ |
1174 static COLORREF | 1152 static COLORREF |
1561 if (devname != 0) | 1539 if (devname != 0) |
1562 { | 1540 { |
1563 char_u *printer_name = (char_u *)devname + devname->wDeviceOffset; | 1541 char_u *printer_name = (char_u *)devname + devname->wDeviceOffset; |
1564 char_u *port_name = (char_u *)devname +devname->wOutputOffset; | 1542 char_u *port_name = (char_u *)devname +devname->wOutputOffset; |
1565 char_u *text = (char_u *)_("to %s on %s"); | 1543 char_u *text = (char_u *)_("to %s on %s"); |
1566 #ifdef FEAT_MBYTE | |
1567 char_u *printer_name_orig = printer_name; | 1544 char_u *printer_name_orig = printer_name; |
1568 char_u *port_name_orig = port_name; | 1545 char_u *port_name_orig = port_name; |
1569 | 1546 |
1570 if (enc_codepage >= 0 && (int)GetACP() != enc_codepage) | 1547 if (enc_codepage >= 0 && (int)GetACP() != enc_codepage) |
1571 { | 1548 { |
1578 printer_name = to_free; | 1555 printer_name = to_free; |
1579 acp_to_enc(port_name, (int)STRLEN(port_name), &to_free, &maxlen); | 1556 acp_to_enc(port_name, (int)STRLEN(port_name), &to_free, &maxlen); |
1580 if (to_free != NULL) | 1557 if (to_free != NULL) |
1581 port_name = to_free; | 1558 port_name = to_free; |
1582 } | 1559 } |
1583 #endif | |
1584 prt_name = alloc((unsigned)(STRLEN(printer_name) + STRLEN(port_name) | 1560 prt_name = alloc((unsigned)(STRLEN(printer_name) + STRLEN(port_name) |
1585 + STRLEN(text))); | 1561 + STRLEN(text))); |
1586 if (prt_name != NULL) | 1562 if (prt_name != NULL) |
1587 wsprintf((char *)prt_name, (const char *)text, | 1563 wsprintf((char *)prt_name, (const char *)text, |
1588 printer_name, port_name); | 1564 printer_name, port_name); |
1589 #ifdef FEAT_MBYTE | |
1590 if (printer_name != printer_name_orig) | 1565 if (printer_name != printer_name_orig) |
1591 vim_free(printer_name); | 1566 vim_free(printer_name); |
1592 if (port_name != port_name_orig) | 1567 if (port_name != port_name_orig) |
1593 vim_free(port_name); | 1568 vim_free(port_name); |
1594 #endif | |
1595 } | 1569 } |
1596 GlobalUnlock(prt_dlg.hDevNames); | 1570 GlobalUnlock(prt_dlg.hDevNames); |
1597 | 1571 |
1598 /* | 1572 /* |
1599 * Initialise the font according to 'printfont' | 1573 * Initialise the font according to 'printfont' |
1678 int | 1652 int |
1679 mch_print_begin(prt_settings_T *psettings) | 1653 mch_print_begin(prt_settings_T *psettings) |
1680 { | 1654 { |
1681 int ret; | 1655 int ret; |
1682 char szBuffer[300]; | 1656 char szBuffer[300]; |
1683 #if defined(FEAT_MBYTE) | |
1684 WCHAR *wp = NULL; | 1657 WCHAR *wp = NULL; |
1685 #endif | |
1686 | 1658 |
1687 hDlgPrint = CreateDialog(GetModuleHandle(NULL), TEXT("PrintDlgBox"), | 1659 hDlgPrint = CreateDialog(GetModuleHandle(NULL), TEXT("PrintDlgBox"), |
1688 prt_dlg.hwndOwner, PrintDlgProc); | 1660 prt_dlg.hwndOwner, PrintDlgProc); |
1689 SetAbortProc(prt_dlg.hDC, AbortProc); | 1661 SetAbortProc(prt_dlg.hDC, AbortProc); |
1690 wsprintf(szBuffer, _("Printing '%s'"), gettail(psettings->jobname)); | 1662 wsprintf(szBuffer, _("Printing '%s'"), gettail(psettings->jobname)); |
1691 vimSetDlgItemText(hDlgPrint, IDC_PRINTTEXT1, (char_u *)szBuffer); | 1663 vimSetDlgItemText(hDlgPrint, IDC_PRINTTEXT1, (char_u *)szBuffer); |
1692 | 1664 |
1693 #if defined(FEAT_MBYTE) | |
1694 if (enc_codepage >= 0 && (int)GetACP() != enc_codepage) | 1665 if (enc_codepage >= 0 && (int)GetACP() != enc_codepage) |
1695 wp = enc_to_utf16(psettings->jobname, NULL); | 1666 wp = enc_to_utf16(psettings->jobname, NULL); |
1696 if (wp != NULL) | 1667 if (wp != NULL) |
1697 { | 1668 { |
1698 DOCINFOW di; | 1669 DOCINFOW di; |
1702 di.lpszDocName = wp; | 1673 di.lpszDocName = wp; |
1703 ret = StartDocW(prt_dlg.hDC, &di); | 1674 ret = StartDocW(prt_dlg.hDC, &di); |
1704 vim_free(wp); | 1675 vim_free(wp); |
1705 } | 1676 } |
1706 else | 1677 else |
1707 #endif | |
1708 { | 1678 { |
1709 DOCINFO di; | 1679 DOCINFO di; |
1710 | 1680 |
1711 vim_memset(&di, 0, sizeof(di)); | 1681 vim_memset(&di, 0, sizeof(di)); |
1712 di.cbSize = sizeof(di); | 1682 di.cbSize = sizeof(di); |
1765 } | 1735 } |
1766 | 1736 |
1767 int | 1737 int |
1768 mch_print_text_out(char_u *p, int len) | 1738 mch_print_text_out(char_u *p, int len) |
1769 { | 1739 { |
1770 #if defined(FEAT_PROPORTIONAL_FONTS) || defined(FEAT_MBYTE) | |
1771 SIZE sz; | 1740 SIZE sz; |
1772 #endif | |
1773 #if defined(FEAT_MBYTE) | |
1774 WCHAR *wp = NULL; | 1741 WCHAR *wp = NULL; |
1775 int wlen = len; | 1742 int wlen = len; |
1776 | 1743 |
1777 if (enc_codepage >= 0 && (int)GetACP() != enc_codepage) | 1744 if (enc_codepage >= 0 && (int)GetACP() != enc_codepage) |
1778 { | 1745 { |
1799 vim_free(wp); | 1766 vim_free(wp); |
1800 } | 1767 } |
1801 } | 1768 } |
1802 return ret; | 1769 return ret; |
1803 } | 1770 } |
1804 #endif | |
1805 TextOut(prt_dlg.hDC, prt_pos_x + prt_left_margin, | 1771 TextOut(prt_dlg.hDC, prt_pos_x + prt_left_margin, |
1806 prt_pos_y + prt_top_margin, | 1772 prt_pos_y + prt_top_margin, |
1807 (LPCSTR)p, len); | 1773 (LPCSTR)p, len); |
1808 #ifndef FEAT_PROPORTIONAL_FONTS | 1774 #ifndef FEAT_PROPORTIONAL_FONTS |
1809 prt_pos_x += len * prt_tm.tmAveCharWidth; | 1775 prt_pos_x += len * prt_tm.tmAveCharWidth; |
1871 OLECHAR wsz[MAX_PATH]; | 1837 OLECHAR wsz[MAX_PATH]; |
1872 WIN32_FIND_DATA ffd; // we get those free of charge | 1838 WIN32_FIND_DATA ffd; // we get those free of charge |
1873 CHAR buf[MAX_PATH]; // could have simply reused 'wsz'... | 1839 CHAR buf[MAX_PATH]; // could have simply reused 'wsz'... |
1874 char_u *rfname = NULL; | 1840 char_u *rfname = NULL; |
1875 int len; | 1841 int len; |
1876 # ifdef FEAT_MBYTE | |
1877 IShellLinkW *pslw = NULL; | 1842 IShellLinkW *pslw = NULL; |
1878 WIN32_FIND_DATAW ffdw; // we get those free of charge | 1843 WIN32_FIND_DATAW ffdw; // we get those free of charge |
1879 # endif | |
1880 | 1844 |
1881 /* Check if the file name ends in ".lnk". Avoid calling | 1845 /* Check if the file name ends in ".lnk". Avoid calling |
1882 * CoCreateInstance(), it's quite slow. */ | 1846 * CoCreateInstance(), it's quite slow. */ |
1883 if (fname == NULL) | 1847 if (fname == NULL) |
1884 return rfname; | 1848 return rfname; |
1886 if (len <= 4 || STRNICMP(fname + len - 4, ".lnk", 4) != 0) | 1850 if (len <= 4 || STRNICMP(fname + len - 4, ".lnk", 4) != 0) |
1887 return rfname; | 1851 return rfname; |
1888 | 1852 |
1889 CoInitialize(NULL); | 1853 CoInitialize(NULL); |
1890 | 1854 |
1891 # ifdef FEAT_MBYTE | |
1892 if (enc_codepage >= 0 && (int)GetACP() != enc_codepage) | 1855 if (enc_codepage >= 0 && (int)GetACP() != enc_codepage) |
1893 { | 1856 { |
1894 // create a link manager object and request its interface | 1857 // create a link manager object and request its interface |
1895 hr = CoCreateInstance( | 1858 hr = CoCreateInstance( |
1896 &CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, | 1859 &CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, |
1928 goto shortcut_end; | 1891 goto shortcut_end; |
1929 } | 1892 } |
1930 } | 1893 } |
1931 goto shortcut_end; | 1894 goto shortcut_end; |
1932 } | 1895 } |
1933 # endif | |
1934 // create a link manager object and request its interface | 1896 // create a link manager object and request its interface |
1935 hr = CoCreateInstance( | 1897 hr = CoCreateInstance( |
1936 &CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, | 1898 &CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, |
1937 &IID_IShellLink, (void**)&psl); | 1899 &IID_IShellLink, (void**)&psl); |
1938 if (hr != S_OK) | 1900 if (hr != S_OK) |
1967 // Release all interface pointers (both belong to the same object) | 1929 // Release all interface pointers (both belong to the same object) |
1968 if (ppf != NULL) | 1930 if (ppf != NULL) |
1969 ppf->lpVtbl->Release(ppf); | 1931 ppf->lpVtbl->Release(ppf); |
1970 if (psl != NULL) | 1932 if (psl != NULL) |
1971 psl->lpVtbl->Release(psl); | 1933 psl->lpVtbl->Release(psl); |
1972 # ifdef FEAT_MBYTE | |
1973 if (pslw != NULL) | 1934 if (pslw != NULL) |
1974 pslw->lpVtbl->Release(pslw); | 1935 pslw->lpVtbl->Release(pslw); |
1975 # endif | |
1976 | 1936 |
1977 CoUninitialize(); | 1937 CoUninitialize(); |
1978 return rfname; | 1938 return rfname; |
1979 } | 1939 } |
1980 #endif | 1940 #endif |
2040 serverSendEnc(HWND target) | 2000 serverSendEnc(HWND target) |
2041 { | 2001 { |
2042 COPYDATASTRUCT data; | 2002 COPYDATASTRUCT data; |
2043 | 2003 |
2044 data.dwData = COPYDATA_ENCODING; | 2004 data.dwData = COPYDATA_ENCODING; |
2045 #ifdef FEAT_MBYTE | |
2046 data.cbData = (DWORD)STRLEN(p_enc) + 1; | 2005 data.cbData = (DWORD)STRLEN(p_enc) + 1; |
2047 data.lpData = p_enc; | 2006 data.lpData = p_enc; |
2048 #else | |
2049 data.cbData = (DWORD)STRLEN("latin1") + 1; | |
2050 data.lpData = "latin1"; | |
2051 #endif | |
2052 (void)SendMessage(target, WM_COPYDATA, (WPARAM)message_window, | 2007 (void)SendMessage(target, WM_COPYDATA, (WPARAM)message_window, |
2053 (LPARAM)(&data)); | 2008 (LPARAM)(&data)); |
2054 } | 2009 } |
2055 | 2010 |
2056 /* | 2011 /* |
2116 char_u *tofree; | 2071 char_u *tofree; |
2117 | 2072 |
2118 switch (data->dwData) | 2073 switch (data->dwData) |
2119 { | 2074 { |
2120 case COPYDATA_ENCODING: | 2075 case COPYDATA_ENCODING: |
2121 # ifdef FEAT_MBYTE | |
2122 /* Remember the encoding that the client uses. */ | 2076 /* Remember the encoding that the client uses. */ |
2123 vim_free(client_enc); | 2077 vim_free(client_enc); |
2124 client_enc = enc_canonize((char_u *)data->lpData); | 2078 client_enc = enc_canonize((char_u *)data->lpData); |
2125 # endif | |
2126 return 1; | 2079 return 1; |
2127 | 2080 |
2128 case COPYDATA_KEYS: | 2081 case COPYDATA_KEYS: |
2129 /* Remember who sent this, for <client> */ | 2082 /* Remember who sent this, for <client> */ |
2130 clientWindow = sender; | 2083 clientWindow = sender; |
2952 { | 2905 { |
2953 char_u *p; | 2906 char_u *p; |
2954 int i; | 2907 int i; |
2955 int ret = FAIL; | 2908 int ret = FAIL; |
2956 static LOGFONT *lastlf = NULL; | 2909 static LOGFONT *lastlf = NULL; |
2957 #ifdef FEAT_MBYTE | |
2958 char_u *acpname = NULL; | 2910 char_u *acpname = NULL; |
2959 #endif | |
2960 | 2911 |
2961 *lf = s_lfDefault; | 2912 *lf = s_lfDefault; |
2962 if (name == NULL) | 2913 if (name == NULL) |
2963 return OK; | 2914 return OK; |
2964 | 2915 |
2965 #ifdef FEAT_MBYTE | |
2966 /* Convert 'name' from 'encoding' to the current codepage, because | 2916 /* Convert 'name' from 'encoding' to the current codepage, because |
2967 * lf->lfFaceName uses the current codepage. | 2917 * lf->lfFaceName uses the current codepage. |
2968 * TODO: Use Wide APIs instead of ANSI APIs. */ | 2918 * TODO: Use Wide APIs instead of ANSI APIs. */ |
2969 if (enc_codepage >= 0 && (int)GetACP() != enc_codepage) | 2919 if (enc_codepage >= 0 && (int)GetACP() != enc_codepage) |
2970 { | 2920 { |
2971 int len; | 2921 int len; |
2972 enc_to_acp(name, (int)STRLEN(name), &acpname, &len); | 2922 enc_to_acp(name, (int)STRLEN(name), &acpname, &len); |
2973 name = acpname; | 2923 name = acpname; |
2974 } | 2924 } |
2975 #endif | |
2976 if (STRCMP(name, "*") == 0) | 2925 if (STRCMP(name, "*") == 0) |
2977 { | 2926 { |
2978 #if defined(FEAT_GUI_W32) | 2927 #if defined(FEAT_GUI_W32) |
2979 CHOOSEFONT cf; | 2928 CHOOSEFONT cf; |
2980 /* if name is "*", bring up std font dialog: */ | 2929 /* if name is "*", bring up std font dialog: */ |
3110 vim_free(lastlf); | 3059 vim_free(lastlf); |
3111 lastlf = (LOGFONT *)alloc(sizeof(LOGFONT)); | 3060 lastlf = (LOGFONT *)alloc(sizeof(LOGFONT)); |
3112 if (lastlf != NULL) | 3061 if (lastlf != NULL) |
3113 mch_memmove(lastlf, lf, sizeof(LOGFONT)); | 3062 mch_memmove(lastlf, lf, sizeof(LOGFONT)); |
3114 } | 3063 } |
3115 #ifdef FEAT_MBYTE | |
3116 vim_free(acpname); | 3064 vim_free(acpname); |
3117 #endif | |
3118 | 3065 |
3119 return ret; | 3066 return ret; |
3120 } | 3067 } |
3121 | 3068 |
3122 #endif /* defined(FEAT_GUI) || defined(FEAT_PRINTER) */ | 3069 #endif /* defined(FEAT_GUI) || defined(FEAT_PRINTER) */ |