Mercurial > hg > nnchat
comparison nnchat.c @ 326:2f7849e505f3
Fix backbuffer functionality.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 13 Jun 2011 06:59:31 +0300 |
parents | c086345d176b |
children | a8bda904846c |
comparison
equal
deleted
inserted
replaced
325:c086345d176b | 326:2f7849e505f3 |
---|---|
376 } | 376 } |
377 | 377 |
378 | 378 |
379 void updateMainWin(BOOL force) | 379 void updateMainWin(BOOL force) |
380 { | 380 { |
381 int y, w, h, offs, o; | 381 int y, w, h, offs; |
382 qringbuf_t *buf; | 382 qringbuf_t *buf; |
383 | 383 |
384 if (mainWin == NULL || currWin == NULL) return; | 384 if (mainWin == NULL || currWin == NULL) return; |
385 if (!force && !currWin->dirty) return; | 385 if (!force && !currWin->dirty) return; |
386 | 386 |
387 buf = currWin->data; | 387 buf = currWin->data; |
388 getmaxyx(mainWin, h, w); | 388 getmaxyx(mainWin, h, w); |
389 werase(mainWin); | 389 werase(mainWin); |
390 | 390 |
391 offs = (int) buf->size; | 391 h -= 1; |
392 offs -= (h + currWin->pos); | 392 offs = ((int) buf->size) - h - currWin->pos; |
393 if (offs < 0) | 393 if (offs < 0) |
394 offs = 0; | 394 offs = 0; |
395 o = offs; | |
396 | 395 |
397 for (y = 0; y < h && offs < buf->size; offs++) { | 396 for (y = 0; y < h && offs < buf->size; offs++) { |
398 if (buf->data[offs] != NULL) | 397 if (buf->data[offs] != NULL) { |
399 printWin(mainWin, (char *) buf->data[offs]); | 398 printWin(mainWin, (char *) buf->data[offs]); |
399 } | |
400 y = getcury(mainWin); | 400 y = getcury(mainWin); |
401 } | 401 } |
402 | |
403 //fprintf(stderr, "pos=%d, offs=%d / %d, buf.size=%d, h=%d, y=%d\n", currWin->pos, o, offs, buf->size, h, y); | |
404 | 402 |
405 currWin->dirty = FALSE; | 403 currWin->dirty = FALSE; |
406 wrefresh(mainWin); | 404 wrefresh(mainWin); |
407 } | 405 } |
408 | 406 |
997 editWin = subwin(stdscr, 3, w, h - 3, 0); | 995 editWin = subwin(stdscr, 3, w, h - 3, 0); |
998 | 996 |
999 if (mainWin == NULL || statusWin == NULL || editWin == NULL) | 997 if (mainWin == NULL || statusWin == NULL || editWin == NULL) |
1000 return FALSE; | 998 return FALSE; |
1001 | 999 |
1002 scrollok(mainWin, 1); | |
1003 | |
1004 return TRUE; | 1000 return TRUE; |
1005 } | 1001 } |
1006 | 1002 |
1007 void updateWindows(void) | 1003 void updateWindows(void) |
1008 { | 1004 { |
1703 update = updateMain = TRUE; | 1699 update = updateMain = TRUE; |
1704 break; | 1700 break; |
1705 | 1701 |
1706 case KEY_NPAGE: | 1702 case KEY_NPAGE: |
1707 case KEY_PPAGE: | 1703 case KEY_PPAGE: |
1704 /* Page Up / Page Down */ | |
1708 if (currWin != NULL) | 1705 if (currWin != NULL) |
1709 { | 1706 { |
1710 int numLines, numCols, oldPos = currWin->pos; | 1707 int oldPos = currWin->pos; |
1711 getmaxyx(mainWin, numLines, numCols); | 1708 |
1712 numLines = (numLines / 2) + 1; | 1709 if (c == KEY_NPAGE) { |
1713 | |
1714 if (c == KEY_PPAGE) { | |
1715 if (currWin->pos > 10) | 1710 if (currWin->pos > 10) |
1716 currWin->pos -= 10; | 1711 currWin->pos -= 10; |
1717 else | 1712 else |
1718 currWin->pos = 0; | 1713 currWin->pos = 0; |
1719 } | 1714 } |
1720 else { | 1715 else { |
1721 if (currWin->pos < currWin->data->size - 10) | 1716 if (currWin->pos < currWin->data->n - 10) |
1722 currWin->pos += 10; | 1717 currWin->pos += 10; |
1723 else | 1718 else |
1724 currWin->pos = currWin->data->size - 10; | 1719 currWin->pos = currWin->data->n - 10; |
1725 } | 1720 } |
1726 | 1721 |
1727 if (oldPos != currWin->pos) | 1722 if (oldPos != currWin->pos) |
1728 updateMain = TRUE; | 1723 updateMain = TRUE; |
1729 } | 1724 } |