From 7dcdd40c2749f5aff5ea9553acdba9e1218e90d1 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Wed, 2 Sep 2015 12:39:35 -0700 Subject: 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. --- termbox/termbox.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'termbox/termbox.c') 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) -- cgit 1.4.1-2-gfad0