aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornoname <noname@inventati.org>2015-05-03 19:28:10 +0000
committerRoberto E. Vargas Caballero <k0ga@shike2.com>2015-05-04 12:06:43 +0200
commitc990abfedf56cb8d3176fe6d5152ff65bb68bff0 (patch)
treebccbfccd50700d31c72501c9652c080c7aa190ed
parent3cb7f27afe89c33c74b51c5460b7fb16413f786b (diff)
downloadst-patched-c990abfedf56cb8d3176fe6d5152ff65bb68bff0.tar.bz2
st-patched-c990abfedf56cb8d3176fe6d5152ff65bb68bff0.tar.xz
st-patched-c990abfedf56cb8d3176fe6d5152ff65bb68bff0.zip
Fix empty selection highlighting bug.
When user clicks LMB, one character is selected, but will not be copied to selection until the user moves cursor a bit. Therefore, the character should not be highlighted as selected yet. Before the patch, the trick was not to mark line as dirty to avoid highlighting it. However, if user has already selected something and clicks in line that contains selection, selclear sets the line as dirty and one character is highlighted when it should not. This patch replaces dirty trick with explicit check for sel.mode inside selected().
-rw-r--r--st.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/st.c b/st.c
index cf6556a..3eb66fa 100644
--- a/st.c
+++ b/st.c
@@ -716,6 +716,9 @@ selnormalize(void) {
716 716
717bool 717bool
718selected(int x, int y) { 718selected(int x, int y) {
719 if(sel.mode == SEL_EMPTY)
720 return false;
721
719 if(sel.type == SEL_RECTANGULAR) 722 if(sel.type == SEL_RECTANGULAR)
720 return BETWEEN(y, sel.nb.y, sel.ne.y) 723 return BETWEEN(y, sel.nb.y, sel.ne.y)
721 && BETWEEN(x, sel.nb.x, sel.ne.x); 724 && BETWEEN(x, sel.nb.x, sel.ne.x);
@@ -921,14 +924,9 @@ bpress(XEvent *e) {
921 } 924 }
922 selnormalize(); 925 selnormalize();
923 926
924 /* 927 if(sel.snap != 0)
925 * Draw selection, unless it's regular and we don't want to
926 * make clicks visible
927 */
928 if(sel.snap != 0) {
929 sel.mode = SEL_READY; 928 sel.mode = SEL_READY;
930 tsetdirt(sel.nb.y, sel.ne.y); 929 tsetdirt(sel.nb.y, sel.ne.y);
931 }
932 sel.tclick2 = sel.tclick1; 930 sel.tclick2 = sel.tclick1;
933 sel.tclick1 = now; 931 sel.tclick1 = now;
934 } 932 }