Mercurial > vim
comparison 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 |
comparison
equal
deleted
inserted
replaced
11932:6dd3262cbf09 | 11933:d033653d3df8 |
---|---|
55 * - do not store terminal window in viminfo. Or prefix term:// ? | 55 * - do not store terminal window in viminfo. Or prefix term:// ? |
56 * - add a character in :ls output | 56 * - add a character in :ls output |
57 * - add 't' to mode() | 57 * - add 't' to mode() |
58 * - set 'filetype' to "terminal"? | 58 * - set 'filetype' to "terminal"? |
59 * - use win_del_lines() to make scroll-up efficient. | 59 * - use win_del_lines() to make scroll-up efficient. |
60 * - Make StatusLineTerm adjust UserN highlighting like StatusLineNC does, see | |
61 * use of hightlight_stlnc[]. | |
60 * - implement term_setsize() | 62 * - implement term_setsize() |
61 * - add test for giving error for invalid 'termsize' value. | 63 * - add test for giving error for invalid 'termsize' value. |
62 * - support minimal size when 'termsize' is "rows*cols". | 64 * - support minimal size when 'termsize' is "rows*cols". |
63 * - support minimal size when 'termsize' is empty? | 65 * - support minimal size when 'termsize' is empty? |
64 * - implement "term" for job_start(): more job options when starting a | 66 * - implement "term" for job_start(): more job options when starting a |
65 * terminal. | 67 * terminal. |
68 * - support ":term NONE" to open a terminal with a pty but not running a job | |
69 * in it. The pty can be passed to gdb to run the executable in. | |
66 * - if the job in the terminal does not support the mouse, we can use the | 70 * - if the job in the terminal does not support the mouse, we can use the |
67 * mouse in the Terminal window for copy/paste. | 71 * mouse in the Terminal window for copy/paste. |
68 * - when 'encoding' is not utf-8, or the job is using another encoding, setup | 72 * - when 'encoding' is not utf-8, or the job is using another encoding, setup |
69 * conversions. | 73 * conversions. |
70 * - update ":help function-list" for terminal functions. | 74 * - update ":help function-list" for terminal functions. |
94 term_T *tl_next; | 98 term_T *tl_next; |
95 | 99 |
96 VTerm *tl_vterm; | 100 VTerm *tl_vterm; |
97 job_T *tl_job; | 101 job_T *tl_job; |
98 buf_T *tl_buffer; | 102 buf_T *tl_buffer; |
103 | |
104 /* used when tl_job is NULL and only a pty was created */ | |
105 int tl_tty_fd; | |
106 char_u *tl_tty_name; | |
99 | 107 |
100 int tl_terminal_mode; | 108 int tl_terminal_mode; |
101 int tl_channel_closed; | 109 int tl_channel_closed; |
102 | 110 |
103 #ifdef WIN3264 | 111 #ifdef WIN3264 |
1923 if (buf->b_term->tl_title != NULL) | 1931 if (buf->b_term->tl_title != NULL) |
1924 rettv->vval.v_string = vim_strsave(buf->b_term->tl_title); | 1932 rettv->vval.v_string = vim_strsave(buf->b_term->tl_title); |
1925 } | 1933 } |
1926 | 1934 |
1927 /* | 1935 /* |
1936 * "term_gettty(buf)" function | |
1937 */ | |
1938 void | |
1939 f_term_gettty(typval_T *argvars, typval_T *rettv) | |
1940 { | |
1941 buf_T *buf = term_get_buf(argvars); | |
1942 char_u *p; | |
1943 | |
1944 rettv->v_type = VAR_STRING; | |
1945 if (buf == NULL) | |
1946 return; | |
1947 if (buf->b_term->tl_job != NULL) | |
1948 p = buf->b_term->tl_job->jv_tty_name; | |
1949 else | |
1950 p = buf->b_term->tl_tty_name; | |
1951 if (p != NULL) | |
1952 rettv->vval.v_string = vim_strsave(p); | |
1953 } | |
1954 | |
1955 /* | |
1928 * "term_list()" function | 1956 * "term_list()" function |
1929 */ | 1957 */ |
1930 void | 1958 void |
1931 f_term_list(typval_T *argvars UNUSED, typval_T *rettv) | 1959 f_term_list(typval_T *argvars UNUSED, typval_T *rettv) |
1932 { | 1960 { |
2214 winpty_config_set_initial_size(term->tl_winpty_config, cols, rows); | 2242 winpty_config_set_initial_size(term->tl_winpty_config, cols, rows); |
2215 term->tl_winpty = winpty_open(term->tl_winpty_config, &winpty_err); | 2243 term->tl_winpty = winpty_open(term->tl_winpty_config, &winpty_err); |
2216 if (term->tl_winpty == NULL) | 2244 if (term->tl_winpty == NULL) |
2217 goto failed; | 2245 goto failed; |
2218 | 2246 |
2247 /* TODO: if the command is "NONE" only create a pty. */ | |
2219 spawn_config = winpty_spawn_config_new( | 2248 spawn_config = winpty_spawn_config_new( |
2220 WINPTY_SPAWN_FLAG_AUTO_SHUTDOWN | | 2249 WINPTY_SPAWN_FLAG_AUTO_SHUTDOWN | |
2221 WINPTY_SPAWN_FLAG_EXIT_AFTER_SHUTDOWN, | 2250 WINPTY_SPAWN_FLAG_EXIT_AFTER_SHUTDOWN, |
2222 NULL, | 2251 NULL, |
2223 p, | 2252 p, |
2357 typval_T argvars[2]; | 2386 typval_T argvars[2]; |
2358 jobopt_T opt; | 2387 jobopt_T opt; |
2359 | 2388 |
2360 create_vterm(term, rows, cols); | 2389 create_vterm(term, rows, cols); |
2361 | 2390 |
2391 /* TODO: if the command is "NONE" only create a pty. */ | |
2362 argvars[0].v_type = VAR_STRING; | 2392 argvars[0].v_type = VAR_STRING; |
2363 argvars[0].vval.v_string = cmd; | 2393 argvars[0].vval.v_string = cmd; |
2364 setup_job_options(&opt, rows, cols); | 2394 setup_job_options(&opt, rows, cols); |
2365 term->tl_job = job_start(argvars, &opt); | 2395 term->tl_job = job_start(argvars, &opt); |
2366 if (term->tl_job != NULL) | 2396 if (term->tl_job != NULL) |