Permalink
Browse files

patch 7.4.1770

Problem:    Cannot use true color in the terminal.
Solution:   Add the 'guicolors' option. (Nikolai Pavlov)
  • Loading branch information...
brammool committed Apr 21, 2016
1 parent 6d4431e commit 8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Showing with 644 additions and 120 deletions.
  1. +13 −1 runtime/doc/options.txt
  2. +21 −1 runtime/doc/term.txt
  3. +1 −0 runtime/doc/various.txt
  4. +18 −0 src/auto/configure
  5. +3 −0 src/config.h.in
  6. +9 −0 src/configure.in
  7. +3 −0 src/eval.c
  8. +4 −0 src/globals.h
  9. +3 −3 src/hardcopy.c
  10. +23 −1 src/option.c
  11. +3 −0 src/option.h
  12. +5 −0 src/proto/term.pro
  13. +77 −23 src/screen.c
  14. +7 −1 src/structs.h
  15. +211 −85 src/syntax.c
  16. +205 −3 src/term.c
  17. +6 −2 src/term.h
  18. +7 −0 src/version.c
  19. +25 −0 src/vim.h
@@ -1,4 +1,4 @@
*options.txt* For Vim version 7.4. Last change: 2016 Apr 20
*options.txt* For Vim version 7.4. Last change: 2016 Apr 21


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|.
This option cannot be set from a |modeline| or in the |sandbox|, for
security reasons.

*'guicolors'* *'gcol'*
'guicolors' 'gcol' boolean (default off)
global
{not in Vi}
{not available when compiled without the
|+termtruecolor| feature}
When on, uses |highlight-guifg| and |highlight-guibg| attributes in
the terminal (thus using 24-bit color). Requires a ISO-8613-3
compatible terminal.
If setting this option does not work (produces a colorless UI)
reading |xterm-true-color| might help.

*'guicursor'* *'gcr'* *E545* *E546* *E548* *E549*
'guicursor' 'gcr' string (default "n-v-c:block-Cursor/lCursor,
ve:ver35-Cursor,
@@ -1,4 +1,4 @@
*term.txt* For Vim version 7.4. Last change: 2015 Nov 24
*term.txt* For Vim version 7.4. Last change: 2016 Apr 21


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

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

*xterm-true-color*
Vim supports using true colors in the terminal (taken from |highlight-guifg|
and |highlight-guibg|), given that terminal supports this. To make this
work, 'guicolors' option needs to be set.

Sometimes setting 'guicolors' is not enough and one has to set the |t_8f| and
|t_8b| options explicitly. Default values of these options are
`^[[38;2;%lu;%lu;%lum` and `^[[48;2;%lu;%lu;%lum` (replace `^[` with real
escape) respectively, but it is only set when `$TERM` is `xterm`. Some
terminals accept the same sequences, but with all semicolons replaced by
colons (this is actually more compatible, but less widely supported). These
options contain printf strings, with |printf()| (actually, its C equivalent
hence `l` modifier) invoked with the t_ option value and three unsigned long
integers that may have any value between 0 and 255 (inclusive) representing
red, green and blue colors respectively.

*xterm-resize*
Window resizing with xterm only works if the allowWindowOps resource is
enabled. On some systems and versions of xterm it's disabled by default
@@ -424,6 +424,7 @@ m *+tcl* Tcl interface |tcl|
m *+tcl/dyn* Tcl interface |tcl-dynamic| |/dyn|
*+terminfo* uses |terminfo| instead of termcap
N *+termresponse* support for |t_RV| and |v:termresponse|
m *+termtruecolor* 24-bit color in xterm-compatible terminals support
N *+textobjects* |text-objects| selection
*+tgetent* non-Unix only: able to use external termcap
N *+timers* the |timer_start()| function
@@ -810,6 +810,7 @@ with_tclsh
enable_rubyinterp
with_ruby_command
enable_cscope
enable_termtruecolor
enable_workshop
enable_netbeans
enable_channel
@@ -1476,6 +1477,7 @@ Optional Features:
--enable-tclinterp=OPTS Include Tcl interpreter. default=no OPTS=no/yes/dynamic
--enable-rubyinterp=OPTS Include Ruby interpreter. default=no OPTS=no/yes/dynamic
--enable-cscope Include cscope interface.
--enable-termtruecolor Include support for 24-bit colors in ISO-8613-3 compatible terminals
--enable-workshop Include Sun Visual Workshop support.
--disable-netbeans Disable NetBeans integration support.
--disable-channel Disable process communication support.
@@ -7216,6 +7218,22 @@ if test "$enable_cscope" = "yes"; then

fi

{ $as_echo "$as_me:${as_lineno-$LINENO}: checking --enable-termtruecolor argument" >&5
$as_echo_n "checking --enable-termtruecolor argument... " >&6; }
# Check whether --enable-termtruecolor was given.
if test "${enable_termtruecolor+set}" = set; then :
enableval=$enable_termtruecolor;
else
enable_termtruecolor="no"
fi

{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_termtruecolor" >&5
$as_echo "$enable_termtruecolor" >&6; }
if test "$enable_termtruecolor" = "yes"; then
$as_echo "#define FEAT_TERMTRUECOLOR 1" >>confdefs.h

fi

{ $as_echo "$as_me:${as_lineno-$LINENO}: checking --enable-workshop argument" >&5
$as_echo_n "checking --enable-workshop argument... " >&6; }
# Check whether --enable-workshop was given.
@@ -362,6 +362,9 @@
/* Define for linking via dlopen() or LoadLibrary() */
#undef DYNAMIC_TCL

/* Define if you want 24-bit colors in ISO-8613-3 compatible terminals. */
#undef FEAT_TERMTRUECOLOR

/* Define if you want to add support for ACL */
#undef HAVE_POSIX_ACL
#undef HAVE_SOLARIS_ZFS_ACL
@@ -1926,6 +1926,15 @@ if test "$enable_cscope" = "yes"; then
AC_DEFINE(FEAT_CSCOPE)
fi

AC_MSG_CHECKING(--enable-termtruecolor argument)
AC_ARG_ENABLE(termtruecolor,
[ --enable-termtruecolor Include support for 24-bit colors in ISO-8613-3 compatible terminals], ,
[enable_termtruecolor="no"])
AC_MSG_RESULT($enable_termtruecolor)
if test "$enable_termtruecolor" = "yes"; then
AC_DEFINE(FEAT_TERMTRUECOLOR)
fi

AC_MSG_CHECKING(--enable-workshop argument)
AC_ARG_ENABLE(workshop,
[ --enable-workshop Include Sun Visual Workshop support.], ,
@@ -14044,6 +14044,9 @@ f_has(typval_T *argvars, typval_T *rettv)
#ifdef FEAT_TERMRESPONSE
"termresponse",
#endif
#ifdef FEAT_TERMTRUECOLOR
"termtruecolor",
#endif
#ifdef FEAT_TEXTOBJ
"textobjects",
#endif
@@ -369,6 +369,10 @@ EXTERN char_u *use_gvimrc INIT(= NULL); /* "-U" cmdline argument */
EXTERN int cterm_normal_fg_color INIT(= 0);
EXTERN int cterm_normal_fg_bold INIT(= 0);
EXTERN int cterm_normal_bg_color INIT(= 0);
#ifdef FEAT_TERMTRUECOLOR
EXTERN long_u cterm_normal_fg_gui_color INIT(= INVALCOLOR);
EXTERN long_u cterm_normal_bg_gui_color INIT(= INVALCOLOR);
#endif

#ifdef FEAT_AUTOCMD
EXTERN int autocmd_busy INIT(= FALSE); /* Is apply_autocmds() busy? */
@@ -164,7 +164,7 @@ parse_printoptions(void)

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

# ifdef FEAT_GUI
if (gui.in_use)
# if defined(FEAT_GUI) || defined(FEAT_TERMTRUECOLOR)
if (USE_24BIT)
{
bg_color = highlight_gui_color_rgb(hl_id, FALSE);
if (bg_color == PRCOLOR_BLACK)
@@ -1305,7 +1305,16 @@ static struct vimoption options[] =
{(char_u *)NULL, (char_u *)0L}
#endif
SCRIPTID_INIT},
{"guicursor", "gcr", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
{"guicolors", "gcol", P_BOOL|P_VI_DEF|P_VIM|P_RCLR,
#ifdef FEAT_TERMTRUECOLOR
(char_u *)&p_guicolors, PV_NONE,
{(char_u *)FALSE, (char_u *)FALSE}
#else
(char_u*)NULL, PV_NONE,
{(char_u *)FALSE, (char_u *)FALSE}
#endif
SCRIPTID_INIT},
{"guicursor", "gcr", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
#ifdef CURSOR_SHAPE
(char_u *)&p_guicursor, PV_NONE,
{
@@ -3011,6 +3020,8 @@ static struct vimoption options[] =
p_term("t_xs", T_XS)
p_term("t_ZH", T_CZH)
p_term("t_ZR", T_CZR)
p_term("t_8f", T_8F)
p_term("t_8b", T_8B)

/* terminal key codes are not in here */

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

#endif

#ifdef FEAT_TERMTRUECOLOR
/* 'guicolors' */
else if ((int *)varp == &p_guicolors)
{
# ifdef FEAT_GUI
if (!gui.in_use && !gui.starting)
# endif
highlight_gui_started();
}
#endif

/*
* End of handling side effects for bool options.
*/
@@ -527,6 +527,9 @@ EXTERN char_u *p_popt; /* 'printoptions' */
EXTERN char_u *p_header; /* 'printheader' */
#endif
EXTERN int p_prompt; /* 'prompt' */
#ifdef FEAT_TERMTRUECOLOR
EXTERN int p_guicolors; /* 'guicolors' */
#endif
#ifdef FEAT_GUI
EXTERN char_u *p_guifont; /* 'guifont' */
# ifdef FEAT_XFONTSET
@@ -1,4 +1,7 @@
/* term.c */
guicolor_T termtrue_mch_get_color(char_u *name);
guicolor_T termtrue_get_color(char_u *name);
long_u termtrue_mch_get_rgb(guicolor_T color);
int set_termname(char_u *term);
void set_mouse_termcode(int n, char_u *s);
void del_mouse_termcode(int n);
@@ -22,6 +25,8 @@ void term_set_winpos(int x, int y);
void term_set_winsize(int width, int height);
void term_fg_color(int n);
void term_bg_color(int n);
void term_fg_rgb_color(long_u rgb);
void term_bg_rgb_color(long_u rgb);
void term_settitle(char_u *title);
void ttest(int pairs);
void add_long_to_buf(long_u val, char_u *dst);
Oops, something went wrong.

0 comments on commit 8a633e3

Please sign in to comment.