Bram,
this patch enables termguicolor setting automatically for terminals 
supporting the "RGB" capability. This needs a relatively recent ncurses 
and xterm release (I believe xterm > 331 is fine). Once the terminfo 
database updates have been spread wide enough (you need a new $TERM 
variable indicating true color mode, e.g. ending with -direct), this 
allows us to get rid of setting the 'termguicolor' mode automatically.

So with a recent xterm and ncurses, running
TERM=xterm-direct vim --clean

will automatically enable better colors. I tested this with my current 
unstable/testing Debian system and this works. Note, all those automatic 
terminal capabilities inside Vim appear like black magic to me. So I am 
not sure this is the best approach.

Best,
Christian

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.
diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt
index c895bf0db..279369a01 100644
--- a/runtime/doc/options.txt
+++ b/runtime/doc/options.txt
@@ -8031,7 +8031,9 @@ A jump table for the options with a short description can be found at |Q_op|.
 			{not available when compiled without the
 			|+termguicolors| feature}
 	When on, uses |highlight-guifg| and |highlight-guibg| attributes in
-	the terminal (thus using 24-bit color).
+	the terminal (thus using 24-bit color).  When the terminal supports
+	the RGB terminfo capability, will then automatically enabled (e.g.
+	xterm newer than 331 with a $TERM environment value of "xterm-direct").
 
 	Requires a ISO-8613-3 compatible terminal.  If setting this option
 	does not work (produces a colorless UI) reading |xterm-true-color|
diff --git a/src/proto/term.pro b/src/proto/term.pro
index 7eafdeffa..a595d2e1c 100644
--- a/src/proto/term.pro
+++ b/src/proto/term.pro
@@ -77,4 +77,5 @@ void swap_tcap(void);
 guicolor_T gui_get_color_cmn(char_u *name);
 guicolor_T gui_get_rgb_color_cmn(int r, int g, int b);
 void cterm_color2rgb(int nr, char_u *r, char_u *g, char_u *b, char_u *ansi_idx);
+int tigetflag(char *id);
 /* vim: set ft=c : */
diff --git a/src/term.c b/src/term.c
index 209a03f5c..28e3f4d27 100644
--- a/src/term.c
+++ b/src/term.c
@@ -1631,6 +1631,10 @@ get_term_entries(int *height, int *width)
 	T_DA = (char_u *)"y";
     if ((T_UT == NULL || T_UT == empty_option) && tgetflag("ut") > 0)
 	T_UT = (char_u *)"y";
+ #ifdef FEAT_TERMGUICOLORS
+    if ((T_RGB == NULL || T_RGB == empty_option) && tigetflag("RGB") > 0)
+	set_option_value((char_u *)"tgc", 1, NULL, 0);
+ #endif
 
     /*
      * get key codes
diff --git a/src/term.h b/src/term.h
index 8808f7db1..77e8c9ff4 100644
--- a/src/term.h
+++ b/src/term.h
@@ -101,7 +101,8 @@ enum SpecialKey
     KS_CBE,	/* enable bracketed paste mode */
     KS_CBD,	/* disable bracketed paste mode */
     KS_CPS,	/* start of bracketed paste */
-    KS_CPE	/* end of bracketed paste */
+    KS_CPE,	/* end of bracketed paste */
+    KS_RGB,     /* RGB support */
 };
 
 #define KS_LAST	    KS_CPE
@@ -196,6 +197,7 @@ extern char_u *(term_strings[]);    /* current terminal strings */
 #define T_BD	(TERM_STR(KS_CBD))	/* disable bracketed paste mode */
 #define T_PS	(TERM_STR(KS_CPS))	/* start of bracketed paste */
 #define T_PE	(TERM_STR(KS_CPE))	/* end of bracketed paste */
+#define T_RGB   (TERM_STR(KS_RGB))	/* supports RGB mode */
 
 #define TMODE_COOK  0	/* terminal mode for external cmds and Ex mode */
 #define TMODE_SLEEP 1	/* terminal mode for sleeping (cooked but no echo) */

Raspunde prin e-mail lui