| 15 |
***************************************************************************/ |
***************************************************************************/ |
| 16 |
|
|
| 17 |
#include "article_cache.h" |
#include "article_cache.h" |
| 18 |
|
#include "article_op.h" |
| 19 |
#include "article_post.h" |
#include "article_post.h" |
| 20 |
#include "article_view_log.h" |
#include "article_view_log.h" |
| 21 |
#include "article_del.h" |
#include "article_del.h" |
| 39 |
enum select_cmd_t |
enum select_cmd_t |
| 40 |
{ |
{ |
| 41 |
EXIT_SECTION = 0, |
EXIT_SECTION = 0, |
| 42 |
VIEW_ARTICLE = 1, |
VIEW_ARTICLE, |
| 43 |
CHANGE_PAGE = 2, |
CHANGE_PAGE, |
| 44 |
SHOW_HELP = 3, |
SHOW_HELP, |
| 45 |
CHANGE_NAME_DISPLAY = 4, |
CHANGE_NAME_DISPLAY, |
| 46 |
POST_ARTICLE = 5, |
POST_ARTICLE, |
| 47 |
EDIT_ARTICLE = 6, |
EDIT_ARTICLE, |
| 48 |
DELETE_ARTICLE = 7, |
DELETE_ARTICLE, |
| 49 |
FIRST_TOPIC_ARTICLE = 8, |
QUERY_ARTICLE, |
| 50 |
LAST_TOPIC_ARTICLE = 9, |
FIRST_TOPIC_ARTICLE, |
| 51 |
VIEW_EX_DIR = 10, |
LAST_TOPIC_ARTICLE, |
| 52 |
|
VIEW_EX_DIR, |
| 53 |
}; |
}; |
| 54 |
|
|
| 55 |
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) |
| 61 |
int eol; |
int eol; |
| 62 |
int len; |
int len; |
| 63 |
int i; |
int i; |
| 64 |
|
size_t j; |
| 65 |
char article_flag; |
char article_flag; |
| 66 |
int is_viewed; |
int is_viewed; |
| 67 |
time_t tm_now; |
time_t tm_now; |
| 112 |
strncpy(title_f, (p_articles[i]->tid == 0 ? "● " : ""), sizeof(title_f) - 1); |
strncpy(title_f, (p_articles[i]->tid == 0 ? "● " : ""), sizeof(title_f) - 1); |
| 113 |
title_f[sizeof(title_f) - 1] = '\0'; |
title_f[sizeof(title_f) - 1] = '\0'; |
| 114 |
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))); |
| 115 |
strncat(title_f, p_articles[i]->title, sizeof(title_f) - 1 - strnlen(title_f, sizeof(title_f))); |
|
| 116 |
|
// Rewrite title with "Re: Re: " prefix into "Re: ... " |
| 117 |
|
j = 0; |
| 118 |
|
if (p_articles[i]->tid != 0) |
| 119 |
|
{ |
| 120 |
|
while (strncmp(p_articles[i]->title + j, "Re: ", strlen("Re: ")) == 0) |
| 121 |
|
{ |
| 122 |
|
j += strlen("Re: "); |
| 123 |
|
} |
| 124 |
|
if (j >= strlen("Re: Re: ")) |
| 125 |
|
{ |
| 126 |
|
strncat(title_f, "Re: ... ", sizeof(title_f) - 1 - strnlen(title_f, sizeof(title_f))); |
| 127 |
|
} |
| 128 |
|
else |
| 129 |
|
{ |
| 130 |
|
j = 0; |
| 131 |
|
} |
| 132 |
|
} |
| 133 |
|
strncat(title_f, p_articles[i]->title + j, sizeof(title_f) - 1 - strnlen(title_f, sizeof(title_f))); |
| 134 |
|
|
| 135 |
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); |
| 136 |
if (title_f[len] != '\0') |
if (title_f[len] != '\0') |
| 137 |
{ |
{ |
| 260 |
case Ctrl('P'): |
case Ctrl('P'): |
| 261 |
return POST_ARTICLE; |
return POST_ARTICLE; |
| 262 |
case 'E': |
case 'E': |
| 263 |
return EDIT_ARTICLE; |
if (item_count > 0) |
| 264 |
|
{ |
| 265 |
|
return EDIT_ARTICLE; |
| 266 |
|
} |
| 267 |
|
break; |
| 268 |
case 'd': |
case 'd': |
| 269 |
return DELETE_ARTICLE; |
if (item_count > 0) |
| 270 |
|
{ |
| 271 |
|
return DELETE_ARTICLE; |
| 272 |
|
} |
| 273 |
|
break; |
| 274 |
|
case Ctrl('Q'): |
| 275 |
|
if (item_count > 0) |
| 276 |
|
{ |
| 277 |
|
return QUERY_ARTICLE; |
| 278 |
|
} |
| 279 |
|
break; |
| 280 |
case KEY_HOME: |
case KEY_HOME: |
| 281 |
*p_page_id = 0; |
*p_page_id = 0; |
| 282 |
case 'P': |
case 'P': |
| 329 |
} |
} |
| 330 |
break; |
break; |
| 331 |
case '=': |
case '=': |
| 332 |
return FIRST_TOPIC_ARTICLE; |
if (item_count > 0) |
| 333 |
|
{ |
| 334 |
|
return FIRST_TOPIC_ARTICLE; |
| 335 |
|
} |
| 336 |
|
break; |
| 337 |
case '\\': |
case '\\': |
| 338 |
return LAST_TOPIC_ARTICLE; |
if (item_count > 0) |
| 339 |
|
{ |
| 340 |
|
return LAST_TOPIC_ARTICLE; |
| 341 |
|
} |
| 342 |
|
break; |
| 343 |
case 'h': |
case 'h': |
| 344 |
return SHOW_HELP; |
return SHOW_HELP; |
| 345 |
case 'x': |
case 'x': |
| 814 |
} |
} |
| 815 |
if (section_list_draw_screen(sname, stitle, master_list, display_nickname) < 0) |
if (section_list_draw_screen(sname, stitle, master_list, display_nickname) < 0) |
| 816 |
{ |
{ |
| 817 |
|
log_error("section_list_draw_screen() error\n"); |
| 818 |
|
return -2; |
| 819 |
|
} |
| 820 |
|
break; |
| 821 |
|
case QUERY_ARTICLE: |
| 822 |
|
if ((ret = display_article_meta(p_articles[selected_index]->aid)) < 0) |
| 823 |
|
{ |
| 824 |
|
log_error("display_article_meta(aid=%d) error\n", p_articles[selected_index]->aid); |
| 825 |
|
} |
| 826 |
|
if (section_list_draw_screen(sname, stitle, master_list, display_nickname) < 0) |
| 827 |
|
{ |
| 828 |
log_error("section_list_draw_screen() error\n"); |
log_error("section_list_draw_screen() error\n"); |
| 829 |
return -2; |
return -2; |
| 830 |
} |
} |