mirror of
https://github.com/vim/vim.git
synced 2025-07-26 11:04:33 -04:00
patch 8.0.0864: cannot specify the name of a terminal
Problem: Cannot specify the name of a terminal. Solution: Add the "term_name" option. (Yasuhiro Matsumoto, closes #1936)
This commit is contained in:
parent
69198197fd
commit
78712a7733
@ -1,4 +1,4 @@
|
|||||||
*eval.txt* For Vim version 8.0. Last change: 2017 Aug 03
|
*eval.txt* For Vim version 8.0. Last change: 2017 Aug 05
|
||||||
|
|
||||||
|
|
||||||
VIM REFERENCE MANUAL by Bram Moolenaar
|
VIM REFERENCE MANUAL by Bram Moolenaar
|
||||||
@ -8008,7 +8008,23 @@ term_start({cmd}, {options}) *term_start()*
|
|||||||
Returns the buffer number of the terminal window.
|
Returns the buffer number of the terminal window.
|
||||||
When opening the window fails zero is returned.
|
When opening the window fails zero is returned.
|
||||||
|
|
||||||
{options} are not implemented yet.
|
{options} are similar to what is used for |job_start()|, see
|
||||||
|
|job-options|. However, not all options can be used. These
|
||||||
|
are supported:
|
||||||
|
all timeout options
|
||||||
|
"stoponexit"
|
||||||
|
"out_cb", "err_cb"
|
||||||
|
"exit_cb", "close_cb"
|
||||||
|
"in_io", "in_top", "in_bot", "in_name", "in_buf"
|
||||||
|
"out_io", "out_name", "out_buf", "out_modifiable", "out_msg"
|
||||||
|
"err_io", "err_name", "err_buf", "err_modifiable", "err_msg"
|
||||||
|
However, at least one of stdin, stdout or stderr must be
|
||||||
|
connected to the terminal. When I/O is connected to the
|
||||||
|
terminal then the callback function for that part is not used.
|
||||||
|
|
||||||
|
There is one extra option:
|
||||||
|
"term_name" name to use for the buffer name, instead of
|
||||||
|
the command name.
|
||||||
|
|
||||||
term_wait({buf}) *term_wait()*
|
term_wait({buf}) *term_wait()*
|
||||||
Wait for pending updates of {buf} to be handled.
|
Wait for pending updates of {buf} to be handled.
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
*terminal.txt* For Vim version 8.0. Last change: 2017 Aug 01
|
*terminal.txt* For Vim version 8.0. Last change: 2017 Aug 05
|
||||||
|
|
||||||
|
|
||||||
VIM REFERENCE MANUAL by Bram Moolenaar
|
VIM REFERENCE MANUAL by Bram Moolenaar
|
||||||
@ -92,10 +92,14 @@ Syntax ~
|
|||||||
When the buffer associated with the terminal is wiped out the job is killed,
|
When the buffer associated with the terminal is wiped out the job is killed,
|
||||||
similar to calling `job_stop(job, "kill")`
|
similar to calling `job_stop(job, "kill")`
|
||||||
|
|
||||||
|
By default the 'bufhidden' option of the buffer will be set to "hide".
|
||||||
So long as the job is running: If the window is closed the buffer becomes
|
So long as the job is running: If the window is closed the buffer becomes
|
||||||
hidden. The command will not be stopped. The `:buffer` command can be used
|
hidden. The command will not be stopped. The `:buffer` command can be used
|
||||||
to turn the current window into a terminal window. If there are unsaved
|
to turn the current window into a terminal window. If there are unsaved
|
||||||
changes this fails, use ! to force, as usual.
|
changes this fails, use ! to force, as usual.
|
||||||
|
*E947*
|
||||||
|
So long as the job is running, the buffer is considered modified and Vim
|
||||||
|
cannot be quit easily, see |abandon|.
|
||||||
|
|
||||||
When the job has finished and no changes were made to the buffer: closing the
|
When the job has finished and no changes were made to the buffer: closing the
|
||||||
window will wipe out the buffer.
|
window will wipe out the buffer.
|
||||||
@ -147,23 +151,6 @@ displayed.
|
|||||||
In Terminal mode the statusline and window title show "(Terminal)". If the
|
In Terminal mode the statusline and window title show "(Terminal)". If the
|
||||||
job ends while in Terminal mode this changes to "(Terminal-finished)".
|
job ends while in Terminal mode this changes to "(Terminal-finished)".
|
||||||
|
|
||||||
Environment variables are used to pass information to the running job:
|
|
||||||
TERM name of the terminal, 'term'
|
|
||||||
ROWS number of rows in the terminal initially
|
|
||||||
LINES same as ROWS
|
|
||||||
COLUMNS number of columns in the terminal initially
|
|
||||||
COLORS number of colors, 't_Co' (256*256*256 in the GUI)
|
|
||||||
VIM_SERVERNAME v:servername
|
|
||||||
|
|
||||||
The |client-server| feature can be used to communicate with the Vim instance
|
|
||||||
where the job was started. This only works when v:servername is not empty.
|
|
||||||
If needed you can set it with: >
|
|
||||||
call remote_startserver('vim-server')
|
|
||||||
|
|
||||||
In the job you can then do something like: >
|
|
||||||
vim --servername $VIM_SERVERNAME --remote +123 some_file.c
|
|
||||||
This will open the file "some_file.c" and put the cursor on line 123.
|
|
||||||
|
|
||||||
|
|
||||||
Unix ~
|
Unix ~
|
||||||
|
|
||||||
|
@ -4391,6 +4391,18 @@ get_job_options(typval_T *tv, jobopt_T *opt, int supported)
|
|||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (STRCMP(hi->hi_key, "term_name") == 0)
|
||||||
|
{
|
||||||
|
if (!(supported & JO2_TERM_NAME))
|
||||||
|
break;
|
||||||
|
opt->jo_set2 |= JO2_TERM_NAME;
|
||||||
|
opt->jo_term_name = get_tv_string_chk(item);
|
||||||
|
if (opt->jo_term_name == NULL)
|
||||||
|
{
|
||||||
|
EMSG2(_(e_invarg2), "term_name");
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (STRCMP(hi->hi_key, "waittime") == 0)
|
else if (STRCMP(hi->hi_key, "waittime") == 0)
|
||||||
{
|
{
|
||||||
if (!(supported & JO_WAITTIME))
|
if (!(supported & JO_WAITTIME))
|
||||||
|
@ -1656,7 +1656,7 @@ struct channel_S {
|
|||||||
#define JO_CALLBACK 0x0010 /* channel callback */
|
#define JO_CALLBACK 0x0010 /* channel callback */
|
||||||
#define JO_OUT_CALLBACK 0x0020 /* stdout callback */
|
#define JO_OUT_CALLBACK 0x0020 /* stdout callback */
|
||||||
#define JO_ERR_CALLBACK 0x0040 /* stderr callback */
|
#define JO_ERR_CALLBACK 0x0040 /* stderr callback */
|
||||||
#define JO_CLOSE_CALLBACK 0x0080 /* close callback */
|
#define JO_CLOSE_CALLBACK 0x0080 /* "close_cb" */
|
||||||
#define JO_WAITTIME 0x0100 /* only for ch_open() */
|
#define JO_WAITTIME 0x0100 /* only for ch_open() */
|
||||||
#define JO_TIMEOUT 0x0200 /* all timeouts */
|
#define JO_TIMEOUT 0x0200 /* all timeouts */
|
||||||
#define JO_OUT_TIMEOUT 0x0400 /* stdout timeouts */
|
#define JO_OUT_TIMEOUT 0x0400 /* stdout timeouts */
|
||||||
@ -1684,7 +1684,8 @@ struct channel_S {
|
|||||||
|
|
||||||
#define JO2_OUT_MSG 0x0001 /* "out_msg" */
|
#define JO2_OUT_MSG 0x0001 /* "out_msg" */
|
||||||
#define JO2_ERR_MSG 0x0002 /* "err_msg" (JO_OUT_ << 1) */
|
#define JO2_ERR_MSG 0x0002 /* "err_msg" (JO_OUT_ << 1) */
|
||||||
#define JO2_ALL 0x0003
|
#define JO2_TERM_NAME 0x0004 /* "term_name" */
|
||||||
|
#define JO2_ALL 0x0007
|
||||||
|
|
||||||
#define JO_MODE_ALL (JO_MODE + JO_IN_MODE + JO_OUT_MODE + JO_ERR_MODE)
|
#define JO_MODE_ALL (JO_MODE + JO_IN_MODE + JO_OUT_MODE + JO_ERR_MODE)
|
||||||
#define JO_CB_ALL \
|
#define JO_CB_ALL \
|
||||||
@ -1741,6 +1742,7 @@ typedef struct
|
|||||||
/* when non-zero run the job in a terminal window of this size */
|
/* when non-zero run the job in a terminal window of this size */
|
||||||
int jo_term_rows;
|
int jo_term_rows;
|
||||||
int jo_term_cols;
|
int jo_term_cols;
|
||||||
|
char_u *jo_term_name;
|
||||||
#endif
|
#endif
|
||||||
} jobopt_T;
|
} jobopt_T;
|
||||||
|
|
||||||
|
@ -36,6 +36,7 @@
|
|||||||
* that buffer, attributes come from the scrollback buffer tl_scrollback.
|
* that buffer, attributes come from the scrollback buffer tl_scrollback.
|
||||||
*
|
*
|
||||||
* TODO:
|
* TODO:
|
||||||
|
* - job_start('ls') sometimes does not work.
|
||||||
* - MS-Windows: no redraw for 'updatetime' #1915
|
* - MS-Windows: no redraw for 'updatetime' #1915
|
||||||
* - in bash mouse clicks are inserting characters.
|
* - in bash mouse clicks are inserting characters.
|
||||||
* - mouse scroll: when over other window, scroll that window.
|
* - mouse scroll: when over other window, scroll that window.
|
||||||
@ -67,8 +68,14 @@
|
|||||||
* - support minimal size when 'termsize' is "rows*cols".
|
* - support minimal size when 'termsize' is "rows*cols".
|
||||||
* - support minimal size when 'termsize' is empty?
|
* - support minimal size when 'termsize' is empty?
|
||||||
* - implement "term" for job_start(): more job options when starting a
|
* - implement "term" for job_start(): more job options when starting a
|
||||||
* terminal. Might allow reading stdin from a file or buffer, sending stderr
|
* terminal. Allow:
|
||||||
* to a file or /dev/null, but something must be connected to the terminal.
|
* "in_io", "in_top", "in_bot", "in_name", "in_buf"
|
||||||
|
"out_io", "out_name", "out_buf", "out_modifiable", "out_msg"
|
||||||
|
"err_io", "err_name", "err_buf", "err_modifiable", "err_msg"
|
||||||
|
* Check that something is connected to the terminal.
|
||||||
|
* Test: "cat" reading from a file or buffer
|
||||||
|
* "ls" writing stdout to a file or buffer
|
||||||
|
* shell writing stderr to a file or buffer
|
||||||
* - support ":term NONE" to open a terminal with a pty but not running a job
|
* - 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.
|
* 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
|
* - if the job in the terminal does not support the mouse, we can use the
|
||||||
@ -265,6 +272,9 @@ term_start(char_u *cmd, jobopt_T *opt)
|
|||||||
if (cmd == NULL || *cmd == NUL)
|
if (cmd == NULL || *cmd == NUL)
|
||||||
cmd = p_sh;
|
cmd = p_sh;
|
||||||
|
|
||||||
|
if (opt->jo_term_name != NULL)
|
||||||
|
curbuf->b_ffname = vim_strsave(opt->jo_term_name);
|
||||||
|
else
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
size_t len = STRLEN(cmd) + 10;
|
size_t len = STRLEN(cmd) + 10;
|
||||||
@ -2140,7 +2150,8 @@ f_term_start(typval_T *argvars, typval_T *rettv)
|
|||||||
if (argvars[1].v_type != VAR_UNKNOWN
|
if (argvars[1].v_type != VAR_UNKNOWN
|
||||||
&& get_job_options(&argvars[1], &opt,
|
&& get_job_options(&argvars[1], &opt,
|
||||||
JO_TIMEOUT_ALL + JO_STOPONEXIT
|
JO_TIMEOUT_ALL + JO_STOPONEXIT
|
||||||
+ JO_EXIT_CB + JO_CLOSE_CALLBACK) == FAIL)
|
+ JO_EXIT_CB + JO_CLOSE_CALLBACK
|
||||||
|
+ JO2_TERM_NAME) == FAIL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
term_start(cmd, &opt);
|
term_start(cmd, &opt);
|
||||||
|
@ -769,6 +769,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
864,
|
||||||
/**/
|
/**/
|
||||||
863,
|
863,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user