diff options
| author | Ivan Delalande <colona@ycc.fr> | 2014-08-20 21:14:08 +0200 |
|---|---|---|
| committer | Roberto E. Vargas Caballero <k0ga@shike2.com> | 2014-08-21 17:50:31 +0200 |
| commit | c490a60b804f467490cd4d8275a181dc37edef9f (patch) | |
| tree | afe57826d9952cd9335cde781cf1fcb4a6ce3235 | |
| parent | Improve readability of enum members (diff) | |
| download | st-c490a60b804f467490cd4d8275a181dc37edef9f.tar.gz st-c490a60b804f467490cd4d8275a181dc37edef9f.zip | |
Move calls to selsnap into selnormalize
This simplifies getbuttoninfo() and bpress(), and fixes a bug which made word
snapping behave incorrectly when a delimiter was at the beginning or end of
line.
Signed-off-by: Roberto E. Vargas Caballero <k0ga@shike2.com>
Diffstat (limited to '')
| -rw-r--r-- | st.c | 14 |
1 files changed, 3 insertions, 11 deletions
| @@ -682,6 +682,9 @@ selnormalize(void) { | |||
| 682 | sel.nb.y = MIN(sel.ob.y, sel.oe.y); | 682 | sel.nb.y = MIN(sel.ob.y, sel.oe.y); |
| 683 | sel.ne.y = MAX(sel.ob.y, sel.oe.y); | 683 | sel.ne.y = MAX(sel.ob.y, sel.oe.y); |
| 684 | 684 | ||
| 685 | selsnap(sel.snap, &sel.nb.x, &sel.nb.y, -1); | ||
| 686 | selsnap(sel.snap, &sel.ne.x, &sel.ne.y, +1); | ||
| 687 | |||
| 685 | /* expand selection over line breaks */ | 688 | /* expand selection over line breaks */ |
| 686 | if (sel.type == SEL_RECTANGULAR) | 689 | if (sel.type == SEL_RECTANGULAR) |
| 687 | return; | 690 | return; |
| @@ -777,15 +780,6 @@ getbuttoninfo(XEvent *e) { | |||
| 777 | 780 | ||
| 778 | sel.oe.x = x2col(e->xbutton.x); | 781 | sel.oe.x = x2col(e->xbutton.x); |
| 779 | sel.oe.y = y2row(e->xbutton.y); | 782 | sel.oe.y = y2row(e->xbutton.y); |
| 780 | |||
| 781 | if(sel.ob.y < sel.oe.y | ||
| 782 | || (sel.ob.y == sel.oe.y && sel.ob.x < sel.oe.x)) { | ||
| 783 | selsnap(sel.snap, &sel.ob.x, &sel.ob.y, -1); | ||
| 784 | selsnap(sel.snap, &sel.oe.x, &sel.oe.y, +1); | ||
| 785 | } else { | ||
| 786 | selsnap(sel.snap, &sel.oe.x, &sel.oe.y, -1); | ||
| 787 | selsnap(sel.snap, &sel.ob.x, &sel.ob.y, +1); | ||
| 788 | } | ||
| 789 | selnormalize(); | 783 | selnormalize(); |
| 790 | 784 | ||
| 791 | sel.type = SEL_REGULAR; | 785 | sel.type = SEL_REGULAR; |
| @@ -900,8 +894,6 @@ bpress(XEvent *e) { | |||
| 900 | } else { | 894 | } else { |
| 901 | sel.snap = 0; | 895 | sel.snap = 0; |
| 902 | } | 896 | } |
| 903 | selsnap(sel.snap, &sel.ob.x, &sel.ob.y, -1); | ||
| 904 | selsnap(sel.snap, &sel.oe.x, &sel.oe.y, +1); | ||
| 905 | selnormalize(); | 897 | selnormalize(); |
| 906 | 898 | ||
| 907 | /* | 899 | /* |
