diff options
author | erw7 <erw7.github@gmail.com> | 2018-06-01 03:04:45 +0900 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2018-12-27 22:35:59 +0100 |
commit | 606030155805732a0aec9da632936e87095d3974 (patch) | |
tree | 4c7bdf30a0968ad50f856dbe667c65033368cc7c | |
parent | 47473b39cb2b88c660e5a9959836440d5cd25d76 (diff) | |
download | rneovim-606030155805732a0aec9da632936e87095d3974.tar.gz rneovim-606030155805732a0aec9da632936e87095d3974.tar.bz2 rneovim-606030155805732a0aec9da632936e87095d3974.zip |
win/TUI: SetConsoleMode() to override libuv #9094
Use uv_set_vterm_state() to override libuv's guess.
See https://github.com/libuv/libuv/pull/1873/ for discussion.
This commit uses a terminal-detection approach based on
GetProcessImageFileNameW(...), which will be reverted in the following
commit. The approach was intended to handle the case of running in
winpty (:terminal), but we will add $NVIM env var for that.
Also add some support for ConEmu, cygwin.
-rw-r--r-- | CMakeLists.txt | 18 | ||||
-rwxr-xr-x | scripts/update_terminfo.sh | 3 | ||||
-rw-r--r-- | src/nvim/tui/terminfo.c | 4 | ||||
-rw-r--r-- | src/nvim/tui/terminfo_defs.h | 106 | ||||
-rw-r--r-- | src/nvim/tui/tui.c | 68 | ||||
-rw-r--r-- | third-party/CMakeLists.txt | 9 |
6 files changed, 202 insertions, 6 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index fa020bf55c..af6aeaf33d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -361,6 +361,24 @@ include_directories("${PROJECT_SOURCE_DIR}/src") find_package(LibUV REQUIRED) include_directories(SYSTEM ${LIBUV_INCLUDE_DIRS}) +if(WIN32) + list(APPEND CMAKE_REQUIRED_INCLUDES "${LIBUV_INCLUDE_DIRS}") + list(APPEND CMAKE_REQUIRED_LIBRARIES "${LIBUV_LIBRARIES}") + check_c_source_compiles(" + #include <uv.h> + + int + main(void) + { + uv_set_vterm_state(UV_UNSUPPORTED); + return 0; + } + " UV_HAS_SET_VTERM_STATE) + if(UV_HAS_SET_VTERM_STATE) + add_definitions(-DNVIM_UV_HAS_SET_VTERM_STATE) + endif() +endif() + find_package(Msgpack 1.0.0 REQUIRED) include_directories(SYSTEM ${MSGPACK_INCLUDE_DIRS}) diff --git a/scripts/update_terminfo.sh b/scripts/update_terminfo.sh index e3b1692b15..c78799a56e 100755 --- a/scripts/update_terminfo.sh +++ b/scripts/update_terminfo.sh @@ -26,6 +26,7 @@ readonly -A entries=( [tmux-256color]=tmux_256colour_terminfo [vte-256color]=vte_256colour_terminfo [xterm-256color]=xterm_256colour_terminfo + [cygwin]=cygwin_terminfo ) db="$(mktemp -du)" @@ -83,7 +84,7 @@ for term in $sorted_terms; do echo "};" done >> "$target" -cat > "$target" <<EOF +cat >> "$target" <<EOF #endif // NVIM_TUI_TERMINFO_DEFS_H EOF print_bold 'done\n' diff --git a/src/nvim/tui/terminfo.c b/src/nvim/tui/terminfo.c index ad86dd928b..bd17c1e746 100644 --- a/src/nvim/tui/terminfo.c +++ b/src/nvim/tui/terminfo.c @@ -86,6 +86,10 @@ static unibi_term *terminfo_builtin(const char *term, char **termname) *termname = xstrdup("builtin_vte"); return unibi_from_mem((const char *)vte_256colour_terminfo, sizeof vte_256colour_terminfo); + } else if (terminfo_is_term_family(term, "cygwin")) { + *termname = xstrdup("builtin_cygwin"); + return unibi_from_mem((const char *)cygwin_terminfo, + sizeof cygwin_terminfo); } else { *termname = xstrdup("builtin_ansi"); return unibi_from_mem((const char *)ansi_terminfo, diff --git a/src/nvim/tui/terminfo_defs.h b/src/nvim/tui/terminfo_defs.h index 000c0ea8e7..eaa0f73d12 100644 --- a/src/nvim/tui/terminfo_defs.h +++ b/src/nvim/tui/terminfo_defs.h @@ -97,6 +97,112 @@ static const int8_t ansi_terminfo[] = { 26,1,40,0,38,0,16,0,125,1,68,2,97,110,115,105,124,97,110,115,105,47,112,99,45,116,101,114,109,32,99,111,109,112,97,116,105,98,108,101,32,119,105,116,104,32,99,111,108,111,114,0,0,1,0,0,0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,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,20,2,30,2,-1,-1,-1,-1,-1,-1,40,2,44,2,48,2,52,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,56,2,62,2,27,91,90,0,7,0,13,0,27,91,51,103,0,27,91,72,27,91,74,0,27,91,75,0,27,91,74,0,27,91,37,105,37,112,49,37,100,71,0,27,91,37,105,37,112,49,37,100,59,37,112,50,37,100,72,0,27,91,66,0,27,91,72,0,27,91,68,0,27,91,67,0,27,91,65,0,27,91,80,0,27,91,77,0,27,91,49,49,109,0,27,91,53,109,0,27,91,49,109,0,27,91,56,109,0,27,91,55,109,0,27,91,55,109,0,27,91,52,109,0,27,91,37,112,49,37,100,88,0,27,91,49,48,109,0,27,91,48,59,49,48,109,0,27,91,109,0,27,91,109,0,27,91,76,0,8,0,27,91,66,0,27,91,72,0,27,91,76,0,27,91,68,0,27,91,67,0,27,91,65,0,13,27,91,83,0,27,91,37,112,49,37,100,80,0,27,91,37,112,49,37,100,77,0,27,91,37,112,49,37,100,66,0,27,91,37,112,49,37,100,64,0,27,91,37,112,49,37,100,83,0,27,91,37,112,49,37,100,76,0,27,91,37,112,49,37,100,68,0,27,91,37,112,49,37,100,67,0,27,91,37,112,49,37,100,84,0,27,91,37,112,49,37,100,65,0,27,91,52,105,0,27,91,53,105,0,37,112,49,37,99,27,91,37,112,50,37,123,49,125,37,45,37,100,98,0,27,91,37,105,37,112,49,37,100,100,0,10,0,27,91,48,59,49,48,37,63,37,112,49,37,116,59,55,37,59,37,63,37,112,50,37,116,59,52,37,59,37,63,37,112,51,37,116,59,55,37,59,37,63,37,112,52,37,116,59,53,37,59,37,63,37,112,54,37,116,59,49,37,59,37,63,37,112,55,37,116,59,56,37,59,37,63,37,112,57,37,116,59,49,49,37,59,109,0,27,72,0,27,91,73,0,43,16,44,17,45,24,46,25,48,-37,96,4,97,-79,102,-8,103,-15,104,-80,106,-39,107,-65,108,-38,109,-64,110,-59,111,126,112,-60,113,-60,114,-60,115,95,116,-61,117,-76,118,-63,119,-62,120,-77,121,-13,122,-14,123,-29,124,-40,125,-100,126,-2,0,27,91,90,0,27,91,49,75,0,27,91,37,105,37,100,59,37,100,82,0,27,91,54,110,0,27,91,63,37,91,59,48,49,50,51,52,53,54,55,56,57,93,99,0,27,91,99,0,27,91,51,57,59,52,57,109,0,27,91,51,37,112,49,37,100,109,0,27,91,52,37,112,49,37,100,109,0,27,40,66,0,27,41,66,0,27,42,66,0,27,43,66,0,27,91,49,49,109,0,27,91,49,48,109,0,1,0,0,0,0,0,1,0,3,0,1,0,0,0,65,88,0 }; +// cygwin|ANSI emulation for Cygwin, +// auto_right_margin, +// has_status_line, +// move_insert_mode, +// move_standout_mode, +// xon_xoff, +// init_tabs#8, +// max_colors#8, +// max_pairs#64, +// acs_chars=+^P\054^Q-^X.^Y0\333`^Da\261f\370g\361h\260j\331k\277l\332m\300n\305o~p\304q\304r\304s_t\303u\264v\301w\302x\263y\363z\362{\343|\330}\234~\376, +// bell=^G, +// carriage_return=\r, +// clear_screen=\E[H\E[J, +// clr_bol=\E[1K, +// clr_eol=\E[K, +// clr_eos=\E[J, +// column_address=\E[%i%p1%dG, +// cursor_address=\E[%i%p1%d;%p2%dH, +// cursor_down=\E[B, +// cursor_home=\E[H, +// cursor_left=^H, +// cursor_right=\E[C, +// cursor_up=\E[A, +// delete_character=\E[P, +// delete_line=\E[M, +// enter_alt_charset_mode=\E[11m, +// enter_bold_mode=\E[1m, +// enter_ca_mode=\E7\E[?47h, +// enter_insert_mode=\E[4h, +// enter_pc_charset_mode=\E[11m, +// enter_reverse_mode=\E[7m, +// enter_secure_mode=\E[8m, +// enter_standout_mode=\E[7m, +// enter_underline_mode=\E[4m, +// exit_alt_charset_mode=\E[10m, +// exit_attribute_mode=\E[0;10m, +// exit_ca_mode=\E[2J\E[?47l\E8, +// exit_insert_mode=\E[4l, +// exit_pc_charset_mode=\E[10m, +// exit_standout_mode=\E[27m, +// exit_underline_mode=\E[24m, +// from_status_line=^G, +// insert_character=\E[@, +// insert_line=\E[L, +// key_b2=\E[G, +// key_backspace=^H, +// key_dc=\E[3~, +// key_down=\E[B, +// key_end=\E[4~, +// key_f1=\E[[A, +// key_f10=\E[21~, +// key_f11=\E[23~, +// key_f12=\E[24~, +// key_f13=\E[25~, +// key_f14=\E[26~, +// key_f15=\E[28~, +// key_f16=\E[29~, +// key_f17=\E[31~, +// key_f18=\E[32~, +// key_f19=\E[33~, +// key_f2=\E[[B, +// key_f20=\E[34~, +// key_f3=\E[[C, +// key_f4=\E[[D, +// key_f5=\E[[E, +// key_f6=\E[17~, +// key_f7=\E[18~, +// key_f8=\E[19~, +// key_f9=\E[20~, +// key_home=\E[1~, +// key_ic=\E[2~, +// key_left=\E[D, +// key_npage=\E[6~, +// key_ppage=\E[5~, +// key_right=\E[C, +// key_suspend=^Z, +// key_up=\E[A, +// newline=\r\n, +// orig_pair=\E[39;49m, +// parm_dch=\E[%p1%dP, +// parm_delete_line=\E[%p1%dM, +// parm_down_cursor=\E[%p1%dB, +// parm_ich=\E[%p1%d@, +// parm_insert_line=\E[%p1%dL, +// parm_left_cursor=\E[%p1%dD, +// parm_right_cursor=\E[%p1%dC, +// parm_up_cursor=\E[%p1%dA, +// reset_1string=\Ec\E]R, +// restore_cursor=\E8, +// row_address=\E[%i%p1%dd, +// save_cursor=\E7, +// scroll_forward=\n, +// scroll_reverse=\EM, +// set_a_background=\E[4%p1%dm, +// set_a_foreground=\E[3%p1%dm, +// set_attributes=\E[0;10%?%p1%t;7%;%?%p2%t;4%;%?%p3%t;7%;%?%p6%t;1%;%?%p7%t;8%;%?%p9%t;11%;m, +// tab=^I, +// to_status_line=\E];, +// user6=\E[%i%d;%dR, +// user7=\E[6n, +// user8=\E[?6c, +// user9=\E[c, +static const int8_t cygwin_terminfo[] = { + 26,1,33,0,21,0,15,0,125,1,-108,2,99,121,103,119,105,110,124,65,78,83,73,32,101,109,117,108,97,116,105,111,110,32,102,111,114,32,67,121,103,119,105,110,0,0,1,0,0,0,0,0,0,0,1,0,0,0,1,1,0,0,0,0,0,1,-1,-1,8,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,0,64,0,-1,-1,0,0,2,0,-1,-1,-1,-1,4,0,11,0,15,0,19,0,-1,-1,30,0,47,0,51,0,-1,-1,55,0,-1,-1,-1,-1,57,0,-1,-1,61,0,-1,-1,65,0,69,0,-1,-1,-1,-1,73,0,-1,-1,79,0,84,0,-1,-1,-1,-1,93,0,98,0,-1,-1,103,0,108,0,113,0,-1,-1,118,0,124,0,-124,0,-1,-1,-111,0,-106,0,-100,0,-1,-1,-1,-1,-94,0,-1,-1,-1,-1,-1,-1,-1,-1,-92,0,-88,0,-1,-1,-84,0,-1,-1,-1,-1,-1,-1,-82,0,-1,-1,-77,0,-1,-1,-1,-1,-1,-1,-1,-1,-73,0,-68,0,-62,0,-57,0,-52,0,-47,0,-42,0,-36,0,-30,0,-24,0,-18,0,-13,0,-1,-1,-8,0,-1,-1,-4,0,1,1,6,1,-1,-1,-1,-1,-1,-1,10,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,14,1,-1,-1,17,1,26,1,35,1,44,1,-1,-1,53,1,62,1,71,1,-1,-1,80,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,89,1,-1,-1,-1,-1,-1,-1,95,1,98,1,109,1,112,1,114,1,117,1,-1,-1,-1,-1,-64,1,-62,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-58,1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1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,116,2,126,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-120,2,-114,2,7,0,13,0,27,91,72,27,91,74,0,27,91,75,0,27,91,74,0,27,91,37,105,37,112,49,37,100,71,0,27,91,37,105,37,112,49,37,100,59,37,112,50,37,100,72,0,27,91,66,0,27,91,72,0,8,0,27,91,67,0,27,91,65,0,27,91,80,0,27,91,77,0,27,91,49,49,109,0,27,91,49,109,0,27,55,27,91,63,52,55,104,0,27,91,52,104,0,27,91,56,109,0,27,91,55,109,0,27,91,55,109,0,27,91,52,109,0,27,91,49,48,109,0,27,91,48,59,49,48,109,0,27,91,50,74,27,91,63,52,55,108,27,56,0,27,91,52,108,0,27,91,50,55,109,0,27,91,50,52,109,0,7,0,27,91,64,0,27,91,76,0,8,0,27,91,51,126,0,27,91,66,0,27,91,91,65,0,27,91,50,49,126,0,27,91,91,66,0,27,91,91,67,0,27,91,91,68,0,27,91,91,69,0,27,91,49,55,126,0,27,91,49,56,126,0,27,91,49,57,126,0,27,91,50,48,126,0,27,91,49,126,0,27,91,50,126,0,27,91,68,0,27,91,54,126,0,27,91,53,126,0,27,91,67,0,27,91,65,0,13,10,0,27,91,37,112,49,37,100,80,0,27,91,37,112,49,37,100,77,0,27,91,37,112,49,37,100,66,0,27,91,37,112,49,37,100,64,0,27,91,37,112,49,37,100,76,0,27,91,37,112,49,37,100,68,0,27,91,37,112,49,37,100,67,0,27,91,37,112,49,37,100,65,0,27,99,27,93,82,0,27,56,0,27,91,37,105,37,112,49,37,100,100,0,27,55,0,10,0,27,77,0,27,91,48,59,49,48,37,63,37,112,49,37,116,59,55,37,59,37,63,37,112,50,37,116,59,52,37,59,37,63,37,112,51,37,116,59,55,37,59,37,63,37,112,54,37,116,59,49,37,59,37,63,37,112,55,37,116,59,56,37,59,37,63,37,112,57,37,116,59,49,49,37,59,109,0,9,0,27,93,59,0,27,91,71,0,43,16,44,17,45,24,46,25,48,-37,96,4,97,-79,102,-8,103,-15,104,-80,106,-39,107,-65,108,-38,109,-64,110,-59,111,126,112,-60,113,-60,114,-60,115,95,116,-61,117,-76,118,-63,119,-62,120,-77,121,-13,122,-14,123,-29,124,-40,125,-100,126,-2,0,27,91,52,126,0,26,0,27,91,50,51,126,0,27,91,50,52,126,0,27,91,50,53,126,0,27,91,50,54,126,0,27,91,50,56,126,0,27,91,50,57,126,0,27,91,51,49,126,0,27,91,51,50,126,0,27,91,51,51,126,0,27,91,51,52,126,0,27,91,49,75,0,27,91,37,105,37,100,59,37,100,82,0,27,91,54,110,0,27,91,63,54,99,0,27,91,99,0,27,91,51,57,59,52,57,109,0,27,91,51,37,112,49,37,100,109,0,27,91,52,37,112,49,37,100,109,0,27,91,49,49,109,0,27,91,49,48,109,0 +}; + // interix|opennt|opennt-25|ntconsole|ntconsole-25|OpenNT-term compatible with color, // auto_right_margin, // back_color_erase, diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index fc7d31edb0..a9599ff322 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -63,6 +63,10 @@ #define UNIBI_SET_NUM_VAR(var, num) (var).i = (num); #endif +#if defined(WIN32) && !defined(ENABLE_VIRTUAL_TERMINAL_PROCESSING) +# define ENABLE_VIRTUAL_TERMINAL_PROCESSING 0x0004 +#endif + typedef struct { int top, bot, left, right; } Rect; @@ -209,6 +213,56 @@ static void terminfo_start(UI *ui) // Set up unibilium/terminfo. const char *term = os_getenv("TERM"); + bool conemu_ansi = false; +#ifdef WIN32 + bool winpty = false; + bool vtp = false; + const char *env = os_getenv("VIM_TERMINAL"); + if (env) { + winpty = true; + } + // If we change to set environment variable in terminal of nvim, + // add condition here + + if (!winpty) { +# ifdef NVIM_UV_HAS_SET_VTERM_STATE + env = os_getenv("ConEmuANSI"); + if (env && !STRCMP(env, "ON")) { + conemu_ansi = true; + } +# endif + + HANDLE handle = (HANDLE)_get_osfhandle(data->out_fd); + DWORD dwMode; + if (handle != INVALID_HANDLE_VALUE && GetConsoleMode(handle, &dwMode)) { + dwMode |= ENABLE_VIRTUAL_TERMINAL_PROCESSING; + if (SetConsoleMode(handle, dwMode)) { + vtp = true; + } + } + } else { + // If it is running under winpty ignore the TERM environment variable and + // force it to be cygwin. + term = "cygwin"; + } + + if (term == NULL) { + if (vtp || conemu_ansi) { + term = "xterm-256color"; + } else { + term = "cygwin"; + } + } + + os_setenv("TERM", term, 1); +# ifdef NVIM_UV_HAS_SET_VTERM_STATE + if (conemu_ansi) { + uv_set_vterm_state(UV_SUPPORTED); + } else if (winpty) { + uv_set_vterm_state(UV_UNSUPPORTED); + } +# endif +#endif data->ut = unibi_from_env(); char *termname = NULL; if (!term || !data->ut) { @@ -230,7 +284,8 @@ static void terminfo_start(UI *ui) || os_getenv("KONSOLE_PROFILE_NAME") || os_getenv("KONSOLE_DBUS_SESSION"); - patch_terminfo_bugs(data, term, colorterm, vte_version, konsole, iterm_env); + patch_terminfo_bugs(data, term, colorterm, vte_version, konsole, iterm_env, + conemu_ansi); augment_terminfo(data, term, colorterm, vte_version, konsole, iterm_env); data->can_change_scroll_region = !!unibi_get_str(data->ut, unibi_change_scroll_region); @@ -1449,7 +1504,7 @@ static int unibi_find_ext_bool(unibi_term *ut, const char *name) /// and several terminal emulators falsely announce incorrect terminal types. static void patch_terminfo_bugs(TUIData *data, const char *term, const char *colorterm, long vte_version, - bool konsole, bool iterm_env) + bool konsole, bool iterm_env, bool conemu_ansi) { unibi_term *ut = data->ut; const char * xterm_version = os_getenv("XTERM_VERSION"); @@ -1480,6 +1535,7 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, bool mate_pretending_xterm = xterm && colorterm && strstr(colorterm, "mate-terminal"); bool true_xterm = xterm && !!xterm_version; + bool cygwin = terminfo_is_term_family(term, "cygwin"); char *fix_normal = (char *)unibi_get_str(ut, unibi_cursor_normal); if (fix_normal) { @@ -1548,6 +1604,11 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, unibi_set_if_empty(ut, unibi_enter_italics_mode, "\x1b[3m"); unibi_set_if_empty(ut, unibi_exit_italics_mode, "\x1b[23m"); } + if (conemu_ansi) { + unibi_set_num(ut, unibi_max_colors, 256); + unibi_set_str(ut, unibi_set_a_foreground, "\x1b[38;5;%p1%dm"); + unibi_set_str(ut, unibi_set_a_background, "\x1b[48;5;%p1%dm"); + } } else if (rxvt) { // 2017-04 terminfo.src lacks these. Unicode rxvt has them. unibi_set_if_empty(ut, unibi_enter_italics_mode, "\x1b[3m"); @@ -1590,7 +1651,6 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, } else if (st) { // No bugs in the vanilla terminfo for our purposes. } - // At this time (2017-07-12) it seems like all terminals that support 256 // color codes can use semicolons in the terminal code and be fine. // However, this is not correct according to the spec. So to reward those @@ -1667,6 +1727,8 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, || iterm || iterm_pretending_xterm || teraterm // per TeraTerm "Supported Control Functions" doco || alacritty // https://github.com/jwilm/alacritty/pull/608 + || cygwin + || conemu_ansi // Some linux-type terminals implement the xterm extension. // Example: console-terminal-emulator from the nosh toolset. || (linuxvt diff --git a/third-party/CMakeLists.txt b/third-party/CMakeLists.txt index cad6ee785e..4ea5f78683 100644 --- a/third-party/CMakeLists.txt +++ b/third-party/CMakeLists.txt @@ -120,8 +120,13 @@ endif() include(ExternalProject) -set(LIBUV_URL https://github.com/libuv/libuv/archive/v1.23.2.tar.gz) -set(LIBUV_SHA256 30af979c4f4b8d1b895ae6d115f7400c751542ccb9e656350fc89fda08d4eabd) +if(WIN32) + set(LIBUV_URL https://github.com/neovim/libuv/archive/0ed7feb71ca949f7a96ccb102481d17ea1bb5933.tar.gz) + set(LIBUV_SHA256 813fe763022f19878557c6fde311b6394fb9180caaaab0dd98d8704732234508) +else() + set(LIBUV_URL https://github.com/libuv/libuv/archive/v1.23.2.tar.gz) + set(LIBUV_SHA256 30af979c4f4b8d1b895ae6d115f7400c751542ccb9e656350fc89fda08d4eabd) +endif() set(MSGPACK_URL https://github.com/msgpack/msgpack-c/releases/download/cpp-3.0.0/msgpack-3.0.0.tar.gz) set(MSGPACK_SHA256 bfbb71b7c02f806393bc3cbc491b40523b89e64f83860c58e3e54af47de176e4) |