X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=st.c;h=f48dab45194c2f1767aaddbd263316f486b80e34;hb=ede83bd08b922f2f53264876f6500b564d3c5ef0;hp=5946c7c04bf9be54caeb31346d131f59331fa1ea;hpb=bdb850a16a6d7a2d12b2bd5500a3b7d70290a74a;p=st.git diff --git a/st.c b/st.c index 5946c7c..f48dab4 100644 --- a/st.c +++ b/st.c @@ -340,7 +340,7 @@ typedef struct { /* Drawing Context */ typedef struct { - Colour col[LEN(colorname) < 256 ? 256 : LEN(colorname)]; + Colour col[MAX(LEN(colorname), 256)]; Font font, bfont, ifont, ibfont; GC gc; } DC; @@ -765,7 +765,7 @@ selsnap(int mode, int *x, int *y, int direction) { void getbuttoninfo(XEvent *e) { int type; - uint state = e->xbutton.state &~Button1Mask; + uint state = e->xbutton.state & ~(Button1Mask | forceselmod); sel.alt = IS_SET(MODE_ALTSCREEN); @@ -858,7 +858,7 @@ bpress(XEvent *e) { struct timeval now; Mousekey *mk; - if(IS_SET(MODE_MOUSE)) { + if(IS_SET(MODE_MOUSE) && !(e->xbutton.state & forceselmod)) { mousereport(e); return; } @@ -949,7 +949,7 @@ getsel(void) { * st. * FIXME: Fix the computer world. */ - if(y < sel.ne.y && x > 0 && !((gp-1)->mode & ATTR_WRAP)) + if(y < sel.ne.y && !(x > 0 && (gp-1)->mode & ATTR_WRAP)) *ptr++ = '\n'; /* @@ -1090,7 +1090,7 @@ xsetsel(char *str) { void brelease(XEvent *e) { - if(IS_SET(MODE_MOUSE)) { + if(IS_SET(MODE_MOUSE) && !(e->xbutton.state & forceselmod)) { mousereport(e); return; } @@ -1113,7 +1113,7 @@ void bmotion(XEvent *e) { int oldey, oldex, oldsby, oldsey; - if(IS_SET(MODE_MOUSE)) { + if(IS_SET(MODE_MOUSE) && !(e->xbutton.state & forceselmod)) { mousereport(e); return; } @@ -2715,7 +2715,7 @@ sixd_to_16bit(int x) { void xloadcols(void) { - int i, r, g, b; + int i; XRenderColor color = { .alpha = 0xffff }; static bool loaded; Colour *cp; @@ -2725,7 +2725,7 @@ xloadcols(void) { XftColorFree(xw.dpy, xw.vis, xw.cmap, cp); } - /* load colors [0-15] colors and [256-LEN(colorname)[ (config.h) */ + /* load colours [0-15] and [256-LEN(colorname)] (config.h) */ for(i = 0; i < LEN(colorname); i++) { if(!colorname[i]) continue; @@ -2734,27 +2734,20 @@ xloadcols(void) { } } - /* load colors [16-255] ; same colors as xterm */ - for(i = 16, r = 0; r < 6; r++) { - for(g = 0; g < 6; g++) { - for(b = 0; b < 6; b++) { - color.red = sixd_to_16bit(r); - color.green = sixd_to_16bit(g); - color.blue = sixd_to_16bit(b); - if(!XftColorAllocValue(xw.dpy, xw.vis, xw.cmap, &color, &dc.col[i])) { - die("Could not allocate color %d\n", i); - } - i++; - } - } + /* load colours [16-231] ; same colours as xterm */ + for(i = 16; i < 6*6*6+16; i++) { + color.red = sixd_to_16bit( ((i-16)/36)%6 ); + color.green = sixd_to_16bit( ((i-16)/6) %6 ); + color.blue = sixd_to_16bit( ((i-16)/1) %6 ); + if(!XftColorAllocValue(xw.dpy, xw.vis, xw.cmap, &color, &dc.col[i])) + die("Could not allocate color %d\n", i); } - for(r = 0; r < 24; r++, i++) { - color.red = color.green = color.blue = 0x0808 + 0x0a0a * r; - if(!XftColorAllocValue(xw.dpy, xw.vis, xw.cmap, &color, - &dc.col[i])) { + /* load colours [232-255] ; grayscale */ + for(; i < 256; i++) { + color.red = color.green = color.blue = 0x0808 + 0x0a0a * (i-(6*6*6+16)); + if(!XftColorAllocValue(xw.dpy, xw.vis, xw.cmap, &color, &dc.col[i])) die("Could not allocate color %d\n", i); - } } loaded = true; } @@ -3149,24 +3142,20 @@ xdraws(char *s, Glyph base, int x, int y, int charlen, int bytelen) { } if(base.mode & ATTR_BOLD) { - if(BETWEEN(base.fg, 0, 7)) { - /* basic system colors */ - fg = &dc.col[base.fg + 8]; - } else if(BETWEEN(base.fg, 16, 195)) { - /* 256 colors */ - fg = &dc.col[base.fg + 36]; - } else if(BETWEEN(base.fg, 232, 251)) { - /* greyscale */ - fg = &dc.col[base.fg + 4]; - } /* - * Those ranges will not be brightened: - * 8 - 15 – bright system colors - * 196 - 231 – highest 256 color cube - * 252 - 255 – brightest colors in greyscale + * change basic system colours [0-7] + * to bright system colours [8-15] */ - font = &dc.bfont; - frcflags = FRC_BOLD; + if(BETWEEN(base.fg, 0, 7)) + fg = &dc.col[base.fg + 8]; + + if(base.mode & ATTR_ITALIC) { + font = &dc.ibfont; + frcflags = FRC_ITALICBOLD; + } else { + font = &dc.bfont; + frcflags = FRC_BOLD; + } } if(IS_SET(MODE_REVERSE)) {