comparison src/os_win32.c @ 15725:a3e2e7948ee4 v8.1.0870

patch 8.1.0870: Vim doesn't use the new ConPTY support in Windows 10 commit https://github.com/vim/vim/commit/aa5df7e3127dff6b7336df0903f5c569a40eb174 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Feb 3 14:53:10 2019 +0100 patch 8.1.0870: Vim doesn't use the new ConPTY support in Windows 10 Problem: Vim doesn't use the new ConPTY support in Windows 10. Solution: Use ConPTY support, if available. (Nobuhiro Takasaki, closes https://github.com/vim/vim/issues/3794)
author Bram Moolenaar <Bram@vim.org>
date Sun, 03 Feb 2019 15:00:08 +0100
parents bfbdef46aa7d
children 864ec0dd71b9
comparison
equal deleted inserted replaced
15724:c75264abac54 15725:a3e2e7948ee4
184 184
185 static int win32_getattrs(char_u *name); 185 static int win32_getattrs(char_u *name);
186 static int win32_setattrs(char_u *name, int attrs); 186 static int win32_setattrs(char_u *name, int attrs);
187 static int win32_set_archive(char_u *name); 187 static int win32_set_archive(char_u *name);
188 188
189 static int vtp_working = 0;
190 static void vtp_flag_init();
191
189 #ifndef FEAT_GUI_W32 192 #ifndef FEAT_GUI_W32
190 static int vtp_working = 0;
191 static void vtp_init(); 193 static void vtp_init();
192 static void vtp_exit(); 194 static void vtp_exit();
193 static int vtp_printf(char *format, ...); 195 static int vtp_printf(char *format, ...);
194 static void vtp_sgr_bulk(int arg); 196 static void vtp_sgr_bulk(int arg);
195 static void vtp_sgr_bulks(int argc, int *argv); 197 static void vtp_sgr_bulks(int argc, int *argv);
245 typedef BOOL (WINAPI *PfnGetConsoleScreenBufferInfoEx)(HANDLE, PDYN_CONSOLE_SCREEN_BUFFER_INFOEX); 247 typedef BOOL (WINAPI *PfnGetConsoleScreenBufferInfoEx)(HANDLE, PDYN_CONSOLE_SCREEN_BUFFER_INFOEX);
246 static PfnGetConsoleScreenBufferInfoEx pGetConsoleScreenBufferInfoEx; 248 static PfnGetConsoleScreenBufferInfoEx pGetConsoleScreenBufferInfoEx;
247 typedef BOOL (WINAPI *PfnSetConsoleScreenBufferInfoEx)(HANDLE, PDYN_CONSOLE_SCREEN_BUFFER_INFOEX); 249 typedef BOOL (WINAPI *PfnSetConsoleScreenBufferInfoEx)(HANDLE, PDYN_CONSOLE_SCREEN_BUFFER_INFOEX);
248 static PfnSetConsoleScreenBufferInfoEx pSetConsoleScreenBufferInfoEx; 250 static PfnSetConsoleScreenBufferInfoEx pSetConsoleScreenBufferInfoEx;
249 static BOOL has_csbiex = FALSE; 251 static BOOL has_csbiex = FALSE;
252 #endif
250 253
251 /* 254 /*
252 * Get version number including build number 255 * Get version number including build number
253 */ 256 */
254 typedef BOOL (WINAPI *PfnRtlGetVersion)(LPOSVERSIONINFOW); 257 typedef BOOL (WINAPI *PfnRtlGetVersion)(LPOSVERSIONINFOW);
274 min(osver.dwBuildNumber, 32767)); 277 min(osver.dwBuildNumber, 32767));
275 } 278 }
276 return ver; 279 return ver;
277 } 280 }
278 281
279 282 #ifndef FEAT_GUI_W32
280 /* 283 /*
281 * Version of ReadConsoleInput() that works with IME. 284 * Version of ReadConsoleInput() that works with IME.
282 * Works around problems on Windows 8. 285 * Works around problems on Windows 8.
283 */ 286 */
284 static BOOL 287 static BOOL
1506 dwEndTime = GetTickCount() + msec; 1509 dwEndTime = GetTickCount() + msec;
1507 else if (msec < 0) 1510 else if (msec < 0)
1508 /* Wait forever. */ 1511 /* Wait forever. */
1509 dwEndTime = INFINITE; 1512 dwEndTime = INFINITE;
1510 1513
1511 /* We need to loop until the end of the time period, because 1514 // We need to loop until the end of the time period, because
1512 * we might get multiple unusable mouse events in that time. 1515 // we might get multiple unusable mouse events in that time.
1513 */
1514 for (;;) 1516 for (;;)
1515 { 1517 {
1516 // Only process messages when waiting. 1518 // Only process messages when waiting.
1517 if (msec != 0) 1519 if (msec != 0)
1518 { 1520 {
2173 set_option_value((char_u *)"grepprg", 0, (char_u *)"grep -n", 0); 2175 set_option_value((char_u *)"grepprg", 0, (char_u *)"grep -n", 0);
2174 2176
2175 #ifdef FEAT_CLIPBOARD 2177 #ifdef FEAT_CLIPBOARD
2176 win_clip_init(); 2178 win_clip_init();
2177 #endif 2179 #endif
2180
2181 vtp_flag_init();
2178 } 2182 }
2179 2183
2180 2184
2181 #else /* FEAT_GUI_W32 */ 2185 #else /* FEAT_GUI_W32 */
2182 2186
2673 2677
2674 #ifdef FEAT_CLIPBOARD 2678 #ifdef FEAT_CLIPBOARD
2675 win_clip_init(); 2679 win_clip_init();
2676 #endif 2680 #endif
2677 2681
2682 vtp_flag_init();
2678 vtp_init(); 2683 vtp_init();
2679 } 2684 }
2680 2685
2681 /* 2686 /*
2682 * non-GUI version of mch_exit(). 2687 * non-GUI version of mch_exit().
5681 5686
5682 if (STRCMP(how, "term") == 0 || STRCMP(how, "kill") == 0 || *how == NUL) 5687 if (STRCMP(how, "term") == 0 || STRCMP(how, "kill") == 0 || *how == NUL)
5683 { 5688 {
5684 /* deadly signal */ 5689 /* deadly signal */
5685 if (job->jv_job_object != NULL) 5690 if (job->jv_job_object != NULL)
5691 {
5692 if (job->jv_channel != NULL && job->jv_channel->ch_anonymous_pipe)
5693 job->jv_channel->ch_killing = TRUE;
5686 return TerminateJobObject(job->jv_job_object, 0) ? OK : FAIL; 5694 return TerminateJobObject(job->jv_job_object, 0) ? OK : FAIL;
5695 }
5687 return terminate_all(job->jv_proc_info.hProcess, 0) ? OK : FAIL; 5696 return terminate_all(job->jv_proc_info.hProcess, 0) ? OK : FAIL;
5688 } 5697 }
5689 5698
5690 if (!AttachConsole(job->jv_proc_info.dwProcessId)) 5699 if (!AttachConsole(job->jv_proc_info.dwProcessId))
5691 return FAIL; 5700 return FAIL;
7619 } 7628 }
7620 7629
7621 return 0; 7630 return 0;
7622 } 7631 }
7623 7632
7624 #ifndef FEAT_GUI_W32
7625
7626 /* 7633 /*
7627 * Support for 256 colors and 24-bit colors was added in Windows 10 7634 * Support for 256 colors and 24-bit colors was added in Windows 10
7628 * version 1703 (Creators update). 7635 * version 1703 (Creators update).
7629 */ 7636 */
7630 # define VTP_FIRST_SUPPORT_BUILD MAKE_VER(10, 0, 15063) 7637 #define VTP_FIRST_SUPPORT_BUILD MAKE_VER(10, 0, 15063)
7638
7639 /*
7640 * Support for pseudo-console (ConPTY) was added in windows 10
7641 * version 1809 (October 2018 update).
7642 */
7643 #define CONPTY_FIRST_SUPPORT_BUILD MAKE_VER(10, 0, 17763)
7644
7645 static void
7646 vtp_flag_init(void)
7647 {
7648 DWORD ver = get_build_number();
7649 #ifndef FEAT_GUI_W32
7650 DWORD mode;
7651 HANDLE out;
7652
7653 out = GetStdHandle(STD_OUTPUT_HANDLE);
7654
7655 vtp_working = (ver >= VTP_FIRST_SUPPORT_BUILD) ? 1 : 0;
7656 GetConsoleMode(out, &mode);
7657 mode |= (ENABLE_PROCESSED_OUTPUT | ENABLE_VIRTUAL_TERMINAL_PROCESSING);
7658 if (SetConsoleMode(out, mode) == 0)
7659 vtp_working = 0;
7660 #endif
7661
7662 #ifdef FEAT_GUI_W32
7663 if (ver >= CONPTY_FIRST_SUPPORT_BUILD)
7664 vtp_working = 1;
7665 #endif
7666
7667 }
7668
7669 #ifndef FEAT_GUI_W32
7631 7670
7632 static void 7671 static void
7633 vtp_init(void) 7672 vtp_init(void)
7634 { 7673 {
7635 DWORD ver, mode;
7636 HMODULE hKerneldll; 7674 HMODULE hKerneldll;
7637 DYN_CONSOLE_SCREEN_BUFFER_INFOEX csbi; 7675 DYN_CONSOLE_SCREEN_BUFFER_INFOEX csbi;
7638 # ifdef FEAT_TERMGUICOLORS 7676 # ifdef FEAT_TERMGUICOLORS
7639 COLORREF fg, bg; 7677 COLORREF fg, bg;
7640 # endif 7678 # endif
7641
7642 ver = get_build_number();
7643 vtp_working = (ver >= VTP_FIRST_SUPPORT_BUILD) ? 1 : 0;
7644 GetConsoleMode(g_hConOut, &mode);
7645 mode |= (ENABLE_PROCESSED_OUTPUT | ENABLE_VIRTUAL_TERMINAL_PROCESSING);
7646 if (SetConsoleMode(g_hConOut, mode) == 0)
7647 vtp_working = 0;
7648 7679
7649 /* Use functions supported from Vista */ 7680 /* Use functions supported from Vista */
7650 hKerneldll = GetModuleHandle("kernel32.dll"); 7681 hKerneldll = GetModuleHandle("kernel32.dll");
7651 if (hKerneldll != NULL) 7682 if (hKerneldll != NULL)
7652 { 7683 {
7827 else 7858 else
7828 reset_console_color_rgb(); 7859 reset_console_color_rgb();
7829 } 7860 }
7830 7861
7831 int 7862 int
7832 has_vtp_working(void)
7833 {
7834 return vtp_working;
7835 }
7836
7837 int
7838 use_vtp(void) 7863 use_vtp(void)
7839 { 7864 {
7840 return USE_VTP; 7865 return USE_VTP;
7841 } 7866 }
7842 7867
7845 { 7870 {
7846 return T_NAME != NULL && STRCMP(T_NAME, "win32") == 0; 7871 return T_NAME != NULL && STRCMP(T_NAME, "win32") == 0;
7847 } 7872 }
7848 7873
7849 #endif 7874 #endif
7875
7876 int
7877 has_vtp_working(void)
7878 {
7879 return vtp_working;
7880 }