0
0
mirror of https://github.com/vim/vim.git synced 2025-10-04 05:25:06 -04:00

patch 7.4.1770

Problem:    Cannot use true color in the terminal.
Solution:   Add the 'guicolors' option. (Nikolai Pavlov)
This commit is contained in:
Bram Moolenaar
2016-04-21 21:10:14 +02:00
parent 6d4431e7b6
commit 8a633e3427
19 changed files with 644 additions and 120 deletions

View File

@@ -7828,7 +7828,7 @@ screen_start_highlight(int attr)
{
if (attr > HL_ALL) /* special HL attr. */
{
if (t_colors > 1)
if (IS_CTERM)
aep = syn_cterm_attr2entry(attr);
else
aep = syn_term_attr2entry(attr);
@@ -7839,8 +7839,16 @@ screen_start_highlight(int attr)
}
if ((attr & HL_BOLD) && T_MD != NULL) /* bold */
out_str(T_MD);
else if (aep != NULL && t_colors > 1 && aep->ae_u.cterm.fg_color
&& cterm_normal_fg_bold)
else if (aep != NULL && cterm_normal_fg_bold &&
#ifdef FEAT_TERMTRUECOLOR
(p_guicolors ?
(aep->ae_u.cterm.fg_rgb != INVALCOLOR):
#endif
(t_colors > 1 && aep->ae_u.cterm.fg_color)
#ifdef FEAT_TERMTRUECOLOR
)
#endif
)
/* If the Normal FG color has BOLD attribute and the new HL
* has a FG color defined, clear BOLD. */
out_str(T_ME);
@@ -7860,17 +7868,29 @@ screen_start_highlight(int attr)
*/
if (aep != NULL)
{
if (t_colors > 1)
#ifdef FEAT_TERMTRUECOLOR
if (p_guicolors)
{
if (aep->ae_u.cterm.fg_color)
term_fg_color(aep->ae_u.cterm.fg_color - 1);
if (aep->ae_u.cterm.bg_color)
term_bg_color(aep->ae_u.cterm.bg_color - 1);
if (aep->ae_u.cterm.fg_rgb != INVALCOLOR)
term_fg_rgb_color(aep->ae_u.cterm.fg_rgb);
if (aep->ae_u.cterm.bg_rgb != INVALCOLOR)
term_bg_rgb_color(aep->ae_u.cterm.bg_rgb);
}
else
#endif
{
if (aep->ae_u.term.start != NULL)
out_str(aep->ae_u.term.start);
if (t_colors > 1)
{
if (aep->ae_u.cterm.fg_color)
term_fg_color(aep->ae_u.cterm.fg_color - 1);
if (aep->ae_u.cterm.bg_color)
term_bg_color(aep->ae_u.cterm.bg_color - 1);
}
else
{
if (aep->ae_u.term.start != NULL)
out_str(aep->ae_u.term.start);
}
}
}
}
@@ -7904,14 +7924,23 @@ screen_stop_highlight(void)
{
attrentry_T *aep;
if (t_colors > 1)
if (IS_CTERM)
{
/*
* Assume that t_me restores the original colors!
*/
aep = syn_cterm_attr2entry(screen_attr);
if (aep != NULL && (aep->ae_u.cterm.fg_color
|| aep->ae_u.cterm.bg_color))
if (aep != NULL &&
#ifdef FEAT_TERMTRUECOLOR
(p_guicolors ?
(aep->ae_u.cterm.fg_rgb != INVALCOLOR ||
aep->ae_u.cterm.bg_rgb != INVALCOLOR):
#endif
(aep->ae_u.cterm.fg_color || aep->ae_u.cterm.bg_color)
#ifdef FEAT_TERMTRUECOLOR
)
#endif
)
do_ME = TRUE;
}
else
@@ -7959,15 +7988,27 @@ screen_stop_highlight(void)
if (do_ME || (screen_attr & (HL_BOLD | HL_INVERSE)))
out_str(T_ME);
if (t_colors > 1)
#ifdef FEAT_TERMTRUECOLOR
if (p_guicolors)
{
/* set Normal cterm colors */
if (cterm_normal_fg_color != 0)
term_fg_color(cterm_normal_fg_color - 1);
if (cterm_normal_bg_color != 0)
term_bg_color(cterm_normal_bg_color - 1);
if (cterm_normal_fg_bold)
out_str(T_MD);
if (cterm_normal_fg_gui_color != INVALCOLOR)
term_fg_rgb_color(cterm_normal_fg_gui_color);
if (cterm_normal_bg_gui_color != INVALCOLOR)
term_bg_rgb_color(cterm_normal_bg_gui_color);
}
else
#endif
{
if (t_colors > 1)
{
/* set Normal cterm colors */
if (cterm_normal_fg_color != 0)
term_fg_color(cterm_normal_fg_color - 1);
if (cterm_normal_bg_color != 0)
term_bg_color(cterm_normal_bg_color - 1);
if (cterm_normal_fg_bold)
out_str(T_MD);
}
}
}
}
@@ -7981,10 +8022,17 @@ screen_stop_highlight(void)
void
reset_cterm_colors(void)
{
if (t_colors > 1)
if (IS_CTERM)
{
/* set Normal cterm colors */
#ifdef FEAT_TERMTRUECOLOR
if (p_guicolors ?
(cterm_normal_fg_gui_color != INVALCOLOR
|| cterm_normal_bg_gui_color != INVALCOLOR):
(cterm_normal_fg_color > 0 || cterm_normal_bg_color > 0))
#else
if (cterm_normal_fg_color > 0 || cterm_normal_bg_color > 0)
#endif
{
out_str(T_OP);
screen_attr = -1;
@@ -8228,7 +8276,7 @@ screen_fill(
#ifdef FEAT_GUI
!gui.in_use &&
#endif
t_colors <= 1);
!IS_CTERM);
for (row = start_row; row < end_row; ++row)
{
#ifdef FEAT_MBYTE
@@ -8910,6 +8958,9 @@ can_clear(char_u *p)
return (*p != NUL && (t_colors <= 1
#ifdef FEAT_GUI
|| gui.in_use
#endif
#ifdef FEAT_TERMTRUECOLOR
|| (p_guicolors && cterm_normal_bg_gui_color != INVALCOLOR)
#endif
|| cterm_normal_bg_color == 0 || *T_UT != NUL));
}
@@ -10241,6 +10292,9 @@ draw_tabline(void)
int use_sep_chars = (t_colors < 8
#ifdef FEAT_GUI
&& !gui.in_use
#endif
#ifdef FEAT_TERMTRUECOLOR
&& !p_guicolors
#endif
);