Fix for cursor position on mail listings

This commit is contained in:
Andrew Pamment 2017-03-17 21:18:59 +10:00
parent f681ddc568
commit 80b6ca1582
2 changed files with 19 additions and 13 deletions

17
email.c
View File

@ -199,7 +199,7 @@ void show_email(struct user_record *user, int msgno, int email_count, struct ema
} }
s_printf(get_string(187)); s_printf(get_string(187));
s_printf(get_string(191)); s_printf(get_string(191));
c = s_getc(); c = s_getchar();
if (tolower(c) == 'r') { if (tolower(c) == 'r') {
should_break = 1; should_break = 1;
@ -209,9 +209,9 @@ void show_email(struct user_record *user, int msgno, int email_count, struct ema
} else if (tolower(c) == 'd') { } else if (tolower(c) == 'd') {
should_break = 1; should_break = 1;
} else if (c == '\e') { } else if (c == '\e') {
c = s_getc(); c = s_getchar();
if (c == 91) { if (c == 91) {
c = s_getc(); c = s_getchar();
if (c == 65) { if (c == 65) {
position--; position--;
if (position < 0) { if (position < 0) {
@ -439,15 +439,16 @@ void list_emails(struct user_record *user) {
} }
} }
s_printf(get_string(190)); s_printf(get_string(190));
s_printf("\e[%d;5H", position - start + 2);
redraw = 0; redraw = 0;
} }
c = s_getc(); c = s_getchar();
if (tolower(c) == 'q') { if (tolower(c) == 'q') {
closed = 1; closed = 1;
} else if (c == 27) { } else if (c == 27) {
c = s_getc(); c = s_getchar();
if (c == 91) { if (c == 91) {
c = s_getc(); c = s_getchar();
if (c == 66) { if (c == 66) {
// down // down
position++; position++;
@ -460,6 +461,7 @@ void list_emails(struct user_record *user) {
} }
if (position == email_count) { if (position == email_count) {
position--; position--;
s_printf("\e[%d;5H", position - start + 2);
} else if (!redraw) { } else if (!redraw) {
s_printf("\e[%d;1H", position - start + 1); s_printf("\e[%d;1H", position - start + 1);
localtime_r((time_t *)&emails[position-1]->date, &msg_date); localtime_r((time_t *)&emails[position-1]->date, &msg_date);
@ -475,6 +477,7 @@ void list_emails(struct user_record *user) {
} else { } else {
s_printf(get_string(193), position + 1, emails[position]->subject, emails[position]->from, msg_date.tm_hour, msg_date.tm_min, msg_date.tm_mday, msg_date.tm_mon + 1, msg_date.tm_year - 100); s_printf(get_string(193), position + 1, emails[position]->subject, emails[position]->from, msg_date.tm_hour, msg_date.tm_min, msg_date.tm_mday, msg_date.tm_mon + 1, msg_date.tm_year - 100);
} }
s_printf("\e[%d;5H", position - start + 2);
} }
} else if (c == 65) { } else if (c == 65) {
// up // up
@ -505,7 +508,7 @@ void list_emails(struct user_record *user) {
} else { } else {
s_printf(get_string(193), position + 1, emails[position]->subject, emails[position]->from, msg_date.tm_hour, msg_date.tm_min, msg_date.tm_mday, msg_date.tm_mon + 1, msg_date.tm_year - 100); s_printf(get_string(193), position + 1, emails[position]->subject, emails[position]->from, msg_date.tm_hour, msg_date.tm_min, msg_date.tm_mday, msg_date.tm_mon + 1, msg_date.tm_year - 100);
} }
s_printf("\e[%d;5H", position - start + 3);
} }
} }
} }

View File

@ -2315,15 +2315,16 @@ int mail_menu(struct user_record *user) {
} }
} }
s_printf(get_string(190)); s_printf(get_string(190));
s_printf("\e[%d;5H", i - start + 1);
redraw = 0; redraw = 0;
} }
c = s_getc(); c = s_getchar();
if (tolower(c) == 'q') { if (tolower(c) == 'q') {
closed = 1; closed = 1;
} else if (c == 27) { } else if (c == 27) {
c = s_getc(); c = s_getchar();
if (c == 91) { if (c == 91) {
c = s_getc(); c = s_getchar();
if (c == 66) { if (c == 66) {
// down // down
i++; i++;
@ -2336,6 +2337,7 @@ int mail_menu(struct user_record *user) {
} }
if (i-1 == msghs->msg_count) { if (i-1 == msghs->msg_count) {
i--; i--;
s_printf("\e[%d;5H", i - start + 1);
} else if (!redraw) { } else if (!redraw) {
s_printf("\e[%d;1H", i - start); s_printf("\e[%d;1H", i - start);
localtime_r((time_t *)&msghs->msgs[i-2]->msg_h->DateWritten, &msg_date); localtime_r((time_t *)&msghs->msgs[i-2]->msg_h->DateWritten, &msg_date);
@ -2351,7 +2353,7 @@ int mail_menu(struct user_record *user) {
} else { } else {
s_printf(get_string(189), i, msghs->msgs[i-1]->subject, msghs->msgs[i-1]->from, msghs->msgs[i-1]->to, msg_date.tm_hour, msg_date.tm_min, msg_date.tm_mday, msg_date.tm_mon + 1, msg_date.tm_year - 100); s_printf(get_string(189), i, msghs->msgs[i-1]->subject, msghs->msgs[i-1]->from, msghs->msgs[i-1]->to, msg_date.tm_hour, msg_date.tm_min, msg_date.tm_mday, msg_date.tm_mon + 1, msg_date.tm_year - 100);
} }
s_printf("\e[%d;5H", i - start + 1);
} }
} else if (c == 65) { } else if (c == 65) {
// up // up
@ -2382,6 +2384,7 @@ int mail_menu(struct user_record *user) {
} else { } else {
s_printf(get_string(189), i, msghs->msgs[i-1]->subject, msghs->msgs[i-1]->from, msghs->msgs[i-1]->to, msg_date.tm_hour, msg_date.tm_min, msg_date.tm_mday, msg_date.tm_mon + 1, msg_date.tm_year - 100); s_printf(get_string(189), i, msghs->msgs[i-1]->subject, msghs->msgs[i-1]->from, msghs->msgs[i-1]->to, msg_date.tm_hour, msg_date.tm_min, msg_date.tm_mday, msg_date.tm_mon + 1, msg_date.tm_year - 100);
} }
s_printf("\e[%d;5H", i - start + 1);
} }
} }