]> granicus.if.org Git - vim/commitdiff
patch 8.0.0760: terminal window colors wrong with 'termguicolors' v8.0.0760
authorBram Moolenaar <Bram@vim.org>
Sun, 23 Jul 2017 16:07:56 +0000 (18:07 +0200)
committerBram Moolenaar <Bram@vim.org>
Sun, 23 Jul 2017 16:07:56 +0000 (18:07 +0200)
Problem:    Terminal window colors wrong with 'termguicolors'.
Solution:   Add 'termguicolors' support.

src/proto/syntax.pro
src/syntax.c
src/terminal.c
src/version.c

index cd21418682f2578daf628664870073dc66ecda5e..be3425834182ee8cfedcf268247ca3bd5f4b8ce1 100644 (file)
@@ -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);
index 6fdc2af2c65bc159c690c5a20a7118546df26c8d..e445fba0ec5924e5b75e46d148723abbc7975106 100644 (file)
@@ -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.
index 95b16c946362250394050104dea87b16b8e8b409..3f1a91d1542cb39ff94ab947a9c98fa9a7f539af 100644 (file)
@@ -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),
index c1c68e358cc36d2335fad4c71b646bcc1e2c419a..00580c711b020af3b0d894b75f153e89c0ee092e 100644 (file)
@@ -769,6 +769,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    760,
 /**/
     759,
 /**/