comparison src/os_mswin.c @ 8140:563c923b1584 v7.4.1364

commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Feb 20 13:55:06 2016 +0100 patch 7.4.1364 Problem: The Win 16 code is not maintained and unused. Solution: Remove the Win 16 support.
author Christian Brabandt <cb@256bit.org>
date Sat, 20 Feb 2016 14:00:06 +0100
parents 54cfe888c627
children caed4b2d305f
comparison
equal deleted inserted replaced
8139:2b0d471e04f7 8140:563c923b1584
8 */ 8 */
9 9
10 /* 10 /*
11 * os_mswin.c 11 * os_mswin.c
12 * 12 *
13 * Routines common to both Win16 and Win32. 13 * Routines for Win32.
14 */ 14 */
15
16 #ifdef WIN16
17 # ifdef __BORLANDC__
18 # pragma warn -par
19 # pragma warn -ucp
20 # pragma warn -use
21 # pragma warn -aus
22 # endif
23 #endif
24 15
25 #include "vim.h" 16 #include "vim.h"
26 17
27 #ifdef WIN16
28 # define SHORT_FNAME /* always 8.3 file name */
29 /* cproto fails on missing include files */
30 # ifndef PROTO
31 # include <dos.h>
32 # endif
33 # include <string.h>
34 #endif
35 #include <sys/types.h> 18 #include <sys/types.h>
36 #include <signal.h> 19 #include <signal.h>
37 #include <limits.h> 20 #include <limits.h>
38 #ifndef PROTO 21 #ifndef PROTO
39 # include <process.h> 22 # include <process.h>
902 typedef LPSTR (*MYINTPROCSTR)(int); 885 typedef LPSTR (*MYINTPROCSTR)(int);
903 typedef int (*MYSTRPROCINT)(LPSTR); 886 typedef int (*MYSTRPROCINT)(LPSTR);
904 typedef int (*MYINTPROCINT)(int); 887 typedef int (*MYINTPROCINT)(int);
905 # endif 888 # endif
906 889
907 # ifndef WIN16
908 /* 890 /*
909 * Check if a pointer points to a valid NUL terminated string. 891 * Check if a pointer points to a valid NUL terminated string.
910 * Return the length of the string, including terminating NUL. 892 * Return the length of the string, including terminating NUL.
911 * Returns 0 for an invalid pointer, 1 for an empty string. 893 * Returns 0 for an invalid pointer, 1 for an empty string.
912 */ 894 */
942 return length + 1; 924 return length + 1;
943 } 925 }
944 926
945 return 0; 927 return 0;
946 } 928 }
947 # endif
948 929
949 /* 930 /*
950 * Passed to do_in_runtimepath() to load a vim.ico file. 931 * Passed to do_in_runtimepath() to load a vim.ico file.
951 */ 932 */
952 static void 933 static void
989 size_t len; 970 size_t len;
990 971
991 BOOL fRunTimeLinkSuccess = FALSE; 972 BOOL fRunTimeLinkSuccess = FALSE;
992 973
993 // Get a handle to the DLL module. 974 // Get a handle to the DLL module.
994 # ifdef WIN16
995 hinstLib = LoadLibrary(libname);
996 # else
997 hinstLib = vimLoadLib((char *)libname); 975 hinstLib = vimLoadLib((char *)libname);
998 # endif
999 976
1000 // If the handle is valid, try to get the function address. 977 // If the handle is valid, try to get the function address.
1001 if (hinstLib != NULL) 978 if (hinstLib != NULL)
1002 { 979 {
1003 #ifdef HAVE_TRY_EXCEPT 980 #ifdef HAVE_TRY_EXCEPT
1032 // Save the string before we free the library. 1009 // Save the string before we free the library.
1033 // Assume that a "1" result is an illegal pointer. 1010 // Assume that a "1" result is an illegal pointer.
1034 if (string_result == NULL) 1011 if (string_result == NULL)
1035 *number_result = retval_int; 1012 *number_result = retval_int;
1036 else if (retval_str != NULL 1013 else if (retval_str != NULL
1037 # ifdef WIN16 1014 && (len = check_str_len(retval_str)) > 0)
1038 && retval_str != (char_u *)1
1039 && retval_str != (char_u *)-1
1040 && !IsBadStringPtr(retval_str, INT_MAX)
1041 && (len = strlen(retval_str) + 1) > 0
1042 # else
1043 && (len = check_str_len(retval_str)) > 0
1044 # endif
1045 )
1046 { 1015 {
1047 *string_result = lalloc((long_u)len, TRUE); 1016 *string_result = lalloc((long_u)len, TRUE);
1048 if (*string_result != NULL) 1017 if (*string_result != NULL)
1049 mch_memmove(*string_result, retval_str, len); 1018 mch_memmove(*string_result, retval_str, len);
1050 } 1019 }
1182 } 1151 }
1183 #endif 1152 #endif
1184 1153
1185 #if (defined(FEAT_PRINTER) && !defined(FEAT_POSTSCRIPT)) || defined(PROTO) 1154 #if (defined(FEAT_PRINTER) && !defined(FEAT_POSTSCRIPT)) || defined(PROTO)
1186 1155
1187 # ifdef WIN16
1188 # define TEXT(a) a
1189 # endif
1190 /*================================================================= 1156 /*=================================================================
1191 * Win32 printer stuff 1157 * Win32 printer stuff
1192 */ 1158 */
1193 1159
1194 static HFONT prt_font_handles[2][2][2]; 1160 static HFONT prt_font_handles[2][2][2];
1209 #define IDC_BOX1 400 1175 #define IDC_BOX1 400
1210 #define IDC_PRINTTEXT1 401 1176 #define IDC_PRINTTEXT1 401
1211 #define IDC_PRINTTEXT2 402 1177 #define IDC_PRINTTEXT2 402
1212 #define IDC_PROGRESS 403 1178 #define IDC_PROGRESS 403
1213 1179
1214 #if !defined(FEAT_MBYTE) || defined(WIN16) 1180 #if !defined(FEAT_MBYTE)
1215 # define vimSetDlgItemText(h, i, s) SetDlgItemText(h, i, s) 1181 # define vimSetDlgItemText(h, i, s) SetDlgItemText(h, i, s)
1216 #else 1182 #else
1217 static BOOL 1183 static BOOL
1218 vimSetDlgItemText(HWND hDlg, int nIDDlgItem, char_u *s) 1184 vimSetDlgItemText(HWND hDlg, int nIDDlgItem, char_u *s)
1219 { 1185 {
1454 int hr; 1420 int hr;
1455 int phyw; 1421 int phyw;
1456 int dvoff; 1422 int dvoff;
1457 int rev_offset; 1423 int rev_offset;
1458 int dpi; 1424 int dpi;
1459 #ifdef WIN16
1460 POINT pagesize;
1461 #endif
1462 1425
1463 GetTextMetrics(prt_dlg.hDC, &prt_tm); 1426 GetTextMetrics(prt_dlg.hDC, &prt_tm);
1464 prt_line_height = prt_tm.tmHeight + prt_tm.tmExternalLeading; 1427 prt_line_height = prt_tm.tmHeight + prt_tm.tmExternalLeading;
1465 1428
1466 hr = GetDeviceCaps(prt_dlg.hDC, HORZRES); 1429 hr = GetDeviceCaps(prt_dlg.hDC, HORZRES);
1467 #ifdef WIN16
1468 Escape(prt_dlg.hDC, GETPHYSPAGESIZE, NULL, NULL, &pagesize);
1469 phyw = pagesize.x;
1470 Escape(prt_dlg.hDC, GETPRINTINGOFFSET, NULL, NULL, &pagesize);
1471 dvoff = pagesize.x;
1472 #else
1473 phyw = GetDeviceCaps(prt_dlg.hDC, PHYSICALWIDTH); 1430 phyw = GetDeviceCaps(prt_dlg.hDC, PHYSICALWIDTH);
1474 dvoff = GetDeviceCaps(prt_dlg.hDC, PHYSICALOFFSETX); 1431 dvoff = GetDeviceCaps(prt_dlg.hDC, PHYSICALOFFSETX);
1475 #endif
1476 dpi = GetDeviceCaps(prt_dlg.hDC, LOGPIXELSX); 1432 dpi = GetDeviceCaps(prt_dlg.hDC, LOGPIXELSX);
1477 1433
1478 rev_offset = phyw - (dvoff + hr); 1434 rev_offset = phyw - (dvoff + hr);
1479 1435
1480 prt_left_margin = to_device_units(OPT_PRINT_LEFT, dpi, phyw, dvoff, 10); 1436 prt_left_margin = to_device_units(OPT_PRINT_LEFT, dpi, phyw, dvoff, 10);
1499 int phyw; 1455 int phyw;
1500 int dvoff; 1456 int dvoff;
1501 int rev_offset; 1457 int rev_offset;
1502 int bottom_margin; 1458 int bottom_margin;
1503 int dpi; 1459 int dpi;
1504 #ifdef WIN16
1505 POINT pagesize;
1506 #endif
1507 1460
1508 vr = GetDeviceCaps(prt_dlg.hDC, VERTRES); 1461 vr = GetDeviceCaps(prt_dlg.hDC, VERTRES);
1509 #ifdef WIN16
1510 Escape(prt_dlg.hDC, GETPHYSPAGESIZE, NULL, NULL, &pagesize);
1511 phyw = pagesize.y;
1512 Escape(prt_dlg.hDC, GETPRINTINGOFFSET, NULL, NULL, &pagesize);
1513 dvoff = pagesize.y;
1514 #else
1515 phyw = GetDeviceCaps(prt_dlg.hDC, PHYSICALHEIGHT); 1462 phyw = GetDeviceCaps(prt_dlg.hDC, PHYSICALHEIGHT);
1516 dvoff = GetDeviceCaps(prt_dlg.hDC, PHYSICALOFFSETY); 1463 dvoff = GetDeviceCaps(prt_dlg.hDC, PHYSICALOFFSETY);
1517 #endif
1518 dpi = GetDeviceCaps(prt_dlg.hDC, LOGPIXELSY); 1464 dpi = GetDeviceCaps(prt_dlg.hDC, LOGPIXELSY);
1519 1465
1520 rev_offset = phyw - (dvoff + vr); 1466 rev_offset = phyw - (dvoff + vr);
1521 1467
1522 prt_top_margin = to_device_units(OPT_PRINT_TOP, dpi, phyw, dvoff, 5); 1468 prt_top_margin = to_device_units(OPT_PRINT_TOP, dpi, phyw, dvoff, 5);
1739 { 1685 {
1740 DWORD err = CommDlgExtendedError(); 1686 DWORD err = CommDlgExtendedError();
1741 1687
1742 if (err) 1688 if (err)
1743 { 1689 {
1744 #ifdef WIN16
1745 char buf[20];
1746
1747 sprintf(buf, "%ld", err);
1748 EMSG2(_("E238: Print error: %s"), buf);
1749 #else
1750 char_u *buf; 1690 char_u *buf;
1751 1691
1752 /* I suspect FormatMessage() doesn't work for values returned by 1692 /* I suspect FormatMessage() doesn't work for values returned by
1753 * CommDlgExtendedError(). What does? */ 1693 * CommDlgExtendedError(). What does? */
1754 FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | 1694 FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
1756 FORMAT_MESSAGE_IGNORE_INSERTS, 1696 FORMAT_MESSAGE_IGNORE_INSERTS,
1757 NULL, err, 0, (LPTSTR)(&buf), 0, NULL); 1697 NULL, err, 0, (LPTSTR)(&buf), 0, NULL);
1758 EMSG2(_("E238: Print error: %s"), 1698 EMSG2(_("E238: Print error: %s"),
1759 buf == NULL ? (char_u *)_("Unknown") : buf); 1699 buf == NULL ? (char_u *)_("Unknown") : buf);
1760 LocalFree((LPVOID)(buf)); 1700 LocalFree((LPVOID)(buf));
1761 #endif
1762 } 1701 }
1763 else 1702 else
1764 msg_clr_eos(); /* Maybe canceled */ 1703 msg_clr_eos(); /* Maybe canceled */
1765 1704
1766 mch_print_cleanup(); 1705 mch_print_cleanup();
1776 static DOCINFO di; 1715 static DOCINFO di;
1777 char szBuffer[300]; 1716 char szBuffer[300];
1778 1717
1779 hDlgPrint = CreateDialog(GetModuleHandle(NULL), TEXT("PrintDlgBox"), 1718 hDlgPrint = CreateDialog(GetModuleHandle(NULL), TEXT("PrintDlgBox"),
1780 prt_dlg.hwndOwner, PrintDlgProc); 1719 prt_dlg.hwndOwner, PrintDlgProc);
1781 #ifdef WIN16
1782 Escape(prt_dlg.hDC, SETABORTPROC, 0, (LPSTR)AbortProc, NULL);
1783 #else
1784 SetAbortProc(prt_dlg.hDC, AbortProc); 1720 SetAbortProc(prt_dlg.hDC, AbortProc);
1785 #endif
1786 wsprintf(szBuffer, _("Printing '%s'"), gettail(psettings->jobname)); 1721 wsprintf(szBuffer, _("Printing '%s'"), gettail(psettings->jobname));
1787 vimSetDlgItemText(hDlgPrint, IDC_PRINTTEXT1, (char_u *)szBuffer); 1722 vimSetDlgItemText(hDlgPrint, IDC_PRINTTEXT1, (char_u *)szBuffer);
1788 1723
1789 vim_memset(&di, 0, sizeof(DOCINFO)); 1724 vim_memset(&di, 0, sizeof(DOCINFO));
1790 di.cbSize = sizeof(DOCINFO); 1725 di.cbSize = sizeof(DOCINFO);
1843 } 1778 }
1844 1779
1845 int 1780 int
1846 mch_print_text_out(char_u *p, int len) 1781 mch_print_text_out(char_u *p, int len)
1847 { 1782 {
1848 #if defined(FEAT_PROPORTIONAL_FONTS) || (defined(FEAT_MBYTE) && !defined(WIN16)) 1783 #if defined(FEAT_PROPORTIONAL_FONTS) || defined(FEAT_MBYTE)
1849 SIZE sz; 1784 SIZE sz;
1850 #endif 1785 #endif
1851 #if defined(FEAT_MBYTE) && !defined(WIN16) 1786 #if defined(FEAT_MBYTE)
1852 WCHAR *wp = NULL; 1787 WCHAR *wp = NULL;
1853 int wlen = len; 1788 int wlen = len;
1854 1789
1855 if (enc_codepage >= 0 && (int)GetACP() != enc_codepage) 1790 if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
1856 { 1791 {
1886 #ifndef FEAT_PROPORTIONAL_FONTS 1821 #ifndef FEAT_PROPORTIONAL_FONTS
1887 prt_pos_x += len * prt_tm.tmAveCharWidth; 1822 prt_pos_x += len * prt_tm.tmAveCharWidth;
1888 return (prt_pos_x + prt_left_margin + prt_tm.tmAveCharWidth 1823 return (prt_pos_x + prt_left_margin + prt_tm.tmAveCharWidth
1889 + prt_tm.tmOverhang > prt_right_margin); 1824 + prt_tm.tmOverhang > prt_right_margin);
1890 #else 1825 #else
1891 # ifdef WIN16
1892 GetTextExtentPoint(prt_dlg.hDC, (LPCSTR)p, len, &sz);
1893 # else
1894 GetTextExtentPoint32(prt_dlg.hDC, (LPCSTR)p, len, &sz); 1826 GetTextExtentPoint32(prt_dlg.hDC, (LPCSTR)p, len, &sz);
1895 # endif
1896 prt_pos_x += (sz.cx - prt_tm.tmOverhang); 1827 prt_pos_x += (sz.cx - prt_tm.tmOverhang);
1897 /* This is wrong when printing spaces for a TAB. */ 1828 /* This is wrong when printing spaces for a TAB. */
1898 if (p[len] == NUL) 1829 if (p[len] == NUL)
1899 return FALSE; 1830 return FALSE;
1900 # ifdef WIN16
1901 GetTextExtentPoint(prt_dlg.hDC, p + len, 1, &sz);
1902 # else
1903 GetTextExtentPoint32(prt_dlg.hDC, p + len, 1, &sz); 1831 GetTextExtentPoint32(prt_dlg.hDC, p + len, 1, &sz);
1904 # endif
1905 return (prt_pos_x + prt_left_margin + sz.cx > prt_right_margin); 1832 return (prt_pos_x + prt_left_margin + sz.cx > prt_right_margin);
1906 #endif 1833 #endif
1907 } 1834 }
1908 1835
1909 void 1836 void
3025 break; 2952 break;
3026 case 'w': 2953 case 'w':
3027 lf->lfWidth = points_to_pixels(p, &p, FALSE, (long_i)printer_dc); 2954 lf->lfWidth = points_to_pixels(p, &p, FALSE, (long_i)printer_dc);
3028 break; 2955 break;
3029 case 'b': 2956 case 'b':
3030 #ifndef MSWIN16_FASTTEXT
3031 lf->lfWeight = FW_BOLD; 2957 lf->lfWeight = FW_BOLD;
3032 #endif
3033 break; 2958 break;
3034 case 'i': 2959 case 'i':
3035 #ifndef MSWIN16_FASTTEXT
3036 lf->lfItalic = TRUE; 2960 lf->lfItalic = TRUE;
3037 #endif
3038 break; 2961 break;
3039 case 'u': 2962 case 'u':
3040 lf->lfUnderline = TRUE; 2963 lf->lfUnderline = TRUE;
3041 break; 2964 break;
3042 case 's': 2965 case 's':