# HG changeset patch # User Matti Hamalainen # Date 1308533675 -10800 # Node ID 1f4def71b8369c28da96c1e0f88f326804f08088 # Parent 3c7676b2b3679c9a822eb065810df4cc75af3e78 Back to simplistic backbuffer implementation due to laziness. diff -r 3c7676b2b367 -r 1f4def71b836 nnchat.c --- a/nnchat.c Mon Jun 20 03:42:36 2011 +0300 +++ b/nnchat.c Mon Jun 20 04:34:35 2011 +0300 @@ -380,7 +380,6 @@ if (*s == '\n') { QPUTCH('\n'); QPUTCH(0); -// th_ringbuf_add(win->data, nn_strtuple_new(win->chlen, win->buf)); th_ringbuf_add(win->data, win->buf); win->buf = NULL; win->chlen = 0; @@ -399,32 +398,34 @@ } -void updateMainWin(BOOL force) +BOOL updateMainWin(BOOL force) { - int y, w, h, offs; + int w, h, offs; qringbuf_t *buf; - if (mainWin == NULL || currWin == NULL) return; - if (!force && !currWin->dirty) return; + /* Check pointers */ + if (mainWin == NULL || currWin == NULL) + return FALSE; + /* Check if update is forced or if the window is dirty */ + if (!force && !currWin->dirty) + return FALSE; + + /* Compute how many lines from backbuffer fit on the screen */ buf = currWin->data; getmaxyx(mainWin, h, w); + + /* Clear and redraw window */ werase(mainWin); - - h -= 1; - offs = ((int) buf->size) - h - currWin->pos; - if (offs < 0) - offs = 0; - - for (y = 0; y < h && offs < buf->size; offs++) { - if (buf->data[offs] != NULL) { - printWin(mainWin, (char *) buf->data[offs]); - } - y = getcury(mainWin); + scrollok(mainWin, 1); + for (offs = buf->size - h - currWin->pos; offs >= 0 && offs < buf->size - currWin->pos && offs < buf->size; offs++) { + if (buf->data[offs] != NULL) + printWin(mainWin, buf->data[offs]); } currWin->dirty = FALSE; wrefresh(mainWin); + return TRUE; } @@ -1587,7 +1588,6 @@ } c = ERR; } - switch (c) { #ifdef KEY_RESIZE