X-Git-Url: https://git.danieliu.xyz/?a=blobdiff_plain;f=st.c;h=16803ec388228153eb8a841b85ec11babc92deb0;hb=8b602a37a65a3c001bd9334d8b1cfc17fc5dd45c;hp=2811876adf260efa70edcafc211acc0da6c2e746;hpb=5d3318c0c734a1d65e78ed4ce103b4517be8ec3b;p=st.git diff --git a/st.c b/st.c index 2811876..16803ec 100644 --- a/st.c +++ b/st.c @@ -888,11 +888,7 @@ bpress(XEvent *e) { gettimeofday(&now, NULL); /* Clear previous selection, logically and visually. */ - if(sel.ob.x != -1) { - sel.ob.x = -1; - tsetdirt(sel.nb.y, sel.ne.y); - draw(); - } + selclear(NULL); sel.mode = 1; sel.type = SEL_REGULAR; sel.oe.x = sel.ob.x = x2col(e->xbutton.x); @@ -920,7 +916,6 @@ bpress(XEvent *e) { if(sel.snap != 0) { sel.mode++; tsetdirt(sel.nb.y, sel.ne.y); - draw(); } sel.tclick2 = sel.tclick1; sel.tclick1 = now; @@ -1108,7 +1103,7 @@ brelease(XEvent *e) { selpaste(NULL); } else if(e->xbutton.button == Button1) { if(sel.mode < 2) { - sel.ob.x = -1; + selclear(NULL); } else { getbuttoninfo(e); selcopy(); @@ -1441,7 +1436,7 @@ selscroll(int orig, int n) { if(BETWEEN(sel.ob.y, orig, term.bot) || BETWEEN(sel.oe.y, orig, term.bot)) { if((sel.ob.y += n) > term.bot || (sel.oe.y += n) < term.top) { - sel.ob.x = -1; + selclear(NULL); return; } if(sel.type == SEL_RECTANGULAR) { @@ -1951,7 +1946,7 @@ csihandle(void) { tputtab(1); break; case 'J': /* ED -- Clear screen */ - sel.ob.x = -1; + selclear(NULL); switch(csiescseq.arg[0]) { case 0: /* below */ tclearregion(term.c.x, term.c.y, term.col-1, term.c.y); @@ -2448,7 +2443,7 @@ tputc(char *c, int len) { if(control && !(term.c.attr.mode & ATTR_GFX)) return; if(sel.ob.x != -1 && BETWEEN(term.c.y, sel.ob.y, sel.oe.y)) - sel.ob.x = -1; + selclear(NULL); if(IS_SET(MODE_WRAP) && (term.c.state & CURSOR_WRAPNEXT)) { term.line[term.c.y][term.c.x].mode |= ATTR_WRAP; tnewline(1); @@ -3360,17 +3355,17 @@ focus(XEvent *ev) { } } -inline bool +static inline bool match(uint mask, uint state) { - state &= ~(ignoremod); + state &= ~ignoremod; if(mask == XK_NO_MOD && state) return false; if(mask != XK_ANY_MOD && mask != XK_NO_MOD && !state) return false; - if((state & mask) != state) - return false; - return true; + if(mask == XK_ANY_MOD) + return true; + return state == mask; } void @@ -3380,7 +3375,6 @@ numlock(const Arg *dummy) { char* kmap(KeySym k, uint state) { - uint mask; Key *kp; int i; @@ -3395,12 +3389,10 @@ kmap(KeySym k, uint state) { } for(kp = key; kp < key + LEN(key); kp++) { - mask = kp->mask; - if(kp->k != k) continue; - if(!match(mask, state)) + if(!match(kp->mask, state)) continue; if(kp->appkey > 0) {