diff options
author | Bram Moolenaar <Bram@vim.org> | 2019-02-08 12:47:03 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2019-02-08 12:47:03 +0100 |
commit | c6ddce3f2cf6daa3a545405373b661f8a9bccad9 (patch) | |
tree | 080830ec75202e61d48d27e4e951dc849fe4cbfc /src | |
parent | 0036201a1a096913840d3df8ff08eb58eaae90a6 (diff) |
patch 8.1.0880: MS-Windows: inconsistent selection of winpty/conptyv8.1.0880
Problem: MS-Windows: inconsistent selection of winpty/conpty.
Solution: Name option 'termwintype', use ++type argument and "term_pty" for
term_start(). (Hirohito Higashi, closes #3915)
Diffstat (limited to 'src')
-rw-r--r-- | src/channel.c | 18 | ||||
-rw-r--r-- | src/option.c | 35 | ||||
-rw-r--r-- | src/option.h | 4 | ||||
-rw-r--r-- | src/structs.h | 9 | ||||
-rw-r--r-- | src/terminal.c | 58 | ||||
-rw-r--r-- | src/testdir/gen_opt_test.vim | 2 | ||||
-rw-r--r-- | src/version.c | 2 |
7 files changed, 68 insertions, 60 deletions
diff --git a/src/channel.c b/src/channel.c index 484d0139b1..34a1fc3e03 100644 --- a/src/channel.c +++ b/src/channel.c @@ -4947,27 +4947,27 @@ get_job_options(typval_T *tv, jobopt_T *opt, int supported, int supported2) opt->jo_set2 |= JO2_TERM_KILL; opt->jo_term_kill = tv_get_string_chk(item); } - else if (STRCMP(hi->hi_key, "term_mode") == 0) + else if (STRCMP(hi->hi_key, "tty_type") == 0) { char_u *p; - if (!(supported2 & JO2_TERM_MODE)) + if (!(supported2 & JO2_TTY_TYPE)) break; - opt->jo_set2 |= JO2_TERM_MODE; + opt->jo_set2 |= JO2_TTY_TYPE; p = tv_get_string_chk(item); if (p == NULL) { - semsg(_(e_invargval), "term_mode"); + semsg(_(e_invargval), "tty_type"); return FAIL; } // Allow empty string, "winpty", "conpty". if (!(*p == NUL || STRCMP(p, "winpty") == 0 || STRCMP(p, "conpty") == 0)) { - semsg(_(e_invargval), "term_mode"); + semsg(_(e_invargval), "tty_type"); return FAIL; } - opt->jo_term_mode = p[0]; + opt->jo_tty_type = p[0]; } # if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS) else if (STRCMP(hi->hi_key, "ansi_colors") == 0) @@ -5194,6 +5194,9 @@ job_free_contents(job_T *job) #ifdef UNIX vim_free(job->jv_termsig); #endif +#ifdef WIN3264 + vim_free(job->jv_tty_type); +#endif free_callback(job->jv_exit_cb, job->jv_exit_partial); if (job->jv_argv != NULL) { @@ -5963,6 +5966,9 @@ job_info(job_T *job, dict_T *dict) #ifdef UNIX dict_add_string(dict, "termsig", job->jv_termsig); #endif +#ifdef WIN3264 + dict_add_string(dict, "tty_type", job->jv_tty_type); +#endif l = list_alloc(); if (l != NULL) diff --git a/src/option.c b/src/option.c index 77d1024ecd..c8808be041 100644 --- a/src/option.c +++ b/src/option.c @@ -253,7 +253,6 @@ # define PV_TWK OPT_WIN(WV_TWK) # define PV_TWS OPT_WIN(WV_TWS) # define PV_TWSL OPT_BUF(BV_TWSL) -# define PV_TMOD OPT_WIN(WV_TMOD) #endif #ifdef FEAT_SIGNS # define PV_SCL OPT_WIN(WV_SCL) @@ -2701,15 +2700,6 @@ static struct vimoption options[] = {(char_u *)FALSE, (char_u *)FALSE} #endif SCTX_INIT}, - {"termmode", "tmod", P_STRING|P_ALLOCED|P_VI_DEF, -#ifdef FEAT_TERMINAL - (char_u *)VAR_WIN, PV_TMOD, - {(char_u *)"", (char_u *)NULL} -#else - (char_u *)NULL, PV_NONE, - {(char_u *)NULL, (char_u *)0L} -#endif - SCTX_INIT}, {"termwinkey", "twk", P_STRING|P_ALLOCED|P_RWIN|P_VI_DEF, #ifdef FEAT_TERMINAL (char_u *)VAR_WIN, PV_TWK, @@ -2737,6 +2727,15 @@ static struct vimoption options[] = {(char_u *)NULL, (char_u *)0L} #endif SCTX_INIT}, + {"termwintype", "twt", P_STRING|P_ALLOCED|P_VI_DEF, +#if defined(WIN3264) && defined(FEAT_TERMINAL) + (char_u *)&p_twt, PV_NONE, + {(char_u *)"", (char_u *)NULL} +#else + (char_u *)NULL, PV_NONE, + {(char_u *)NULL, (char_u *)0L} +#endif + SCTX_INIT}, {"terse", NULL, P_BOOL|P_VI_DEF, (char_u *)&p_terse, PV_NONE, {(char_u *)FALSE, (char_u *)0L} SCTX_INIT}, @@ -3218,8 +3217,8 @@ static char *(p_cot_values[]) = {"menu", "menuone", "longest", "preview", "noins #ifdef FEAT_SIGNS static char *(p_scl_values[]) = {"yes", "no", "auto", NULL}; #endif -#ifdef FEAT_TERMINAL -static char *(p_tmod_values[]) = {"winpty", "conpty", "", NULL}; +#if defined(WIN3264) && defined(FEAT_TERMINAL) +static char *(p_twt_values[]) = {"winpty", "conpty", "", NULL}; #endif static void set_options_default(int opt_flags); @@ -7505,12 +7504,14 @@ did_set_string_option( errmsg = e_invarg; } } - // 'termmode' - else if (varp == &curwin->w_p_tmod) +# if defined(WIN3264) + // 'termwintype' + else if (varp == &p_twt) { - if (check_opt_strings(*varp, p_tmod_values, FALSE) != OK) + if (check_opt_strings(*varp, p_twt_values, FALSE) != OK) errmsg = e_invarg; } +# endif #endif #ifdef FEAT_VARTABS @@ -10952,7 +10953,6 @@ get_varp(struct vimoption *p) case PV_TWK: return (char_u *)&(curwin->w_p_twk); case PV_TWS: return (char_u *)&(curwin->w_p_tws); case PV_TWSL: return (char_u *)&(curbuf->b_p_twsl); - case PV_TMOD: return (char_u *)&(curwin->w_p_tmod); #endif case PV_AI: return (char_u *)&(curbuf->b_p_ai); @@ -11153,7 +11153,6 @@ copy_winopt(winopt_T *from, winopt_T *to) #ifdef FEAT_TERMINAL to->wo_twk = vim_strsave(from->wo_twk); to->wo_tws = vim_strsave(from->wo_tws); - to->wo_tmod = vim_strsave(from->wo_tmod); #endif #ifdef FEAT_FOLDING to->wo_fdc = from->wo_fdc; @@ -11224,7 +11223,6 @@ check_winopt(winopt_T *wop UNUSED) #ifdef FEAT_TERMINAL check_string_option(&wop->wo_twk); check_string_option(&wop->wo_tws); - check_string_option(&wop->wo_tmod); #endif #ifdef FEAT_LINEBREAK check_string_option(&wop->wo_briopt); @@ -11268,7 +11266,6 @@ clear_winopt(winopt_T *wop UNUSED) #ifdef FEAT_TERMINAL clear_string_option(&wop->wo_twk); clear_string_option(&wop->wo_tws); - clear_string_option(&wop->wo_tmod); #endif } diff --git a/src/option.h b/src/option.h index 2985781e65..26e5fd04c6 100644 --- a/src/option.h +++ b/src/option.h @@ -834,6 +834,9 @@ EXTERN char_u *p_tenc; /* 'termencoding' */ #ifdef FEAT_TERMGUICOLORS EXTERN int p_tgc; /* 'termguicolors' */ #endif +#if defined(WIN3264) && defined(FEAT_TERMINAL) +EXTERN char_u *p_twt; // 'termwintype' +#endif EXTERN int p_terse; /* 'terse' */ EXTERN int p_ta; /* 'textauto' */ EXTERN int p_to; /* 'tildeop' */ @@ -1112,7 +1115,6 @@ enum #ifdef FEAT_TERMINAL , WV_TWK , WV_TWS - , WV_TMOD #endif , WV_CRBIND #ifdef FEAT_LINEBREAK diff --git a/src/structs.h b/src/structs.h index 5d0541bc83..4464c4b8d1 100644 --- a/src/structs.h +++ b/src/structs.h @@ -282,8 +282,6 @@ typedef struct # define w_p_twk w_onebuf_opt.wo_twk /* 'termwinkey' */ char_u *wo_tws; # define w_p_tws w_onebuf_opt.wo_tws /* 'termwinsize' */ - char_u *wo_tmod; -# define w_p_tmod w_onebuf_opt.wo_tmod /* 'termmode' */ #endif #ifdef FEAT_EVAL @@ -1556,6 +1554,9 @@ struct jobvar_S #ifdef UNIX char_u *jv_termsig; /* allocated */ #endif +#ifdef WIN3264 + char_u *jv_tty_type; // allocated +#endif int jv_exitval; char_u *jv_exit_cb; /* allocated */ partial_T *jv_exit_partial; @@ -1791,7 +1792,7 @@ struct channel_S { #define JO2_NORESTORE 0x2000 /* "norestore" */ #define JO2_TERM_KILL 0x4000 /* "term_kill" */ #define JO2_ANSI_COLORS 0x8000 /* "ansi_colors" */ -#define JO2_TERM_MODE 0x10000 /* "term_mode" */ +#define JO2_TTY_TYPE 0x10000 /* "tty_type" */ #define JO_MODE_ALL (JO_MODE + JO_IN_MODE + JO_OUT_MODE + JO_ERR_MODE) #define JO_CB_ALL \ @@ -1864,7 +1865,7 @@ typedef struct # if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS) long_u jo_ansi_colors[16]; # endif - int jo_term_mode; // first character of "term_mode" + int jo_tty_type; // first character of "tty_type" #endif } jobopt_T; diff --git a/src/terminal.c b/src/terminal.c index 41cd5c952b..27ff24f103 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -742,16 +742,26 @@ ex_terminal(exarg_T *eap) vim_free(buf); *p = ' '; } - else if ((int)(p - cmd) == 6 && STRNICMP(cmd, "winpty", 6) == 0) - { - opt.jo_set2 |= JO2_TERM_MODE; - opt.jo_term_mode = 'w'; - } - else if ((int)(p - cmd) == 6 && STRNICMP(cmd, "conpty", 6) == 0) +#ifdef WIN3264 + else if ((int)(p - cmd) == 4 && STRNICMP(cmd, "type", 4) == 0 + && ep != NULL) { - opt.jo_set2 |= JO2_TERM_MODE; - opt.jo_term_mode = 'c'; + int tty_type = NUL; + + p = skiptowhite(cmd); + if (STRNICMP(ep + 1, "winpty", p - (ep + 1)) == 0) + tty_type = 'w'; + else if (STRNICMP(ep + 1, "conpty", p - (ep + 1)) == 0) + tty_type = 'c'; + else + { + semsg(e_invargval, "type"); + goto theend; + } + opt.jo_set2 |= JO2_TTY_TYPE; + opt.jo_tty_type = tty_type; } +#endif else { if (*p) @@ -809,9 +819,8 @@ term_write_session(FILE *fd, win_T *wp) term->tl_cols, term->tl_rows) < 0) return FAIL; #ifdef WIN3264 - if (*wp->w_p_tmod != NUL) - if (fprintf(fd, "++%s ", wp->w_p_tmod) < 0) - return FAIL; + if (fprintf(fd, "++type=%s ", term->tl_job->jv_tty_type) < 0) + return FAIL; #endif if (term->tl_command != NULL && fputs((char *)term->tl_command, fd) < 0) return FAIL; @@ -5369,7 +5378,7 @@ f_term_start(typval_T *argvars, typval_T *rettv) + JO2_TERM_COLS + JO2_TERM_ROWS + JO2_VERTICAL + JO2_CURWIN + JO2_CWD + JO2_ENV + JO2_EOF_CHARS + JO2_NORESTORE + JO2_TERM_KILL - + JO2_ANSI_COLORS + JO2_TERM_MODE) == FAIL) + + JO2_ANSI_COLORS + JO2_TTY_TYPE) == FAIL) return; buf = term_start(&argvars[0], NULL, &opt, 0); @@ -5713,6 +5722,7 @@ conpty_term_and_job_init( job->jv_proc_info = proc_info; job->jv_job_object = jo; job->jv_status = JOB_STARTED; + job->jv_tty_type = vim_strsave("conpty"); ++job->jv_refcount; term->tl_job = job; @@ -6046,6 +6056,7 @@ winpty_term_and_job_init( (short_u *)winpty_conin_name(term->tl_winpty), NULL); job->jv_tty_out = utf16_to_enc( (short_u *)winpty_conout_name(term->tl_winpty), NULL); + job->jv_tty_type = vim_strsave("winpty"); ++job->jv_refcount; term->tl_job = job; @@ -6113,6 +6124,7 @@ term_and_job_init( { int use_winpty = FALSE; int use_conpty = FALSE; + int tty_type = *p_twt; has_winpty = dyn_winpty_init(FALSE) != FAIL ? TRUE : FALSE; has_conpty = dyn_conpty_init(FALSE) != FAIL ? TRUE : FALSE; @@ -6122,14 +6134,10 @@ term_and_job_init( // conpty is not available it can't be installed either. return dyn_winpty_init(TRUE); - if (opt->jo_term_mode == 'w') - set_string_option_direct((char_u *)"tmod", -1, (char_u *)"winpty", - OPT_FREE|OPT_LOCAL, 0); - if (opt->jo_term_mode == 'c') - set_string_option_direct((char_u *)"tmod", -1, (char_u *)"conpty", - OPT_FREE|OPT_LOCAL, 0); + if (opt->jo_tty_type != NUL) + tty_type = opt->jo_tty_type; - if (curwin->w_p_tmod == NULL || *curwin->w_p_tmod == NUL) + if (tty_type == NUL) { if (has_conpty) use_conpty = TRUE; @@ -6137,12 +6145,12 @@ term_and_job_init( use_winpty = TRUE; // else: error } - else if (STRICMP(curwin->w_p_tmod, "winpty") == 0) + else if (tty_type == 'w') // winpty { if (has_winpty) use_winpty = TRUE; } - else if (STRICMP(curwin->w_p_tmod, "conpty") == 0) + else if (tty_type == 'c') // conpty { if (has_conpty) use_conpty = TRUE; @@ -6151,18 +6159,10 @@ term_and_job_init( } if (use_conpty) - { - set_string_option_direct((char_u *)"tmod", -1, (char_u *)"conpty", - OPT_FREE|OPT_LOCAL, 0); return conpty_term_and_job_init(term, argvar, argv, opt, orig_opt); - } if (use_winpty) - { - set_string_option_direct((char_u *)"tmod", -1, (char_u *)"winpty", - OPT_FREE|OPT_LOCAL, 0); return winpty_term_and_job_init(term, argvar, argv, opt, orig_opt); - } // error return dyn_winpty_init(TRUE); diff --git a/src/testdir/gen_opt_test.vim b/src/testdir/gen_opt_test.vim index 8c75d377ee..bd3f80ce6c 100644 --- a/src/testdir/gen_opt_test.vim +++ b/src/testdir/gen_opt_test.vim @@ -131,8 +131,8 @@ let test_values = { \ 'term': [[], []], \ 'termguicolors': [[], []], \ 'termencoding': [has('gui_gtk') ? [] : ['', 'utf-8'], ['xxx']], - \ 'termmode': [['', 'winpty', 'conpty'], ['xxx']], \ 'termwinsize': [['', '24x80', '0x80', '32x0', '0x0'], ['xxx', '80', '8ax9', '24x80b']], + \ 'termwintype': [['', 'winpty', 'conpty'], ['xxx']], \ 'toolbar': [['', 'icons', 'text'], ['xxx']], \ 'toolbariconsize': [['', 'tiny', 'huge'], ['xxx']], \ 'ttymouse': [['', 'xterm'], ['xxx']], diff --git a/src/version.c b/src/version.c index f1205f12dd..1235cf0eda 100644 --- a/src/version.c +++ b/src/version.c @@ -784,6 +784,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 880, +/**/ 879, /**/ 878, |