aboutsummaryrefslogtreecommitdiff
path: root/st.c
diff options
context:
space:
mode:
authorDevin J. Pohly <djpohly@gmail.com>2018-02-21 23:54:29 -0600
committerDevin J. Pohly <djpohly@gmail.com>2018-02-25 21:53:24 -0600
commitcfc7acdfd923924ae150a32061fb95987697b159 (patch)
tree81b6e86f3f21c1263c58880ccc0e45ac885cf627 /st.c
parentbcb5d3adbe57ead05a829e5144c2ba1dc465865f (diff)
downloadst-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.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/st.c b/st.c
index 21cba9e..b7e215e 100644
--- a/st.c
+++ b/st.c
@@ -167,11 +167,11 @@ static ssize_t xwrite(int, const char *, size_t);
167 167
168/* Globals */ 168/* Globals */
169Term term; 169Term term;
170Selection sel;
171int cmdfd; 170int cmdfd;
172pid_t pid; 171pid_t pid;
173int oldbutton = 3; /* button event on startup: 3 = release */ 172int oldbutton = 3; /* button event on startup: 3 = release */
174 173
174static Selection sel;
175static CSIEscape csiescseq; 175static CSIEscape csiescseq;
176static STREscape strescseq; 176static STREscape strescseq;
177static int iofd = 1; 177static int iofd = 1;
@@ -402,9 +402,17 @@ selstart(int col, int row, int snap)
402} 402}
403 403
404void 404void
405selextend(int col, int row, int type) 405selextend(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
424void 434void