diff options
| author | Devin J. Pohly <djpohly@gmail.com> | 2018-02-21 23:29:41 -0600 |
|---|---|---|
| committer | Devin J. Pohly <djpohly@gmail.com> | 2018-02-25 21:53:24 -0600 |
| commit | bcb5d3adbe57ead05a829e5144c2ba1dc465865f (patch) | |
| tree | d72e99c54044e02063924f2416ceb9760c2141ec /st.c | |
| parent | Move X-specific selection info into XSelection (diff) | |
| download | st-bcb5d3adbe57ead05a829e5144c2ba1dc465865f.tar.gz st-bcb5d3adbe57ead05a829e5144c2ba1dc465865f.zip | |
Move terminal-related selection logic into st.c
The front-end determines information about mouse clicks and motion, and
the terminal handles the actual selection start/extend/dirty logic by
row and column.
While we're in the neighborhood, we'll also rename getbuttoninfo() to
mousesel() which is, at least, less wrong.
Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
Diffstat (limited to '')
| -rw-r--r-- | st.c | 37 |
1 files changed, 37 insertions, 0 deletions
| @@ -140,6 +140,7 @@ static void tscrollup(int, int); | |||
| 140 | static void tscrolldown(int, int); | 140 | static void tscrolldown(int, int); |
| 141 | static void tsetattr(int *, int); | 141 | static void tsetattr(int *, int); |
| 142 | static void tsetchar(Rune, Glyph *, int, int); | 142 | static void tsetchar(Rune, Glyph *, int, int); |
| 143 | static void tsetdirt(int, int); | ||
| 143 | static void tsetscroll(int, int); | 144 | static void tsetscroll(int, int); |
| 144 | static void tswapscreen(void); | 145 | static void tswapscreen(void); |
| 145 | static void tsetmode(int, int, int *, int); | 146 | static void tsetmode(int, int, int *, int); |
| @@ -385,6 +386,42 @@ tlinelen(int y) | |||
| 385 | } | 386 | } |
| 386 | 387 | ||
| 387 | void | 388 | void |
| 389 | selstart(int col, int row, int snap) | ||
| 390 | { | ||
| 391 | selclear(); | ||
| 392 | sel.mode = SEL_EMPTY; | ||
| 393 | sel.type = SEL_REGULAR; | ||
| 394 | sel.snap = snap; | ||
| 395 | sel.oe.x = sel.ob.x = col; | ||
| 396 | sel.oe.y = sel.ob.y = row; | ||
| 397 | selnormalize(); | ||
| 398 | |||
| 399 | if (sel.snap != 0) | ||
| 400 | sel.mode = SEL_READY; | ||
| 401 | tsetdirt(sel.nb.y, sel.ne.y); | ||
| 402 | } | ||
| 403 | |||
| 404 | void | ||
| 405 | selextend(int col, int row, int type) | ||
| 406 | { | ||
| 407 | int oldey, oldex, oldsby, oldsey, oldtype; | ||
| 408 | oldey = sel.oe.y; | ||
| 409 | oldex = sel.oe.x; | ||
| 410 | oldsby = sel.nb.y; | ||
| 411 | oldsey = sel.ne.y; | ||
| 412 | oldtype = sel.type; | ||
| 413 | |||
| 414 | sel.alt = IS_SET(MODE_ALTSCREEN); | ||
| 415 | sel.oe.x = col; | ||
| 416 | sel.oe.y = row; | ||
| 417 | selnormalize(); | ||
| 418 | sel.type = type; | ||
| 419 | |||
| 420 | if (oldey != sel.oe.y || oldex != sel.oe.x || oldtype != sel.type) | ||
| 421 | tsetdirt(MIN(sel.nb.y, oldsby), MAX(sel.ne.y, oldsey)); | ||
| 422 | } | ||
| 423 | |||
| 424 | void | ||
| 388 | selnormalize(void) | 425 | selnormalize(void) |
| 389 | { | 426 | { |
| 390 | int i; | 427 | int i; |
