forked from aniani/vim
patch 8.0.1544: when using 'termguicolors' SpellBad doesn't show
Problem: When using 'termguicolors' SpellBad doesn't show. Solution: When the GUI colors are not set fall back to the cterm colors.
This commit is contained in:
parent
33ef5bb0e4
commit
d4fc577e60
@ -207,6 +207,8 @@ typedef long guicolor_T; /* handle for a GUI color; for X11 this should
|
||||
#define INVALCOLOR (guicolor_T)-11111 /* number for invalid color; on 32 bit
|
||||
displays there is a tiny chance this is an
|
||||
actual color */
|
||||
#define CTERMCOLOR (guicolor_T)-11110 /* only used for cterm.bg_rgb and
|
||||
cterm.fg_rgb: use cterm color */
|
||||
|
||||
#ifdef FEAT_GUI_GTK
|
||||
typedef PangoFontDescription *GuiFont; /* handle for a GUI font */
|
||||
|
66
src/screen.c
66
src/screen.c
@ -8066,16 +8066,13 @@ screen_start_highlight(int attr)
|
||||
}
|
||||
if ((attr & HL_BOLD) && *T_MD != NUL) /* bold */
|
||||
out_str(T_MD);
|
||||
else if (aep != NULL && cterm_normal_fg_bold &&
|
||||
else if (aep != NULL && cterm_normal_fg_bold && (
|
||||
#ifdef FEAT_TERMGUICOLORS
|
||||
(p_tgc ?
|
||||
(aep->ae_u.cterm.fg_rgb != INVALCOLOR):
|
||||
p_tgc && aep->ae_u.cterm.fg_rgb != CTERMCOLOR
|
||||
? aep->ae_u.cterm.fg_rgb != INVALCOLOR
|
||||
:
|
||||
#endif
|
||||
(t_colors > 1 && aep->ae_u.cterm.fg_color)
|
||||
#ifdef FEAT_TERMGUICOLORS
|
||||
)
|
||||
#endif
|
||||
)
|
||||
t_colors > 1 && aep->ae_u.cterm.fg_color))
|
||||
/* If the Normal FG color has BOLD attribute and the new HL
|
||||
* has a FG color defined, clear BOLD. */
|
||||
out_str(T_ME);
|
||||
@ -8101,28 +8098,39 @@ screen_start_highlight(int attr)
|
||||
if (aep != NULL)
|
||||
{
|
||||
#ifdef FEAT_TERMGUICOLORS
|
||||
if (p_tgc)
|
||||
/* When 'termguicolors' is set but fg or bg is unset,
|
||||
* fall back to the cterm colors. This helps for SpellBad,
|
||||
* where the GUI uses a red undercurl. */
|
||||
if (p_tgc && aep->ae_u.cterm.fg_rgb != CTERMCOLOR)
|
||||
{
|
||||
if (aep->ae_u.cterm.fg_rgb != INVALCOLOR)
|
||||
term_fg_rgb_color(aep->ae_u.cterm.fg_rgb);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
if (t_colors > 1)
|
||||
{
|
||||
if (aep->ae_u.cterm.fg_color)
|
||||
term_fg_color(aep->ae_u.cterm.fg_color - 1);
|
||||
}
|
||||
#ifdef FEAT_TERMGUICOLORS
|
||||
if (p_tgc && aep->ae_u.cterm.bg_rgb != CTERMCOLOR)
|
||||
{
|
||||
if (aep->ae_u.cterm.bg_rgb != INVALCOLOR)
|
||||
term_bg_rgb_color(aep->ae_u.cterm.bg_rgb);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
if (t_colors > 1)
|
||||
{
|
||||
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);
|
||||
}
|
||||
if (aep->ae_u.cterm.bg_color)
|
||||
term_bg_color(aep->ae_u.cterm.bg_color - 1);
|
||||
}
|
||||
|
||||
if (t_colors <= 1)
|
||||
{
|
||||
if (aep->ae_u.term.start != NULL)
|
||||
out_str(aep->ae_u.term.start);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -8162,17 +8170,19 @@ screen_stop_highlight(void)
|
||||
* Assume that t_me restores the original colors!
|
||||
*/
|
||||
aep = syn_cterm_attr2entry(screen_attr);
|
||||
if (aep != NULL &&
|
||||
if (aep != NULL && ((
|
||||
#ifdef FEAT_TERMGUICOLORS
|
||||
(p_tgc ?
|
||||
(aep->ae_u.cterm.fg_rgb != INVALCOLOR
|
||||
|| aep->ae_u.cterm.bg_rgb != INVALCOLOR):
|
||||
p_tgc && aep->ae_u.cterm.fg_rgb != CTERMCOLOR
|
||||
? aep->ae_u.cterm.fg_rgb != INVALCOLOR
|
||||
:
|
||||
#endif
|
||||
(aep->ae_u.cterm.fg_color || aep->ae_u.cterm.bg_color)
|
||||
aep->ae_u.cterm.fg_color) || (
|
||||
#ifdef FEAT_TERMGUICOLORS
|
||||
)
|
||||
p_tgc && aep->ae_u.cterm.bg_rgb != CTERMCOLOR
|
||||
? aep->ae_u.cterm.bg_rgb != INVALCOLOR
|
||||
:
|
||||
#endif
|
||||
)
|
||||
aep->ae_u.cterm.bg_color)))
|
||||
do_ME = TRUE;
|
||||
}
|
||||
else
|
||||
|
@ -101,7 +101,10 @@ typedef struct {
|
||||
# endif
|
||||
# define guicolor_T long
|
||||
# define INVALCOLOR ((guicolor_T)0x1ffffff)
|
||||
/* only used for cterm.bg_rgb and cterm.fg_rgb: use cterm color */
|
||||
# define CTERMCOLOR ((guicolor_T)0x1fffffe)
|
||||
#endif
|
||||
#define COLOR_INVALID(x) ((x) == INVALCOLOR || (x) == CTERMCOLOR)
|
||||
|
||||
/*
|
||||
* marks: positions in a file
|
||||
|
43
src/syntax.c
43
src/syntax.c
@ -8952,8 +8952,18 @@ get_tgc_attr_idx(int attr, guicolor_T fg, guicolor_T bg)
|
||||
|
||||
vim_memset(&at_en, 0, sizeof(attrentry_T));
|
||||
at_en.ae_attr = attr;
|
||||
at_en.ae_u.cterm.fg_rgb = fg;
|
||||
at_en.ae_u.cterm.bg_rgb = bg;
|
||||
if (fg == INVALCOLOR && bg == INVALCOLOR)
|
||||
{
|
||||
/* If both GUI colors are not set fall back to the cterm colors. Helps
|
||||
* if the GUI only has an attribute, such as undercurl. */
|
||||
at_en.ae_u.cterm.fg_rgb = CTERMCOLOR;
|
||||
at_en.ae_u.cterm.bg_rgb = CTERMCOLOR;
|
||||
}
|
||||
else
|
||||
{
|
||||
at_en.ae_u.cterm.fg_rgb = fg;
|
||||
at_en.ae_u.cterm.bg_rgb = bg;
|
||||
}
|
||||
return get_attr_entry(&cterm_attr_table, &at_en);
|
||||
}
|
||||
#endif
|
||||
@ -9094,10 +9104,23 @@ hl_combine_attr(int char_attr, int prim_attr)
|
||||
if (spell_aep->ae_u.cterm.bg_color > 0)
|
||||
new_en.ae_u.cterm.bg_color = spell_aep->ae_u.cterm.bg_color;
|
||||
#ifdef FEAT_TERMGUICOLORS
|
||||
if (spell_aep->ae_u.cterm.fg_rgb != INVALCOLOR)
|
||||
new_en.ae_u.cterm.fg_rgb = spell_aep->ae_u.cterm.fg_rgb;
|
||||
if (spell_aep->ae_u.cterm.bg_rgb != INVALCOLOR)
|
||||
new_en.ae_u.cterm.bg_rgb = spell_aep->ae_u.cterm.bg_rgb;
|
||||
/* If both fg and bg are not set fall back to cterm colors.
|
||||
* Helps for SpellBad which uses undercurl in the GUI. */
|
||||
if (COLOR_INVALID(spell_aep->ae_u.cterm.fg_rgb)
|
||||
&& COLOR_INVALID(spell_aep->ae_u.cterm.bg_rgb))
|
||||
{
|
||||
if (spell_aep->ae_u.cterm.fg_color > 0)
|
||||
new_en.ae_u.cterm.fg_rgb = CTERMCOLOR;
|
||||
if (spell_aep->ae_u.cterm.bg_color > 0)
|
||||
new_en.ae_u.cterm.bg_rgb = CTERMCOLOR;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (spell_aep->ae_u.cterm.fg_rgb != INVALCOLOR)
|
||||
new_en.ae_u.cterm.fg_rgb = spell_aep->ae_u.cterm.fg_rgb;
|
||||
if (spell_aep->ae_u.cterm.bg_rgb != INVALCOLOR)
|
||||
new_en.ae_u.cterm.bg_rgb = spell_aep->ae_u.cterm.bg_rgb;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@ -9592,6 +9615,14 @@ set_hl_attr(
|
||||
# endif
|
||||
at_en.ae_u.cterm.fg_rgb = GUI_MCH_GET_RGB2(sgp->sg_gui_fg);
|
||||
at_en.ae_u.cterm.bg_rgb = GUI_MCH_GET_RGB2(sgp->sg_gui_bg);
|
||||
if (at_en.ae_u.cterm.fg_rgb == INVALCOLOR
|
||||
&& at_en.ae_u.cterm.bg_rgb == INVALCOLOR)
|
||||
{
|
||||
/* If both fg and bg are invalid fall back to the cterm colors.
|
||||
* Helps when the GUI only uses an attribute, e.g. undercurl. */
|
||||
at_en.ae_u.cterm.fg_rgb = CTERMCOLOR;
|
||||
at_en.ae_u.cterm.bg_rgb = CTERMCOLOR;
|
||||
}
|
||||
# endif
|
||||
sgp->sg_cterm_attr = get_attr_entry(&cterm_attr_table, &at_en);
|
||||
}
|
||||
|
@ -778,6 +778,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
1544,
|
||||
/**/
|
||||
1543,
|
||||
/**/
|
||||
|
Loading…
x
Reference in New Issue
Block a user