X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=st.c;h=3fcf543a811d1ae26d075a36617e176d2cde3258;hb=8315dc417982936186837edfac24420d0d0e516e;hp=826f745416bfd85ab8da9e8181229179dca53cea;hpb=8f1bef05025c0052603f7ca30552a43395b4c13f;p=st.git diff --git a/st.c b/st.c index 826f745..3fcf543 100644 --- a/st.c +++ b/st.c @@ -667,16 +667,21 @@ y2row(int y) { static void selsort(void) { - sel.nb.x = sel.ob.y < sel.oe.y ? sel.ob.x : sel.oe.x; + if(sel.ob.y == sel.oe.y) { + sel.nb.x = MIN(sel.ob.x, sel.oe.x); + sel.ne.x = MAX(sel.ob.x, sel.oe.x); + } else { + sel.nb.x = sel.ob.y < sel.oe.y ? sel.ob.x : sel.oe.x; + sel.ne.x = sel.ob.y < sel.oe.y ? sel.oe.x : sel.ob.x; + } sel.nb.y = MIN(sel.ob.y, sel.oe.y); - sel.ne.x = sel.ob.y < sel.oe.y ? sel.oe.x : sel.ob.x; sel.ne.y = MAX(sel.ob.y, sel.oe.y); } static inline bool selected(int x, int y) { if(sel.ne.y == y && sel.nb.y == y) - return BETWEEN(x, sel.nb.x, sel.ne.y); + return BETWEEN(x, sel.nb.x, sel.ne.x); if(sel.type == SEL_RECTANGULAR) { return ((sel.nb.y <= y && y <= sel.ne.y) @@ -775,7 +780,7 @@ getbuttoninfo(XEvent *e) { sel.oe.x = x2col(e->xbutton.x); sel.oe.y = y2row(e->xbutton.y); - if (sel.ob.y < sel.oe.y + if(sel.ob.y < sel.oe.y || (sel.ob.y == sel.oe.y && sel.ob.x < sel.oe.x)) { selsnap(sel.snap, &sel.ob.x, &sel.ob.y, -1); selsnap(sel.snap, &sel.oe.x, &sel.oe.y, +1); @@ -783,7 +788,6 @@ getbuttoninfo(XEvent *e) { selsnap(sel.snap, &sel.oe.x, &sel.oe.y, -1); selsnap(sel.snap, &sel.ob.x, &sel.ob.y, +1); } - selsort(); sel.type = SEL_REGULAR; @@ -1094,7 +1098,7 @@ brelease(XEvent *e) { selcopy(); } sel.mode = 0; - term.dirty[sel.oe.y] = 1; + tsetdirt(sel.nb.y, sel.ne.y); } }