summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-12-02 21:35:31 +0100
committerBram Moolenaar <Bram@vim.org>2019-12-02 21:35:31 +0100
commita050b9471c66b383ed674bfd57ac78016199d972 (patch)
tree1d6ec4d0a775fa46b85f3870e886975c2a6b132b
parent54c8d229f54e36e89fcd5d84e523fd894d018024 (diff)
patch 8.1.2382: MS-Windows: When using VTP bold+inverse doesn't workv8.1.2382
Problem: MS-Windows: When using VTP bold+inverse doesn't work. Solution: Compare with the default colors. (Nobuhiro Takasaki, closes #5303)
-rw-r--r--src/os_win32.c73
-rw-r--r--src/proto/os_win32.pro1
-rw-r--r--src/screen.c27
-rw-r--r--src/version.c2
4 files changed, 79 insertions, 24 deletions
diff --git a/src/os_win32.c b/src/os_win32.c
index e281b373ce..ff37f54b27 100644
--- a/src/os_win32.c
+++ b/src/os_win32.c
@@ -7414,34 +7414,14 @@ set_console_color_rgb(void)
{
# ifdef FEAT_TERMGUICOLORS
DYN_CONSOLE_SCREEN_BUFFER_INFOEX csbi;
- int id;
- guicolor_T fg = INVALCOLOR;
- guicolor_T bg = INVALCOLOR;
- int ctermfg;
- int ctermbg;
+ guicolor_T fg, bg;
+ int ctermfg, ctermbg;
if (!USE_VTP)
return;
- id = syn_name2id((char_u *)"Normal");
- if (id > 0 && p_tgc)
- syn_id2colors(id, &fg, &bg);
- if (fg == INVALCOLOR)
- {
- ctermfg = -1;
- if (id > 0)
- syn_id2cterm_bg(id, &ctermfg, &ctermbg);
- fg = ctermfg != -1 ? ctermtoxterm(ctermfg) : default_console_color_fg;
- cterm_normal_fg_gui_color = fg;
- }
- if (bg == INVALCOLOR)
- {
- ctermbg = -1;
- if (id > 0)
- syn_id2cterm_bg(id, &ctermfg, &ctermbg);
- bg = ctermbg != -1 ? ctermtoxterm(ctermbg) : default_console_color_bg;
- cterm_normal_bg_gui_color = bg;
- }
+ get_default_console_color(&ctermfg, &ctermbg, &fg, &bg);
+
fg = (GetRValue(fg) << 16) | (GetGValue(fg) << 8) | GetBValue(fg);
bg = (GetRValue(bg) << 16) | (GetGValue(bg) << 8) | GetBValue(bg);
@@ -7459,6 +7439,51 @@ set_console_color_rgb(void)
# endif
}
+# if defined(FEAT_TERMGUICOLORS) || defined(PROTO)
+ void
+get_default_console_color(
+ int *cterm_fg,
+ int *cterm_bg,
+ guicolor_T *gui_fg,
+ guicolor_T *gui_bg)
+{
+ int id;
+ guicolor_T guifg = INVALCOLOR;
+ guicolor_T guibg = INVALCOLOR;
+ int ctermfg = 0;
+ int ctermbg = 0;
+
+ id = syn_name2id((char_u *)"Normal");
+ if (id > 0 && p_tgc)
+ syn_id2colors(id, &guifg, &guibg);
+ if (guifg == INVALCOLOR)
+ {
+ ctermfg = -1;
+ if (id > 0)
+ syn_id2cterm_bg(id, &ctermfg, &ctermbg);
+ guifg = ctermfg != -1 ? ctermtoxterm(ctermfg)
+ : default_console_color_fg;
+ cterm_normal_fg_gui_color = guifg;
+ ctermfg = ctermfg < 0 ? 0 : ctermfg;
+ }
+ if (guibg == INVALCOLOR)
+ {
+ ctermbg = -1;
+ if (id > 0)
+ syn_id2cterm_bg(id, &ctermfg, &ctermbg);
+ guibg = ctermbg != -1 ? ctermtoxterm(ctermbg)
+ : default_console_color_bg;
+ cterm_normal_bg_gui_color = guibg;
+ ctermbg = ctermbg < 0 ? 0 : ctermbg;
+ }
+
+ *cterm_fg = ctermfg;
+ *cterm_bg = ctermbg;
+ *gui_fg = guifg;
+ *gui_bg = guibg;
+}
+# endif
+
static void
reset_console_color_rgb(void)
{
diff --git a/src/proto/os_win32.pro b/src/proto/os_win32.pro
index 94b2f72005..e60ce92ca1 100644
--- a/src/proto/os_win32.pro
+++ b/src/proto/os_win32.pro
@@ -71,6 +71,7 @@ void used_file_arg(char *name, int literal, int full_path, int diff_mode);
void set_alist_count(void);
void fix_arg_enc(void);
int mch_setenv(char *var, char *value, int x);
+void get_default_console_color(int *cterm_fg, int *cterm_bg, guicolor_T *gui_fg, guicolor_T *gui_bg);
void control_console_color_rgb(void);
int use_vtp(void);
int is_term_win32(void);
diff --git a/src/screen.c b/src/screen.c
index 4a70295187..17b1ff2192 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -1777,6 +1777,33 @@ screen_start_highlight(int attr)
else
attr = aep->ae_attr;
}
+#if defined(FEAT_VTP) && defined(FEAT_TERMGUICOLORS)
+ if (use_vtp())
+ {
+ guicolor_T defguifg, defguibg;
+ int defctermfg, defctermbg;
+
+ // If FG and BG are unset, the color is undefined when
+ // BOLD+INVERSE. Use Normal as the default value.
+ get_default_console_color(&defctermfg, &defctermbg, &defguifg,
+ &defguibg);
+
+ if (p_tgc)
+ {
+ if (aep == NULL || COLOR_INVALID(aep->ae_u.cterm.fg_rgb))
+ term_fg_rgb_color(defguifg);
+ if (aep == NULL || COLOR_INVALID(aep->ae_u.cterm.bg_rgb))
+ term_bg_rgb_color(defguibg);
+ }
+ else if (t_colors >= 256)
+ {
+ if (aep == NULL || aep->ae_u.cterm.fg_color == 0)
+ term_fg_color(defctermfg);
+ if (aep == NULL || aep->ae_u.cterm.bg_color == 0)
+ term_bg_color(defctermbg);
+ }
+ }
+#endif
if ((attr & HL_BOLD) && *T_MD != NUL) /* bold */
out_str(T_MD);
else if (aep != NULL && cterm_normal_fg_bold && (
diff --git a/src/version.c b/src/version.c
index 62bf063207..066e2093aa 100644
--- a/src/version.c
+++ b/src/version.c
@@ -743,6 +743,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 2382,
+/**/
2381,
/**/
2380,