comparison src/os_mswin.c @ 10264:c036c0f636d5 v8.0.0029

commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1 Author: Bram Moolenaar <Bram@vim.org> Date: Wed Oct 12 14:20:24 2016 +0200 patch 8.0.0029 Problem: Code for MS-Windows is complicated because of the exceptions for old systems. Solution: Drop support for MS-Windows older than Windows XP. (Ken Takata)
author Christian Brabandt <cb@256bit.org>
date Wed, 12 Oct 2016 14:30:05 +0200
parents 4aead6a9b7a9
children 9f88dba65a2d
comparison
equal deleted inserted replaced
10263:b758a787983a 10264:c036c0f636d5
36 # include <shellapi.h> 36 # include <shellapi.h>
37 # endif 37 # endif
38 38
39 # if defined(FEAT_PRINTER) && !defined(FEAT_POSTSCRIPT) 39 # if defined(FEAT_PRINTER) && !defined(FEAT_POSTSCRIPT)
40 # include <dlgs.h> 40 # include <dlgs.h>
41 # ifdef WIN3264 41 # include <winspool.h>
42 # include <winspool.h>
43 # else
44 # include <print.h>
45 # endif
46 # include <commdlg.h> 42 # include <commdlg.h>
47 #endif 43 #endif
48 44
49 #endif /* PROTO */ 45 #endif /* PROTO */
50 46
128 124
129 #ifdef MCH_WRITE_DUMP 125 #ifdef MCH_WRITE_DUMP
130 FILE* fdDump = NULL; 126 FILE* fdDump = NULL;
131 #endif 127 #endif
132 128
133 #ifdef WIN3264
134 extern DWORD g_PlatformId;
135 #endif
136
137 #ifndef FEAT_GUI_MSWIN 129 #ifndef FEAT_GUI_MSWIN
138 extern char g_szOrigTitle[]; 130 extern char g_szOrigTitle[];
139 #endif 131 #endif
140 132
141 #ifdef FEAT_GUI 133 #ifdef FEAT_GUI
246 void 238 void
247 mch_early_init(void) 239 mch_early_init(void)
248 { 240 {
249 int i; 241 int i;
250 242
251 #ifdef WIN3264
252 PlatformId(); 243 PlatformId();
253 #endif
254 244
255 /* Init the tables for toupper() and tolower() */ 245 /* Init the tables for toupper() and tolower() */
256 for (i = 0; i < 256; ++i) 246 for (i = 0; i < 256; ++i)
257 toupper_tab[i] = tolower_tab[i] = i; 247 toupper_tab[i] = tolower_tab[i] = i;
258 #ifdef WIN3264
259 CharUpperBuff((LPSTR)toupper_tab, 256); 248 CharUpperBuff((LPSTR)toupper_tab, 256);
260 CharLowerBuff((LPSTR)tolower_tab, 256); 249 CharLowerBuff((LPSTR)tolower_tab, 256);
261 #else
262 AnsiUpperBuff((LPSTR)toupper_tab, 256);
263 AnsiLowerBuff((LPSTR)tolower_tab, 256);
264 #endif
265 } 250 }
266 251
267 252
268 /* 253 /*
269 * Return TRUE if the input comes from a terminal, FALSE otherwise. 254 * Return TRUE if the input comes from a terminal, FALSE otherwise.
297 # ifdef FEAT_MBYTE 282 # ifdef FEAT_MBYTE
298 if (enc_codepage >= 0 && (int)GetACP() != enc_codepage) 283 if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
299 { 284 {
300 /* Convert the title from 'encoding' to the active codepage. */ 285 /* Convert the title from 'encoding' to the active codepage. */
301 WCHAR *wp = enc_to_utf16(title, NULL); 286 WCHAR *wp = enc_to_utf16(title, NULL);
302 int n;
303 287
304 if (wp != NULL) 288 if (wp != NULL)
305 { 289 {
306 n = SetConsoleTitleW(wp); 290 SetConsoleTitleW(wp);
307 vim_free(wp); 291 vim_free(wp);
308 if (n != 0 || GetLastError() != ERROR_CALL_NOT_IMPLEMENTED) 292 return;
309 return;
310 } 293 }
311 } 294 }
312 # endif 295 # endif
313 SetConsoleTitle((LPCSTR)title); 296 SetConsoleTitle((LPCSTR)title);
314 } 297 }
377 nResult = mch_dirname(buf, len); 360 nResult = mch_dirname(buf, len);
378 else 361 else
379 #endif 362 #endif
380 { 363 {
381 #ifdef FEAT_MBYTE 364 #ifdef FEAT_MBYTE
382 if (enc_codepage >= 0 && (int)GetACP() != enc_codepage 365 if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
383 # ifdef __BORLANDC__
384 /* Wide functions of Borland C 5.5 do not work on Windows 98. */
385 && g_PlatformId == VER_PLATFORM_WIN32_NT
386 # endif
387 )
388 { 366 {
389 WCHAR *wname; 367 WCHAR *wname;
390 WCHAR wbuf[MAX_PATH]; 368 WCHAR wbuf[MAX_PATH];
391 char_u *cname = NULL; 369 char_u *cname = NULL;
392 370
639 if (p == NULL) 617 if (p == NULL)
640 STRCAT(buf, "\\"); 618 STRCAT(buf, "\\");
641 } 619 }
642 } 620 }
643 #ifdef FEAT_MBYTE 621 #ifdef FEAT_MBYTE
644 if (enc_codepage >= 0 && (int)GetACP() != enc_codepage 622 if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
645 # ifdef __BORLANDC__
646 /* Wide functions of Borland C 5.5 do not work on Windows 98. */
647 && g_PlatformId == VER_PLATFORM_WIN32_NT
648 # endif
649 )
650 { 623 {
651 WCHAR *wp = enc_to_utf16(buf, NULL); 624 WCHAR *wp = enc_to_utf16(buf, NULL);
652 int n; 625 int n;
653 626
654 if (wp != NULL) 627 if (wp != NULL)
655 { 628 {
656 n = wstat_symlink_aware(wp, stp); 629 n = wstat_symlink_aware(wp, stp);
657 vim_free(wp); 630 vim_free(wp);
658 if (n >= 0 || g_PlatformId == VER_PLATFORM_WIN32_NT) 631 return n;
659 return n;
660 /* Retry with non-wide function (for Windows 98). Can't use
661 * GetLastError() here and it's unclear what errno gets set to if
662 * the _wstat() fails for missing wide functions. */
663 } 632 }
664 } 633 }
665 #endif 634 #endif
666 return stat_symlink_aware((char *)buf, stp); 635 return stat_symlink_aware((char *)buf, stp);
667 } 636 }
821 790
822 if (p != NULL) 791 if (p != NULL)
823 { 792 {
824 n = _wchdir(p); 793 n = _wchdir(p);
825 vim_free(p); 794 vim_free(p);
826 if (n == 0 || g_PlatformId == VER_PLATFORM_WIN32_NT) 795 return n;
827 return n;
828 /* Retry with non-wide function (for Windows 98). */
829 } 796 }
830 } 797 }
831 #endif 798 #endif
832 799
833 return chdir(path); /* let the normal chdir() do the rest */ 800 return chdir(path); /* let the normal chdir() do the rest */
834 } 801 }
835 802
836
837 /*
838 * Switching off termcap mode is only allowed when Columns is 80, otherwise a
839 * crash may result. It's always allowed on NT or when running the GUI.
840 */
841 /*ARGSUSED*/
842 int
843 can_end_termcap_mode(
844 int give_msg)
845 {
846 #ifdef FEAT_GUI_MSWIN
847 return TRUE; /* GUI starts a new console anyway */
848 #else
849 if (g_PlatformId == VER_PLATFORM_WIN32_NT || Columns == 80)
850 return TRUE;
851 if (give_msg)
852 msg((char_u *)
853 _("'columns' is not 80, cannot execute external commands"));
854 return FALSE;
855 #endif
856 }
857 803
858 #ifdef FEAT_GUI_MSWIN 804 #ifdef FEAT_GUI_MSWIN
859 /* 805 /*
860 * return non-zero if a character is available 806 * return non-zero if a character is available
861 */ 807 */
885 /* 831 /*
886 * Call a DLL routine which takes either a string or int param 832 * Call a DLL routine which takes either a string or int param
887 * and returns an allocated string. 833 * and returns an allocated string.
888 * Return OK if it worked, FAIL if not. 834 * Return OK if it worked, FAIL if not.
889 */ 835 */
890 # ifdef WIN3264
891 typedef LPTSTR (*MYSTRPROCSTR)(LPTSTR); 836 typedef LPTSTR (*MYSTRPROCSTR)(LPTSTR);
892 typedef LPTSTR (*MYINTPROCSTR)(int); 837 typedef LPTSTR (*MYINTPROCSTR)(int);
893 typedef int (*MYSTRPROCINT)(LPTSTR); 838 typedef int (*MYSTRPROCINT)(LPTSTR);
894 typedef int (*MYINTPROCINT)(int); 839 typedef int (*MYINTPROCINT)(int);
895 # else
896 typedef LPSTR (*MYSTRPROCSTR)(LPSTR);
897 typedef LPSTR (*MYINTPROCSTR)(int);
898 typedef int (*MYSTRPROCINT)(LPSTR);
899 typedef int (*MYINTPROCINT)(int);
900 # endif
901 840
902 /* 841 /*
903 * Check if a pointer points to a valid NUL terminated string. 842 * Check if a pointer points to a valid NUL terminated string.
904 * Return the length of the string, including terminating NUL. 843 * Return the length of the string, including terminating NUL.
905 * Returns 0 for an invalid pointer, 1 for an empty string. 844 * Returns 0 for an invalid pointer, 1 for an empty string.
1091 } 1030 }
1092 1031
1093 #endif //_DEBUG 1032 #endif //_DEBUG
1094 1033
1095 #if !defined(FEAT_GUI) || defined(PROTO) 1034 #if !defined(FEAT_GUI) || defined(PROTO)
1096 # if defined(FEAT_TITLE) && defined(WIN3264) 1035 # ifdef FEAT_TITLE
1097 extern HWND g_hWnd; /* This is in os_win32.c. */ 1036 extern HWND g_hWnd; /* This is in os_win32.c. */
1098 # endif 1037 # endif
1099 1038
1100 /* 1039 /*
1101 * Showing the printer dialog is tricky since we have no GUI 1040 * Showing the printer dialog is tricky since we have no GUI
1112 1051
1113 /* Skip if it's already set. */ 1052 /* Skip if it's already set. */
1114 if (s_hwnd != 0) 1053 if (s_hwnd != 0)
1115 return; 1054 return;
1116 1055
1117 # if defined(FEAT_TITLE) && defined(WIN3264) 1056 # ifdef FEAT_TITLE
1118 /* Window handle may have been found by init code (Windows NT only) */ 1057 /* Window handle may have been found by init code (Windows NT only) */
1119 if (g_hWnd != 0) 1058 if (g_hWnd != 0)
1120 { 1059 {
1121 s_hwnd = g_hWnd; 1060 s_hwnd = g_hWnd;
1122 return; 1061 return;
1537 || !term_console 1476 || !term_console
1538 #endif 1477 #endif
1539 ) 1478 )
1540 { 1479 {
1541 prt_dlg.Flags |= PD_RETURNDEFAULT; 1480 prt_dlg.Flags |= PD_RETURNDEFAULT;
1542 #ifdef WIN3264
1543 /* 1481 /*
1544 * MSDN suggests setting the first parameter to WINSPOOL for 1482 * MSDN suggests setting the first parameter to WINSPOOL for
1545 * NT, but NULL appears to work just as well. 1483 * NT, but NULL appears to work just as well.
1546 */ 1484 */
1547 if (*p_pdev != NUL) 1485 if (*p_pdev != NUL)
1548 prt_dlg.hDC = CreateDC(NULL, (LPCSTR)p_pdev, NULL, NULL); 1486 prt_dlg.hDC = CreateDC(NULL, (LPCSTR)p_pdev, NULL, NULL);
1549 else 1487 else
1550 #endif
1551 { 1488 {
1552 prt_dlg.Flags |= PD_RETURNDEFAULT; 1489 prt_dlg.Flags |= PD_RETURNDEFAULT;
1553 if (PrintDlg(&prt_dlg) == 0) 1490 if (PrintDlg(&prt_dlg) == 0)
1554 goto init_fail_dlg; 1491 goto init_fail_dlg;
1555 } 1492 }
1591 * hDevMode struct. 1528 * hDevMode struct.
1592 */ 1529 */
1593 mem = (DEVMODE *)GlobalLock(prt_dlg.hDevMode); 1530 mem = (DEVMODE *)GlobalLock(prt_dlg.hDevMode);
1594 if (mem != NULL) 1531 if (mem != NULL)
1595 { 1532 {
1596 #ifdef WIN3264
1597 if (mem->dmCopies != 1) 1533 if (mem->dmCopies != 1)
1598 stored_nCopies = mem->dmCopies; 1534 stored_nCopies = mem->dmCopies;
1599 #endif
1600 if ((mem->dmFields & DM_DUPLEX) && (mem->dmDuplex & ~DMDUP_SIMPLEX)) 1535 if ((mem->dmFields & DM_DUPLEX) && (mem->dmDuplex & ~DMDUP_SIMPLEX))
1601 psettings->duplex = TRUE; 1536 psettings->duplex = TRUE;
1602 if ((mem->dmFields & DM_COLOR) && (mem->dmColor & DMCOLOR_COLOR)) 1537 if ((mem->dmFields & DM_COLOR) && (mem->dmColor & DMCOLOR_COLOR))
1603 psettings->has_color = TRUE; 1538 psettings->has_color = TRUE;
1604 } 1539 }
1951 shortcut_errorw: 1886 shortcut_errorw:
1952 vim_free(p); 1887 vim_free(p);
1953 goto shortcut_end; 1888 goto shortcut_end;
1954 } 1889 }
1955 } 1890 }
1956 /* Retry with non-wide function (for Windows 98). */ 1891 goto shortcut_end;
1957 } 1892 }
1958 # endif 1893 # endif
1959 // create a link manager object and request its interface 1894 // create a link manager object and request its interface
1960 hr = CoCreateInstance( 1895 hr = CoCreateInstance(
1961 &CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, 1896 &CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
2679 {"DEFAULT", DEFAULT_CHARSET}, 2614 {"DEFAULT", DEFAULT_CHARSET},
2680 {"HANGEUL", HANGEUL_CHARSET}, 2615 {"HANGEUL", HANGEUL_CHARSET},
2681 {"OEM", OEM_CHARSET}, 2616 {"OEM", OEM_CHARSET},
2682 {"SHIFTJIS", SHIFTJIS_CHARSET}, 2617 {"SHIFTJIS", SHIFTJIS_CHARSET},
2683 {"SYMBOL", SYMBOL_CHARSET}, 2618 {"SYMBOL", SYMBOL_CHARSET},
2684 #ifdef WIN3264
2685 {"ARABIC", ARABIC_CHARSET}, 2619 {"ARABIC", ARABIC_CHARSET},
2686 {"BALTIC", BALTIC_CHARSET}, 2620 {"BALTIC", BALTIC_CHARSET},
2687 {"EASTEUROPE", EASTEUROPE_CHARSET}, 2621 {"EASTEUROPE", EASTEUROPE_CHARSET},
2688 {"GB2312", GB2312_CHARSET}, 2622 {"GB2312", GB2312_CHARSET},
2689 {"GREEK", GREEK_CHARSET}, 2623 {"GREEK", GREEK_CHARSET},
2691 {"JOHAB", JOHAB_CHARSET}, 2625 {"JOHAB", JOHAB_CHARSET},
2692 {"MAC", MAC_CHARSET}, 2626 {"MAC", MAC_CHARSET},
2693 {"RUSSIAN", RUSSIAN_CHARSET}, 2627 {"RUSSIAN", RUSSIAN_CHARSET},
2694 {"THAI", THAI_CHARSET}, 2628 {"THAI", THAI_CHARSET},
2695 {"TURKISH", TURKISH_CHARSET}, 2629 {"TURKISH", TURKISH_CHARSET},
2696 # if (!defined(_MSC_VER) || (_MSC_VER > 1010)) \ 2630 #ifdef VIETNAMESE_CHARSET
2697 && (!defined(__BORLANDC__) || (__BORLANDC__ > 0x0500))
2698 {"VIETNAMESE", VIETNAMESE_CHARSET}, 2631 {"VIETNAMESE", VIETNAMESE_CHARSET},
2699 # endif
2700 #endif 2632 #endif
2701 {NULL, 0} 2633 {NULL, 0}
2702 }; 2634 };
2703 2635
2704 struct quality_pair 2636 struct quality_pair