Patch 8.0.1362
Problem:    Terminal window colors wrong when using Terminal highlighting.
Solution:   Set ansi_index when setting the default color.  Also cache the
            color index for Terminal. (Ozaki Kiichi, closes #2393)
Files:      src/libvterm/src/pen.c, src/proto/terminal.pro, src/syntax.c,
            src/terminal.c


*** ../vim-8.0.1361/src/libvterm/src/pen.c      2017-11-29 22:33:31.051416026 
+0100
--- src/libvterm/src/pen.c      2017-12-01 20:58:25.116033574 +0100
***************
*** 213,221 ****
  void vterm_state_set_default_colors(VTermState *state, const VTermColor 
*default_fg, const VTermColor *default_bg)
  {
    state->default_fg = *default_fg;
-   state->default_fg.ansi_index = VTERM_ANSI_INDEX_DEFAULT;
    state->default_bg = *default_bg;
-   state->default_bg.ansi_index = VTERM_ANSI_INDEX_DEFAULT;
  }
  
  void vterm_state_set_palette_color(VTermState *state, int index, const 
VTermColor *col)
--- 213,219 ----
*** ../vim-8.0.1361/src/proto/terminal.pro      2017-09-14 20:37:49.963213752 
+0200
--- src/proto/terminal.pro      2017-12-01 20:58:25.116033574 +0100
***************
*** 20,25 ****
--- 20,26 ----
  int term_get_attr(buf_T *buf, linenr_T lnum, int col);
  char_u *term_get_status_text(term_T *term);
  int set_ref_in_term(int copyID);
+ void set_terminal_default_colors(int cterm_fg, int cterm_bg);
  void f_term_getaltscreen(typval_T *argvars, typval_T *rettv);
  void f_term_getattr(typval_T *argvars, typval_T *rettv);
  void f_term_getcursor(typval_T *argvars, typval_T *rettv);
*** ../vim-8.0.1361/src/syntax.c        2017-11-18 22:13:04.749908702 +0100
--- src/syntax.c        2017-12-01 20:58:25.120033551 +0100
***************
*** 7391,7396 ****
--- 7391,7399 ----
      int               error = FALSE;
      int               color;
      int               is_normal_group = FALSE;        /* "Normal" group */
+ #ifdef FEAT_TERMINAL
+     int               is_terminal_group = FALSE;      /* "Terminal" group */
+ #endif
  #ifdef FEAT_GUI_X11
      int               is_menu_group = FALSE;          /* "Menu" group */
      int               is_scrollbar_group = FALSE;     /* "Scrollbar" group */
***************
*** 7616,7621 ****
--- 7619,7628 ----
  
      if (STRCMP(HL_TABLE()[idx].sg_name_u, "NORMAL") == 0)
        is_normal_group = TRUE;
+ #ifdef FEAT_TERMINAL
+     else if (STRCMP(HL_TABLE()[idx].sg_name_u, "TERMINAL") == 0)
+       is_terminal_group = TRUE;
+ #endif
  #ifdef FEAT_GUI_X11
      else if (STRCMP(HL_TABLE()[idx].sg_name_u, "MENU") == 0)
        is_menu_group = TRUE;
***************
*** 8239,8244 ****
--- 8246,8256 ----
            }
  #endif
        }
+ #ifdef FEAT_TERMINAL
+       else if (is_terminal_group)
+           set_terminal_default_colors(
+                   HL_TABLE()[idx].sg_cterm_fg, HL_TABLE()[idx].sg_cterm_bg);
+ #endif
  #ifdef FEAT_GUI_X11
  # ifdef FEAT_MENU
        else if (is_menu_group)
*** ../vim-8.0.1361/src/terminal.c      2017-11-30 22:07:03.896029952 +0100
--- src/terminal.c      2017-12-01 20:58:25.120033551 +0100
***************
*** 188,193 ****
--- 188,196 ----
   * backspace key. */
  static int term_backspace_char = BS;
  
+ /* "Terminal" highlight group colors. */
+ static int term_default_cterm_fg = -1;
+ static int term_default_cterm_bg = -1;
  
  /**************************************
   * 1. Generic code for all systems.
***************
*** 1834,1853 ****
        int bg = color2index(&cellbg, FALSE, &bold);
  
        /* Use the "Terminal" highlighting for the default colors. */
!       if (fg == 0 || bg == 0)
        {
!           int id = syn_name2id((char_u *)"Terminal");
! 
!           if (id != 0 && t_colors >= 16)
!           {
!               int cterm_fg, cterm_bg;
! 
!               syn_id2cterm_bg(id, &cterm_fg, &cterm_bg);
!               if (cterm_fg >= 0)
!                   fg = cterm_fg + 1;
!               if (cterm_bg >= 0)
!                   bg = cterm_bg + 1;
!           }
        }
  
        /* with 8 colors set the bold attribute to get a bright foreground */
--- 1837,1848 ----
        int bg = color2index(&cellbg, FALSE, &bold);
  
        /* Use the "Terminal" highlighting for the default colors. */
!       if ((fg == 0 || bg == 0) && t_colors >= 16)
        {
!           if (fg == 0 && term_default_cterm_fg >= 0)
!               fg = term_default_cterm_fg + 1;
!           if (bg == 0 && term_default_cterm_bg >= 0)
!               bg = term_default_cterm_bg + 1;
        }
  
        /* with 8 colors set the bold attribute to get a bright foreground */
***************
*** 2470,2475 ****
--- 2465,2471 ----
        rgb->blue  = cube_value[idx      % 6];
        rgb->green = cube_value[idx / 6  % 6];
        rgb->red   = cube_value[idx / 36 % 6];
+       rgb->ansi_index = VTERM_ANSI_INDEX_NONE;
      }
      else if (nr < 256)
      {
***************
*** 2478,2483 ****
--- 2474,2480 ----
        rgb->blue  = grey_ramp[idx];
        rgb->green = grey_ramp[idx];
        rgb->red   = grey_ramp[idx];
+       rgb->ansi_index = VTERM_ANSI_INDEX_NONE;
      }
  }
  
***************
*** 2520,2525 ****
--- 2517,2523 ----
      }
      fg->red = fg->green = fg->blue = fgval;
      bg->red = bg->green = bg->blue = bgval;
+     fg->ansi_index = bg->ansi_index = VTERM_ANSI_INDEX_DEFAULT;
  
      /* The "Terminal" highlight group overrules the defaults. */
      id = syn_name2id((char_u *)"Terminal");
***************
*** 2582,2594 ****
  #endif
      if (id != 0 && t_colors >= 16)
      {
!       int cterm_fg, cterm_bg;
! 
!       syn_id2cterm_bg(id, &cterm_fg, &cterm_bg);
!       if (cterm_fg >= 0)
!           cterm_color2rgb(cterm_fg, fg);
!       if (cterm_bg >= 0)
!           cterm_color2rgb(cterm_bg, bg);
      }
      else
      {
--- 2580,2589 ----
  #endif
      if (id != 0 && t_colors >= 16)
      {
!       if (term_default_cterm_fg >= 0)
!           cterm_color2rgb(term_default_cterm_fg, fg);
!       if (term_default_cterm_bg >= 0)
!           cterm_color2rgb(term_default_cterm_bg, bg);
      }
      else
      {
***************
*** 2705,2710 ****
--- 2700,2715 ----
  }
  
  /*
+  * Cache "Terminal" highlight group colors.
+  */
+     void
+ set_terminal_default_colors(int cterm_fg, int cterm_bg)
+ {
+     term_default_cterm_fg = cterm_fg - 1;
+     term_default_cterm_bg = cterm_bg - 1;
+ }
+ 
+ /*
   * Get the buffer from the first argument in "argvars".
   * Returns NULL when the buffer is not for a terminal window.
   */
*** ../vim-8.0.1361/src/version.c       2017-12-01 20:35:54.868077089 +0100
--- src/version.c       2017-12-01 21:00:50.623190972 +0100
***************
*** 773,774 ****
--- 773,776 ----
  {   /* Add new patch number below this line */
+ /**/
+     1362,
  /**/

-- 
I'm trying to be an optimist, but I don't think it'll work.

 /// 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].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui