summaryrefslogtreecommitdiff
path: root/src/buffer.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2017-07-24 21:44:43 +0200
committerBram Moolenaar <Bram@vim.org>2017-07-24 21:44:43 +0200
commit2155441460a6dc0a72125f7860507693112a1460 (patch)
treebfc7f9ad6f58cf6d2cf980e93a90695186ca2b97 /src/buffer.c
parentd60547bf80881f6c99bcbd7c8c4c6cfb7e405a90 (diff)
downloadvim-git-2155441460a6dc0a72125f7860507693112a1460.tar.gz
patch 8.0.0768: terminal window status shows "[Scratch]"v8.0.0768
Problem: Terminal window status shows "[Scratch]". Solution: Show "[Terminal]" when no title was set. (Yasuhiro Matsumoto) Store the terminal title that vterm sends and use it. Update the special buffer name. (closes #1869)
Diffstat (limited to 'src/buffer.c')
-rw-r--r--src/buffer.c64
1 files changed, 36 insertions, 28 deletions
diff --git a/src/buffer.c b/src/buffer.c
index ae23db080..fb1331736 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -3626,6 +3626,13 @@ maketitle(void)
#define SPACE_FOR_ARGNR (IOSIZE - 10) /* at least room for " - VIM" */
if (curbuf->b_fname == NULL)
vim_strncpy(buf, (char_u *)_("[No Name]"), SPACE_FOR_FNAME);
+#ifdef FEAT_TERMINAL
+ else if (curbuf->b_term != NULL)
+ {
+ vim_strncpy(buf, term_get_status_text(curbuf->b_term),
+ SPACE_FOR_FNAME);
+ }
+#endif
else
{
p = transstr(gettail(curbuf->b_fname));
@@ -3633,20 +3640,27 @@ maketitle(void)
vim_free(p);
}
- switch (bufIsChanged(curbuf)
- + (curbuf->b_p_ro * 2)
- + (!curbuf->b_p_ma * 4))
- {
- case 1: STRCAT(buf, " +"); break;
- case 2: STRCAT(buf, " ="); break;
- case 3: STRCAT(buf, " =+"); break;
- case 4:
- case 6: STRCAT(buf, " -"); break;
- case 5:
- case 7: STRCAT(buf, " -+"); break;
- }
+#ifdef FEAT_TERMINAL
+ if (curbuf->b_term == NULL)
+#endif
+ switch (bufIsChanged(curbuf)
+ + (curbuf->b_p_ro * 2)
+ + (!curbuf->b_p_ma * 4))
+ {
+ case 1: STRCAT(buf, " +"); break;
+ case 2: STRCAT(buf, " ="); break;
+ case 3: STRCAT(buf, " =+"); break;
+ case 4:
+ case 6: STRCAT(buf, " -"); break;
+ case 5:
+ case 7: STRCAT(buf, " -+"); break;
+ }
- if (curbuf->b_fname != NULL)
+ if (curbuf->b_fname != NULL
+#ifdef FEAT_TERMINAL
+ && curbuf->b_term == NULL
+#endif
+ )
{
/* Get path of file, replace home dir with ~ */
off = (int)STRLEN(buf);
@@ -3663,18 +3677,8 @@ maketitle(void)
p = gettail_sep(buf + off);
if (p == buf + off)
{
- char *txt;
-
-#ifdef FEAT_TERMINAL
- if (curbuf->b_term != NULL)
- txt = term_job_running(curbuf)
- ? _("running") : _("finished");
- else
-#endif
- txt = _("help");
-
- /* must be a help or terminal buffer */
- vim_strncpy(buf + off, (char_u *)txt,
+ /* must be a help buffer */
+ vim_strncpy(buf + off, (char_u *)_("help"),
(size_t)(SPACE_FOR_DIR - off - 1));
}
else
@@ -5670,16 +5674,20 @@ buf_spname(buf_T *buf)
return (char_u *)_(msg_qflist);
}
#endif
-#ifdef FEAT_QUICKFIX
+
/* There is no _file_ when 'buftype' is "nofile", b_sfname
- * contains the name as specified by the user */
+ * contains the name as specified by the user. */
if (bt_nofile(buf))
{
+#ifdef FEAT_TERMINAL
+ if (buf->b_term != NULL)
+ return term_get_status_text(buf->b_term);
+#endif
if (buf->b_sfname != NULL)
return buf->b_sfname;
return (char_u *)_("[Scratch]");
}
-#endif
+
if (buf->b_fname == NULL)
return (char_u *)_("[No Name]");
return NULL;