]> granicus.if.org Git - vim/commitdiff
patch 8.1.0880: MS-Windows: inconsistent selection of winpty/conpty v8.1.0880
authorBram Moolenaar <Bram@vim.org>
Fri, 8 Feb 2019 11:47:03 +0000 (12:47 +0100)
committerBram Moolenaar <Bram@vim.org>
Fri, 8 Feb 2019 11:47:03 +0000 (12:47 +0100)
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)

12 files changed:
runtime/doc/eval.txt
runtime/doc/options.txt
runtime/doc/quickref.txt
runtime/doc/terminal.txt
runtime/optwin.vim
src/channel.c
src/option.c
src/option.h
src/structs.h
src/terminal.c
src/testdir/gen_opt_test.vim
src/version.c

index 50ca3769b8af6a930cec70cd72ce60e7b832894d..0fc249c8b27e135d8c18bd31f1641a873c82ed73 100644 (file)
@@ -5750,6 +5750,11 @@ job_info([{job}])                                        *job_info()*
                                (See |job_stop()| for the values)
                                only valid when "status" is "dead"
 
+                  Only in MS-Windows:
+                  "tty_type"   Type of virtual console in use.
+                               Values are "winpty" or "conpty".
+                               See 'termwintype'.
+
                Without any arguments, returns a List with all Job objects.
 
 job_setoptions({job}, {options})                       *job_setoptions()*
@@ -9469,10 +9474,8 @@ term_start({cmd}, {options})                             *term_start()*
                   "ansi_colors"     A list of 16 color names or hex codes
                                     defining the ANSI palette used in GUI
                                     color modes.  See |g:terminal_ansi_colors|.
-                  "term_mode"       (MS-Windows only): Specify which pty to
-                                    use:
-                                       "winpty": Use winpty
-                                       "conpty": Use ConPTY (if available)
+                  "tty_type"        (MS-Windows only): Specify which pty to
+                                    use.  See 'termwintype' for the values.
 
                {only available when compiled with the |+terminal| feature}
 
index c9e2b0b5bb98d753c54b0bd361301e02d2e521d0..413342087ef15fb1755ce039398756a1593963db 100644 (file)
@@ -8054,23 +8054,6 @@ A jump table for the options with a short description can be found at |Q_op|.
        Note that the "cterm" attributes are still used, not the "gui" ones.
        NOTE: This option is reset when 'compatible' is set.
 
-                                               *'termmode'* *'tmod'*
-'termmode' 'tmod'      string  (default "")
-                       local to window
-                       {not in Vi, MS-Windows only}
-       Whether the window uses winpty or |ConPTY| as the virtual console.
-       When set before opening the terminal, it influences what pty is used.
-       When opening the terminal it will be set to the actually used pty.
-
-       Possible values are:
-           ""          use ConPTY if possible, winpty otherwise
-           "winpty"    use winpty, fail if not supported
-           "conpty"    use |ConPTY|, fail if not supported
-
-       |ConPTY| support depends on the platform (Windows 10 October 2018
-       edition).  winpty support needs to be installed.  If neither is
-       supported then you cannot open a terminal window.
-
                                                *'termwinscroll'* *'twsl'*
 'termwinscroll' 'twsl' number  (default 10000)
                        local to buffer
@@ -8119,6 +8102,24 @@ A jump table for the options with a short description can be found at |Q_op|.
        the size of the terminal.  In that case the Vim window will be
        adjusted to that size, if possible.
 
+                                               *'termwintype'* *'twt'*
+'termwintype' 'twt'    string  (default "")
+                       global
+                       {not in Vi}
+                       {only available when compiled with the |terminal|
+                       feature on MS-Windows}
+       Specify the virtual console (pty) used when opening the terminal
+       window.
+
+       Possible values are:
+           ""          use ConPTY if possible, winpty otherwise
+           "winpty"    use winpty, fail if not supported
+           "conpty"    use |ConPTY|, fail if not supported
+
+       |ConPTY| support depends on the platform (Windows 10 October 2018
+       edition).  winpty support needs to be installed.  If neither is
+       supported then you cannot open a terminal window.
+
                                                *'terse'* *'noterse'*
 'terse'                        boolean (default off)
                        global
index 03ac35772674bf334a8b1dcd36f8a8e08c54431b..75f400f6d7ff5f72f051e7957ffdc12c8012a33a 100644 (file)
@@ -1,4 +1,4 @@
-*quickref.txt*  For Vim version 8.1.  Last change: 2018 Apr 18
+*quickref.txt*  For Vim version 8.1.  Last change: 2019 Feb 08
 
 
                  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -930,6 +930,7 @@ Short explanation of each option:           *option-list*
 'termwinkey'     'twk'     key that precedes a Vim command in a terminal
 'termwinscroll'   'twsl'    max number of scrollback lines in a terminal window
 'termwinsize'    'tws'     size of a terminal window
+'termwintype'    'twt'     MS-Windows: type of pty to use for terminal window
 'terse'                            shorten some messages
 'textauto'       'ta'      obsolete, use 'fileformats'
 'textmode'       'tx'      obsolete, use 'fileformat'
index de79ff00aab651f7151067328cdfa9a80d7e9846..4b009d32fb7b55856526be54a250be821e316994 100644 (file)
@@ -228,8 +228,10 @@ Syntax ~
                                        for Python "++eof=exit()".  Special
                                        codes can be used like with `:map`,
                                        e.g. "<C-Z>" for CTRL-Z.
-                       ++winpty        Use winpty as the virtual console.
-                       ++conpty        Use |ConPTY| as the virtual console.
+                       ++type={pty}    (MS-Windows only): Use {pty} as the
+                                       virtual console.  See 'termwintype'
+                                       for the values.
+
                        If you want to use more options use the |term_start()|
                        function.
                        If you want to split the window vertically, use: >
@@ -416,8 +418,8 @@ On more recent versions of MS-Windows 10 (beginning with the "October 2018
 Update"), winpty is no longer required. On those versions, |:terminal| will use
 Windows' built-in support for hosting terminal applications, "ConPTY".  When
 ConPTY is in use, there may be rendering artifacts regarding ambiguous-width
-characters. If you encounter any such issues, set 'termmode' to winpty (which
-you then must have instlled).
+characters. If you encounter any such issues, set 'termwintype' to "winpty"
+(which you then must have instlled).
 
 Environment variables are used to pass information to the running job:
     VIM_SERVERNAME     v:servername
index de3cdfb0a59ae1a98072f5fda6afd1380b9da124..d929836e7426699a4986ac6f6db14c49455bb0ab 100644 (file)
@@ -1,7 +1,7 @@
 " These commands create the option window.
 "
 " Maintainer:  Bram Moolenaar <Bram@vim.org>
-" Last Change: 2019 Jan 27
+" Last Change: 2019 Feb 08
 
 " If there already is an option window, jump to that one.
 let buf = bufnr('option-window')
@@ -503,6 +503,10 @@ if has("terminal")
   call <SID>OptionL("twk")
   call append("$", "termwinscroll\tmax number of lines to keep for scrollback in a terminal window")
   call append("$", "\t(local to window)")
+  if has('win32')
+    call append("$", "termwintype\ttype of pty to use for a terminal window")
+    call <SID>OptionG("twt", &twt)
+  endif
   call <SID>OptionL("twsl")
   if exists("&winptydll")
     call append("$", "winptydll\tname of the winpty dynamic library")
index 484d0139b16562f52516afe5d97d0ee91c9c4f69..34a1fc3e039e1f561b24f6d68e4828f7ccd14af6 100644 (file)
@@ -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)
@@ -5193,6 +5193,9 @@ job_free_contents(job_T *job)
     vim_free(job->jv_stoponexit);
 #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)
index 77d1024ecddb41d0dcd8b46ddd56b5d1e3f56f09..c8808be041e97e79fa933e6a50c0be7dad0740f7 100644 (file)
 # 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)
@@ -2699,15 +2698,6 @@ static struct vimoption options[] =
 #else
                            (char_u*)NULL, PV_NONE,
                            {(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,
@@ -2735,6 +2725,15 @@ static struct vimoption options[] =
 #else
                            (char_u *)NULL, PV_NONE,
                            {(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,
@@ -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
 }
 
index 2985781e65fc22e59f400e3ee26ae238f1669ebc..26e5fd04c60a9dc128e05428d41ad1f647b8a807 100644 (file)
@@ -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
index 5d0541bc83bb291959c2b1c67f932b67c97e4287..4464c4b8d19d0acf2bc99751d67bcd8381ad60c7 100644 (file)
@@ -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
@@ -1555,6 +1553,9 @@ struct jobvar_S
     char_u     *jv_stoponexit; /* allocated */
 #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 */
@@ -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;
 
index 41cd5c952b4598acefdc5d85f68283d380a5529c..27ff24f1032d7677ef9334552a18514a92106c1d 100644 (file)
@@ -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);
index 8c75d377eef722727e6a5a553b1cbbb9d0ac6849..bd3f80ce6c5710cdad0e429eb76180c24c382578 100644 (file)
@@ -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']],
index f1205f12ddf13f1583585fde2af6b97a27cd95f1..1235cf0edaaea2626de0ffaeefbe78ad79e6a54d 100644 (file)
@@ -783,6 +783,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    880,
 /**/
     879,
 /**/