isbadawi/badavi

Isolate termbox dependency

Closed this issue · 0 comments

There are references to termbox sprinkled throughout the code. Could imagine a struct terminal with function pointers wrapping the termbox api.
One advantage would be that we could set up a mock terminal for testing. This would let us test the code in draw.c, and also clean this up:

badavi/draw.c

Lines 351 to 357 in 63feceb

// FIXME(ibadawi): Hack to make the tests run.
// If termbox wasn't initialized (like in the tests), let's not try to draw,
// because we can hit a segfault when we try to access the tb_cell buffer.
// (search_motion() calls editor_draw(), which is why the tests draw).
if (tb_width() == -1) {
return;
}