(wrong string) élien Aptel

From: <hg_AT_suckless.org>
Date: Thu, 20 Oct 2011 23:21:05 +0200 (CEST)

changeset: 216:fb96d95c5174
tag: tip
user: Aurélien Aptel <aurelien.aptel_AT_gmail.com>
date: Thu Oct 20 23:20:59 2011 +0200
files: st.c
description:
add dirty flag for lines


diff -r 704261718508 -r fb96d95c5174 st.c
--- a/st.c Thu Oct 06 21:32:34 2011 +0200
+++ b/st.c Thu Oct 20 23:20:59 2011 +0200
_AT_@ -111,6 +111,7 @@
         int col; /* nb col */
         Line* line; /* screen */
         Line* alt; /* alternate screen */
+ char* dirty; /* dirtyness of lines */
         TCursor c; /* cursor */
         int top; /* top scroll limit */
         int bot; /* bottom scroll limit */
_AT_@ -203,6 +204,7 @@
 static void tsetchar(char*);
 static void tsetscroll(int, int);
 static void tswapscreen(void);
+static void tfulldirt(void);
 
 static void ttynew(void);
 static void ttyread(void);
_AT_@ -749,6 +751,14 @@
 }
 
 void
+tfulldirt(void)
+{
+ int i;
+ for(i = 0; i < term.row; i++)
+ term.dirty[i] = 1;
+}
+
+void
 tcursor(int mode) {
         static TCursor c;
 
_AT_@ -777,9 +787,12 @@
         term.row = row, term.col = col;
         term.line = malloc(term.row * sizeof(Line));
         term.alt = malloc(term.row * sizeof(Line));
+ term.dirty = malloc(term.row * sizeof(*term.dirty));
+
         for(row = 0; row < term.row; row++) {
                 term.line[row] = malloc(term.col * sizeof(Glyph));
                 term.alt [row] = malloc(term.col * sizeof(Glyph));
+ term.dirty[row] = 0;
         }
         /* setup screen */
         treset();
_AT_@ -791,6 +804,7 @@
         term.line = term.alt;
         term.alt = tmp;
         term.mode ^= MODE_ALTSCREEN;
+ tfulldirt();
 }
 
 void
_AT_@ -806,6 +820,9 @@
                 temp = term.line[i];
                 term.line[i] = term.line[i-n];
                 term.line[i-n] = temp;
+
+ term.dirty[i] = 1;
+ term.dirty[i-n] = 1;
         }
 
         selscroll(orig, n);
_AT_@ -823,6 +840,9 @@
                  temp = term.line[i];
                  term.line[i] = term.line[i+n];
                  term.line[i+n] = temp;
+
+ term.dirty[i] = 1;
+ term.dirty[i+n] = 1;
         }
 
         selscroll(orig, -n);
_AT_@ -896,6 +916,7 @@
 
 void
 tsetchar(char *c) {
+ term.dirty[term.c.y] = 1;
         term.line[term.c.y][term.c.x] = term.c.attr;
         memcpy(term.line[term.c.y][term.c.x].c, c, UTF_SIZ);
         term.line[term.c.y][term.c.x].state |= GLYPH_SET;
_AT_@ -915,9 +936,11 @@
         LIMIT(y1, 0, term.row-1);
         LIMIT(y2, 0, term.row-1);
 
- for(y = y1; y <= y2; y++)
+ for(y = y1; y <= y2; y++) {
+ term.dirty[y] = 1;
                 for(x = x1; x <= x2; x++)
                         term.line[y][x].state = 0;
+ }
 }
 
 void
_AT_@ -925,6 +948,8 @@
         int src = term.c.x + n;
         int dst = term.c.x;
         int size = term.col - src;
+
+ term.dirty[term.c.y] = 1;
 
         if(src >= term.col) {
                 tclearregion(term.c.x, term.c.y, term.col-1, term.c.y);
_AT_@ -940,6 +965,8 @@
         int dst = src + n;
         int size = term.col - dst;
 
+ term.dirty[term.c.y] = 1;
+
         if(dst >= term.col) {
                 tclearregion(term.c.x, term.c.y, term.col-1, term.c.y);
                 return;
_AT_@ -1411,7 +1438,8 @@
                         }
                 }
         } else {
- if(sel.bx != -1 && BETWEEN(term.c.y, sel.by, sel.ey)) sel.bx = -1;
+ if(sel.bx != -1 && BETWEEN(term.c.y, sel.by, sel.ey))
+ sel.bx = -1;
                 switch(ascii) {
                 case '\t':
                         tputtab();
_AT_@ -1479,9 +1507,11 @@
         /* resize to new height */
         term.line = realloc(term.line, row * sizeof(Line));
         term.alt = realloc(term.alt, row * sizeof(Line));
+ term.dirty = realloc(term.dirty, row * sizeof(*term.dirty));
 
         /* resize each row to new width, zero-pad if needed */
         for(i = 0; i < minrow; i++) {
+ term.dirty[i] = 1;
                 term.line[i] = realloc(term.line[i], col * sizeof(Glyph));
                 term.alt[i] = realloc(term.alt[i], col * sizeof(Glyph));
                 for(x = mincol; x < col; x++) {
_AT_@ -1492,6 +1522,7 @@
 
         /* allocate any new rows */
         for(/* i == minrow */; i < row; i++) {
+ term.dirty[i] = 1;
                 term.line[i] = calloc(col, sizeof(Glyph));
                 term.alt [i] = calloc(col, sizeof(Glyph));
         }
_AT_@ -1502,6 +1533,7 @@
         tmoveto(term.c.x, term.c.y);
         /* reset scrolling region */
         tsetscroll(0, row-1);
+
         return (slide > 0);
 }
 
_AT_@ -1792,8 +1824,11 @@
         if(!(xw.state & WIN_VISIBLE))
                 return;
 
- xclear(x1, y1, x2-1, y2-1);
         for(y = y1; y < y2; y++) {
+ if(!term.dirty[y])
+ continue;
+ xclear(0, y, term.col, y);
+ term.dirty[y] = 0;
                 base = term.line[y][0];
                 ic = ib = ox = 0;
                 for(x = x1; x < x2; x++) {
_AT_@ -1801,7 +1836,7 @@
                         if(sel.bx != -1 && *(new.c) && selected(x, y))
                                 new.mode ^= ATTR_REVERSE;
                         if(ib > 0 && (!(new.state & GLYPH_SET) || ATTRCMP(base, new) ||
- ib >= DRAW_BUF_SIZ-UTF_SIZ)) {
+ ib >= DRAW_BUF_SIZ-UTF_SIZ)) {
                                 xdraws(buf, base, ox, y, ic, ib);
                                 ic = ib = 0;
                         }
Received on Thu Oct 20 2011 - 23:21:05 CEST

This archive was generated by hypermail 2.3.0 : Thu Oct 20 2011 - 23:24:05 CEST