diff options
author | Christoph Lohmann <20h@r-36.net> | 2013-05-26 16:10:22 +0200 |
---|---|---|
committer | Christoph Lohmann <20h@r-36.net> | 2013-05-26 16:10:22 +0200 |
commit | b5144100a59956b5bf69614a077bd4d252d7dc6c (patch) | |
tree | 661b2729a418566faa03ec42cf9269dd1508164d | |
parent | 8f1bef05025c0052603f7ca30552a43395b4c13f (diff) | |
download | st-patched-b5144100a59956b5bf69614a077bd4d252d7dc6c.tar.bz2 st-patched-b5144100a59956b5bf69614a077bd4d252d7dc6c.tar.xz st-patched-b5144100a59956b5bf69614a077bd4d252d7dc6c.zip |
Fixing the selection in a single line again.
Thanks p37sitdu@lavabit.com!
-rw-r--r-- | st.c | 11 |
1 files changed, 8 insertions, 3 deletions
@@ -667,16 +667,21 @@ y2row(int y) { | |||
667 | 667 | ||
668 | static void | 668 | static void |
669 | selsort(void) { | 669 | selsort(void) { |
670 | sel.nb.x = sel.ob.y < sel.oe.y ? sel.ob.x : sel.oe.x; | 670 | if(sel.ob.y == sel.oe.y) { |
671 | sel.nb.x = MIN(sel.ob.x, sel.oe.x); | ||
672 | sel.ne.x = MAX(sel.ob.x, sel.oe.x); | ||
673 | } else { | ||
674 | sel.nb.x = sel.ob.y < sel.oe.y ? sel.ob.x : sel.oe.x; | ||
675 | sel.ne.x = sel.ob.y < sel.oe.y ? sel.oe.x : sel.ob.x; | ||
676 | } | ||
671 | sel.nb.y = MIN(sel.ob.y, sel.oe.y); | 677 | sel.nb.y = MIN(sel.ob.y, sel.oe.y); |
672 | sel.ne.x = sel.ob.y < sel.oe.y ? sel.oe.x : sel.ob.x; | ||
673 | sel.ne.y = MAX(sel.ob.y, sel.oe.y); | 678 | sel.ne.y = MAX(sel.ob.y, sel.oe.y); |
674 | } | 679 | } |
675 | 680 | ||
676 | static inline bool | 681 | static inline bool |
677 | selected(int x, int y) { | 682 | selected(int x, int y) { |
678 | if(sel.ne.y == y && sel.nb.y == y) | 683 | if(sel.ne.y == y && sel.nb.y == y) |
679 | return BETWEEN(x, sel.nb.x, sel.ne.y); | 684 | return BETWEEN(x, sel.nb.x, sel.ne.x); |
680 | 685 | ||
681 | if(sel.type == SEL_RECTANGULAR) { | 686 | if(sel.type == SEL_RECTANGULAR) { |
682 | return ((sel.nb.y <= y && y <= sel.ne.y) | 687 | return ((sel.nb.y <= y && y <= sel.ne.y) |