diff --git a/src/chat.c b/src/chat.c index 0fbb60b..481620d 100644 --- a/src/chat.c +++ b/src/chat.c @@ -296,7 +296,7 @@ static void chat_onKey(ToxWindow *self, Tox *m, wint_t key) wmove(self->window, y2 - CURS_Y_OFFSET, 0); } else if (key == KEY_END) { /* END key: move cursor to end of line */ ctx->pos = ctx->len; - int end_y = (ctx->pos / x2) + y; + int end_y = (ctx->len / x2) + (y2 - CURS_Y_OFFSET); int end_x = ctx->len % x2; wmove(self->window, end_y, end_x); } else if (key == KEY_LEFT && ctx->pos > 0) { diff --git a/src/groupchat.c b/src/groupchat.c index 70efe7a..6ed792f 100644 --- a/src/groupchat.c +++ b/src/groupchat.c @@ -236,7 +236,7 @@ static void groupchat_onKey(ToxWindow *self, Tox *m, wint_t key) wmove(self->window, y2 - CURS_Y_OFFSET, 0); } else if (key == KEY_END) { /* END key: move cursor to end of line */ ctx->pos = ctx->len; - int end_y = (ctx->pos / x2) + y; + int end_y = (ctx->len / x2) + (y2 - CURS_Y_OFFSET); int end_x = ctx->len % x2; wmove(self->window, end_y, end_x); } else if (key == KEY_LEFT && ctx->pos > 0) {