# HG changeset patch # User Matti Hamalainen # Date 1338694375 -10800 # Node ID 942eea564b1597059269607ed0ea5a63aa6fef71 # Parent f71c59cbc5a7ce46cf19dcb2133470020834d7e2 Fix backbuffer offset manipulation, prevents a segfault. diff -r f71c59cbc5a7 -r 942eea564b15 main.c --- 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; diff -r f71c59cbc5a7 -r 942eea564b15 ui.h --- a/ui.h Sun Jun 03 06:32:18 2012 +0300 +++ b/ui.h Sun Jun 03 06:32:55 2012 +0300 @@ -45,6 +45,7 @@ extern nn_window_t *currWin; extern BOOL cursesInit; +extern int scrHeight, scrWidth; BOOL nnwin_init(int delay); void nnwin_shutdown();