Skip to content

Commit

Permalink
patch 7.4.1770
Browse files Browse the repository at this point in the history
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 8a633e3
Show file tree
Hide file tree
Showing 19 changed files with 644 additions and 120 deletions.
14 changes: 13 additions & 1 deletion runtime/doc/options.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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,
Expand Down
22 changes: 21 additions & 1 deletion runtime/doc/term.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions runtime/doc/various.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 18 additions & 0 deletions src/auto/configure
Original file line number Diff line number Diff line change
Expand Up @@ -810,6 +810,7 @@ with_tclsh
enable_rubyinterp
with_ruby_command
enable_cscope
enable_termtruecolor
enable_workshop
enable_netbeans
enable_channel
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
3 changes: 3 additions & 0 deletions src/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions src/configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -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.], ,
Expand Down
3 changes: 3 additions & 0 deletions src/eval.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -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? */
Expand Down
6 changes: 3 additions & 3 deletions src/hardcopy.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 *
Expand Down Expand Up @@ -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)
Expand Down
24 changes: 23 additions & 1 deletion src/option.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
{
Expand Down Expand Up @@ -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 */

Expand Down Expand Up @@ -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.
*/
Expand Down
3 changes: 3 additions & 0 deletions src/option.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions src/proto/term.pro
Original file line number Diff line number Diff line change
@@ -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);
Expand All @@ -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);
Expand Down
Loading

0 comments on commit 8a633e3

Please sign in to comment.