diff options
| author | Devin J. Pohly <djpohly@gmail.com> | 2018-02-21 23:54:29 -0600 |
|---|---|---|
| committer | Devin J. Pohly <djpohly@gmail.com> | 2018-02-25 21:53:24 -0600 |
| commit | cfc7acdfd923924ae150a32061fb95987697b159 (patch) | |
| tree | 81b6e86f3f21c1263c58880ccc0e45ac885cf627 /st.c | |
| parent | Move terminal-related selection logic into st.c (diff) | |
| download | st-cfc7acdfd923924ae150a32061fb95987697b159.tar.gz st-cfc7acdfd923924ae150a32061fb95987697b159.zip | |
Move remaining selection mode logic into selextend
The "done" parameter indicates a change which finalizes the selection
(e.g. a mouse button release as opposed to motion).
Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
Diffstat (limited to 'st.c')
| -rw-r--r-- | st.c | 14 |
1 files changed, 12 insertions, 2 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 |
