all repos — st @ ebbac77d7416d365a2a33f159780ef0f06cc3351

st (suckless terminal) config

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.
Roberto E. Vargas Caballero k0ga@shike2.com
commit

ebbac77d7416d365a2a33f159780ef0f06cc3351

parent

7af030c999ba87cad2f3155bb9f58bf2854ad2bb

1 files changed, 5 insertions(+), 9 deletions(-)

jump to
M st.cst.c

@@ -888,11 +888,7 @@ if(e->xbutton.button == Button1) {

gettimeofday(&now, NULL); /* Clear previous selection, logically and visually. */ - if(sel.ob.x != -1) { - sel.ob.x = -1; - tsetdirt(sel.nb.y, sel.ne.y); - draw(); - } + selclear(NULL); sel.mode = 1; sel.type = SEL_REGULAR; sel.oe.x = sel.ob.x = x2col(e->xbutton.x);

@@ -1108,7 +1104,7 @@ if(e->xbutton.button == Button2) {

selpaste(NULL); } else if(e->xbutton.button == Button1) { if(sel.mode < 2) { - sel.ob.x = -1; + selclear(NULL); } else { getbuttoninfo(e); selcopy();

@@ -1441,7 +1437,7 @@ return;

if(BETWEEN(sel.ob.y, orig, term.bot) || BETWEEN(sel.oe.y, orig, term.bot)) { if((sel.ob.y += n) > term.bot || (sel.oe.y += n) < term.top) { - sel.ob.x = -1; + selclear(NULL); return; } if(sel.type == SEL_RECTANGULAR) {

@@ -1951,7 +1947,7 @@ while(csiescseq.arg[0]--)

tputtab(1); break; case 'J': /* ED -- Clear screen */ - sel.ob.x = -1; + selclear(NULL); switch(csiescseq.arg[0]) { case 0: /* below */ tclearregion(term.c.x, term.c.y, term.col-1, term.c.y);

@@ -2448,7 +2444,7 @@ */

if(control && !(term.c.attr.mode & ATTR_GFX)) return; if(sel.ob.x != -1 && BETWEEN(term.c.y, sel.ob.y, sel.oe.y)) - sel.ob.x = -1; + selclear(NULL); if(IS_SET(MODE_WRAP) && (term.c.state & CURSOR_WRAPNEXT)) { term.line[term.c.y][term.c.x].mode |= ATTR_WRAP; tnewline(1);