diff options
author | Bram Moolenaar <Bram@vim.org> | 2017-08-03 13:51:25 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2017-08-03 13:51:25 +0200 |
commit | 7c9aec4ac86ccc455c0859d9393253141e3f77b6 (patch) | |
tree | e03624a977c4f3d9b040a866356dbc8245036603 /src/terminal.c | |
parent | d8dc1799377027be622d8571545658b20042e92e (diff) | |
download | vim-git-7c9aec4ac86ccc455c0859d9393253141e3f77b6.tar.gz |
patch 8.0.0846: cannot get the name of the pty of a jobv8.0.0846
Problem: Cannot get the name of the pty of a job.
Solution: Add the "tty" entry to the job info. (Ozaki Kiichi, closes #1920)
Add the term_gettty() function.
Diffstat (limited to 'src/terminal.c')
-rw-r--r-- | src/terminal.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/terminal.c b/src/terminal.c index edb4b7558..c24ac9e72 100644 --- 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, typval_T *rettv) } /* + * "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, int cols, char_u *cmd) 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, int cols, char_u *cmd) 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); |