Skip to content

Commit 065f41c

Browse files
committed
patch 8.0.0760: terminal window colors wrong with 'termguicolors'
Problem: Terminal window colors wrong with 'termguicolors'. Solution: Add 'termguicolors' support.
1 parent 43da3e3 commit 065f41c

4 files changed

Lines changed: 28 additions & 2 deletions

File tree

src/proto/syntax.pro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ void hl_set_font_name(char_u *font_name);
3232
void hl_set_bg_color_name(char_u *name);
3333
void hl_set_fg_color_name(char_u *name);
3434
int get_cterm_attr_idx(int attr, int fg, int bg);
35+
int get_tgc_attr_idx(int attr, guicolor_T fg, guicolor_T bg);
3536
int get_gui_attr_idx(int attr, guicolor_T fg, guicolor_T bg);
3637
void clear_hl_tables(void);
3738
int hl_combine_attr(int char_attr, int prim_attr);

src/syntax.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8796,6 +8796,24 @@ get_cterm_attr_idx(int attr, int fg, int bg)
87968796
return get_attr_entry(&cterm_attr_table, &at_en);
87978797
}
87988798

8799+
#if defined(FEAT_TERMGUICOLORS) || defined(PROTO)
8800+
/*
8801+
* Get an attribute index for a 'termguicolors' entry.
8802+
* Uses an existing entry when possible or adds one when needed.
8803+
*/
8804+
int
8805+
get_tgc_attr_idx(int attr, guicolor_T fg, guicolor_T bg)
8806+
{
8807+
attrentry_T at_en;
8808+
8809+
vim_memset(&at_en, 0, sizeof(attrentry_T));
8810+
at_en.ae_attr = attr;
8811+
at_en.ae_u.cterm.fg_rgb = fg;
8812+
at_en.ae_u.cterm.bg_rgb = bg;
8813+
return get_attr_entry(&cterm_attr_table, &at_en);
8814+
}
8815+
#endif
8816+
87998817
#if defined(FEAT_GUI) || defined(PROTO)
88008818
/*
88018819
* Get an attribute index for a cterm entry.

src/terminal.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
* while, if the terminal window is visible, the screen contents is drawn.
3434
*
3535
* TODO:
36-
* - color for 'termguicolors'
3736
* - cursor flickers when moving the cursor
3837
* - set buffer options to be scratch, hidden, nomodifiable, etc.
3938
* - set buffer name to command, add (1) to avoid duplicates.
@@ -731,8 +730,14 @@ cell2attr(VTermScreenCell *cell)
731730
#ifdef FEAT_TERMGUICOLORS
732731
if (p_tgc)
733732
{
734-
/* TODO */
733+
guicolor_T fg, bg;
734+
735+
fg = gui_get_rgb_color_cmn(cell->fg.red, cell->fg.green, cell->fg.blue);
736+
bg = gui_get_rgb_color_cmn(cell->bg.red, cell->bg.green, cell->bg.blue);
737+
738+
return get_tgc_attr_idx(attr, fg, bg);
735739
}
740+
else
736741
#endif
737742
{
738743
return get_cterm_attr_idx(attr, color2index(&cell->fg),

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -769,6 +769,8 @@ static char *(features[]) =
769769

770770
static int included_patches[] =
771771
{ /* Add new patch number below this line */
772+
/**/
773+
760,
772774
/**/
773775
759,
774776
/**/

0 commit comments

Comments
 (0)