Patch 8.1.2382
Problem:    MS-Windows: When using VTP bold+inverse doesn't work.
Solution:   Compare with the default colors. (Nobuhiro Takasaki, closes #5303)
Files:      src/os_win32.c, src/proto/os_win32.pro, src/screen.c


*** ../vim-8.1.2381/src/os_win32.c      2019-12-01 18:58:07.614835593 +0100
--- src/os_win32.c      2019-12-02 21:34:39.553322661 +0100
***************
*** 7414,7447 ****
  {
  # ifdef FEAT_TERMGUICOLORS
      DYN_CONSOLE_SCREEN_BUFFER_INFOEX csbi;
!     int id;
!     guicolor_T fg = INVALCOLOR;
!     guicolor_T bg = INVALCOLOR;
!     int ctermfg;
!     int 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;
!     }
      fg = (GetRValue(fg) << 16) | (GetGValue(fg) << 8) | GetBValue(fg);
      bg = (GetRValue(bg) << 16) | (GetGValue(bg) << 8) | GetBValue(bg);
  
--- 7414,7427 ----
  {
  # ifdef FEAT_TERMGUICOLORS
      DYN_CONSOLE_SCREEN_BUFFER_INFOEX csbi;
!     guicolor_T        fg, bg;
!     int               ctermfg, ctermbg;
  
      if (!USE_VTP)
        return;
  
!     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,7464 ****
--- 7439,7489 ----
  # 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)
  {
*** ../vim-8.1.2381/src/proto/os_win32.pro      2019-09-13 22:30:07.588524105 
+0200
--- src/proto/os_win32.pro      2019-12-02 21:30:25.682428922 +0100
***************
*** 71,76 ****
--- 71,77 ----
  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);
*** ../vim-8.1.2381/src/screen.c        2019-11-30 22:47:42.655331183 +0100
--- src/screen.c        2019-12-02 21:33:28.305633446 +0100
***************
*** 1777,1782 ****
--- 1777,1809 ----
                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 && (
*** ../vim-8.1.2381/src/version.c       2019-12-02 20:41:36.326885014 +0100
--- src/version.c       2019-12-02 21:35:19.645147731 +0100
***************
*** 744,745 ****
--- 744,747 ----
  {   /* Add new patch number below this line */
+ /**/
+     2382,
  /**/

-- 
If Apple would build a car...
... it would be powered by the sun, be reliable, five times
as fast and twice as easy to drive; but would only run on
five percent of the roads.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/201912022036.xB2KaUFN022861%40masaka.moolenaar.net.

Raspunde prin e-mail lui