On Di, 07 Jan 2014, Matteo Cavalleri wrote:

> some easy steps to reproduce the problem:
> 
> :set t_Co?
> t_Co=256
> :set background?
> background=light
> :set background=dark
> :set background?
> background=dark
> :hi Normal ctermfg=grey ctermbg=234
> :set background?
> background=light
> :hi Normal ctermfg=grey ctermbg=0
> :set background?
> background=dark

> as you can see, the "hi" command changes background to light when
> ctermbg is set to 234, however, according to
> http://upload.wikimedia.org/wikipedia/commons/9/95/Xterm_color_chart.png
> color 234 is indeed a dark grey

I see the problem:

7728           if (color >= 0)
7729            {
7730                if (termcap_active)
7731                    term_bg_color(color);
7732                if (t_colors < 16)
7733                    i = (color == 0 || color == 4);
7734                else
7735                    i = (color < 7 || color == 8);
7736                /* Set the 'background' option if the value is
7737                 * wrong. */
7738                if (i != (*p_bg == 'd'))
7739                    set_option_value((char_u *)"bg", 0L,
7740                            i ?  (char_u *)"dark"
7741                              : (char_u *)"light", 0);
7742            }

i.e. Vim always sets a light background for all colors except the first 
7 and color 8 for which it will set a dark background. I don't think Vim 
should try to determine what color is used and depending on it's value 
try to set a sane 'bg' value for the other 256 colors (in a 256 color 
terminal or the 88 rxvt color cube) so for now, I would propose to 
adjust the logic only slightly to something like this:

diff --git a/src/syntax.c b/src/syntax.c
--- a/src/syntax.c
+++ b/src/syntax.c
@@ -7731,6 +7731,14 @@
                                term_bg_color(color);
                            if (t_colors < 16)
                                i = (color == 0 || color == 4);
+                           else if (t_colors == 256)
+                           {
+                               i = (color < 7 || color == 8 ||
+                                       (color > 231 && color < 244));
+                               if (i > 16 && i < 232)
+                                   i = (*p_bg == 'd');
+                           }
+

Which means only for the lower 12 (dark) gray colors (232 until 243) in 
the 256 color cube set the 'bg' to dark, for all other (except the ones 
mentioned above) leave the bg setting alone.

Best,
Christian
-- 
Die Radfahrer haben einen alten Wunsch der Menschheit verwirklicht:
Im Sitzen zu wandern.
                -- Franz Molnar

-- 
-- 
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/groups/opt_out.

Raspunde prin e-mail lui