Mercurial > vim
diff src/terminal.c @ 11933:d033653d3df8 v8.0.0846
patch 8.0.0846: cannot get the name of the pty of a job
commit https://github.com/vim/vim/commit/7c9aec4ac86ccc455c0859d9393253141e3f77b6
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Aug 3 13:51:25 2017 +0200
patch 8.0.0846: cannot get the name of the pty of a job
Problem: Cannot get the name of the pty of a job.
Solution: Add the "tty" entry to the job info. (Ozaki Kiichi, closes https://github.com/vim/vim/issues/1920)
Add the term_gettty() function.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Thu, 03 Aug 2017 14:00:06 +0200 |
parents | 689bcb8f241c |
children | c893d6c00497 |
line wrap: on
line diff
--- a/src/terminal.c +++ b/src/terminal.c @@ -57,12 +57,16 @@ * - add 't' to mode() * - set 'filetype' to "terminal"? * - use win_del_lines() to make scroll-up efficient. + * - Make StatusLineTerm adjust UserN highlighting like StatusLineNC does, see + * use of hightlight_stlnc[]. * - implement term_setsize() * - add test for giving error for invalid 'termsize' value. * - support minimal size when 'termsize' is "rows*cols". * - support minimal size when 'termsize' is empty? * - implement "term" for job_start(): more job options when starting a * terminal. + * - support ":term NONE" to open a terminal with a pty but not running a job + * in it. The pty can be passed to gdb to run the executable in. * - if the job in the terminal does not support the mouse, we can use the * mouse in the Terminal window for copy/paste. * - when 'encoding' is not utf-8, or the job is using another encoding, setup @@ -97,6 +101,10 @@ struct terminal_S { job_T *tl_job; buf_T *tl_buffer; + /* used when tl_job is NULL and only a pty was created */ + int tl_tty_fd; + char_u *tl_tty_name; + int tl_terminal_mode; int tl_channel_closed; @@ -1925,6 +1933,26 @@ f_term_gettitle(typval_T *argvars, typva } /* + * "term_gettty(buf)" function + */ + void +f_term_gettty(typval_T *argvars, typval_T *rettv) +{ + buf_T *buf = term_get_buf(argvars); + char_u *p; + + rettv->v_type = VAR_STRING; + if (buf == NULL) + return; + if (buf->b_term->tl_job != NULL) + p = buf->b_term->tl_job->jv_tty_name; + else + p = buf->b_term->tl_tty_name; + if (p != NULL) + rettv->vval.v_string = vim_strsave(p); +} + +/* * "term_list()" function */ void @@ -2216,6 +2244,7 @@ term_and_job_init(term_T *term, int rows if (term->tl_winpty == NULL) goto failed; + /* TODO: if the command is "NONE" only create a pty. */ spawn_config = winpty_spawn_config_new( WINPTY_SPAWN_FLAG_AUTO_SHUTDOWN | WINPTY_SPAWN_FLAG_EXIT_AFTER_SHUTDOWN, @@ -2359,6 +2388,7 @@ term_and_job_init(term_T *term, int rows create_vterm(term, rows, cols); + /* TODO: if the command is "NONE" only create a pty. */ argvars[0].v_type = VAR_STRING; argvars[0].vval.v_string = cmd; setup_job_options(&opt, rows, cols);