# HG changeset patch # User Matti Hamalainen # Date 1307937571 -10800 # Node ID 2f7849e505f30e02b31f8097176cde734b570fc5 # Parent c086345d176bc2a2a202c1d46930aea7f4d4098d Fix backbuffer functionality. diff -r c086345d176b -r 2f7849e505f3 nnchat.c --- a/nnchat.c Sat Jun 11 10:03:44 2011 +0300 +++ b/nnchat.c Mon Jun 13 06:59:31 2011 +0300 @@ -378,7 +378,7 @@ void updateMainWin(BOOL force) { - int y, w, h, offs, o; + int y, w, h, offs; qringbuf_t *buf; if (mainWin == NULL || currWin == NULL) return; @@ -388,19 +388,17 @@ getmaxyx(mainWin, h, w); werase(mainWin); - offs = (int) buf->size; - offs -= (h + currWin->pos); + h -= 1; + offs = ((int) buf->size) - h - currWin->pos; if (offs < 0) offs = 0; - o = offs; for (y = 0; y < h && offs < buf->size; offs++) { - if (buf->data[offs] != NULL) + if (buf->data[offs] != NULL) { printWin(mainWin, (char *) buf->data[offs]); + } y = getcury(mainWin); } - -//fprintf(stderr, "pos=%d, offs=%d / %d, buf.size=%d, h=%d, y=%d\n", currWin->pos, o, offs, buf->size, h, y); currWin->dirty = FALSE; wrefresh(mainWin); @@ -999,8 +997,6 @@ if (mainWin == NULL || statusWin == NULL || editWin == NULL) return FALSE; - scrollok(mainWin, 1); - return TRUE; } @@ -1705,23 +1701,22 @@ case KEY_NPAGE: case KEY_PPAGE: + /* Page Up / Page Down */ if (currWin != NULL) { - int numLines, numCols, oldPos = currWin->pos; - getmaxyx(mainWin, numLines, numCols); - numLines = (numLines / 2) + 1; + int oldPos = currWin->pos; - if (c == KEY_PPAGE) { + if (c == KEY_NPAGE) { if (currWin->pos > 10) currWin->pos -= 10; else currWin->pos = 0; } else { - if (currWin->pos < currWin->data->size - 10) + if (currWin->pos < currWin->data->n - 10) currWin->pos += 10; else - currWin->pos = currWin->data->size - 10; + currWin->pos = currWin->data->n - 10; } if (oldPos != currWin->pos)