diff options
author | Devin J. Pohly <djpohly@gmail.com> | 2018-02-24 17:09:13 -0600 |
---|---|---|
committer | Devin J. Pohly <djpohly@gmail.com> | 2018-02-25 21:56:26 -0600 |
commit | 20e0da7f14cc5f30863e0b8014fa223fbaff1e30 (patch) | |
tree | 565e9db20e2873c6029553bb622b0209a76fc560 | |
parent | 403c57ebb5b3745ff93e49b87e526c49dc59a5b9 (diff) | |
download | st-patched-20e0da7f14cc5f30863e0b8014fa223fbaff1e30.tar.bz2 st-patched-20e0da7f14cc5f30863e0b8014fa223fbaff1e30.tar.xz st-patched-20e0da7f14cc5f30863e0b8014fa223fbaff1e30.zip |
General cleanup
Simplifies logic in a couple places and removes a redundant function
call.
Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
-rw-r--r-- | st.c | 1 | ||||
-rw-r--r-- | x.c | 46 |
2 files changed, 21 insertions, 26 deletions
@@ -1693,7 +1693,6 @@ csihandle(void) | |||
1693 | tputtab(csiescseq.arg[0]); | 1693 | tputtab(csiescseq.arg[0]); |
1694 | break; | 1694 | break; |
1695 | case 'J': /* ED -- Clear screen */ | 1695 | case 'J': /* ED -- Clear screen */ |
1696 | selclear(); | ||
1697 | switch (csiescseq.arg[0]) { | 1696 | switch (csiescseq.arg[0]) { |
1698 | case 0: /* below */ | 1697 | case 0: /* below */ |
1699 | tclearregion(term.c.x, term.c.y, term.col-1, term.c.y); | 1698 | tclearregion(term.c.x, term.c.y, term.col-1, term.c.y); |
@@ -149,8 +149,8 @@ static void xunloadfont(Font *); | |||
149 | static void xunloadfonts(void); | 149 | static void xunloadfonts(void); |
150 | static void xsetenv(void); | 150 | static void xsetenv(void); |
151 | static void xseturgency(int); | 151 | static void xseturgency(int); |
152 | static int x2col(int); | 152 | static int evcol(XEvent *); |
153 | static int y2row(int); | 153 | static int evrow(XEvent *); |
154 | 154 | ||
155 | static void expose(XEvent *); | 155 | static void expose(XEvent *); |
156 | static void visibility(XEvent *); | 156 | static void visibility(XEvent *); |
@@ -308,17 +308,17 @@ zoomreset(const Arg *arg) | |||
308 | } | 308 | } |
309 | 309 | ||
310 | int | 310 | int |
311 | x2col(int x) | 311 | evcol(XEvent *e) |
312 | { | 312 | { |
313 | x -= borderpx; | 313 | int x = e->xbutton.x - borderpx; |
314 | LIMIT(x, 0, win.tw - 1); | 314 | LIMIT(x, 0, win.tw - 1); |
315 | return x / win.cw; | 315 | return x / win.cw; |
316 | } | 316 | } |
317 | 317 | ||
318 | int | 318 | int |
319 | y2row(int y) | 319 | evrow(XEvent *e) |
320 | { | 320 | { |
321 | y -= borderpx; | 321 | int y = e->xbutton.y - borderpx; |
322 | LIMIT(y, 0, win.th - 1); | 322 | LIMIT(y, 0, win.th - 1); |
323 | return y / win.ch; | 323 | return y / win.ch; |
324 | } | 324 | } |
@@ -335,7 +335,7 @@ mousesel(XEvent *e, int done) | |||
335 | break; | 335 | break; |
336 | } | 336 | } |
337 | } | 337 | } |
338 | selextend(x2col(e->xbutton.x), y2row(e->xbutton.y), seltype, done); | 338 | selextend(evcol(e), evrow(e), seltype, done); |
339 | if (done) | 339 | if (done) |
340 | setsel(getsel(), e->xbutton.time); | 340 | setsel(getsel(), e->xbutton.time); |
341 | } | 341 | } |
@@ -343,9 +343,8 @@ mousesel(XEvent *e, int done) | |||
343 | void | 343 | void |
344 | mousereport(XEvent *e) | 344 | mousereport(XEvent *e) |
345 | { | 345 | { |
346 | int x = x2col(e->xbutton.x), y = y2row(e->xbutton.y), | 346 | int len, x = evcol(e), y = evrow(e), |
347 | button = e->xbutton.button, state = e->xbutton.state, | 347 | button = e->xbutton.button, state = e->xbutton.state; |
348 | len; | ||
349 | char buf[40]; | 348 | char buf[40]; |
350 | static int ox, oy; | 349 | static int ox, oy; |
351 | 350 | ||
@@ -440,7 +439,7 @@ bpress(XEvent *e) | |||
440 | xsel.tclick2 = xsel.tclick1; | 439 | xsel.tclick2 = xsel.tclick1; |
441 | xsel.tclick1 = now; | 440 | xsel.tclick1 = now; |
442 | 441 | ||
443 | selstart(x2col(e->xbutton.x), y2row(e->xbutton.y), snap); | 442 | selstart(evcol(e), evrow(e), snap); |
444 | } | 443 | } |
445 | } | 444 | } |
446 | 445 | ||
@@ -464,18 +463,16 @@ selnotify(XEvent *e) | |||
464 | ulong nitems, ofs, rem; | 463 | ulong nitems, ofs, rem; |
465 | int format; | 464 | int format; |
466 | uchar *data, *last, *repl; | 465 | uchar *data, *last, *repl; |
467 | Atom type, incratom, property; | 466 | Atom type, incratom, property = None; |
468 | 467 | ||
469 | incratom = XInternAtom(xw.dpy, "INCR", 0); | 468 | incratom = XInternAtom(xw.dpy, "INCR", 0); |
470 | 469 | ||
471 | ofs = 0; | 470 | ofs = 0; |
472 | if (e->type == SelectionNotify) { | 471 | if (e->type == SelectionNotify) |
473 | property = e->xselection.property; | 472 | property = e->xselection.property; |
474 | } else if(e->type == PropertyNotify) { | 473 | else if (e->type == PropertyNotify) |
475 | property = e->xproperty.atom; | 474 | property = e->xproperty.atom; |
476 | } else { | 475 | |
477 | return; | ||
478 | } | ||
479 | if (property == None) | 476 | if (property == None) |
480 | return; | 477 | return; |
481 | 478 | ||
@@ -625,7 +622,7 @@ setsel(char *str, Time t) | |||
625 | 622 | ||
626 | XSetSelectionOwner(xw.dpy, XA_PRIMARY, xw.win, t); | 623 | XSetSelectionOwner(xw.dpy, XA_PRIMARY, xw.win, t); |
627 | if (XGetSelectionOwner(xw.dpy, XA_PRIMARY) != xw.win) | 624 | if (XGetSelectionOwner(xw.dpy, XA_PRIMARY) != xw.win) |
628 | selclear_(NULL); | 625 | selclear(); |
629 | } | 626 | } |
630 | 627 | ||
631 | void | 628 | void |
@@ -1407,12 +1404,13 @@ xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og) | |||
1407 | og.mode ^= ATTR_REVERSE; | 1404 | og.mode ^= ATTR_REVERSE; |
1408 | xdrawglyph(og, ox, oy); | 1405 | xdrawglyph(og, ox, oy); |
1409 | 1406 | ||
1407 | if (IS_SET(MODE_HIDE)) | ||
1408 | return; | ||
1409 | |||
1410 | /* | 1410 | /* |
1411 | * Select the right color for the right mode. | 1411 | * Select the right color for the right mode. |
1412 | */ | 1412 | */ |
1413 | g.mode &= ATTR_BOLD|ATTR_ITALIC|ATTR_UNDERLINE|ATTR_STRUCK|ATTR_WIDE; | 1413 | g.mode &= ATTR_BOLD|ATTR_ITALIC|ATTR_UNDERLINE|ATTR_STRUCK|ATTR_WIDE; |
1414 | g.fg = defaultbg; | ||
1415 | g.bg = defaultcs; | ||
1416 | 1414 | ||
1417 | if (IS_SET(MODE_REVERSE)) { | 1415 | if (IS_SET(MODE_REVERSE)) { |
1418 | g.mode |= ATTR_REVERSE; | 1416 | g.mode |= ATTR_REVERSE; |
@@ -1426,17 +1424,15 @@ xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og) | |||
1426 | } | 1424 | } |
1427 | } else { | 1425 | } else { |
1428 | if (selected(cx, cy)) { | 1426 | if (selected(cx, cy)) { |
1429 | drawcol = dc.col[defaultrcs]; | ||
1430 | g.fg = defaultfg; | 1427 | g.fg = defaultfg; |
1431 | g.bg = defaultrcs; | 1428 | g.bg = defaultrcs; |
1432 | } else { | 1429 | } else { |
1433 | drawcol = dc.col[defaultcs]; | 1430 | g.fg = defaultbg; |
1431 | g.bg = defaultcs; | ||
1434 | } | 1432 | } |
1433 | drawcol = dc.col[g.bg]; | ||
1435 | } | 1434 | } |
1436 | 1435 | ||
1437 | if (IS_SET(MODE_HIDE)) | ||
1438 | return; | ||
1439 | |||
1440 | /* draw the new one */ | 1436 | /* draw the new one */ |
1441 | if (IS_SET(MODE_FOCUSED)) { | 1437 | if (IS_SET(MODE_FOCUSED)) { |
1442 | switch (win.cursor) { | 1438 | switch (win.cursor) { |