diff --git a/src/line_info.c b/src/line_info.c index 7177408..3dbda18 100644 --- a/src/line_info.c +++ b/src/line_info.c @@ -51,7 +51,7 @@ void line_info_init(struct history *hst) static void line_info_reset_start(struct history *hst) { struct line_info *line = hst->line_end; - uint32_t start_id = hst->start_id + 1; + uint32_t start_id = hst->start_id; while (line) { if (line->id == start_id) { @@ -110,7 +110,6 @@ void line_info_add(ToxWindow *self, uint8_t *tmstmp, uint8_t *name1, uint8_t *na /* for type-specific formatting in print function */ switch (type) { case ACTION: - case NAME_CHANGE: len += 3; break; default: @@ -170,12 +169,13 @@ void line_info_add(ToxWindow *self, uint8_t *tmstmp, uint8_t *name1, uint8_t *na getyx(self->chatwin->history, y, x); int offst = self->is_groupchat ? SIDEBAR_WIDTH : 0; /* offset width of groupchat sidebar */ - int lines = 1 + (len / (x2 - offst)); + int lines = (1 + newlines + (len / (x2 - offst))); + hst->queue += lines; int max_y = self->is_prompt ? y2 : y2 - CHATBOX_HEIGHT; /* move line_start forward proportionate to the number of new lines */ - if (y >= max_y) { + if (y + hst->queue - 1 >= max_y) { while (lines > 0 && hst->line_start->next) { lines -= (1 + hst->line_start->len / (x2 - offst)); hst->line_start = hst->line_start->next; @@ -193,6 +193,8 @@ void line_info_print(ToxWindow *self) int y2, x2; getmaxyx(self->window, y2, x2); + ctx->hst->queue = 0; + if (self->is_groupchat) wmove(win, 0, 0); else diff --git a/src/line_info.h b/src/line_info.h index 0929e85..3f4f4b1 100644 --- a/src/line_info.h +++ b/src/line_info.h @@ -55,8 +55,7 @@ struct history { uint32_t start_id; /* keeps track of where line_start should be when at bottom of history */ uint32_t line_items; bool scroll_mode; - int y; - int old_y; + uint8_t queue; /* keeps track of lines added between window refreshes */ }; /* adds a line to history (also moves line_start and/or line_root forward if necessary) */ diff --git a/src/main.c b/src/main.c index 64481a0..8dede87 100644 --- a/src/main.c +++ b/src/main.c @@ -84,7 +84,6 @@ struct _Winthread Winthread; void on_window_resize(int sig) { - endwin(); refresh(); clear(); }