X-Git-Url: https://git.xinqibao.xyz/st.git/blobdiff_plain/f211bc2eedaa8ea86dc66ad04ccd08938c73a93c..9703859e6c1e2280036dc7992cb4c54688f719f5:/st.c?ds=sidebyside diff --git a/st.c b/st.c index 1497dd2..bff500b 100644 --- a/st.c +++ b/st.c @@ -185,9 +185,9 @@ static char* kmap(KeySym); static void kpress(XEvent *); static void resize(XEvent *); static void focus(XEvent *); -static void brelease(XEvent *e); -static void bpress(XEvent *e); -static void bmotion(XEvent *e); +static void brelease(XEvent *); +static void bpress(XEvent *); +static void bmotion(XEvent *); static void (*handler[LASTEvent])(XEvent *) = { @@ -210,14 +210,21 @@ static int cmdfd; static pid_t pid; static Selection sel; +void +selinit(void) { + sel.mode = 0; + sel.bx = -1; + sel.clip = NULL; +} + static inline int selected(int x, int y) { - if ((sel.ey==y && sel.by==y)) { + if(sel.ey == y && sel.by == y) { int bx = MIN(sel.bx, sel.ex); int ex = MAX(sel.bx, sel.ex); - return (x>=bx && x<=ex); + return BETWEEN(x, bx, ex); } - return (((y>sel.b[1] && y=sel.b[0] && (x<=sel.e[0] || sel.b[1]!=sel.e[1]))); + return ((sel.b[1] < y&&y < sel.e[1]) || (y==sel.e[1] && x<=sel.e[0])) + || (y==sel.b[1] && x>=sel.b[0] && (x<=sel.e[0] || sel.b[1]!=sel.e[1])); } static void getbuttoninfo(XEvent *e, int *b, int *x, int *y) { @@ -225,9 +232,9 @@ static void getbuttoninfo(XEvent *e, int *b, int *x, int *y) { *b=*b==4096?5:*b==2048?4:*b==1024?3:*b==512?2:*b==256?1:-1; *x = e->xbutton.x/xw.cw; *y = e->xbutton.y/xw.ch; - sel.b[0] = sel.by