From 3a176e1cab8cf7a64d645e91338289fa2a766283 Mon Sep 17 00:00:00 2001 From: Jfreegman Date: Thu, 25 Sep 2014 00:42:08 -0400 Subject: [PATCH] move to page end after pressing return --- src/chat.c | 3 ++- src/groupchat.c | 1 + src/line_info.c | 10 +++++----- src/line_info.h | 5 ++++- src/prompt.c | 1 + 5 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/chat.c b/src/chat.c index 255b6a5..d0c0243 100644 --- a/src/chat.c +++ b/src/chat.c @@ -928,6 +928,7 @@ static void chat_onKey(ToxWindow *self, Tox *m, wint_t key, bool ltr) wclear(ctx->linewin); wmove(self->window, y2 - CURS_Y_OFFSET, 0); + line_info_reset_start(self, ctx->hst); reset_buf(ctx); } @@ -1013,7 +1014,7 @@ static void chat_onDraw(ToxWindow *self, Tox *m) self->x = x2; /* Truncate note if it doesn't fit in statusbar */ - uint16_t maxlen = x2 - getcurx(statusbar->topline) - (KEY_IDENT_DIGITS * 2) - 3; + uint16_t maxlen = x2 - getcurx(statusbar->topline) - (KEY_IDENT_DIGITS * 2) - 6; if (statusbar->statusmsg_len > maxlen) { statusbar->statusmsg[maxlen - 3] = '\0'; diff --git a/src/groupchat.c b/src/groupchat.c index 959ce5f..37f6b46 100644 --- a/src/groupchat.c +++ b/src/groupchat.c @@ -426,6 +426,7 @@ static void groupchat_onKey(ToxWindow *self, Tox *m, wint_t key, bool ltr) wclear(ctx->linewin); wmove(self->window, y2 - CURS_Y_OFFSET, 0); + line_info_reset_start(self, ctx->hst); reset_buf(ctx); } } diff --git a/src/line_info.c b/src/line_info.c index 1ea5dab..e271797 100644 --- a/src/line_info.c +++ b/src/line_info.c @@ -48,8 +48,8 @@ void line_info_init(struct history *hst) hst->queue_sz = 0; } -/* resets line_start (page end) */ -static void line_info_reset_start(ToxWindow *self, struct history *hst) +/* resets line_start (moves to end of chat history) */ +void line_info_reset_start(ToxWindow *self, struct history *hst) { struct line_info *line = hst->line_end; @@ -111,13 +111,13 @@ static void line_info_root_fwd(struct history *hst) hst->line_root = tmp; } -/* returns ptr to queue item 0 and removes it from queue */ +/* returns ptr to queue item 0 and removes it from queue. Returns NULL if queue is empty. */ static struct line_info *line_info_ret_queue(struct history *hst) { if (hst->queue_sz <= 0) return NULL; - struct line_info *ret = hst->queue[0]; + struct line_info *line = hst->queue[0]; int i; @@ -126,7 +126,7 @@ static struct line_info *line_info_ret_queue(struct history *hst) --hst->queue_sz; - return ret; + return line; } /* creates new line_info line and puts it in the queue. */ diff --git a/src/line_info.h b/src/line_info.h index 1e0b66e..454e8fa 100644 --- a/src/line_info.h +++ b/src/line_info.h @@ -28,7 +28,7 @@ #define MAX_HISTORY 100000 #define MIN_HISTORY 40 -#define MAX_LINE_INFO_QUEUE 512 +#define MAX_LINE_INFO_QUEUE 1024 #define MAX_LINE_INFO_MSG_SIZE MAX_STR_SIZE + TOXIC_MAX_NAME_LENGTH + 32 /* needs extra room for log loading */ enum { @@ -89,6 +89,9 @@ void line_info_clear(struct history *hst); /* puts msg in specified line_info msg buffer */ void line_info_set(ToxWindow *self, uint32_t id, char *msg); +/* resets line_start (moves to end of chat history) */ +void line_info_reset_start(ToxWindow *self, struct history *hst); + void line_info_init(struct history *hst); bool line_info_onKey(ToxWindow *self, wint_t key); /* returns true if key is a match */ diff --git a/src/prompt.c b/src/prompt.c index 42f81ed..9c95394 100644 --- a/src/prompt.c +++ b/src/prompt.c @@ -212,6 +212,7 @@ static void prompt_onKey(ToxWindow *self, Tox *m, wint_t key, bool ltr) wclear(ctx->linewin); wmove(self->window, y2 - CURS_Y_OFFSET, 0); + line_info_reset_start(self, ctx->hst); reset_buf(ctx); } }