about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-09-02 12:39:35 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-09-02 12:39:35 -0700
commit7dcdd40c2749f5aff5ea9553acdba9e1218e90d1 (patch)
tree37e7165ed24f423923542a50b62fcacf98908c9c
parent4977f1e03608dcdcf30276bc54e3aed2ab266c94 (diff)
downloadmu-7dcdd40c2749f5aff5ea9553acdba9e1218e90d1.tar.gz
2131 - better tb_sync()
For some reason porting the termbox-go implementation was still leaving
some gunk from git on screen when I ran my usual test:

  $ mkdir lesson; cd lesson; git init; mu edit.mu
  Then hit F4, generating messages from git on the initial commit.
  Then hit ctrl-l to clear all git gunk.
-rw-r--r--termbox/termbox.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/termbox/termbox.c b/termbox/termbox.c
index 76d43753..79e6e3cc 100644
--- a/termbox/termbox.c
+++ b/termbox/termbox.c
@@ -159,8 +159,7 @@ int tb_is_active(void)
   return termw != -1;
 }
 
-void tb_present(void)
-{
+static void tb_repaint(bool force) {
   int x,y,w,i;
   struct tb_cell *back, *front;
 
@@ -181,7 +180,7 @@ void tb_present(void)
       front = &CELL(&front_buffer, x, y);
       w = wcwidth(back->ch);
       if (w < 1) w = 1;
-      if (memcmp(back, front, sizeof(struct tb_cell)) == 0) {
+      if (!force && memcmp(back, front, sizeof(struct tb_cell)) == 0) {
         x += w;
         continue;
       }
@@ -209,9 +208,14 @@ void tb_present(void)
   bytebuffer_flush(&output_buffer, inout);
 }
 
-void tb_sync(void) {
-  cellbuf_clear(&front_buffer);
-  tb_present();
+void tb_present(void)
+{
+  tb_repaint(false);
+}
+
+void tb_sync(void)
+{
+  tb_repaint(true);
 }
 
 void tb_set_cursor(int cx, int cy)