aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosh Triplett <josh@joshtriplett.org>2016-07-09 12:17:23 -0700
committerJosh Triplett <josh@joshtriplett.org>2016-07-12 14:42:17 -0700
commitd529ca01034f7c4991be77e52ad9883a3c8dbd68 (patch)
tree4f41dc6c11c307f8a319bab56e95942b6f91fd8a
parentef72303a1ff862fde6d9399941c091c0a0692cce (diff)
downloadrneovim-d529ca01034f7c4991be77e52ad9883a3c8dbd68.tar.gz
rneovim-d529ca01034f7c4991be77e52ad9883a3c8dbd68.tar.bz2
rneovim-d529ca01034f7c4991be77e52ad9883a3c8dbd68.zip
terminal: Ensure b:term_title always has a value
Factor out a helper function to set b:term_title, and call it during terminal initialization as well, to set the initial title to the term:// URL. This makes it much easier to use b:term_title in a statusline, with just `setlocal statusline=%{b:term_title}`, rather than needing an expression to handle the unset case.
-rw-r--r--src/nvim/terminal.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/nvim/terminal.c b/src/nvim/terminal.c
index fd416b3dcc..6f50c03be9 100644
--- a/src/nvim/terminal.c
+++ b/src/nvim/terminal.c
@@ -241,6 +241,7 @@ Terminal *terminal_open(TerminalOptions opts)
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 *)"relativenumber", false, NULL, OPT_LOCAL);
+ buf_set_term_title(curbuf, (char *)curbuf->b_ffname);
RESET_BINDING(curwin);
// Apply TermOpen autocmds so the user can configure the terminal
apply_autocmds(EVENT_TERMOPEN, NULL, NULL, false, curbuf);
@@ -618,6 +619,17 @@ static int term_movecursor(VTermPos new, VTermPos old, int visible,
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)
{
Terminal *term = data;
@@ -633,12 +645,7 @@ static int term_settermprop(VTermProp prop, VTermValue *val, void *data)
case VTERM_PROP_TITLE: {
buf_T *buf = handle_get_buffer(term->buf_handle);
- Error err;
- api_free_object(dict_set_value(buf->b_vars,
- cstr_as_string("term_title"),
- STRING_OBJ(cstr_as_string(val->string)),
- false,
- &err));
+ buf_set_term_title(buf, val->string);
break;
}