aboutsummaryrefslogtreecommitdiff
path: root/st.c
diff options
context:
space:
mode:
authorRoberto E. Vargas Caballero <k0ga@shike2.com>2013-06-23 12:09:19 +0200
committerRoberto E. Vargas Caballero <k0ga@shike2.com>2013-07-04 09:14:50 +0200
commitebbac77d7416d365a2a33f159780ef0f06cc3351 (patch)
treeeb2a09055418bea363d6bcc9f33ed2f1d4071816 /st.c
parent7af030c999ba87cad2f3155bb9f58bf2854ad2bb (diff)
downloadst-ebbac77d7416d365a2a33f159780ef0f06cc3351.tar.gz
st-ebbac77d7416d365a2a33f159780ef0f06cc3351.zip
Fix selection clearing
The way st knows if there is a selection activated is checking if sel.ob.x is equal to -1. In some parts of the code the way of disabling the selection was only setting it to -1, but after it you can't be sure if the selection is clearing from the terminal representation, because it is necessary mark all the lines affected by the selection as dirty. Already there is a functon which perform this task, selclear.
Diffstat (limited to 'st.c')
-rw-r--r--st.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/st.c b/st.c
index 2811876..96111a0 100644
--- a/st.c
+++ b/st.c
@@ -888,11 +888,7 @@ bpress(XEvent *e) {
888 gettimeofday(&now, NULL); 888 gettimeofday(&now, NULL);
889 889
890 /* Clear previous selection, logically and visually. */ 890 /* Clear previous selection, logically and visually. */
891 if(sel.ob.x != -1) { 891 selclear(NULL);
892 sel.ob.x = -1;
893 tsetdirt(sel.nb.y, sel.ne.y);
894 draw();
895 }
896 sel.mode = 1; 892 sel.mode = 1;
897 sel.type = SEL_REGULAR; 893 sel.type = SEL_REGULAR;
898 sel.oe.x = sel.ob.x = x2col(e->xbutton.x); 894 sel.oe.x = sel.ob.x = x2col(e->xbutton.x);
@@ -1108,7 +1104,7 @@ brelease(XEvent *e) {
1108 selpaste(NULL); 1104 selpaste(NULL);
1109 } else if(e->xbutton.button == Button1) { 1105 } else if(e->xbutton.button == Button1) {
1110 if(sel.mode < 2) { 1106 if(sel.mode < 2) {
1111 sel.ob.x = -1; 1107 selclear(NULL);
1112 } else { 1108 } else {
1113 getbuttoninfo(e); 1109 getbuttoninfo(e);
1114 selcopy(); 1110 selcopy();
@@ -1441,7 +1437,7 @@ selscroll(int orig, int n) {
1441 1437
1442 if(BETWEEN(sel.ob.y, orig, term.bot) || BETWEEN(sel.oe.y, orig, term.bot)) { 1438 if(BETWEEN(sel.ob.y, orig, term.bot) || BETWEEN(sel.oe.y, orig, term.bot)) {
1443 if((sel.ob.y += n) > term.bot || (sel.oe.y += n) < term.top) { 1439 if((sel.ob.y += n) > term.bot || (sel.oe.y += n) < term.top) {
1444 sel.ob.x = -1; 1440 selclear(NULL);
1445 return; 1441 return;
1446 } 1442 }
1447 if(sel.type == SEL_RECTANGULAR) { 1443 if(sel.type == SEL_RECTANGULAR) {
@@ -1951,7 +1947,7 @@ csihandle(void) {
1951 tputtab(1); 1947 tputtab(1);
1952 break; 1948 break;
1953 case 'J': /* ED -- Clear screen */ 1949 case 'J': /* ED -- Clear screen */
1954 sel.ob.x = -1; 1950 selclear(NULL);
1955 switch(csiescseq.arg[0]) { 1951 switch(csiescseq.arg[0]) {
1956 case 0: /* below */ 1952 case 0: /* below */
1957 tclearregion(term.c.x, term.c.y, term.col-1, term.c.y); 1953 tclearregion(term.c.x, term.c.y, term.col-1, term.c.y);
@@ -2448,7 +2444,7 @@ tputc(char *c, int len) {
2448 if(control && !(term.c.attr.mode & ATTR_GFX)) 2444 if(control && !(term.c.attr.mode & ATTR_GFX))
2449 return; 2445 return;
2450 if(sel.ob.x != -1 && BETWEEN(term.c.y, sel.ob.y, sel.oe.y)) 2446 if(sel.ob.x != -1 && BETWEEN(term.c.y, sel.ob.y, sel.oe.y))
2451 sel.ob.x = -1; 2447 selclear(NULL);
2452 if(IS_SET(MODE_WRAP) && (term.c.state & CURSOR_WRAPNEXT)) { 2448 if(IS_SET(MODE_WRAP) && (term.c.state & CURSOR_WRAPNEXT)) {
2453 term.line[term.c.y][term.c.x].mode |= ATTR_WRAP; 2449 term.line[term.c.y][term.c.x].mode |= ATTR_WRAP;
2454 tnewline(1); 2450 tnewline(1);