diff src/buffer.c @ 11772:f33b9375ba03 v8.0.0768

patch 8.0.0768: terminal window status shows "[Scratch]" commit https://github.com/vim/vim/commit/2155441460a6dc0a72125f7860507693112a1460 Author: Bram Moolenaar <Bram@vim.org> Date: Mon Jul 24 21:44:43 2017 +0200 patch 8.0.0768: terminal window status shows "[Scratch]" 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)
author Christian Brabandt <cb@256bit.org>
date Mon, 24 Jul 2017 21:45:04 +0200
parents 74abb6c84984
children 77bf0346687e
line wrap: on
line diff
--- 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;
-	    }
-
-	    if (curbuf->b_fname != NULL)
+#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
+#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;