Xinqi Bao's Git
projects
/
st.git
/ diff
summary
|
log
|
commit
|
diff
|
tree
raw
|
patch
|
inline
| side by side (parent:
9e3e8ce
)
Simplify selected().
author
noname <
[email protected]
>
Sun, 27 Apr 2014 11:16:41 +0000
(15:16 +0400)
committer
Roberto E. Vargas Caballero <
[email protected]
>
Mon, 28 Apr 2014 16:49:45 +0000
(18:49 +0200)
st.c
diff
|
blob
|
history
diff --git
a/st.c
b/st.c
index
672c47a
..
5198749
100644
(file)
--- a/
st.c
+++ b/
st.c
@@
-674,18
+674,13
@@
selsort(void) {
static inline bool
selected(int x, int 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.x);
+ if(sel.type == SEL_RECTANGULAR)
+ return BETWEEN(y, sel.nb.y, sel.ne.y)
+ && BETWEEN(x, sel.nb.x, sel.ne.x);
- if(sel.type == SEL_RECTANGULAR) {
- return ((sel.nb.y <= y && y <= sel.ne.y)
- && (sel.nb.x <= x && x <= sel.ne.x));
- }
-
- return ((sel.nb.y < y && y < sel.ne.y)
- || (y == sel.ne.y && x <= sel.ne.x))
- || (y == sel.nb.y && x >= sel.nb.x
- && (x <= sel.ne.x || sel.nb.y != sel.ne.y));
+ return BETWEEN(y, sel.nb.y, sel.ne.y)
+ && (y != sel.nb.y || x >= sel.nb.x)
+ && (y != sel.ne.y || x <= sel.ne.x);
}
void
}
void