Mercurial > hg > nnchat
changeset 509:942eea564b15 dev-1_1_0
Fix backbuffer offset manipulation, prevents a segfault.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sun, 03 Jun 2012 06:32:55 +0300 |
parents | f71c59cbc5a7 |
children | 54f4f84bae5c |
files | main.c ui.h |
diffstat | 2 files changed, 5 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/main.c Sun Jun 03 06:32:18 2012 +0300 +++ b/main.c Sun Jun 03 06:32:55 2012 +0300 @@ -1076,7 +1076,6 @@ char *tmp; // Trim right side - if (bufLen > 0) buf[--bufLen] = 0; while (bufLen > 0 && th_isspace(buf[bufLen - 1])) buf[--bufLen] = 0; @@ -1772,7 +1771,6 @@ histBuf[1] = nn_editbuf_copy(editBuf); if (histMax < SET_MAX_HISTORY) histMax++; - nn_editbuf_insert(editBuf, editBuf->len, 0); result = nn_handle_input(conn, editBuf->data, editBuf->len); nn_editbuf_clear(editBuf); @@ -1895,14 +1893,14 @@ // Page Up / Page Down if (currWin != NULL) { - int oldPos = currWin->pos; + int oldPos = currWin->pos, page = scrHeight - 4; - currWin->pos += (c == KEY_NPAGE) ? -10 : +10; + currWin->pos += (c == KEY_NPAGE) ? - page : page; + if (currWin->pos >= currWin->data->n - page) + currWin->pos = currWin->data->n - page; if (currWin->pos < 0) currWin->pos = 0; - else if (currWin->pos >= currWin->data->n - 10) - currWin->pos = currWin->data->n - 10; if (oldPos != currWin->pos) update = TRUE;