| 22 |
#include "io.h" |
#include "io.h" |
| 23 |
#include "log.h" |
#include "log.h" |
| 24 |
#include "login.h" |
#include "login.h" |
| 25 |
|
#include "menu.h" |
| 26 |
#include "section_list_display.h" |
#include "section_list_display.h" |
| 27 |
#include "section_list_loader.h" |
#include "section_list_loader.h" |
| 28 |
#include "screen.h" |
#include "screen.h" |
| 47 |
DELETE_ARTICLE = 7, |
DELETE_ARTICLE = 7, |
| 48 |
FIRST_TOPIC_ARTICLE = 8, |
FIRST_TOPIC_ARTICLE = 8, |
| 49 |
LAST_TOPIC_ARTICLE = 9, |
LAST_TOPIC_ARTICLE = 9, |
| 50 |
|
VIEW_EX_DIR = 10, |
| 51 |
}; |
}; |
| 52 |
|
|
| 53 |
static int section_list_draw_items(int page_id, ARTICLE *p_articles[], int article_count, int display_nickname, int ontop_start_offset) |
static int section_list_draw_items(int page_id, ARTICLE *p_articles[], int article_count, int display_nickname, int ontop_start_offset) |
| 106 |
strftime(str_time, sizeof(str_time), "%m/%Y", &tm_sub); |
strftime(str_time, sizeof(str_time), "%m/%Y", &tm_sub); |
| 107 |
} |
} |
| 108 |
|
|
| 109 |
strncpy(title_f, (p_articles[i]->tid == 0 ? " " : ""), sizeof(title_f) - 1); |
strncpy(title_f, (p_articles[i]->tid == 0 ? "● " : ""), sizeof(title_f) - 1); |
| 110 |
title_f[sizeof(title_f) - 1] = '\0'; |
title_f[sizeof(title_f) - 1] = '\0'; |
| 111 |
strncat(title_f, (p_articles[i]->transship ? "[ת]" : ""), sizeof(title_f) - 1 - strnlen(title_f, sizeof(title_f))); |
strncat(title_f, (p_articles[i]->transship ? "[转载]" : ""), sizeof(title_f) - 1 - strnlen(title_f, sizeof(title_f))); |
| 112 |
strncat(title_f, p_articles[i]->title, sizeof(title_f) - 1 - strnlen(title_f, sizeof(title_f))); |
strncat(title_f, p_articles[i]->title, sizeof(title_f) - 1 - strnlen(title_f, sizeof(title_f))); |
| 113 |
len = split_line(title_f, 47 - (display_nickname ? 8 : 0), &eol, &title_f_len, 1); |
len = split_line(title_f, 47 - (display_nickname ? 8 : 0), &eol, &title_f_len, 1); |
| 114 |
if (title_f[len] != '\0') |
if (title_f[len] != '\0') |
| 119 |
moveto(4 + i, 1); |
moveto(4 + i, 1); |
| 120 |
if (i >= ontop_start_offset) |
if (i >= ontop_start_offset) |
| 121 |
{ |
{ |
| 122 |
prints(" \033[1;33m[ʾ]\033[m %c %s%*s %s %s%s\033[m", |
prints(" \033[1;33m[提示]\033[m %c %s%*s %s %s%s\033[m", |
| 123 |
article_flag, |
article_flag, |
| 124 |
(display_nickname ? p_articles[i]->nickname : p_articles[i]->username), |
(display_nickname ? p_articles[i]->nickname : p_articles[i]->username), |
| 125 |
(display_nickname ? BBS_nickname_max_len - (int)strnlen(p_articles[i]->nickname, sizeof(p_articles[i]->nickname)) |
(display_nickname ? BBS_nickname_max_len - (int)strnlen(p_articles[i]->nickname, sizeof(p_articles[i]->nickname)) |
| 162 |
|
|
| 163 |
static int section_list_draw_screen(const char *sname, const char *stitle, const char *master_list, int display_nickname) |
static int section_list_draw_screen(const char *sname, const char *stitle, const char *master_list, int display_nickname) |
| 164 |
{ |
{ |
| 165 |
char str_section_master[LINE_BUFFER_LEN] = ""; |
char str_section_master[LINE_BUFFER_LEN] = "诚征版主中"; |
| 166 |
char str_section_name[LINE_BUFFER_LEN]; |
char str_section_name[LINE_BUFFER_LEN]; |
| 167 |
|
|
| 168 |
if (master_list[0] != '\0') |
if (master_list[0] != '\0') |
| 169 |
{ |
{ |
| 170 |
snprintf(str_section_master, sizeof(str_section_master), "%s", master_list); |
snprintf(str_section_master, sizeof(str_section_master), "版主:%s", master_list); |
| 171 |
} |
} |
| 172 |
snprintf(str_section_name, sizeof(str_section_name), " [%s]", sname); |
snprintf(str_section_name, sizeof(str_section_name), "讨论区 [%s]", sname); |
| 173 |
|
|
| 174 |
clearscr(); |
clearscr(); |
| 175 |
show_top(str_section_master, stitle, str_section_name); |
show_top(str_section_master, stitle, str_section_name); |
| 176 |
moveto(2, 0); |
moveto(2, 0); |
| 177 |
prints("[\033[1;32m\033[0;37m,\033[1;32mESC\033[0;37m] ѡ[\033[1;32m\033[0;37m,\033[1;32m\033[0;37m] " |
prints("返回[\033[1;32m←\033[0;37m,\033[1;32mESC\033[0;37m] 选择[\033[1;32m↑\033[0;37m,\033[1;32m↓\033[0;37m] " |
| 178 |
"Ķ[\033[1;32m\033[0;37m,\033[1;32mENTER\033[0;37m] [\033[1;32mCtrl-P\033[0;37m] " |
"阅读[\033[1;32m→\033[0;37m,\033[1;32mENTER\033[0;37m] 发表[\033[1;32mCtrl-P\033[0;37m] " |
| 179 |
"%s[\033[1;32mn\033[0;37m] [\033[1;32mh\033[0;37m]\033[m", |
"%s[\033[1;32mn\033[0;37m] 精华区[\033[1;32mx\033[0;37m] 帮助[\033[1;32mh\033[0;37m]\033[m", |
| 180 |
(display_nickname ? "ʾû" : "ʾdz")); |
(display_nickname ? "用户名" : "昵称")); |
| 181 |
moveto(3, 0); |
moveto(3, 0); |
| 182 |
if (display_nickname) |
if (display_nickname) |
| 183 |
{ |
{ |
| 184 |
prints("\033[44;37m \033[1;37m dz ± \033[m"); |
prints("\033[44;37m \033[1;37m 编 号 发布者昵称 日 期 文章标题 \033[m"); |
| 185 |
} |
} |
| 186 |
else |
else |
| 187 |
{ |
{ |
| 188 |
prints("\033[44;37m \033[1;37m ± \033[m"); |
prints("\033[44;37m \033[1;37m 编 号 发 布 者 日 期 文章标题 \033[m"); |
| 189 |
} |
} |
| 190 |
|
|
| 191 |
return 0; |
return 0; |
| 298 |
return LAST_TOPIC_ARTICLE; |
return LAST_TOPIC_ARTICLE; |
| 299 |
case 'h': |
case 'h': |
| 300 |
return SHOW_HELP; |
return SHOW_HELP; |
| 301 |
|
case 'x': |
| 302 |
|
return VIEW_EX_DIR; |
| 303 |
default: |
default: |
| 304 |
} |
} |
| 305 |
|
|
| 346 |
if (section_topic_view_mode) |
if (section_topic_view_mode) |
| 347 |
{ |
{ |
| 348 |
snprintf(p_ctx->msg, sizeof(p_ctx->msg), |
snprintf(p_ctx->msg, sizeof(p_ctx->msg), |
| 349 |
"| [\033[32m\033[33m,\033[32mESC\033[33m] " |
"| 返回[\033[32m←\033[33m,\033[32mESC\033[33m] " |
| 350 |
"ͬĶ[\033[32m\033[33m/\033[32m\033[33m] " |
"同主题阅读[\033[32m↑\033[33m/\033[32m↓\033[33m] " |
| 351 |
"л[\033[32mp\033[33m] ظ[\033[32mr\033[33m] [\033[32mh\033[33m] |"); |
"切换[\033[32mp\033[33m] 回复[\033[32mr\033[33m] 帮助[\033[32mh\033[33m] |"); |
| 352 |
} |
} |
| 353 |
else |
else |
| 354 |
{ |
{ |
| 355 |
snprintf(p_ctx->msg, sizeof(p_ctx->msg), |
snprintf(p_ctx->msg, sizeof(p_ctx->msg), |
| 356 |
"| [\033[32m\033[33m,\033[32mESC\033[33m] " |
"| 返回[\033[32m←\033[33m,\033[32mESC\033[33m] " |
| 357 |
"ƶ[\033[32m\033[33m/\033[32m\033[33m/\033[32mPgUp\033[33m/\033[32mPgDn\033[33m] " |
"移动[\033[32m↑\033[33m/\033[32m↓\033[33m/\033[32mPgUp\033[33m/\033[32mPgDn\033[33m] " |
| 358 |
"л[\033[32mp\033[33m] ظ[\033[32mr\033[33m] [\033[32mh\033[33m] |"); |
"切换[\033[32mp\033[33m] 回复[\033[32mr\033[33m] 帮助[\033[32mh\033[33m] |"); |
| 359 |
} |
} |
| 360 |
*p_key = 0; |
*p_key = 0; |
| 361 |
break; |
break; |
| 495 |
} |
} |
| 496 |
|
|
| 497 |
snprintf(page_info_str, sizeof(page_info_str), |
snprintf(page_info_str, sizeof(page_info_str), |
| 498 |
"\033[33m[\033[36m%d\033[33m/\033[36m%d\033[33mҳ]", |
"\033[33m[第\033[36m%d\033[33m/\033[36m%d\033[33m页]", |
| 499 |
page_id + 1, MAX(page_count, 1)); |
page_id + 1, MAX(page_count, 1)); |
| 500 |
|
|
| 501 |
show_bottom(page_info_str); |
show_bottom(page_info_str); |
| 805 |
return -2; |
return -2; |
| 806 |
} |
} |
| 807 |
break; |
break; |
| 808 |
|
case VIEW_EX_DIR: |
| 809 |
|
if (section_list_ex_dir_display(p_section) < 0) |
| 810 |
|
{ |
| 811 |
|
log_error("section_list_ex_dir_display(sid=%d) error\n", p_section->sid); |
| 812 |
|
} |
| 813 |
|
if (section_list_draw_screen(sname, stitle, master_list, display_nickname) < 0) |
| 814 |
|
{ |
| 815 |
|
log_error("section_list_draw_screen() error\n"); |
| 816 |
|
return -2; |
| 817 |
|
} |
| 818 |
|
break; |
| 819 |
default: |
default: |
| 820 |
log_error("Unknown command %d\n", ret); |
log_error("Unknown command %d\n", ret); |
| 821 |
} |
} |
| 823 |
|
|
| 824 |
return 0; |
return 0; |
| 825 |
} |
} |
| 826 |
|
|
| 827 |
|
int section_list_ex_dir_display(SECTION_LIST *p_section) |
| 828 |
|
{ |
| 829 |
|
MENU_SET ex_menu_set; |
| 830 |
|
int ch = 0; |
| 831 |
|
|
| 832 |
|
if (p_section == NULL) |
| 833 |
|
{ |
| 834 |
|
log_error("NULL pointer error\n"); |
| 835 |
|
return -1; |
| 836 |
|
} |
| 837 |
|
|
| 838 |
|
if (p_section->ex_menu_tm == 0) // N/A |
| 839 |
|
{ |
| 840 |
|
moveto(2, 1); |
| 841 |
|
clrtoeol(); |
| 842 |
|
prints("该版块精华区未开放"); |
| 843 |
|
press_any_key(); |
| 844 |
|
return 0; |
| 845 |
|
} |
| 846 |
|
|
| 847 |
|
if (get_section_ex_menu_set(p_section, &ex_menu_set) < 0) |
| 848 |
|
{ |
| 849 |
|
log_error("get_section_ex_menu_set(sid=%d) error\n", p_section->sid); |
| 850 |
|
return -3; |
| 851 |
|
} |
| 852 |
|
if (get_menu_shm_readonly(&ex_menu_set) < 0) |
| 853 |
|
{ |
| 854 |
|
log_error("get_menu_shm_readonly(sid=%d) error\n", p_section->sid); |
| 855 |
|
return -3; |
| 856 |
|
} |
| 857 |
|
|
| 858 |
|
clearscr(); |
| 859 |
|
show_bottom(""); |
| 860 |
|
|
| 861 |
|
if (display_menu(&ex_menu_set) == 0) |
| 862 |
|
{ |
| 863 |
|
while (!SYS_server_exit) |
| 864 |
|
{ |
| 865 |
|
iflush(); |
| 866 |
|
ch = igetch(100); |
| 867 |
|
switch (ch) |
| 868 |
|
{ |
| 869 |
|
case KEY_NULL: // broken pipe |
| 870 |
|
return 0; |
| 871 |
|
case KEY_TIMEOUT: |
| 872 |
|
if (time(NULL) - BBS_last_access_tm >= MAX_DELAY_TIME) |
| 873 |
|
{ |
| 874 |
|
return 0; |
| 875 |
|
} |
| 876 |
|
continue; |
| 877 |
|
case CR: |
| 878 |
|
igetch_reset(); |
| 879 |
|
default: |
| 880 |
|
switch (menu_control(&ex_menu_set, ch)) |
| 881 |
|
{ |
| 882 |
|
case EXITMENU: |
| 883 |
|
ch = EXITMENU; |
| 884 |
|
break; |
| 885 |
|
case REDRAW: |
| 886 |
|
clearscr(); |
| 887 |
|
show_bottom(""); |
| 888 |
|
display_menu(&ex_menu_set); |
| 889 |
|
break; |
| 890 |
|
case NOREDRAW: |
| 891 |
|
case UNKNOWN_CMD: |
| 892 |
|
default: |
| 893 |
|
break; |
| 894 |
|
} |
| 895 |
|
} |
| 896 |
|
|
| 897 |
|
BBS_last_access_tm = time(NULL); |
| 898 |
|
|
| 899 |
|
if (ch == EXITMENU) |
| 900 |
|
{ |
| 901 |
|
break; |
| 902 |
|
} |
| 903 |
|
} |
| 904 |
|
} |
| 905 |
|
|
| 906 |
|
detach_menu_shm(&ex_menu_set); |
| 907 |
|
|
| 908 |
|
return 0; |
| 909 |
|
} |