From 7340e7c2540685e676e55a1c6a72110f8c2d68bd Mon Sep 17 00:00:00 2001 From: Andrew Pamment Date: Fri, 2 Dec 2016 12:23:47 +1000 Subject: [PATCH] Mail list index now uses a lightbar similar to mystic --- magicka.strings | 9 ++-- mail_menu.c | 129 +++++++++++++++++++++++++++++++++++------------- 2 files changed, 102 insertions(+), 36 deletions(-) diff --git a/magicka.strings b/magicka.strings index f676c9f..64c0e37 100644 --- a/magicka.strings +++ b/magicka.strings @@ -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\r\n 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[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;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[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[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[K\e[0m\r\n (#) Read Message # (Q) Quit (ENTER) Continue\r\n \r\nThere is no mail in this area\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[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[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 diff --git a/mail_menu.c b/mail_menu.c index 8280212..65ac6ba 100644 --- a/mail_menu.c +++ b/mail_menu.c @@ -1302,7 +1302,9 @@ int mail_menu(struct user_record *user) { int result; int sem_fd; int all_unread = 0; - + int redraw; + int start; + if (conf.script_path != NULL) { sprintf(buffer, "%s/mailmenu.lua", conf.script_path); if (stat(buffer, &s) == 0) { @@ -1703,43 +1705,104 @@ int mail_menu(struct user_record *user) { } } closed = 0; - s_printf(get_string(126)); + - for (j=i-1;jmsg_count;j++) { - localtime_r((time_t *)&msghs->msgs[j]->msg_h->DateWritten, &msg_date); - if (msghs->msgs[j]->msg_h->MsgNum > jlr.HighReadMsg || all_unread) { - 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); - } else { - 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); - } - - if ((j - (i - 1)) != 0 && (j - (i - 1)) % 20 == 0) { - s_printf(get_string(129)); - s_readstring(buffer, 6); - - if (tolower(buffer[0]) == 'q') { - closed = 1; - break; - } else if (strlen(buffer) > 0) { - z = atoi(buffer); - if (z > 0 && z <= msghs->msg_count) { - closed = 1; - read_message(user, msghs, z - 1); - break; + redraw = 1; + start = i-1; + while (!closed) { + if (redraw) { + s_printf(get_string(126)); + for (j=start;jmsg_count;j++) { + localtime_r((time_t *)&msghs->msgs[j]->msg_h->DateWritten, &msg_date); + if (j == i -1) { + if (msghs->msgs[j]->msg_h->MsgNum > jlr.HighReadMsg || all_unread) { + 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); + } 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); + } + } else { + if (msghs->msgs[j]->msg_h->MsgNum > jlr.HighReadMsg || all_unread) { + 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); + } else { + 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); + } } } - s_printf(get_string(126)); + s_printf(get_string(190)); + redraw = 0; } - - } - if (closed == 0) { - s_printf(get_string(129)); - s_readstring(buffer, 6); - if (strlen(buffer) > 0) { - z = atoi(buffer); - if (z > 0 && z <= msghs->msg_count) { - read_message(user, msghs, z - 1); + c = s_getc(); + if (tolower(c) == 'q') { + closed = 1; + } else if (c == 27) { + c = s_getc(); + if (c == 91) { + c = s_getc(); + if (c == 66) { + // 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); } } }