diff options
author | Devin J. Pohly <djpohly@gmail.com> | 2018-02-21 22:48:28 -0600 |
---|---|---|
committer | Devin J. Pohly <djpohly@gmail.com> | 2018-02-25 21:53:24 -0600 |
commit | 138caf294ea4d7968df36ead9d5ff5fc49f6215f (patch) | |
tree | 195d9158175673e0a59d8fd5e013e5506c652bce | |
parent | d84f3f4bd15e7d65fc0334cf7d62913c901bad00 (diff) | |
download | st-patched-138caf294ea4d7968df36ead9d5ff5fc49f6215f.tar.bz2 st-patched-138caf294ea4d7968df36ead9d5ff5fc49f6215f.tar.xz st-patched-138caf294ea4d7968df36ead9d5ff5fc49f6215f.zip |
Have selected() check whether selection exists
Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
-rw-r--r-- | st.c | 3 | ||||
-rw-r--r-- | x.c | 10 |
2 files changed, 6 insertions, 7 deletions
@@ -419,7 +419,8 @@ selnormalize(void) | |||
419 | int | 419 | int |
420 | selected(int x, int y) | 420 | selected(int x, int y) |
421 | { | 421 | { |
422 | if (sel.mode == SEL_EMPTY) | 422 | if (sel.mode == SEL_EMPTY || sel.ob.x == -1 || |
423 | sel.alt != IS_SET(MODE_ALTSCREEN)) | ||
423 | return 0; | 424 | return 0; |
424 | 425 | ||
425 | if (sel.type == SEL_RECTANGULAR) | 426 | if (sel.type == SEL_RECTANGULAR) |
@@ -1418,7 +1418,6 @@ xdrawcursor(void) | |||
1418 | static int oldx = 0, oldy = 0; | 1418 | static int oldx = 0, oldy = 0; |
1419 | int curx; | 1419 | int curx; |
1420 | Glyph g = {' ', ATTR_NULL, defaultbg, defaultcs}, og; | 1420 | Glyph g = {' ', ATTR_NULL, defaultbg, defaultcs}, og; |
1421 | int ena_sel = sel.ob.x != -1 && sel.alt == IS_SET(MODE_ALTSCREEN); | ||
1422 | Color drawcol; | 1421 | Color drawcol; |
1423 | 1422 | ||
1424 | LIMIT(oldx, 0, term.col-1); | 1423 | LIMIT(oldx, 0, term.col-1); |
@@ -1434,7 +1433,7 @@ xdrawcursor(void) | |||
1434 | 1433 | ||
1435 | /* remove the old cursor */ | 1434 | /* remove the old cursor */ |
1436 | og = term.line[oldy][oldx]; | 1435 | og = term.line[oldy][oldx]; |
1437 | if (ena_sel && selected(oldx, oldy)) | 1436 | if (selected(oldx, oldy)) |
1438 | og.mode ^= ATTR_REVERSE; | 1437 | og.mode ^= ATTR_REVERSE; |
1439 | xdrawglyph(og, oldx, oldy); | 1438 | xdrawglyph(og, oldx, oldy); |
1440 | 1439 | ||
@@ -1448,7 +1447,7 @@ xdrawcursor(void) | |||
1448 | if (IS_SET(MODE_REVERSE)) { | 1447 | if (IS_SET(MODE_REVERSE)) { |
1449 | g.mode |= ATTR_REVERSE; | 1448 | g.mode |= ATTR_REVERSE; |
1450 | g.bg = defaultfg; | 1449 | g.bg = defaultfg; |
1451 | if (ena_sel && selected(term.c.x, term.c.y)) { | 1450 | if (selected(term.c.x, term.c.y)) { |
1452 | drawcol = dc.col[defaultcs]; | 1451 | drawcol = dc.col[defaultcs]; |
1453 | g.fg = defaultrcs; | 1452 | g.fg = defaultrcs; |
1454 | } else { | 1453 | } else { |
@@ -1456,7 +1455,7 @@ xdrawcursor(void) | |||
1456 | g.fg = defaultcs; | 1455 | g.fg = defaultcs; |
1457 | } | 1456 | } |
1458 | } else { | 1457 | } else { |
1459 | if (ena_sel && selected(term.c.x, term.c.y)) { | 1458 | if (selected(term.c.x, term.c.y)) { |
1460 | drawcol = dc.col[defaultrcs]; | 1459 | drawcol = dc.col[defaultrcs]; |
1461 | g.fg = defaultfg; | 1460 | g.fg = defaultfg; |
1462 | g.bg = defaultrcs; | 1461 | g.bg = defaultrcs; |
@@ -1555,7 +1554,6 @@ drawregion(int x1, int y1, int x2, int y2) | |||
1555 | int i, x, y, ox, numspecs; | 1554 | int i, x, y, ox, numspecs; |
1556 | Glyph base, new; | 1555 | Glyph base, new; |
1557 | XftGlyphFontSpec *specs; | 1556 | XftGlyphFontSpec *specs; |
1558 | int ena_sel = sel.ob.x != -1 && sel.alt == IS_SET(MODE_ALTSCREEN); | ||
1559 | 1557 | ||
1560 | if (!(win.state & WIN_VISIBLE)) | 1558 | if (!(win.state & WIN_VISIBLE)) |
1561 | return; | 1559 | return; |
@@ -1574,7 +1572,7 @@ drawregion(int x1, int y1, int x2, int y2) | |||
1574 | new = term.line[y][x]; | 1572 | new = term.line[y][x]; |
1575 | if (new.mode == ATTR_WDUMMY) | 1573 | if (new.mode == ATTR_WDUMMY) |
1576 | continue; | 1574 | continue; |
1577 | if (ena_sel && selected(x, y)) | 1575 | if (selected(x, y)) |
1578 | new.mode ^= ATTR_REVERSE; | 1576 | new.mode ^= ATTR_REVERSE; |
1579 | if (i > 0 && ATTRCMP(base, new)) { | 1577 | if (i > 0 && ATTRCMP(base, new)) { |
1580 | xdrawglyphfontspecs(specs, base, i, ox, y); | 1578 | xdrawglyphfontspecs(specs, base, i, ox, y); |