mirror of
https://github.com/neovim/neovim.git
synced 2024-12-20 03:05:11 -07:00
Merge #5026 from joshtriplett/term-title-statusline
Please support setting terminal title in :terminal
This commit is contained in:
commit
5ea4d58a1b
@ -10,6 +10,7 @@ Embedded terminal emulator *terminal-emulator*
|
|||||||
2. Spawning |terminal-emulator-spawning|
|
2. Spawning |terminal-emulator-spawning|
|
||||||
3. Input |terminal-emulator-input|
|
3. Input |terminal-emulator-input|
|
||||||
4. Configuration |terminal-emulator-configuration|
|
4. Configuration |terminal-emulator-configuration|
|
||||||
|
5. Status Variables |terminal-emulator-status|
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
1. Introduction *terminal-emulator-intro*
|
1. Introduction *terminal-emulator-intro*
|
||||||
@ -112,5 +113,26 @@ There is also a corresponding |TermClose| event.
|
|||||||
The terminal cursor can be highlighted via |hl-TermCursor| and
|
The terminal cursor can be highlighted via |hl-TermCursor| and
|
||||||
|hl-TermCursorNC|.
|
|hl-TermCursorNC|.
|
||||||
|
|
||||||
|
==============================================================================
|
||||||
|
5. Status Variables *terminal-emulator-status*
|
||||||
|
|
||||||
|
Terminal buffers maintain some information about the terminal in buffer-local
|
||||||
|
variables:
|
||||||
|
|
||||||
|
- *b:term_title* The settable title of the terminal, typically displayed in
|
||||||
|
the window title or tab title of a graphical terminal emulator. Programs
|
||||||
|
running in the terminal can set this title via an escape sequence.
|
||||||
|
- *b:terminal_job_id* The nvim job ID of the job running in the terminal. See
|
||||||
|
|job-control| for more information.
|
||||||
|
- *b:terminal_job_pid* The PID of the top-level process running in the
|
||||||
|
terminal.
|
||||||
|
|
||||||
|
These variables will have a value by the time the TermOpen autocmd runs, and
|
||||||
|
will continue to have a value for the lifetime of the terminal buffer, making
|
||||||
|
them suitable for use in 'statusline'. For example, to show the terminal title
|
||||||
|
as the status line:
|
||||||
|
>
|
||||||
|
:autocmd TermOpen * setlocal statusline=%{b:term_title}
|
||||||
|
<
|
||||||
==============================================================================
|
==============================================================================
|
||||||
vim:tw=78:ts=8:noet:ft=help:norl:
|
vim:tw=78:ts=8:noet:ft=help:norl:
|
||||||
|
@ -241,6 +241,7 @@ Terminal *terminal_open(TerminalOptions opts)
|
|||||||
set_option_value((uint8_t *)"wrap", false, NULL, OPT_LOCAL);
|
set_option_value((uint8_t *)"wrap", false, NULL, OPT_LOCAL);
|
||||||
set_option_value((uint8_t *)"number", false, NULL, OPT_LOCAL);
|
set_option_value((uint8_t *)"number", false, NULL, OPT_LOCAL);
|
||||||
set_option_value((uint8_t *)"relativenumber", false, NULL, OPT_LOCAL);
|
set_option_value((uint8_t *)"relativenumber", false, NULL, OPT_LOCAL);
|
||||||
|
buf_set_term_title(curbuf, (char *)curbuf->b_ffname);
|
||||||
RESET_BINDING(curwin);
|
RESET_BINDING(curwin);
|
||||||
// Apply TermOpen autocmds so the user can configure the terminal
|
// Apply TermOpen autocmds so the user can configure the terminal
|
||||||
apply_autocmds(EVENT_TERMOPEN, NULL, NULL, false, curbuf);
|
apply_autocmds(EVENT_TERMOPEN, NULL, NULL, false, curbuf);
|
||||||
@ -618,6 +619,17 @@ static int term_movecursor(VTermPos new, VTermPos old, int visible,
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void buf_set_term_title(buf_T *buf, char *title)
|
||||||
|
FUNC_ATTR_NONNULL_ALL
|
||||||
|
{
|
||||||
|
Error err;
|
||||||
|
api_free_object(dict_set_value(buf->b_vars,
|
||||||
|
cstr_as_string("term_title"),
|
||||||
|
STRING_OBJ(cstr_as_string(title)),
|
||||||
|
false,
|
||||||
|
&err));
|
||||||
|
}
|
||||||
|
|
||||||
static int term_settermprop(VTermProp prop, VTermValue *val, void *data)
|
static int term_settermprop(VTermProp prop, VTermValue *val, void *data)
|
||||||
{
|
{
|
||||||
Terminal *term = data;
|
Terminal *term = data;
|
||||||
@ -633,12 +645,7 @@ static int term_settermprop(VTermProp prop, VTermValue *val, void *data)
|
|||||||
|
|
||||||
case VTERM_PROP_TITLE: {
|
case VTERM_PROP_TITLE: {
|
||||||
buf_T *buf = handle_get_buffer(term->buf_handle);
|
buf_T *buf = handle_get_buffer(term->buf_handle);
|
||||||
Error err;
|
buf_set_term_title(buf, val->string);
|
||||||
api_free_object(dict_set_value(buf->b_vars,
|
|
||||||
cstr_as_string("term_title"),
|
|
||||||
STRING_OBJ(cstr_as_string(val->string)),
|
|
||||||
false,
|
|
||||||
&err));
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user