diff options
author | Bram Moolenaar <Bram@vim.org> | 2017-07-23 18:07:56 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2017-07-23 18:07:56 +0200 |
commit | 065f41c8143271d1af7c8f5d14a59e29bf7ecdf3 (patch) | |
tree | 882fdc9e6dcafd380a6efce8670f0c2345cde44a /src | |
parent | 43da3e36b21b9df20e4b2f380df76bbc7e91a965 (diff) |
patch 8.0.0760: terminal window colors wrong with 'termguicolors'v8.0.0760
Problem: Terminal window colors wrong with 'termguicolors'.
Solution: Add 'termguicolors' support.
Diffstat (limited to 'src')
-rw-r--r-- | src/proto/syntax.pro | 1 | ||||
-rw-r--r-- | src/syntax.c | 18 | ||||
-rw-r--r-- | src/terminal.c | 9 | ||||
-rw-r--r-- | src/version.c | 2 |
4 files changed, 28 insertions, 2 deletions
diff --git a/src/proto/syntax.pro b/src/proto/syntax.pro index cd21418682..be34258341 100644 --- a/src/proto/syntax.pro +++ b/src/proto/syntax.pro @@ -32,6 +32,7 @@ void hl_set_font_name(char_u *font_name); void hl_set_bg_color_name(char_u *name); void hl_set_fg_color_name(char_u *name); int get_cterm_attr_idx(int attr, int fg, int bg); +int get_tgc_attr_idx(int attr, guicolor_T fg, guicolor_T bg); int get_gui_attr_idx(int attr, guicolor_T fg, guicolor_T bg); void clear_hl_tables(void); int hl_combine_attr(int char_attr, int prim_attr); diff --git a/src/syntax.c b/src/syntax.c index 6fdc2af2c6..e445fba0ec 100644 --- a/src/syntax.c +++ b/src/syntax.c @@ -8796,6 +8796,24 @@ get_cterm_attr_idx(int attr, int fg, int bg) return get_attr_entry(&cterm_attr_table, &at_en); } +#if defined(FEAT_TERMGUICOLORS) || defined(PROTO) +/* + * Get an attribute index for a 'termguicolors' entry. + * Uses an existing entry when possible or adds one when needed. + */ + int +get_tgc_attr_idx(int attr, guicolor_T fg, guicolor_T bg) +{ + attrentry_T at_en; + + 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; + return get_attr_entry(&cterm_attr_table, &at_en); +} +#endif + #if defined(FEAT_GUI) || defined(PROTO) /* * Get an attribute index for a cterm entry. diff --git a/src/terminal.c b/src/terminal.c index 95b16c9463..3f1a91d154 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -33,7 +33,6 @@ * while, if the terminal window is visible, the screen contents is drawn. * * TODO: - * - color for 'termguicolors' * - cursor flickers when moving the cursor * - set buffer options to be scratch, hidden, nomodifiable, etc. * - set buffer name to command, add (1) to avoid duplicates. @@ -731,8 +730,14 @@ cell2attr(VTermScreenCell *cell) #ifdef FEAT_TERMGUICOLORS if (p_tgc) { - /* TODO */ + guicolor_T fg, bg; + + fg = gui_get_rgb_color_cmn(cell->fg.red, cell->fg.green, cell->fg.blue); + bg = gui_get_rgb_color_cmn(cell->bg.red, cell->bg.green, cell->bg.blue); + + return get_tgc_attr_idx(attr, fg, bg); } + else #endif { return get_cterm_attr_idx(attr, color2index(&cell->fg), diff --git a/src/version.c b/src/version.c index c1c68e358c..00580c711b 100644 --- a/src/version.c +++ b/src/version.c @@ -770,6 +770,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 760, +/**/ 759, /**/ 758, |