about summary refs log tree commit diff stats
path: root/termbox
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-05-10 11:38:18 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-05-10 11:40:33 -0700
commit4071055aeed22737366b3cb863b24a59f0625a28 (patch)
tree671bfd7bee9d5d75f5890bc78d1106719568fcde /termbox
parent6b16a2ef6b12eedc14f2a7652bf8d977c8192b6e (diff)
downloadmu-4071055aeed22737366b3cb863b24a59f0625a28.tar.gz
1327 - better error handling in chessboard
Also a bugfix in break to label, because I noticed the screen wasn't
being cleaned up on quit.
Diffstat (limited to 'termbox')
-rw-r--r--termbox/termbox.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/termbox/termbox.c b/termbox/termbox.c
index 2fbbf5b4..80aeb3a9 100644
--- a/termbox/termbox.c
+++ b/termbox/termbox.c
@@ -158,6 +158,8 @@ void tb_present(void)
   int x,y,w,i;
   struct tb_cell *back, *front;
 
+  assert(termw != -1);
+
   /* invalidate cursor position */
   lastx = LAST_COORD_INIT;
   lasty = LAST_COORD_INIT;
@@ -203,12 +205,11 @@ void tb_present(void)
 
 void tb_set_cursor(int cx, int cy)
 {
+  assert(termw != -1);
   if (IS_CURSOR_HIDDEN(cursor_x, cursor_y) && !IS_CURSOR_HIDDEN(cx, cy))
     bytebuffer_puts(&output_buffer, funcs[T_SHOW_CURSOR]);
-
   if (!IS_CURSOR_HIDDEN(cursor_x, cursor_y) && IS_CURSOR_HIDDEN(cx, cy))
     bytebuffer_puts(&output_buffer, funcs[T_HIDE_CURSOR]);
-
   cursor_x = cx;
   cursor_y = cy;
   if (!IS_CURSOR_HIDDEN(cursor_x, cursor_y))
@@ -217,6 +218,7 @@ void tb_set_cursor(int cx, int cy)
 
 void tb_change_cell(int x, int y, uint32_t ch, uint16_t fg, uint16_t bg)
 {
+  assert(termw != -1);
   if ((unsigned)x >= (unsigned)back_buffer.width)
     return;
   if ((unsigned)y >= (unsigned)back_buffer.height)
@@ -232,6 +234,7 @@ struct tb_cell *tb_cell_buffer()
 
 int tb_poll_event(struct tb_event *event)
 {
+  assert(termw != -1);
   return wait_fill_event(event, 0);
 }
 
@@ -240,21 +243,25 @@ int tb_peek_event(struct tb_event *event, int timeout)
   struct timeval tv;
   tv.tv_sec = timeout / 1000;
   tv.tv_usec = (timeout - (tv.tv_sec * 1000)) * 1000;
+  assert(termw != -1);
   return wait_fill_event(event, &tv);
 }
 
 int tb_width(void)
 {
+  assert(termw != -1);
   return termw;
 }
 
 int tb_height(void)
 {
+  assert(termw != -1);
   return termh;
 }
 
 void tb_clear(void)
 {
+  assert(termw != -1);
   if (buffer_size_change_request) {
     update_size();
     buffer_size_change_request = 0;
@@ -264,6 +271,7 @@ void tb_clear(void)
 
 void tb_set_clear_attributes(uint16_t fg, uint16_t bg)
 {
+  assert(termw != -1);
   foreground = fg;
   background = bg;
 }