• R/O
  • SSH

vim: Commit

Mirror of the Vim source from https://github.com/vim/vim


Commit MetaInfo

Revision1756fe125914a37a7998631400b948bf3511960d (tree)
Zeit2019-12-03 05:45:04
AutorBram Moolenaar <Bram@vim....>
CommiterBram Moolenaar

Log Message

patch 8.1.2382: MS-Windows: When using VTP bold+inverse doesn't work

Commit: https://github.com/vim/vim/commit/a050b9471c66b383ed674bfd57ac78016199d972
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Dec 2 21:35:31 2019 +0100

patch 8.1.2382: MS-Windows: When using VTP bold+inverse doesn't work
Problem: MS-Windows: When using VTP bold+inverse doesn't work.
Solution: Compare with the default colors. (Nobuhiro Takasaki, closes https://github.com/vim/vim/issues/5303)

Ändern Zusammenfassung

Diff

diff -r b3ddaa7a8b5b -r 1756fe125914 src/os_win32.c
--- a/src/os_win32.c Mon Dec 02 20:45:04 2019 +0100
+++ b/src/os_win32.c Mon Dec 02 21:45:04 2019 +0100
@@ -7414,34 +7414,14 @@
74147414 {
74157415 # ifdef FEAT_TERMGUICOLORS
74167416 DYN_CONSOLE_SCREEN_BUFFER_INFOEX csbi;
7417- int id;
7418- guicolor_T fg = INVALCOLOR;
7419- guicolor_T bg = INVALCOLOR;
7420- int ctermfg;
7421- int ctermbg;
7417+ guicolor_T fg, bg;
7418+ int ctermfg, ctermbg;
74227419
74237420 if (!USE_VTP)
74247421 return;
74257422
7426- id = syn_name2id((char_u *)"Normal");
7427- if (id > 0 && p_tgc)
7428- syn_id2colors(id, &fg, &bg);
7429- if (fg == INVALCOLOR)
7430- {
7431- ctermfg = -1;
7432- if (id > 0)
7433- syn_id2cterm_bg(id, &ctermfg, &ctermbg);
7434- fg = ctermfg != -1 ? ctermtoxterm(ctermfg) : default_console_color_fg;
7435- cterm_normal_fg_gui_color = fg;
7436- }
7437- if (bg == INVALCOLOR)
7438- {
7439- ctermbg = -1;
7440- if (id > 0)
7441- syn_id2cterm_bg(id, &ctermfg, &ctermbg);
7442- bg = ctermbg != -1 ? ctermtoxterm(ctermbg) : default_console_color_bg;
7443- cterm_normal_bg_gui_color = bg;
7444- }
7423+ get_default_console_color(&ctermfg, &ctermbg, &fg, &bg);
7424+
74457425 fg = (GetRValue(fg) << 16) | (GetGValue(fg) << 8) | GetBValue(fg);
74467426 bg = (GetRValue(bg) << 16) | (GetGValue(bg) << 8) | GetBValue(bg);
74477427
@@ -7459,6 +7439,51 @@
74597439 # endif
74607440 }
74617441
7442+# if defined(FEAT_TERMGUICOLORS) || defined(PROTO)
7443+ void
7444+get_default_console_color(
7445+ int *cterm_fg,
7446+ int *cterm_bg,
7447+ guicolor_T *gui_fg,
7448+ guicolor_T *gui_bg)
7449+{
7450+ int id;
7451+ guicolor_T guifg = INVALCOLOR;
7452+ guicolor_T guibg = INVALCOLOR;
7453+ int ctermfg = 0;
7454+ int ctermbg = 0;
7455+
7456+ id = syn_name2id((char_u *)"Normal");
7457+ if (id > 0 && p_tgc)
7458+ syn_id2colors(id, &guifg, &guibg);
7459+ if (guifg == INVALCOLOR)
7460+ {
7461+ ctermfg = -1;
7462+ if (id > 0)
7463+ syn_id2cterm_bg(id, &ctermfg, &ctermbg);
7464+ guifg = ctermfg != -1 ? ctermtoxterm(ctermfg)
7465+ : default_console_color_fg;
7466+ cterm_normal_fg_gui_color = guifg;
7467+ ctermfg = ctermfg < 0 ? 0 : ctermfg;
7468+ }
7469+ if (guibg == INVALCOLOR)
7470+ {
7471+ ctermbg = -1;
7472+ if (id > 0)
7473+ syn_id2cterm_bg(id, &ctermfg, &ctermbg);
7474+ guibg = ctermbg != -1 ? ctermtoxterm(ctermbg)
7475+ : default_console_color_bg;
7476+ cterm_normal_bg_gui_color = guibg;
7477+ ctermbg = ctermbg < 0 ? 0 : ctermbg;
7478+ }
7479+
7480+ *cterm_fg = ctermfg;
7481+ *cterm_bg = ctermbg;
7482+ *gui_fg = guifg;
7483+ *gui_bg = guibg;
7484+}
7485+# endif
7486+
74627487 static void
74637488 reset_console_color_rgb(void)
74647489 {
diff -r b3ddaa7a8b5b -r 1756fe125914 src/proto/os_win32.pro
--- a/src/proto/os_win32.pro Mon Dec 02 20:45:04 2019 +0100
+++ b/src/proto/os_win32.pro Mon Dec 02 21:45:04 2019 +0100
@@ -71,6 +71,7 @@
7171 void set_alist_count(void);
7272 void fix_arg_enc(void);
7373 int mch_setenv(char *var, char *value, int x);
74+void get_default_console_color(int *cterm_fg, int *cterm_bg, guicolor_T *gui_fg, guicolor_T *gui_bg);
7475 void control_console_color_rgb(void);
7576 int use_vtp(void);
7677 int is_term_win32(void);
diff -r b3ddaa7a8b5b -r 1756fe125914 src/screen.c
--- a/src/screen.c Mon Dec 02 20:45:04 2019 +0100
+++ b/src/screen.c Mon Dec 02 21:45:04 2019 +0100
@@ -1777,6 +1777,33 @@
17771777 else
17781778 attr = aep->ae_attr;
17791779 }
1780+#if defined(FEAT_VTP) && defined(FEAT_TERMGUICOLORS)
1781+ if (use_vtp())
1782+ {
1783+ guicolor_T defguifg, defguibg;
1784+ int defctermfg, defctermbg;
1785+
1786+ // If FG and BG are unset, the color is undefined when
1787+ // BOLD+INVERSE. Use Normal as the default value.
1788+ get_default_console_color(&defctermfg, &defctermbg, &defguifg,
1789+ &defguibg);
1790+
1791+ if (p_tgc)
1792+ {
1793+ if (aep == NULL || COLOR_INVALID(aep->ae_u.cterm.fg_rgb))
1794+ term_fg_rgb_color(defguifg);
1795+ if (aep == NULL || COLOR_INVALID(aep->ae_u.cterm.bg_rgb))
1796+ term_bg_rgb_color(defguibg);
1797+ }
1798+ else if (t_colors >= 256)
1799+ {
1800+ if (aep == NULL || aep->ae_u.cterm.fg_color == 0)
1801+ term_fg_color(defctermfg);
1802+ if (aep == NULL || aep->ae_u.cterm.bg_color == 0)
1803+ term_bg_color(defctermbg);
1804+ }
1805+ }
1806+#endif
17801807 if ((attr & HL_BOLD) && *T_MD != NUL) /* bold */
17811808 out_str(T_MD);
17821809 else if (aep != NULL && cterm_normal_fg_bold && (
diff -r b3ddaa7a8b5b -r 1756fe125914 src/version.c
--- a/src/version.c Mon Dec 02 20:45:04 2019 +0100
+++ b/src/version.c Mon Dec 02 21:45:04 2019 +0100
@@ -743,6 +743,8 @@
743743 static int included_patches[] =
744744 { /* Add new patch number below this line */
745745 /**/
746+ 2382,
747+/**/
746748 2381,
747749 /**/
748750 2380,
Show on old repository browser