]> granicus.if.org Git - vim/commitdiff
patch 8.0.1665: when running a terminal from the GUI 'term' is not useful v8.0.1665
authorBram Moolenaar <Bram@vim.org>
Thu, 5 Apr 2018 20:15:22 +0000 (22:15 +0200)
committerBram Moolenaar <Bram@vim.org>
Thu, 5 Apr 2018 20:15:22 +0000 (22:15 +0200)
Problem:    When running a terminal from the GUI 'term' is not useful.
Solution:   Use $TERM in the GUI if it starts with "xterm". (closes #2776)

runtime/doc/terminal.txt
src/os_unix.c
src/version.c

index f575c82d1b2be98d4f603781941e253a6caa9b65..8dc19cbf609eed57f9315685ec3150dff2a547a1 100644 (file)
@@ -352,7 +352,9 @@ On Unix a pty is used to make it possible to run all kinds of commands.  You
 can even run Vim in the terminal!  That's used for debugging, see below.
 
 Environment variables are used to pass information to the running job:
-    TERM               name of the terminal, from the 'term' option
+    TERM               the name of the terminal, from the 'term' option or
+                       $TERM in the GUI; falls back to "xterm" if it does not
+                       start with "xterm"
     ROWS               number of rows in the terminal initially
     LINES              same as ROWS
     COLUMNS            number of columns in the terminal initially
index b811ac3f4b812adb33a2bbe5fa56b6444b50ffa0..42917c25b4310bb7890b62c3ddc2ee12412fc23a 100644 (file)
@@ -5579,11 +5579,23 @@ mch_job_start(char **argv, job_T *job, jobopt_T *options)
 
 # ifdef FEAT_TERMINAL
        if (options->jo_term_rows > 0)
+       {
+           char *term = (char *)T_NAME;
+
+#ifdef FEAT_GUI
+           if (term_is_gui(T_NAME))
+               /* In the GUI 'term' is not what we want, use $TERM. */
+               term = getenv("TERM");
+#endif
+           /* Use 'term' or $TERM if it starts with "xterm", otherwise fall
+            * back to "xterm". */
+           if (term == NULL || *term == NUL || STRNCMP(term, "xterm", 5) != 0)
+               term = "xterm";
            set_child_environment(
                    (long)options->jo_term_rows,
                    (long)options->jo_term_cols,
-                   STRNCMP(T_NAME, "xterm", 5) == 0
-                                                  ? (char *)T_NAME : "xterm");
+                   term);
+       }
        else
 # endif
            set_default_child_environment();
index a9b4dca755807051e7179a607e1291ea4ce6327c..b29d64c82536f0521fc52780e23a9abd3d9c56aa 100644 (file)
@@ -762,6 +762,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1665,
 /**/
     1664,
 /**/