1
0
mirror of https://github.com/Tha14/toxic.git synced 2024-11-23 03:03:02 +01:00

move to page end after pressing return

This commit is contained in:
Jfreegman 2014-09-25 00:42:08 -04:00
parent 00cccad22c
commit 3a176e1cab
No known key found for this signature in database
GPG Key ID: 3627F3144076AE63
5 changed files with 13 additions and 7 deletions

View File

@ -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';

View File

@ -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);
}
}

View File

@ -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. */

View File

@ -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 */

View File

@ -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);
}
}