summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQuentin Carbonneaux2014-07-21 17:46:20 -0400
committerQuentin Carbonneaux2014-07-21 17:46:20 -0400
commite2d8b78074c5b0982e6de56c29033dbba925411e (patch)
treeb03cbccb844cd98e5f3604a603fc5448e7d8f57c
parenteab23a29bf2de0e755fcb032817985a18c4e3723 (diff)
use buffer revisions to detect dirty windows
-rw-r--r--win.c25
-rw-r--r--win.h2
2 files changed, 18 insertions, 9 deletions
diff --git a/win.c b/win.c
index 90cc085..fb62b20 100644
--- a/win.c
+++ b/win.c
@@ -16,6 +16,7 @@ struct lineinfo {
unsigned sl[RingSize]; /* beginning of line offsets */
};
+static int dirty(W *);
static void draw(W *w, GColor bg);
static void move(W *pw, int x, int w, int h);
static void lineinfo(W *w, unsigned off, unsigned lim, struct lineinfo *li);
@@ -129,13 +130,13 @@ win_redraw_frame()
W *w;
for (w=wins; w-wins<MaxWins; w++)
- if (w->eb && w->dirty) {
+ if (w->eb && dirty(w)) {
draw(w, GPaleYellow);
- w->dirty = 0;
+ w->rev = eb_revision(w->eb);
if (tag.owner == w)
- tag.win.dirty = 1;
+ tag.win.rev = 0;
}
- if (tag.visible && tag.win.dirty)
+ if (tag.visible && dirty(&tag.win))
draw(&tag.win, GPaleGreen);
g->sync();
}
@@ -210,7 +211,7 @@ win_set_cursor(W *w, int x, int y)
if (lx + HMargin >= x)
break;
}
- w->dirty = 1;
+ w->rev = 0;
w->cu = p;
}
@@ -242,7 +243,7 @@ win_tag_toggle(W *w)
{
if (tag.visible) {
tag.visible = 0;
- tag.owner->dirty = 1;
+ tag.owner->rev = 0;
if (w == &tag.win)
return tag.owner;
}
@@ -250,7 +251,7 @@ win_tag_toggle(W *w)
tag.visible = 1;
tag.owner = w;
move(&tag.win, w->gr.x, w->gr.w, w->gr.h/TagRatio);
- w->dirty = 1;
+ w->rev = 0;
return &tag.win;
}
@@ -284,11 +285,19 @@ win_update(W *w)
for (; top<li.len; top++, l++)
w->l[l] = li.sl[(li.beg + top) % RingSize];
}
- w->dirty = 1;
+ w->rev = 0;
}
/* static functions */
+static int
+dirty(W *w)
+{
+ if (w->rev && w->rev != eb_revision(w->eb))
+ win_update(w);
+ return !w->rev;
+}
+
/* runewidth - returns the width of a given
* rune, if called on '\n', it returns 0.
*/
diff --git a/win.h b/win.h
index 3ec6509..66ac139 100644
--- a/win.h
+++ b/win.h
@@ -26,7 +26,7 @@ enum {
struct w {
unsigned l[MaxHeight]; /* line start offsets */
int nl; /* current number of lines */
- int dirty; /* dirty bit */
+ unsigned rev; /* on-screen revision or 0 if dirty */
unsigned cu; /* cursor offset */
int hrig; /* horizontal rigidity */
EBuf *eb; /* underlying buffer object */