Christian Brabandt wrote: > On Fr, 10 Jan 2014, Bram Moolenaar wrote: > > > Christian Brabandt wrote: > > > > > 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. > > > > It's a start. However, if we change this we might as well do it > > properly. > > > > In my opinion we should take the color chart and compute the brightness > > of each color. If it's above 50% 'background' should be set to light. > > > > There at least is this image: > > http://upload.wikimedia.org/wikipedia/en/thumb/1/15/Xterm_256color_chart.svg/2000px-Xterm_256color_chart.svg.png > > > > A list of #RGB values could be used to compute the brightness. > > How about the attached patch? For colors > 15, it uses the rxvt color > cube for 88 color terminals and the xterm color cube for 256 color > terminals and computes the luminance. If the luminance is above a > certain treshhold, it uses a light background, else it uses a dark > background. > > It uses the same logic, that I have been using for my Colorizer plugin > (https://github.com/chrisbra/color_highlight) for which I haven't seen > any complaints about the luminance yet (of course this doesn't mean this > is correct by all means).
I suppose this would be OK. But I was thinking of a built-in table. Avoids computing stuff at runtime, just lookup the flag. -- The coffee just wasn't strong enough to defend itself -- Tom Waits /// 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/groups/opt_out.
