Mercurial > hg > nnchat
comparison nnchat.c @ 335:1f4def71b836 dev-0_9_4
Back to simplistic backbuffer implementation due to laziness.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 20 Jun 2011 04:34:35 +0300 |
parents | 3c7676b2b367 |
children | 058e3633bd73 |
comparison
equal
deleted
inserted
replaced
334:3c7676b2b367 | 335:1f4def71b836 |
---|---|
378 } | 378 } |
379 } else | 379 } else |
380 if (*s == '\n') { | 380 if (*s == '\n') { |
381 QPUTCH('\n'); | 381 QPUTCH('\n'); |
382 QPUTCH(0); | 382 QPUTCH(0); |
383 // th_ringbuf_add(win->data, nn_strtuple_new(win->chlen, win->buf)); | |
384 th_ringbuf_add(win->data, win->buf); | 383 th_ringbuf_add(win->data, win->buf); |
385 win->buf = NULL; | 384 win->buf = NULL; |
386 win->chlen = 0; | 385 win->chlen = 0; |
387 win->dirty = TRUE; | 386 win->dirty = TRUE; |
388 } | 387 } |
397 | 396 |
398 return 0; | 397 return 0; |
399 } | 398 } |
400 | 399 |
401 | 400 |
402 void updateMainWin(BOOL force) | 401 BOOL updateMainWin(BOOL force) |
403 { | 402 { |
404 int y, w, h, offs; | 403 int w, h, offs; |
405 qringbuf_t *buf; | 404 qringbuf_t *buf; |
406 | 405 |
407 if (mainWin == NULL || currWin == NULL) return; | 406 /* Check pointers */ |
408 if (!force && !currWin->dirty) return; | 407 if (mainWin == NULL || currWin == NULL) |
409 | 408 return FALSE; |
409 | |
410 /* Check if update is forced or if the window is dirty */ | |
411 if (!force && !currWin->dirty) | |
412 return FALSE; | |
413 | |
414 /* Compute how many lines from backbuffer fit on the screen */ | |
410 buf = currWin->data; | 415 buf = currWin->data; |
411 getmaxyx(mainWin, h, w); | 416 getmaxyx(mainWin, h, w); |
417 | |
418 /* Clear and redraw window */ | |
412 werase(mainWin); | 419 werase(mainWin); |
413 | 420 scrollok(mainWin, 1); |
414 h -= 1; | 421 for (offs = buf->size - h - currWin->pos; offs >= 0 && offs < buf->size - currWin->pos && offs < buf->size; offs++) { |
415 offs = ((int) buf->size) - h - currWin->pos; | 422 if (buf->data[offs] != NULL) |
416 if (offs < 0) | 423 printWin(mainWin, buf->data[offs]); |
417 offs = 0; | |
418 | |
419 for (y = 0; y < h && offs < buf->size; offs++) { | |
420 if (buf->data[offs] != NULL) { | |
421 printWin(mainWin, (char *) buf->data[offs]); | |
422 } | |
423 y = getcury(mainWin); | |
424 } | 424 } |
425 | 425 |
426 currWin->dirty = FALSE; | 426 currWin->dirty = FALSE; |
427 wrefresh(mainWin); | 427 wrefresh(mainWin); |
428 return TRUE; | |
428 } | 429 } |
429 | 430 |
430 | 431 |
431 int printFile(FILE *outFile, const char *fmt) | 432 int printFile(FILE *outFile, const char *fmt) |
432 { | 433 { |
1585 currWin = chatWindows[win]; | 1586 currWin = chatWindows[win]; |
1586 update = updateMain = TRUE; | 1587 update = updateMain = TRUE; |
1587 } | 1588 } |
1588 c = ERR; | 1589 c = ERR; |
1589 } | 1590 } |
1590 | |
1591 | 1591 |
1592 switch (c) { | 1592 switch (c) { |
1593 #ifdef KEY_RESIZE | 1593 #ifdef KEY_RESIZE |
1594 case KEY_RESIZE: | 1594 case KEY_RESIZE: |
1595 resize_term(0, 0); | 1595 resize_term(0, 0); |