diff --git a/src/chat.c b/src/chat.c index d995ada..ed96347 100644 --- a/src/chat.c +++ b/src/chat.c @@ -688,20 +688,23 @@ static void chat_onDraw(ToxWindow *self, Tox *m) ChatContext *ctx = self->chatwin; - if (!ctx->hst->scroll_mode) + line_info_print(self); + wclear(ctx->linewin); + + if (ctx->hst->scroll_mode) { + line_info_onDraw(self); + } else { curs_set(1); - wclear(ctx->linewin); - line_info_print(self); - - if (ctx->len > 0) { - uint8_t line[MAX_STR_SIZE]; - - if (wcs_to_mbs_buf(line, ctx->line, MAX_STR_SIZE) == -1) { - reset_buf(ctx->line, &ctx->pos, &ctx->len); - wmove(self->window, y2 - CURS_Y_OFFSET, 0); - } else { - mvwprintw(ctx->linewin, 1, 0, "%s", line); + if (ctx->len > 0 && !ctx->hst->scroll_mode) { + uint8_t line[MAX_STR_SIZE]; + + if (wcs_to_mbs_buf(line, ctx->line, MAX_STR_SIZE) == -1) { + reset_buf(ctx->line, &ctx->pos, &ctx->len); + wmove(self->window, y2 - CURS_Y_OFFSET, 0); + } else { + mvwprintw(ctx->linewin, 1, 0, "%s", line); + } } } diff --git a/src/groupchat.c b/src/groupchat.c index 2220382..dc9bb5f 100644 --- a/src/groupchat.c +++ b/src/groupchat.c @@ -538,20 +538,23 @@ static void groupchat_onDraw(ToxWindow *self, Tox *m) ChatContext *ctx = self->chatwin; - if (!ctx->hst->scroll_mode) - scrollok(ctx->history, 1); - - wclear(ctx->linewin); line_info_print(self); + wclear(ctx->linewin); - if (ctx->len > 0) { - uint8_t line[MAX_STR_SIZE]; + if (ctx->hst->scroll_mode) { + line_info_onDraw(self); + } else { + curs_set(1); - if (wcs_to_mbs_buf(line, ctx->line, MAX_STR_SIZE) == -1) { - reset_buf(ctx->line, &ctx->pos, &ctx->len); - wmove(self->window, y2 - CURS_Y_OFFSET, 0); - } else { - mvwprintw(ctx->linewin, 1, 0, "%s", line); + if (ctx->len > 0) { + uint8_t line[MAX_STR_SIZE]; + + if (wcs_to_mbs_buf(line, ctx->line, MAX_STR_SIZE) == -1) { + reset_buf(ctx->line, &ctx->pos, &ctx->len); + wmove(self->window, y2 - CURS_Y_OFFSET, 0); + } else { + mvwprintw(ctx->linewin, 1, 0, "%s", line); + } } } diff --git a/src/line_info.c b/src/line_info.c index 28a053d..5d7ac51 100644 --- a/src/line_info.c +++ b/src/line_info.c @@ -392,6 +392,17 @@ void line_info_onKey(ToxWindow *self, wint_t key) } } +void line_info_onDraw(ToxWindow *self) +{ + ChatContext *ctx = self->chatwin; + + wattron(ctx->linewin, A_BOLD | COLOR_PAIR(BLUE)); + mvwprintw(ctx->linewin, 1, 0, "Scroll mode:\n"); + wattroff(ctx->linewin, A_BOLD | COLOR_PAIR(BLUE)); + mvwprintw(ctx->linewin, 1, 13, "Use up/down arrows, page up/page down, and home/end to navigate.\n" + " ESC to exit.\n"); +} + void line_info_clear(struct history *hst) { hst->line_start = hst->line_end; diff --git a/src/line_info.h b/src/line_info.h index 6ac1f2c..85c087b 100644 --- a/src/line_info.h +++ b/src/line_info.h @@ -79,3 +79,4 @@ void line_info_clear(struct history *hst); 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