Mail list index now uses a lightbar similar to mystic

This commit is contained in:
Andrew Pamment 2016-12-02 12:23:47 +10:00
parent 2aac742174
commit 7340e7c254
2 changed files with 102 additions and 36 deletions

View File

@ -124,9 +124,9 @@ Read message [1-%d] or N for New:
\r\nMailing to %d:%d/%d.%d\r\n \r\nMailing to %d:%d/%d.%d\r\n
\r\nMailing to @%d\r\n \r\nMailing to @%d\r\n
Start at message [1-%d] or N for New? Start at message [1-%d] or N for New?
\e[2J\e[1;37;44m[MSG#] Subject From To Date \r\n\e[0m \e[2J\e[1;1H\e[1;37;44m[MSG#] Subject From To Date \r\n\e[0m
\e[1;30m[\e[1;34m%4d\e[1;30m]\e[1;32m*\e[1;37m%-25.25s \e[1;32m%-15.15s \e[1;33m%-15.15s \e[1;35m%02d:%02d %02d-%02d-%02d\e[0m\r\n \e[1;30m[\e[1;34m%4d\e[1;30m]\e[1;32m*\e[1;37m%-25.25s \e[1;32m%-15.15s \e[1;33m%-15.15s \e[1;35m%02d:%02d %02d-%02d-%02d\e[K\e[0m\r\n
\e[1;30m[\e[1;34m%4d\e[1;30m] \e[1;37m%-25.25s \e[1;32m%-15.15s \e[1;33m%-15.15s \e[1;35m%02d:%02d %02d-%02d-%02d\e[0m\r\n \e[1;30m[\e[1;34m%4d\e[1;30m] \e[1;37m%-25.25s \e[1;32m%-15.15s \e[1;33m%-15.15s \e[1;35m%02d:%02d %02d-%02d-%02d\e[K\e[0m\r\n
(#) Read Message # (Q) Quit (ENTER) Continue\r\n (#) Read Message # (Q) Quit (ENTER) Continue\r\n
\r\nThere is no mail in this area\r\n \r\nThere is no mail in this area\r\n
\r\n\r\nMail Conferences:\r\n\r\n \r\n\r\nMail Conferences:\r\n\r\n
@ -186,3 +186,6 @@ Is this Correct? (Y/N)
\e[1;37mPress any key to continue...\e[0m \e[1;37mPress any key to continue...\e[0m
\e[24;1H\e[1;32mUp / Down \e[1;37mto Scroll, \e[1;32mLeft / Right \e[1;37mChange Message, \e[1;32mR \e[1;37mreply, \e[1;32mQ \e[1;37mquit\e[K\e[0m \e[24;1H\e[1;32mUp / Down \e[1;37mto Scroll, \e[1;32mLeft / Right \e[1;37mChange Message, \e[1;32mR \e[1;37mreply, \e[1;32mQ \e[1;37mquit\e[K\e[0m
\e[23;1H\e[1;30m-------------------------------------------------------------------------------\e[0m\r\n \e[23;1H\e[1;30m-------------------------------------------------------------------------------\e[0m\r\n
\e[1;30m[\e[1;34;44m%4d\e[1;30;40m]\e[1;32m*\e[1;37m%-25.25s \e[1;32m%-15.15s \e[1;33m%-15.15s \e[1;35m%02d:%02d %02d-%02d-%02d\e[K\e[0m\r\n
\e[1;30m[\e[1;34;44m%4d\e[1;30;40m] \e[1;37m%-25.25s \e[1;32m%-15.15s \e[1;33m%-15.15s \e[1;35m%02d:%02d %02d-%02d-%02d\e[K\e[0m\r\n
\e[24;1H\e[1;37;44mUp/Down to Scroll, Enter to read, Q to quit\e[K\e[0m

View File

@ -1302,7 +1302,9 @@ int mail_menu(struct user_record *user) {
int result; int result;
int sem_fd; int sem_fd;
int all_unread = 0; int all_unread = 0;
int redraw;
int start;
if (conf.script_path != NULL) { if (conf.script_path != NULL) {
sprintf(buffer, "%s/mailmenu.lua", conf.script_path); sprintf(buffer, "%s/mailmenu.lua", conf.script_path);
if (stat(buffer, &s) == 0) { if (stat(buffer, &s) == 0) {
@ -1703,43 +1705,104 @@ int mail_menu(struct user_record *user) {
} }
} }
closed = 0; closed = 0;
s_printf(get_string(126));
for (j=i-1;j<msghs->msg_count;j++) { redraw = 1;
localtime_r((time_t *)&msghs->msgs[j]->msg_h->DateWritten, &msg_date); start = i-1;
if (msghs->msgs[j]->msg_h->MsgNum > jlr.HighReadMsg || all_unread) { while (!closed) {
s_printf(get_string(127), j + 1, msghs->msgs[j]->subject, msghs->msgs[j]->from, msghs->msgs[j]->to, msg_date.tm_hour, msg_date.tm_min, msg_date.tm_mday, msg_date.tm_mon + 1, msg_date.tm_year - 100); if (redraw) {
} else { s_printf(get_string(126));
s_printf(get_string(128), j + 1, msghs->msgs[j]->subject, msghs->msgs[j]->from, msghs->msgs[j]->to, msg_date.tm_hour, msg_date.tm_min, msg_date.tm_mday, msg_date.tm_mon + 1, msg_date.tm_year - 100); for (j=start;j<start + 22 && j<msghs->msg_count;j++) {
} localtime_r((time_t *)&msghs->msgs[j]->msg_h->DateWritten, &msg_date);
if (j == i -1) {
if ((j - (i - 1)) != 0 && (j - (i - 1)) % 20 == 0) { if (msghs->msgs[j]->msg_h->MsgNum > jlr.HighReadMsg || all_unread) {
s_printf(get_string(129)); s_printf(get_string(188), j + 1, msghs->msgs[j]->subject, msghs->msgs[j]->from, msghs->msgs[j]->to, msg_date.tm_hour, msg_date.tm_min, msg_date.tm_mday, msg_date.tm_mon + 1, msg_date.tm_year - 100);
s_readstring(buffer, 6); } else {
s_printf(get_string(189), j + 1, msghs->msgs[j]->subject, msghs->msgs[j]->from, msghs->msgs[j]->to, msg_date.tm_hour, msg_date.tm_min, msg_date.tm_mday, msg_date.tm_mon + 1, msg_date.tm_year - 100);
if (tolower(buffer[0]) == 'q') { }
closed = 1; } else {
break; if (msghs->msgs[j]->msg_h->MsgNum > jlr.HighReadMsg || all_unread) {
} else if (strlen(buffer) > 0) { s_printf(get_string(127), j + 1, msghs->msgs[j]->subject, msghs->msgs[j]->from, msghs->msgs[j]->to, msg_date.tm_hour, msg_date.tm_min, msg_date.tm_mday, msg_date.tm_mon + 1, msg_date.tm_year - 100);
z = atoi(buffer); } else {
if (z > 0 && z <= msghs->msg_count) { s_printf(get_string(128), j + 1, msghs->msgs[j]->subject, msghs->msgs[j]->from, msghs->msgs[j]->to, msg_date.tm_hour, msg_date.tm_min, msg_date.tm_mday, msg_date.tm_mon + 1, msg_date.tm_year - 100);
closed = 1; }
read_message(user, msghs, z - 1);
break;
} }
} }
s_printf(get_string(126)); s_printf(get_string(190));
redraw = 0;
} }
c = s_getc();
} if (tolower(c) == 'q') {
if (closed == 0) { closed = 1;
s_printf(get_string(129)); } else if (c == 27) {
s_readstring(buffer, 6); c = s_getc();
if (strlen(buffer) > 0) { if (c == 91) {
z = atoi(buffer); c = s_getc();
if (z > 0 && z <= msghs->msg_count) { if (c == 66) {
read_message(user, msghs, z - 1); // down
i++;
if (i > start + 22) {
start += 22;
if (start > msghs->msg_count) {
start = msghs->msg_count - 22;
}
redraw = 1;
}
if (i-1 == msghs->msg_count) {
i--;
} else if (!redraw) {
s_printf("\e[%d;1H", i - start);
localtime_r((time_t *)&msghs->msgs[i-2]->msg_h->DateWritten, &msg_date);
if (msghs->msgs[i-2]->msg_h->MsgNum > jlr.HighReadMsg || all_unread) {
s_printf(get_string(127), i - 1, msghs->msgs[i-2]->subject, msghs->msgs[i-2]->from, msghs->msgs[i-2]->to, msg_date.tm_hour, msg_date.tm_min, msg_date.tm_mday, msg_date.tm_mon + 1, msg_date.tm_year - 100);
} else {
s_printf(get_string(128), i - 1, msghs->msgs[i-2]->subject, msghs->msgs[i-2]->from, msghs->msgs[i-2]->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;1H", i - start + 1);
localtime_r((time_t *)&msghs->msgs[i-1]->msg_h->DateWritten, &msg_date);
if (msghs->msgs[i-1]->msg_h->MsgNum > jlr.HighReadMsg || all_unread) {
s_printf(get_string(188), 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);
} 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);
}
}
} else if (c == 65) {
// up
i--;
if (i - 1 < start) {
start -=22;
if (start < 0) {
start = 0;
}
redraw = 1;
}
if (i <= 1) {
start = 0;
i = 1;
redraw = 1;
} else if (!redraw) {
s_printf("\e[%d;1H", i - start + 2);
localtime_r((time_t *)&msghs->msgs[i]->msg_h->DateWritten, &msg_date);
if (msghs->msgs[i]->msg_h->MsgNum > jlr.HighReadMsg || all_unread) {
s_printf(get_string(127), i + 1, msghs->msgs[i]->subject, msghs->msgs[i]->from, msghs->msgs[i]->to, msg_date.tm_hour, msg_date.tm_min, msg_date.tm_mday, msg_date.tm_mon + 1, msg_date.tm_year - 100);
} else {
s_printf(get_string(128), i + 1, msghs->msgs[i]->subject, msghs->msgs[i]->from, msghs->msgs[i]->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;1H", i - start + 1);
localtime_r((time_t *)&msghs->msgs[i-1]->msg_h->DateWritten, &msg_date);
if (msghs->msgs[i-1]->msg_h->MsgNum > jlr.HighReadMsg || all_unread) {
s_printf(get_string(188), 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);
} 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);
}
}
}
} }
} else if (c == 13) {
closed = 1;
read_message(user, msghs, i - 1);
} }
} }
} }