Mercurial > hg > nnchat
changeset 326:2f7849e505f3
Fix backbuffer functionality.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 13 Jun 2011 06:59:31 +0300 |
parents | c086345d176b |
children | fae4651d37bc |
files | nnchat.c |
diffstat | 1 files changed, 10 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- 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)