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.
diff --git a/src/os_unix.c b/src/os_unix.c
index bbc74c7..4caf38b 100644
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -4063,7 +4063,13 @@
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 @@
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 @@
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
}