From 26640cda14a50cea47ada18f40e33e5dced543b5 Mon Sep 17 00:00:00 2001 From: Jfreegman Date: Fri, 28 Mar 2014 17:33:23 -0400 Subject: [PATCH] prevent screen from moving on input when in scroll mode --- src/line_info.c | 16 ++++++++-------- src/line_info.h | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/line_info.c b/src/line_info.c index 197a030..68f072f 100644 --- a/src/line_info.c +++ b/src/line_info.c @@ -143,7 +143,6 @@ void line_info_add(ToxWindow *self, uint8_t *tmstmp, uint8_t *name1, uint8_t *na /* If chat history exceeds limit move root forward and free old root */ if (++hst->line_items > MAX_HISTORY) { - --hst->line_items; struct line_info *tmp = hst->line_root->next; tmp->prev = NULL; @@ -181,9 +180,11 @@ void line_info_add(ToxWindow *self, uint8_t *tmstmp, uint8_t *name1, uint8_t *na /* move line_start forward proportionate to the number of new lines */ if (y + hst->queue_lns - hst->queue >= max_y) { while (lines > 0 && hst->line_start->next) { - lines -= (1 + hst->line_start->len / (x2 - offst)); - hst->line_start = hst->line_start->next; ++hst->start_id; + lines -= (1 + hst->line_start->len / (x2 - offst)); + + if (!hst->scroll_mode) + hst->line_start = hst->line_start->next; } } } @@ -193,6 +194,9 @@ void line_info_print(ToxWindow *self) ChatContext *ctx = self->chatwin; WINDOW *win = ctx->history; + ctx->hst->queue = 0; + ctx->hst->queue_lns = 0; + wclear(win); int y2, x2; getmaxyx(self->window, y2, x2); @@ -200,9 +204,6 @@ void line_info_print(ToxWindow *self) if (x2 <= SIDEBAR_WIDTH) return; - ctx->hst->queue = 0; - ctx->hst->queue_lns = 0; - if (self->is_groupchat) wmove(win, 0, 0); else @@ -212,9 +213,8 @@ void line_info_print(ToxWindow *self) int offst = self->is_groupchat ? SIDEBAR_WIDTH : 0; int numlines = 0; - while(line && numlines <= y2) { + while(line && numlines++ <= y2) { uint8_t type = line->type; - numlines += line->len / (x2 - offst); switch (type) { case OUT_MSG: diff --git a/src/line_info.h b/src/line_info.h index 4801b86..f0821ed 100644 --- a/src/line_info.h +++ b/src/line_info.h @@ -77,9 +77,9 @@ void line_info_toggle_scroll(ToxWindow *self, bool scroll); /* clears the screen (does not delete anything) */ void line_info_clear(struct history *hst); -/* puts msg in specified line_info->msg buffer */ +/* puts msg in specified line_info msg buffer */ void line_info_set(ToxWindow *self, uint32_t id, uint8_t *msg); void line_info_init(struct history *hst); void line_info_onKey(ToxWindow *self, wint_t key); -void line_info_onDraw(ToxWindow *self); \ No newline at end of file +void line_info_onDraw(ToxWindow *self);