LukeSmithxyz / st

Luke's fork of the suckless simple terminal (st) with vim bindings and Xresource compatibility.
MIT License
1.64k stars 1.01k forks source link

Not using exact color from .Xresources #245

Closed danielepusceddu closed 4 years ago

danielepusceddu commented 4 years ago

I am using the gruvbox color scheme in .Xresources. The line is this: st.background: #1d2021 But on the screen I will get color #17191a, found with gpick. I have gruvbox installed in nvim. When I open nvim, the background color is visibly different and gpick tells me it's #1d2021 as expected. This also means that true color works fine, but somehow it's not getting it from the .Xresources. alpha is set to 1.

The background is parsed fine, because if I set it to #ffffff and run xrdb, it will become white.

danielepusceddu commented 4 years ago

After commenting out all of these lines in x.c, I'm finally getting the right color. Again, this is with alpha set to 1. I also had this problem even when alpha wasn't defined at all. I suspect that the colors are being changed because of conversion issues

    /* set alpha value of bg color */

    if (opt_alpha)
        alpha = strtof(opt_alpha, NULL); //maybe this is not exactly 1?
    dc.col[defaultbg].color.alpha = (unsigned short)(0xffff * alpha);
    dc.col[defaultbg].color.red =
        ((unsigned short)(dc.col[defaultbg].color.red * alpha)) & 0xff00;
    dc.col[defaultbg].color.green =
        ((unsigned short)(dc.col[defaultbg].color.green * alpha)) & 0xff00;
    dc.col[defaultbg].color.blue =
        ((unsigned short)(dc.col[defaultbg].color.blue * alpha)) & 0xff00;
    dc.col[defaultbg].pixel &= 0x00FFFFFF;
    dc.col[defaultbg].pixel |= (unsigned char)(0xff * alpha) << 24;