Skip to content

Commit 8a633e3

Browse files
committed
patch 7.4.1770
Problem: Cannot use true color in the terminal. Solution: Add the 'guicolors' option. (Nikolai Pavlov)
1 parent 6d4431e commit 8a633e3

19 files changed

Lines changed: 644 additions & 120 deletions

runtime/doc/options.txt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*options.txt* For Vim version 7.4. Last change: 2016 Apr 20
1+
*options.txt* For Vim version 7.4. Last change: 2016 Apr 21
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -3477,6 +3477,18 @@ A jump table for the options with a short description can be found at |Q_op|.
34773477
This option cannot be set from a |modeline| or in the |sandbox|, for
34783478
security reasons.
34793479

3480+
*'guicolors'* *'gcol'*
3481+
'guicolors' 'gcol' boolean (default off)
3482+
global
3483+
{not in Vi}
3484+
{not available when compiled without the
3485+
|+termtruecolor| feature}
3486+
When on, uses |highlight-guifg| and |highlight-guibg| attributes in
3487+
the terminal (thus using 24-bit color). Requires a ISO-8613-3
3488+
compatible terminal.
3489+
If setting this option does not work (produces a colorless UI)
3490+
reading |xterm-true-color| might help.
3491+
34803492
*'guicursor'* *'gcr'* *E545* *E546* *E548* *E549*
34813493
'guicursor' 'gcr' string (default "n-v-c:block-Cursor/lCursor,
34823494
ve:ver35-Cursor,

runtime/doc/term.txt

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*term.txt* For Vim version 7.4. Last change: 2015 Nov 24
1+
*term.txt* For Vim version 7.4. Last change: 2016 Apr 21
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -303,6 +303,10 @@ Added by Vim (there are no standard codes for these):
303303
see |'ambiwidth'|
304304
t_RB request terminal background color *t_RB* *'t_RB'*
305305
see |'ambiwidth'|
306+
t_8f set foreground color (R, G, B) *t_8f* *'t_8f'*
307+
|xterm-true-color|
308+
t_8b set background color (R, G, B) *t_8b* *'t_8b'*
309+
|xterm-true-color|
306310

307311
KEY CODES
308312
Note: Use the <> form if possible
@@ -419,6 +423,22 @@ VT220, etc.). The result is that codes like <xF1> are no longer needed.
419423
Note: This is only done on startup. If the xterm options are changed after
420424
Vim has started, the escape sequences may not be recognized anymore.
421425

426+
*xterm-true-color*
427+
Vim supports using true colors in the terminal (taken from |highlight-guifg|
428+
and |highlight-guibg|), given that terminal supports this. To make this
429+
work, 'guicolors' option needs to be set.
430+
431+
Sometimes setting 'guicolors' is not enough and one has to set the |t_8f| and
432+
|t_8b| options explicitly. Default values of these options are
433+
`^[[38;2;%lu;%lu;%lum` and `^[[48;2;%lu;%lu;%lum` (replace `^[` with real
434+
escape) respectively, but it is only set when `$TERM` is `xterm`. Some
435+
terminals accept the same sequences, but with all semicolons replaced by
436+
colons (this is actually more compatible, but less widely supported). These
437+
options contain printf strings, with |printf()| (actually, its C equivalent
438+
hence `l` modifier) invoked with the t_ option value and three unsigned long
439+
integers that may have any value between 0 and 255 (inclusive) representing
440+
red, green and blue colors respectively.
441+
422442
*xterm-resize*
423443
Window resizing with xterm only works if the allowWindowOps resource is
424444
enabled. On some systems and versions of xterm it's disabled by default

runtime/doc/various.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,7 @@ m *+tcl* Tcl interface |tcl|
424424
m *+tcl/dyn* Tcl interface |tcl-dynamic| |/dyn|
425425
*+terminfo* uses |terminfo| instead of termcap
426426
N *+termresponse* support for |t_RV| and |v:termresponse|
427+
m *+termtruecolor* 24-bit color in xterm-compatible terminals support
427428
N *+textobjects* |text-objects| selection
428429
*+tgetent* non-Unix only: able to use external termcap
429430
N *+timers* the |timer_start()| function

src/auto/configure

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -810,6 +810,7 @@ with_tclsh
810810
enable_rubyinterp
811811
with_ruby_command
812812
enable_cscope
813+
enable_termtruecolor
813814
enable_workshop
814815
enable_netbeans
815816
enable_channel
@@ -1476,6 +1477,7 @@ Optional Features:
14761477
--enable-tclinterp=OPTS Include Tcl interpreter. default=no OPTS=no/yes/dynamic
14771478
--enable-rubyinterp=OPTS Include Ruby interpreter. default=no OPTS=no/yes/dynamic
14781479
--enable-cscope Include cscope interface.
1480+
--enable-termtruecolor Include support for 24-bit colors in ISO-8613-3 compatible terminals
14791481
--enable-workshop Include Sun Visual Workshop support.
14801482
--disable-netbeans Disable NetBeans integration support.
14811483
--disable-channel Disable process communication support.
@@ -7216,6 +7218,22 @@ if test "$enable_cscope" = "yes"; then
72167218

72177219
fi
72187220

7221+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking --enable-termtruecolor argument" >&5
7222+
$as_echo_n "checking --enable-termtruecolor argument... " >&6; }
7223+
# Check whether --enable-termtruecolor was given.
7224+
if test "${enable_termtruecolor+set}" = set; then :
7225+
enableval=$enable_termtruecolor;
7226+
else
7227+
enable_termtruecolor="no"
7228+
fi
7229+
7230+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_termtruecolor" >&5
7231+
$as_echo "$enable_termtruecolor" >&6; }
7232+
if test "$enable_termtruecolor" = "yes"; then
7233+
$as_echo "#define FEAT_TERMTRUECOLOR 1" >>confdefs.h
7234+
7235+
fi
7236+
72197237
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking --enable-workshop argument" >&5
72207238
$as_echo_n "checking --enable-workshop argument... " >&6; }
72217239
# Check whether --enable-workshop was given.

src/config.h.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,9 @@
362362
/* Define for linking via dlopen() or LoadLibrary() */
363363
#undef DYNAMIC_TCL
364364

365+
/* Define if you want 24-bit colors in ISO-8613-3 compatible terminals. */
366+
#undef FEAT_TERMTRUECOLOR
367+
365368
/* Define if you want to add support for ACL */
366369
#undef HAVE_POSIX_ACL
367370
#undef HAVE_SOLARIS_ZFS_ACL

src/configure.in

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1926,6 +1926,15 @@ if test "$enable_cscope" = "yes"; then
19261926
AC_DEFINE(FEAT_CSCOPE)
19271927
fi
19281928

1929+
AC_MSG_CHECKING(--enable-termtruecolor argument)
1930+
AC_ARG_ENABLE(termtruecolor,
1931+
[ --enable-termtruecolor Include support for 24-bit colors in ISO-8613-3 compatible terminals], ,
1932+
[enable_termtruecolor="no"])
1933+
AC_MSG_RESULT($enable_termtruecolor)
1934+
if test "$enable_termtruecolor" = "yes"; then
1935+
AC_DEFINE(FEAT_TERMTRUECOLOR)
1936+
fi
1937+
19291938
AC_MSG_CHECKING(--enable-workshop argument)
19301939
AC_ARG_ENABLE(workshop,
19311940
[ --enable-workshop Include Sun Visual Workshop support.], ,

src/eval.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14044,6 +14044,9 @@ f_has(typval_T *argvars, typval_T *rettv)
1404414044
#ifdef FEAT_TERMRESPONSE
1404514045
"termresponse",
1404614046
#endif
14047+
#ifdef FEAT_TERMTRUECOLOR
14048+
"termtruecolor",
14049+
#endif
1404714050
#ifdef FEAT_TEXTOBJ
1404814051
"textobjects",
1404914052
#endif

src/globals.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,10 @@ EXTERN char_u *use_gvimrc INIT(= NULL); /* "-U" cmdline argument */
369369
EXTERN int cterm_normal_fg_color INIT(= 0);
370370
EXTERN int cterm_normal_fg_bold INIT(= 0);
371371
EXTERN int cterm_normal_bg_color INIT(= 0);
372+
#ifdef FEAT_TERMTRUECOLOR
373+
EXTERN long_u cterm_normal_fg_gui_color INIT(= INVALCOLOR);
374+
EXTERN long_u cterm_normal_bg_gui_color INIT(= INVALCOLOR);
375+
#endif
372376

373377
#ifdef FEAT_AUTOCMD
374378
EXTERN int autocmd_busy INIT(= FALSE); /* Is apply_autocmds() busy? */

src/hardcopy.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ parse_printoptions(void)
164164

165165
#if (defined(FEAT_MBYTE) && defined(FEAT_POSTSCRIPT)) || defined(PROTO)
166166
/*
167-
* Parse 'printoptions' and set the flags in "printer_opts".
167+
* Parse 'printmbfont' and set the flags in "mbfont_opts".
168168
* Returns an error message or NULL;
169169
*/
170170
char_u *
@@ -307,8 +307,8 @@ prt_get_attr(
307307
pattr->underline = (highlight_has_attr(hl_id, HL_UNDERLINE, modec) != NULL);
308308
pattr->undercurl = (highlight_has_attr(hl_id, HL_UNDERCURL, modec) != NULL);
309309

310-
# ifdef FEAT_GUI
311-
if (gui.in_use)
310+
# if defined(FEAT_GUI) || defined(FEAT_TERMTRUECOLOR)
311+
if (USE_24BIT)
312312
{
313313
bg_color = highlight_gui_color_rgb(hl_id, FALSE);
314314
if (bg_color == PRCOLOR_BLACK)

src/option.c

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1305,7 +1305,16 @@ static struct vimoption options[] =
13051305
{(char_u *)NULL, (char_u *)0L}
13061306
#endif
13071307
SCRIPTID_INIT},
1308-
{"guicursor", "gcr", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
1308+
{"guicolors", "gcol", P_BOOL|P_VI_DEF|P_VIM|P_RCLR,
1309+
#ifdef FEAT_TERMTRUECOLOR
1310+
(char_u *)&p_guicolors, PV_NONE,
1311+
{(char_u *)FALSE, (char_u *)FALSE}
1312+
#else
1313+
(char_u*)NULL, PV_NONE,
1314+
{(char_u *)FALSE, (char_u *)FALSE}
1315+
#endif
1316+
SCRIPTID_INIT},
1317+
{"guicursor", "gcr", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
13091318
#ifdef CURSOR_SHAPE
13101319
(char_u *)&p_guicursor, PV_NONE,
13111320
{
@@ -3011,6 +3020,8 @@ static struct vimoption options[] =
30113020
p_term("t_xs", T_XS)
30123021
p_term("t_ZH", T_CZH)
30133022
p_term("t_ZR", T_CZR)
3023+
p_term("t_8f", T_8F)
3024+
p_term("t_8b", T_8B)
30143025

30153026
/* terminal key codes are not in here */
30163027

@@ -8353,6 +8364,17 @@ set_bool_option(
83538364

83548365
#endif
83558366

8367+
#ifdef FEAT_TERMTRUECOLOR
8368+
/* 'guicolors' */
8369+
else if ((int *)varp == &p_guicolors)
8370+
{
8371+
# ifdef FEAT_GUI
8372+
if (!gui.in_use && !gui.starting)
8373+
# endif
8374+
highlight_gui_started();
8375+
}
8376+
#endif
8377+
83568378
/*
83578379
* End of handling side effects for bool options.
83588380
*/

0 commit comments

Comments
 (0)