[hackers] [st] Unset mode when clearing regions || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Sun, 10 Aug 2014 21:23:17 +0200

commit 8de8ae3923b3b91b034077c8c35acba629588233
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
Date: Thu Aug 7 10:11:38 2014 +0200

    Unset mode when clearing regions
    
    tclearregion() was clearing regions using spaces and the current
    attributes of the terminal. It was correct with all the modes excepct
    underline, because they didn't affect the space character, but in
    the case of underline it was a problem. A easy way of seeing this
    problem is writing this in the last line of the terminal:
    
            tput smul ; echo first; tput rmul; echo second; echo third
    
    Fist was underlined, and second and third were not underlined, but
    the spaces at the right of second was underlined becuause in the
    previous scrool underline mode was set.

diff --git a/st.c b/st.c
index 45bc89d..e0aae9d 100644
--- a/st.c
+++ b/st.c
_AT_@ -1553,6 +1553,7 @@ tsetchar(char *c, Glyph *attr, int x, int y) {
 void
 tclearregion(int x1, int y1, int x2, int y2) {
         int x, y, temp;
+ Glyph *gp;
 
         if(x1 > x2)
                 temp = x1, x1 = x2, x2 = temp;
_AT_@ -1567,10 +1568,13 @@ tclearregion(int x1, int y1, int x2, int y2) {
         for(y = y1; y <= y2; y++) {
                 term.dirty[y] = 1;
                 for(x = x1; x <= x2; x++) {
+ gp = &term.line[y][x];
                         if(selected(x, y))
                                 selclear(NULL);
- term.line[y][x] = term.c.attr;
- memcpy(term.line[y][x].c, " ", 2);
+ gp->fg = term.c.attr.fg;
+ gp->bg = term.c.attr.bg;
+ gp->mode = 0;
+ memcpy(gp->c, " ", 2);
                 }
         }
 }
Received on Sun Aug 10 2014 - 21:23:17 CEST

This archive was generated by hypermail 2.3.0 : Sun Aug 10 2014 - 21:24:13 CEST