mirror of
https://github.com/alrayyes/st.git
synced 2024-11-26 12:56:22 +00:00
parent
a32c5f5726
commit
8b4cfcea73
1 changed files with 18 additions and 14 deletions
32
st.c
32
st.c
|
@ -2757,28 +2757,32 @@ xloadcols(void) {
|
||||||
int
|
int
|
||||||
xsetcolorname(int x, const char *name) {
|
xsetcolorname(int x, const char *name) {
|
||||||
XRenderColor color = { .alpha = 0xffff };
|
XRenderColor color = { .alpha = 0xffff };
|
||||||
|
Colour colour;
|
||||||
if(!BETWEEN(x, 0, LEN(colorname)))
|
if(!BETWEEN(x, 0, LEN(colorname)))
|
||||||
return -1;
|
return -1;
|
||||||
if(!name) {
|
if(!name) {
|
||||||
if(BETWEEN(x, 16, 6*6*6+16)) { /* 256 colour */
|
if(BETWEEN(x, 16, 16 + 215)) {
|
||||||
color.red = sixd_to_16bit( ((x-16)/36)%6 );
|
int r = (x - 16) / 36, g = ((x - 16) % 36) / 6, b = (x - 16) % 6;
|
||||||
color.green = sixd_to_16bit( ((x-16)/6) %6 );
|
color.red = sixd_to_16bit(r);
|
||||||
color.blue = sixd_to_16bit( ((x-16)/1) %6 );
|
color.green = sixd_to_16bit(g);
|
||||||
if(!XftColorAllocValue(xw.dpy, xw.vis, xw.cmap, &color, &dc.col[x]))
|
color.blue = sixd_to_16bit(b);
|
||||||
die("Could not allocate color %d\n", x);
|
if(!XftColorAllocValue(xw.dpy, xw.vis, xw.cmap, &color, &colour))
|
||||||
|
return 0; /* something went wrong */
|
||||||
|
dc.col[x] = colour;
|
||||||
return 1;
|
return 1;
|
||||||
} else if(BETWEEN(x, 6*6*6+16, 255)) { /* grayscale */
|
} else if(BETWEEN(x, 16 + 216, 255)) {
|
||||||
color.red = color.green = color.blue = 0x0808 + 0x0a0a * (x-(6*6*6+16));
|
color.red = color.green = color.blue = 0x0808 + 0x0a0a * (x - (16 + 216));
|
||||||
if(!XftColorAllocValue(xw.dpy, xw.vis, xw.cmap, &color, &dc.col[x]))
|
if(!XftColorAllocValue(xw.dpy, xw.vis, xw.cmap, &color, &colour))
|
||||||
die("Could not allocate color %d\n", x);
|
return 0; /* something went wrong */
|
||||||
|
dc.col[x] = colour;
|
||||||
return 1;
|
return 1;
|
||||||
} else { /* system colours */
|
} else {
|
||||||
name = colorname[x];
|
name = colorname[x];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!XftColorAllocName(xw.dpy, xw.vis, xw.cmap, name, &dc.col[x]))
|
if(!XftColorAllocName(xw.dpy, xw.vis, xw.cmap, name, &colour))
|
||||||
return 0; /* invalid name */
|
return 0;
|
||||||
|
dc.col[x] = colour;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue