Mercurial > vim
comparison src/terminal.c @ 12144:abd69cea3459 v8.0.0952
patch 8.0.0952: has('terminal') does not check existence of dll file
commit https://github.com/vim/vim/commit/a83e3962ac0e4bbfef15a072ad9a7390fc255409
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Aug 17 14:39:07 2017 +0200
patch 8.0.0952: has('terminal') does not check existence of dll file
Problem: MS-Windows: has('terminal') does not check existence of dll file.
Solution: Check if the winpty dll file can be loaded. (Ken Takata)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Thu, 17 Aug 2017 14:45:04 +0200 |
parents | bee3751f3d4e |
children | 59c1e09cf1a9 |
comparison
equal
deleted
inserted
replaced
12143:9af04854550d | 12144:abd69cea3459 |
---|---|
2707 * TODO: is there a better way? */ | 2707 * TODO: is there a better way? */ |
2708 parse_queued_messages(); | 2708 parse_queued_messages(); |
2709 } | 2709 } |
2710 } | 2710 } |
2711 | 2711 |
2712 # ifdef WIN3264 | 2712 # if defined(WIN3264) || defined(PROTO) |
2713 | 2713 |
2714 /************************************** | 2714 /************************************** |
2715 * 2. MS-Windows implementation. | 2715 * 2. MS-Windows implementation. |
2716 */ | 2716 */ |
2717 | |
2718 # ifndef PROTO | |
2717 | 2719 |
2718 #define WINPTY_SPAWN_FLAG_AUTO_SHUTDOWN 1ul | 2720 #define WINPTY_SPAWN_FLAG_AUTO_SHUTDOWN 1ul |
2719 #define WINPTY_SPAWN_FLAG_EXIT_AFTER_SHUTDOWN 2ull | 2721 #define WINPTY_SPAWN_FLAG_EXIT_AFTER_SHUTDOWN 2ull |
2720 | 2722 |
2721 void* (*winpty_config_new)(UINT64, void*); | 2723 void* (*winpty_config_new)(UINT64, void*); |
2735 HANDLE (*winpty_agent_process)(void*); | 2737 HANDLE (*winpty_agent_process)(void*); |
2736 | 2738 |
2737 #define WINPTY_DLL "winpty.dll" | 2739 #define WINPTY_DLL "winpty.dll" |
2738 | 2740 |
2739 static HINSTANCE hWinPtyDLL = NULL; | 2741 static HINSTANCE hWinPtyDLL = NULL; |
2740 | 2742 # endif |
2741 int | 2743 |
2742 dyn_winpty_init(void) | 2744 static int |
2745 dyn_winpty_init(int verbose) | |
2743 { | 2746 { |
2744 int i; | 2747 int i; |
2745 static struct | 2748 static struct |
2746 { | 2749 { |
2747 char *name; | 2750 char *name; |
2766 {NULL, NULL} | 2769 {NULL, NULL} |
2767 }; | 2770 }; |
2768 | 2771 |
2769 /* No need to initialize twice. */ | 2772 /* No need to initialize twice. */ |
2770 if (hWinPtyDLL) | 2773 if (hWinPtyDLL) |
2771 return 1; | 2774 return OK; |
2772 /* Load winpty.dll, prefer using the 'winptydll' option, fall back to just | 2775 /* Load winpty.dll, prefer using the 'winptydll' option, fall back to just |
2773 * winpty.dll. */ | 2776 * winpty.dll. */ |
2774 if (*p_winptydll != NUL) | 2777 if (*p_winptydll != NUL) |
2775 hWinPtyDLL = vimLoadLib((char *)p_winptydll); | 2778 hWinPtyDLL = vimLoadLib((char *)p_winptydll); |
2776 if (!hWinPtyDLL) | 2779 if (!hWinPtyDLL) |
2777 hWinPtyDLL = vimLoadLib(WINPTY_DLL); | 2780 hWinPtyDLL = vimLoadLib(WINPTY_DLL); |
2778 if (!hWinPtyDLL) | 2781 if (!hWinPtyDLL) |
2779 { | 2782 { |
2780 EMSG2(_(e_loadlib), *p_winptydll != NUL ? p_winptydll : WINPTY_DLL); | 2783 if (verbose) |
2781 return 0; | 2784 EMSG2(_(e_loadlib), *p_winptydll != NUL ? p_winptydll |
2785 : (char_u *)WINPTY_DLL); | |
2786 return FAIL; | |
2782 } | 2787 } |
2783 for (i = 0; winpty_entry[i].name != NULL | 2788 for (i = 0; winpty_entry[i].name != NULL |
2784 && winpty_entry[i].ptr != NULL; ++i) | 2789 && winpty_entry[i].ptr != NULL; ++i) |
2785 { | 2790 { |
2786 if ((*winpty_entry[i].ptr = (FARPROC)GetProcAddress(hWinPtyDLL, | 2791 if ((*winpty_entry[i].ptr = (FARPROC)GetProcAddress(hWinPtyDLL, |
2787 winpty_entry[i].name)) == NULL) | 2792 winpty_entry[i].name)) == NULL) |
2788 { | 2793 { |
2789 EMSG2(_(e_loadfunc), winpty_entry[i].name); | 2794 if (verbose) |
2790 return 0; | 2795 EMSG2(_(e_loadfunc), winpty_entry[i].name); |
2791 } | 2796 return FAIL; |
2792 } | 2797 } |
2793 | 2798 } |
2794 return 1; | 2799 |
2800 return OK; | |
2795 } | 2801 } |
2796 | 2802 |
2797 /* | 2803 /* |
2798 * Create a new terminal of "rows" by "cols" cells. | 2804 * Create a new terminal of "rows" by "cols" cells. |
2799 * Store a reference in "term". | 2805 * Store a reference in "term". |
2811 void *spawn_config = NULL; | 2817 void *spawn_config = NULL; |
2812 char buf[MAX_PATH]; | 2818 char buf[MAX_PATH]; |
2813 garray_T ga; | 2819 garray_T ga; |
2814 char_u *cmd; | 2820 char_u *cmd; |
2815 | 2821 |
2816 if (!dyn_winpty_init()) | 2822 if (dyn_winpty_init(TRUE) == FAIL) |
2817 return FAIL; | 2823 return FAIL; |
2818 | 2824 |
2819 if (argvar->v_type == VAR_STRING) | 2825 if (argvar->v_type == VAR_STRING) |
2820 cmd = argvar->vval.v_string; | 2826 cmd = argvar->vval.v_string; |
2821 else | 2827 else |
2975 term_report_winsize(term_T *term, int rows, int cols) | 2981 term_report_winsize(term_T *term, int rows, int cols) |
2976 { | 2982 { |
2977 winpty_set_size(term->tl_winpty, cols, rows, NULL); | 2983 winpty_set_size(term->tl_winpty, cols, rows, NULL); |
2978 } | 2984 } |
2979 | 2985 |
2986 int | |
2987 terminal_enabled(void) | |
2988 { | |
2989 return dyn_winpty_init(FALSE) == OK; | |
2990 } | |
2991 | |
2992 | |
2980 # else | 2993 # else |
2981 | 2994 |
2982 /************************************** | 2995 /************************************** |
2983 * 3. Unix-like implementation. | 2996 * 3. Unix-like implementation. |
2984 */ | 2997 */ |