From 12e1a60ca3defcc0d94115a4604de3e3e0ef5cce Mon Sep 17 00:00:00 2001 From: Jfreegman Date: Wed, 11 Dec 2013 05:41:02 -0500 Subject: [PATCH] ugly partial fix for bug --- src/prompt.c | 16 ++++++++++++++-- src/toxic_strings.c | 1 - 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/prompt.c b/src/prompt.c index 0f7fcc1..13787e3 100644 --- a/src/prompt.c +++ b/src/prompt.c @@ -170,9 +170,21 @@ static void prompt_onKey(ToxWindow *self, Tox *m, wint_t key) wmove(self->window, prt->orig_y, X_OFST); fetch_hist_item(prt->line, &prt->pos, &prt->len, prt->ln_history, prt->hst_tot, &prt->hst_pos, LN_HIST_MV_UP); + + /* adjust line y origin appropriately when window scrolls down */ if (prt->at_bottom && prt->len >= x2 - X_OFST) { - --prt->orig_y; - prt->scroll = true; + int px2 = prt->len >= x2 ? x2 : x2 - X_OFST; + int p_ofst = px2 != x2 ? 0 : X_OFST; + + if (px2 <= 0) + return; + + int k = prt->orig_y + ((prt->len + p_ofst) / px2); + + if (k == y2) { /* cursor is below max_y */ + wprintw(self->window, "\n"); + --prt->orig_y; + } } } } diff --git a/src/toxic_strings.c b/src/toxic_strings.c index 0ba06c5..3f92cc0 100644 --- a/src/toxic_strings.c +++ b/src/toxic_strings.c @@ -119,7 +119,6 @@ void fetch_hist_item(wchar_t *buf, size_t *pos, size_t *len, wchar_t (*hst)[MAX_ if (--(*hst_pos) < 0) { ++(*hst_pos); beep(); - return; } } else { if (++(*hst_pos) == hst_tot) {