From b7a8dfeb49784145fe133496ce38703d236e4fbe Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sat, 22 Jul 2017 20:33:05 +0200 Subject: patch 8.0.0748: running Vim in terminal window doesn't use the right colors Problem: When running Vim in a terminal window it does not detect the right number of colors available. Solution: Detect the version string that libvterm returns. Pass the number of colors in $COLORS. --- src/os_unix.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/os_unix.c') diff --git a/src/os_unix.c b/src/os_unix.c index bbc74c7f7..4caf38bb4 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -4063,7 +4063,13 @@ set_child_environment(long rows, long columns, char *term) static char envbuf_Rows[20]; static char envbuf_Lines[20]; static char envbuf_Columns[20]; + static char envbuf_Colors[20]; # endif + long colors = +# ifdef FEAT_GUI + gui.in_use ? 256*256*256 : +# endif + t_colors; /* Simulate to have a dumb terminal (for now) */ # ifdef HAVE_SETENV @@ -4074,6 +4080,8 @@ set_child_environment(long rows, long columns, char *term) setenv("LINES", (char *)envbuf, 1); sprintf((char *)envbuf, "%ld", columns); setenv("COLUMNS", (char *)envbuf, 1); + sprintf((char *)envbuf, "%ld", colors); + setenv("COLORS", (char *)envbuf, 1); # else /* * Putenv does not copy the string, it has to remain valid. @@ -4088,6 +4096,8 @@ set_child_environment(long rows, long columns, char *term) vim_snprintf(envbuf_Columns, sizeof(envbuf_Columns), "COLUMNS=%ld", columns); putenv(envbuf_Columns); + vim_snprintf(envbuf_Colors, sizeof(envbuf_Colors), "COLORS=%ld", colors); + putenv(envbuf_Colors); # endif } -- cgit v1.2.1