aboutsummaryrefslogtreecommitdiff
path: root/x.c
diff options
context:
space:
mode:
authorJules Maselbas <jules.maselbas@grenoble-inp.org>2018-07-15 13:53:37 +0200
committerHiltjo Posthuma <hiltjo@codemadness.org>2018-07-15 18:16:52 +0200
commit5535c1f04c665c05faff2a65d5558246b7748d49 (patch)
tree88f6a4d989b1ad7a4355fcdd2ef8bfb965dab315 /x.c
parentb51bcd5553af3db394014efbd78acf7828fa48ff (diff)
downloadst-patched-5535c1f04c665c05faff2a65d5558246b7748d49.tar.bz2
st-patched-5535c1f04c665c05faff2a65d5558246b7748d49.tar.xz
st-patched-5535c1f04c665c05faff2a65d5558246b7748d49.zip
Fix crash when cursor color is truecolor
Reported-by: Ivan Tham <pickfire@riseup.net>
Diffstat (limited to 'x.c')
-rw-r--r--x.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/x.c b/x.c
index b51821d..4155a70 100644
--- a/x.c
+++ b/x.c
@@ -1404,6 +1404,7 @@ void
1404xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og) 1404xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og)
1405{ 1405{
1406 Color drawcol; 1406 Color drawcol;
1407 uint32_t cc;
1407 1408
1408 /* remove the old cursor */ 1409 /* remove the old cursor */
1409 if (selected(ox, oy)) 1410 if (selected(ox, oy))
@@ -1419,14 +1420,22 @@ xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og)
1419 g.mode &= ATTR_BOLD|ATTR_ITALIC|ATTR_UNDERLINE|ATTR_STRUCK|ATTR_WIDE; 1420 g.mode &= ATTR_BOLD|ATTR_ITALIC|ATTR_UNDERLINE|ATTR_STRUCK|ATTR_WIDE;
1420 1421
1421 if (selected(cx, cy)) { 1422 if (selected(cx, cy)) {
1422 drawcol = dc.col[g.bg]; 1423 cc = g.bg;
1423 } else { 1424 } else {
1424 g.mode |= ATTR_REVERSE; 1425 g.mode |= ATTR_REVERSE;
1425
1426 if (g.mode & ATTR_BOLD && BETWEEN(g.fg, 0, 7)) 1426 if (g.mode & ATTR_BOLD && BETWEEN(g.fg, 0, 7))
1427 drawcol = dc.col[g.fg + 8]; 1427 cc = g.fg + 8;
1428 else 1428 else
1429 drawcol = dc.col[g.fg]; 1429 cc = g.fg;
1430 }
1431
1432 if (IS_TRUECOL(cc)) {
1433 drawcol.color.alpha = 0xffff;
1434 drawcol.color.red = TRUERED(cc);
1435 drawcol.color.green = TRUEGREEN(cc);
1436 drawcol.color.blue = TRUEBLUE(cc);
1437 } else {
1438 drawcol = dc.col[cc];
1430 } 1439 }
1431 1440
1432 if (IS_SET(MODE_REVERSE)) { 1441 if (IS_SET(MODE_REVERSE)) {