diff options
| -rw-r--r-- | st.c | 14 | ||||
| -rw-r--r-- | st.h | 3 | ||||
| -rw-r--r-- | x.c | 27 |
3 files changed, 22 insertions, 22 deletions
| @@ -167,11 +167,11 @@ static ssize_t xwrite(int, const char *, size_t); | |||
| 167 | 167 | ||
| 168 | /* Globals */ | 168 | /* Globals */ |
| 169 | Term term; | 169 | Term term; |
| 170 | Selection sel; | ||
| 171 | int cmdfd; | 170 | int cmdfd; |
| 172 | pid_t pid; | 171 | pid_t pid; |
| 173 | int oldbutton = 3; /* button event on startup: 3 = release */ | 172 | int oldbutton = 3; /* button event on startup: 3 = release */ |
| 174 | 173 | ||
| 174 | static Selection sel; | ||
| 175 | static CSIEscape csiescseq; | 175 | static CSIEscape csiescseq; |
| 176 | static STREscape strescseq; | 176 | static STREscape strescseq; |
| 177 | static int iofd = 1; | 177 | static int iofd = 1; |
| @@ -402,9 +402,17 @@ selstart(int col, int row, int snap) | |||
| 402 | } | 402 | } |
| 403 | 403 | ||
| 404 | void | 404 | void |
| 405 | selextend(int col, int row, int type) | 405 | selextend(int col, int row, int type, int done) |
| 406 | { | 406 | { |
| 407 | int oldey, oldex, oldsby, oldsey, oldtype; | 407 | int oldey, oldex, oldsby, oldsey, oldtype; |
| 408 | |||
| 409 | if (!sel.mode) | ||
| 410 | return; | ||
| 411 | if (done && sel.mode == SEL_EMPTY) { | ||
| 412 | selclear(); | ||
| 413 | return; | ||
| 414 | } | ||
| 415 | |||
| 408 | oldey = sel.oe.y; | 416 | oldey = sel.oe.y; |
| 409 | oldex = sel.oe.x; | 417 | oldex = sel.oe.x; |
| 410 | oldsby = sel.nb.y; | 418 | oldsby = sel.nb.y; |
| @@ -419,6 +427,8 @@ selextend(int col, int row, int type) | |||
| 419 | 427 | ||
| 420 | if (oldey != sel.oe.y || oldex != sel.oe.x || oldtype != sel.type) | 428 | if (oldey != sel.oe.y || oldex != sel.oe.x || oldtype != sel.type) |
| 421 | tsetdirt(MIN(sel.nb.y, oldsby), MAX(sel.ne.y, oldsey)); | 429 | tsetdirt(MIN(sel.nb.y, oldsby), MAX(sel.ne.y, oldsey)); |
| 430 | |||
| 431 | sel.mode = done ? SEL_IDLE : SEL_READY; | ||
| 422 | } | 432 | } |
| 423 | 433 | ||
| 424 | void | 434 | void |
| @@ -184,7 +184,7 @@ void resettitle(void); | |||
| 184 | void selclear(void); | 184 | void selclear(void); |
| 185 | void selinit(void); | 185 | void selinit(void); |
| 186 | void selstart(int, int, int); | 186 | void selstart(int, int, int); |
| 187 | void selextend(int, int, int); | 187 | void selextend(int, int, int, int); |
| 188 | void selnormalize(void); | 188 | void selnormalize(void); |
| 189 | int selected(int, int); | 189 | int selected(int, int); |
| 190 | char *getsel(void); | 190 | char *getsel(void); |
| @@ -198,7 +198,6 @@ char *xstrdup(char *); | |||
| 198 | 198 | ||
| 199 | /* Globals */ | 199 | /* Globals */ |
| 200 | extern Term term; | 200 | extern Term term; |
| 201 | extern Selection sel; | ||
| 202 | extern int cmdfd; | 201 | extern int cmdfd; |
| 203 | extern pid_t pid; | 202 | extern pid_t pid; |
| 204 | extern int oldbutton; | 203 | extern int oldbutton; |
| @@ -157,7 +157,7 @@ static void selnotify(XEvent *); | |||
| 157 | static void selclear_(XEvent *); | 157 | static void selclear_(XEvent *); |
| 158 | static void selrequest(XEvent *); | 158 | static void selrequest(XEvent *); |
| 159 | static void setsel(char *, Time); | 159 | static void setsel(char *, Time); |
| 160 | static void mousesel(XEvent *); | 160 | static void mousesel(XEvent *, int); |
| 161 | static void mousereport(XEvent *); | 161 | static void mousereport(XEvent *); |
| 162 | static char *kmap(KeySym, uint); | 162 | static char *kmap(KeySym, uint); |
| 163 | static int match(uint, uint); | 163 | static int match(uint, uint); |
| @@ -313,7 +313,7 @@ y2row(int y) | |||
| 313 | } | 313 | } |
| 314 | 314 | ||
| 315 | void | 315 | void |
| 316 | mousesel(XEvent *e) | 316 | mousesel(XEvent *e, int done) |
| 317 | { | 317 | { |
| 318 | int type, seltype = SEL_REGULAR; | 318 | int type, seltype = SEL_REGULAR; |
| 319 | uint state = e->xbutton.state & ~(Button1Mask | forceselmod); | 319 | uint state = e->xbutton.state & ~(Button1Mask | forceselmod); |
| @@ -324,8 +324,9 @@ mousesel(XEvent *e) | |||
| 324 | break; | 324 | break; |
| 325 | } | 325 | } |
| 326 | } | 326 | } |
| 327 | 327 | selextend(x2col(e->xbutton.x), y2row(e->xbutton.y), seltype, done); | |
| 328 | selextend(x2col(e->xbutton.x), y2row(e->xbutton.y), seltype); | 328 | if (done) |
| 329 | setsel(getsel(), e->xbutton.time); | ||
| 329 | } | 330 | } |
| 330 | 331 | ||
| 331 | void | 332 | void |
| @@ -630,16 +631,10 @@ brelease(XEvent *e) | |||
| 630 | return; | 631 | return; |
| 631 | } | 632 | } |
| 632 | 633 | ||
| 633 | if (e->xbutton.button == Button2) { | 634 | if (e->xbutton.button == Button2) |
| 634 | selpaste(NULL); | 635 | selpaste(NULL); |
| 635 | } else if (e->xbutton.button == Button1) { | 636 | else if (e->xbutton.button == Button1) |
| 636 | if (sel.mode == SEL_READY) { | 637 | mousesel(e, 1); |
| 637 | mousesel(e); | ||
| 638 | setsel(getsel(), e->xbutton.time); | ||
| 639 | } else | ||
| 640 | selclear_(NULL); | ||
| 641 | sel.mode = SEL_IDLE; | ||
| 642 | } | ||
| 643 | } | 638 | } |
| 644 | 639 | ||
| 645 | void | 640 | void |
| @@ -650,11 +645,7 @@ bmotion(XEvent *e) | |||
| 650 | return; | 645 | return; |
| 651 | } | 646 | } |
| 652 | 647 | ||
| 653 | if (!sel.mode) | 648 | mousesel(e, 0); |
| 654 | return; | ||
| 655 | |||
| 656 | sel.mode = SEL_READY; | ||
| 657 | mousesel(e); | ||
| 658 | } | 649 | } |
| 659 | 650 | ||
| 660 | void | 651 | void |
