comparison src/terminal.c @ 15746:c017195b121b v8.1.0880

patch 8.1.0880: MS-Windows: inconsistent selection of winpty/conpty commit https://github.com/vim/vim/commit/c6ddce3f2cf6daa3a545405373b661f8a9bccad9 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Feb 8 12:47:03 2019 +0100 patch 8.1.0880: MS-Windows: inconsistent selection of winpty/conpty 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)
author Bram Moolenaar <Bram@vim.org>
date Fri, 08 Feb 2019 13:00:08 +0100
parents a3e2e7948ee4
children ec39beb7e61f
comparison
equal deleted inserted replaced
15745:655ee4b0a5cc 15746:c017195b121b
740 opt.jo_set2 |= JO2_EOF_CHARS; 740 opt.jo_set2 |= JO2_EOF_CHARS;
741 opt.jo_eof_chars = vim_strsave(keys); 741 opt.jo_eof_chars = vim_strsave(keys);
742 vim_free(buf); 742 vim_free(buf);
743 *p = ' '; 743 *p = ' ';
744 } 744 }
745 else if ((int)(p - cmd) == 6 && STRNICMP(cmd, "winpty", 6) == 0) 745 #ifdef WIN3264
746 { 746 else if ((int)(p - cmd) == 4 && STRNICMP(cmd, "type", 4) == 0
747 opt.jo_set2 |= JO2_TERM_MODE; 747 && ep != NULL)
748 opt.jo_term_mode = 'w'; 748 {
749 } 749 int tty_type = NUL;
750 else if ((int)(p - cmd) == 6 && STRNICMP(cmd, "conpty", 6) == 0) 750
751 { 751 p = skiptowhite(cmd);
752 opt.jo_set2 |= JO2_TERM_MODE; 752 if (STRNICMP(ep + 1, "winpty", p - (ep + 1)) == 0)
753 opt.jo_term_mode = 'c'; 753 tty_type = 'w';
754 } 754 else if (STRNICMP(ep + 1, "conpty", p - (ep + 1)) == 0)
755 tty_type = 'c';
756 else
757 {
758 semsg(e_invargval, "type");
759 goto theend;
760 }
761 opt.jo_set2 |= JO2_TTY_TYPE;
762 opt.jo_tty_type = tty_type;
763 }
764 #endif
755 else 765 else
756 { 766 {
757 if (*p) 767 if (*p)
758 *p = NUL; 768 *p = NUL;
759 semsg(_("E181: Invalid attribute: %s"), cmd); 769 semsg(_("E181: Invalid attribute: %s"), cmd);
807 * will be OK. */ 817 * will be OK. */
808 if (fprintf(fd, "terminal ++curwin ++cols=%d ++rows=%d ", 818 if (fprintf(fd, "terminal ++curwin ++cols=%d ++rows=%d ",
809 term->tl_cols, term->tl_rows) < 0) 819 term->tl_cols, term->tl_rows) < 0)
810 return FAIL; 820 return FAIL;
811 #ifdef WIN3264 821 #ifdef WIN3264
812 if (*wp->w_p_tmod != NUL) 822 if (fprintf(fd, "++type=%s ", term->tl_job->jv_tty_type) < 0)
813 if (fprintf(fd, "++%s ", wp->w_p_tmod) < 0) 823 return FAIL;
814 return FAIL;
815 #endif 824 #endif
816 if (term->tl_command != NULL && fputs((char *)term->tl_command, fd) < 0) 825 if (term->tl_command != NULL && fputs((char *)term->tl_command, fd) < 0)
817 return FAIL; 826 return FAIL;
818 827
819 return put_eol(fd); 828 return put_eol(fd);
5367 + JO_EXIT_CB + JO_CLOSE_CALLBACK + JO_OUT_IO, 5376 + JO_EXIT_CB + JO_CLOSE_CALLBACK + JO_OUT_IO,
5368 JO2_TERM_NAME + JO2_TERM_FINISH + JO2_HIDDEN + JO2_TERM_OPENCMD 5377 JO2_TERM_NAME + JO2_TERM_FINISH + JO2_HIDDEN + JO2_TERM_OPENCMD
5369 + JO2_TERM_COLS + JO2_TERM_ROWS + JO2_VERTICAL + JO2_CURWIN 5378 + JO2_TERM_COLS + JO2_TERM_ROWS + JO2_VERTICAL + JO2_CURWIN
5370 + JO2_CWD + JO2_ENV + JO2_EOF_CHARS 5379 + JO2_CWD + JO2_ENV + JO2_EOF_CHARS
5371 + JO2_NORESTORE + JO2_TERM_KILL 5380 + JO2_NORESTORE + JO2_TERM_KILL
5372 + JO2_ANSI_COLORS + JO2_TERM_MODE) == FAIL) 5381 + JO2_ANSI_COLORS + JO2_TTY_TYPE) == FAIL)
5373 return; 5382 return;
5374 5383
5375 buf = term_start(&argvars[0], NULL, &opt, 0); 5384 buf = term_start(&argvars[0], NULL, &opt, 0);
5376 5385
5377 if (buf != NULL && buf->b_term != NULL) 5386 if (buf != NULL && buf->b_term != NULL)
5711 5720
5712 job->jv_channel = channel; 5721 job->jv_channel = channel;
5713 job->jv_proc_info = proc_info; 5722 job->jv_proc_info = proc_info;
5714 job->jv_job_object = jo; 5723 job->jv_job_object = jo;
5715 job->jv_status = JOB_STARTED; 5724 job->jv_status = JOB_STARTED;
5725 job->jv_tty_type = vim_strsave("conpty");
5716 ++job->jv_refcount; 5726 ++job->jv_refcount;
5717 term->tl_job = job; 5727 term->tl_job = job;
5718 5728
5719 /* Redirecting stdout and stderr doesn't work at the job level. Instead 5729 /* Redirecting stdout and stderr doesn't work at the job level. Instead
5720 * open the file here and handle it in. opt->jo_io was changed in 5730 * open the file here and handle it in. opt->jo_io was changed in
6044 job->jv_status = JOB_STARTED; 6054 job->jv_status = JOB_STARTED;
6045 job->jv_tty_in = utf16_to_enc( 6055 job->jv_tty_in = utf16_to_enc(
6046 (short_u *)winpty_conin_name(term->tl_winpty), NULL); 6056 (short_u *)winpty_conin_name(term->tl_winpty), NULL);
6047 job->jv_tty_out = utf16_to_enc( 6057 job->jv_tty_out = utf16_to_enc(
6048 (short_u *)winpty_conout_name(term->tl_winpty), NULL); 6058 (short_u *)winpty_conout_name(term->tl_winpty), NULL);
6059 job->jv_tty_type = vim_strsave("winpty");
6049 ++job->jv_refcount; 6060 ++job->jv_refcount;
6050 term->tl_job = job; 6061 term->tl_job = job;
6051 6062
6052 /* Redirecting stdout and stderr doesn't work at the job level. Instead 6063 /* Redirecting stdout and stderr doesn't work at the job level. Instead
6053 * open the file here and handle it in. opt->jo_io was changed in 6064 * open the file here and handle it in. opt->jo_io was changed in
6111 jobopt_T *opt, 6122 jobopt_T *opt,
6112 jobopt_T *orig_opt) 6123 jobopt_T *orig_opt)
6113 { 6124 {
6114 int use_winpty = FALSE; 6125 int use_winpty = FALSE;
6115 int use_conpty = FALSE; 6126 int use_conpty = FALSE;
6127 int tty_type = *p_twt;
6116 6128
6117 has_winpty = dyn_winpty_init(FALSE) != FAIL ? TRUE : FALSE; 6129 has_winpty = dyn_winpty_init(FALSE) != FAIL ? TRUE : FALSE;
6118 has_conpty = dyn_conpty_init(FALSE) != FAIL ? TRUE : FALSE; 6130 has_conpty = dyn_conpty_init(FALSE) != FAIL ? TRUE : FALSE;
6119 6131
6120 if (!has_winpty && !has_conpty) 6132 if (!has_winpty && !has_conpty)
6121 // If neither is available give the errors for winpty, since when 6133 // If neither is available give the errors for winpty, since when
6122 // conpty is not available it can't be installed either. 6134 // conpty is not available it can't be installed either.
6123 return dyn_winpty_init(TRUE); 6135 return dyn_winpty_init(TRUE);
6124 6136
6125 if (opt->jo_term_mode == 'w') 6137 if (opt->jo_tty_type != NUL)
6126 set_string_option_direct((char_u *)"tmod", -1, (char_u *)"winpty", 6138 tty_type = opt->jo_tty_type;
6127 OPT_FREE|OPT_LOCAL, 0); 6139
6128 if (opt->jo_term_mode == 'c') 6140 if (tty_type == NUL)
6129 set_string_option_direct((char_u *)"tmod", -1, (char_u *)"conpty",
6130 OPT_FREE|OPT_LOCAL, 0);
6131
6132 if (curwin->w_p_tmod == NULL || *curwin->w_p_tmod == NUL)
6133 { 6141 {
6134 if (has_conpty) 6142 if (has_conpty)
6135 use_conpty = TRUE; 6143 use_conpty = TRUE;
6136 else if (has_winpty) 6144 else if (has_winpty)
6137 use_winpty = TRUE; 6145 use_winpty = TRUE;
6138 // else: error 6146 // else: error
6139 } 6147 }
6140 else if (STRICMP(curwin->w_p_tmod, "winpty") == 0) 6148 else if (tty_type == 'w') // winpty
6141 { 6149 {
6142 if (has_winpty) 6150 if (has_winpty)
6143 use_winpty = TRUE; 6151 use_winpty = TRUE;
6144 } 6152 }
6145 else if (STRICMP(curwin->w_p_tmod, "conpty") == 0) 6153 else if (tty_type == 'c') // conpty
6146 { 6154 {
6147 if (has_conpty) 6155 if (has_conpty)
6148 use_conpty = TRUE; 6156 use_conpty = TRUE;
6149 else 6157 else
6150 return dyn_conpty_init(TRUE); 6158 return dyn_conpty_init(TRUE);
6151 } 6159 }
6152 6160
6153 if (use_conpty) 6161 if (use_conpty)
6154 {
6155 set_string_option_direct((char_u *)"tmod", -1, (char_u *)"conpty",
6156 OPT_FREE|OPT_LOCAL, 0);
6157 return conpty_term_and_job_init(term, argvar, argv, opt, orig_opt); 6162 return conpty_term_and_job_init(term, argvar, argv, opt, orig_opt);
6158 }
6159 6163
6160 if (use_winpty) 6164 if (use_winpty)
6161 {
6162 set_string_option_direct((char_u *)"tmod", -1, (char_u *)"winpty",
6163 OPT_FREE|OPT_LOCAL, 0);
6164 return winpty_term_and_job_init(term, argvar, argv, opt, orig_opt); 6165 return winpty_term_and_job_init(term, argvar, argv, opt, orig_opt);
6165 }
6166 6166
6167 // error 6167 // error
6168 return dyn_winpty_init(TRUE); 6168 return dyn_winpty_init(TRUE);
6169 } 6169 }
6170 6170