| 14 |
* * |
* * |
| 15 |
***************************************************************************/ |
***************************************************************************/ |
| 16 |
|
|
| 17 |
|
#define _POSIX_C_SOURCE 200809L |
| 18 |
|
|
| 19 |
#include "section_list_display.h" |
#include "section_list_display.h" |
| 20 |
#include "section_list_loader.h" |
#include "section_list_loader.h" |
| 21 |
#include "article_cache.h" |
#include "article_cache.h" |
| 28 |
#include "user_priv.h" |
#include "user_priv.h" |
| 29 |
#include "article_view_log.h" |
#include "article_view_log.h" |
| 30 |
#include "str_process.h" |
#include "str_process.h" |
| 31 |
|
#include <string.h> |
| 32 |
#include <time.h> |
#include <time.h> |
| 33 |
#include <sys/param.h> |
#include <sys/param.h> |
|
#define _POSIX_C_SOURCE 200809L |
|
|
#include <string.h> |
|
| 34 |
|
|
| 35 |
static int section_topic_view_mode = 0; |
static int section_topic_view_mode = 0; |
| 36 |
static int section_topic_view_tid = -1; |
static int section_topic_view_tid = -1; |
| 45 |
POST_ARTICLE = 5, |
POST_ARTICLE = 5, |
| 46 |
EDIT_ARTICLE = 6, |
EDIT_ARTICLE = 6, |
| 47 |
DELETE_ARTICLE = 7, |
DELETE_ARTICLE = 7, |
| 48 |
|
SHOW_HELP = 8, |
| 49 |
}; |
}; |
| 50 |
|
|
| 51 |
static int section_list_draw_items(int page_id, ARTICLE *p_articles[], int article_count, int display_nickname) |
static int section_list_draw_items(int page_id, ARTICLE *p_articles[], int article_count, int display_nickname) |
| 106 |
title_f[sizeof(title_f) - 1] = '\0'; |
title_f[sizeof(title_f) - 1] = '\0'; |
| 107 |
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))); |
| 108 |
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))); |
| 109 |
len = split_line(title_f, 47 - (display_nickname ? 8 : 0), &eol, &title_f_len); |
len = split_line(title_f, 47 - (display_nickname ? 8 : 0), &eol, &title_f_len, 1); |
| 110 |
if (title_f[len] != '\0') |
if (title_f[len] != '\0') |
| 111 |
{ |
{ |
| 112 |
title_f[len] = '\0'; |
title_f[len] = '\0'; |
| 145 |
moveto(2, 0); |
moveto(2, 0); |
| 146 |
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] " |
| 147 |
"阅读[\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] " |
| 148 |
"修改[\033[1;32mE\033[0;37m] 删除[\033[1;32md\033[0;37m] %s[\033[1;32mn\033[0;37m]\033[m", |
"%s[\033[1;32mn\033[0;37m] 帮助[\033[1;32mh\033[0;37m]\033[m", |
| 149 |
(display_nickname ? "显示用户名" : "显示昵称")); |
(display_nickname ? "显示用户名" : "显示昵称")); |
| 150 |
moveto(3, 0); |
moveto(3, 0); |
| 151 |
if (display_nickname) |
if (display_nickname) |
| 195 |
return CHANGE_NAME_DISPLAY; |
return CHANGE_NAME_DISPLAY; |
| 196 |
case CR: |
case CR: |
| 197 |
igetch_reset(); |
igetch_reset(); |
| 198 |
|
case 'r': |
| 199 |
case KEY_RIGHT: |
case KEY_RIGHT: |
| 200 |
if (item_count > 0) |
if (item_count > 0) |
| 201 |
{ |
{ |
| 210 |
return DELETE_ARTICLE; |
return DELETE_ARTICLE; |
| 211 |
case KEY_HOME: |
case KEY_HOME: |
| 212 |
*p_page_id = 0; |
*p_page_id = 0; |
| 213 |
|
case 'P': |
| 214 |
case KEY_PGUP: |
case KEY_PGUP: |
| 215 |
*p_selected_index = 0; |
*p_selected_index = 0; |
| 216 |
|
case 'k': |
| 217 |
case KEY_UP: |
case KEY_UP: |
| 218 |
if (*p_selected_index <= 0) |
if (*p_selected_index <= 0) |
| 219 |
{ |
{ |
| 228 |
(*p_selected_index)--; |
(*p_selected_index)--; |
| 229 |
} |
} |
| 230 |
break; |
break; |
| 231 |
|
case '$': |
| 232 |
case KEY_END: |
case KEY_END: |
| 233 |
if (total_page > 0) |
if (total_page > 0) |
| 234 |
{ |
{ |
| 235 |
*p_page_id = total_page - 1; |
*p_page_id = total_page - 1; |
| 236 |
} |
} |
| 237 |
|
case 'N': |
| 238 |
case KEY_PGDN: |
case KEY_PGDN: |
| 239 |
if (item_count > 0) |
if (item_count > 0) |
| 240 |
{ |
{ |
| 241 |
*p_selected_index = item_count - 1; |
*p_selected_index = item_count - 1; |
| 242 |
} |
} |
| 243 |
|
case 'j': |
| 244 |
case KEY_DOWN: |
case KEY_DOWN: |
| 245 |
if (*p_selected_index + 1 >= item_count) // next page |
if (*p_selected_index + 1 >= item_count) // next page |
| 246 |
{ |
{ |
| 259 |
(*p_selected_index)++; |
(*p_selected_index)++; |
| 260 |
} |
} |
| 261 |
break; |
break; |
| 262 |
|
case 'h': |
| 263 |
|
return SHOW_HELP; |
| 264 |
default: |
default: |
| 265 |
} |
} |
| 266 |
|
|
| 297 |
switch (*p_key) |
switch (*p_key) |
| 298 |
{ |
{ |
| 299 |
case 'p': |
case 'p': |
| 300 |
|
case Ctrl('X'): |
| 301 |
section_topic_view_mode = !section_topic_view_mode; |
section_topic_view_mode = !section_topic_view_mode; |
| 302 |
case 0: // Set msg |
case 0: // Set msg |
| 303 |
if (section_topic_view_mode) |
if (section_topic_view_mode) |
| 334 |
return 1; |
return 1; |
| 335 |
} |
} |
| 336 |
break; |
break; |
| 337 |
|
case 'k': |
| 338 |
|
if (section_topic_view_mode) |
| 339 |
|
{ |
| 340 |
|
*p_key = KEY_PGUP; |
| 341 |
|
} |
| 342 |
|
else |
| 343 |
|
{ |
| 344 |
|
*p_key = KEY_UP; |
| 345 |
|
} |
| 346 |
|
return 1; |
| 347 |
case KEY_DOWN: |
case KEY_DOWN: |
| 348 |
case KEY_PGDN: |
case KEY_PGDN: |
| 349 |
case KEY_END: |
case KEY_END: |
| 360 |
return 1; |
return 1; |
| 361 |
} |
} |
| 362 |
break; |
break; |
| 363 |
|
case 'j': |
| 364 |
|
if (section_topic_view_mode) |
| 365 |
|
{ |
| 366 |
|
*p_key = KEY_PGDN; |
| 367 |
|
} |
| 368 |
|
else |
| 369 |
|
{ |
| 370 |
|
*p_key = KEY_DOWN; |
| 371 |
|
} |
| 372 |
|
return 1; |
| 373 |
} |
} |
| 374 |
|
|
| 375 |
return 0; |
return 0; |
| 661 |
if (section_list_draw_screen(sname, stitle, master_list, display_nickname) < 0) |
if (section_list_draw_screen(sname, stitle, master_list, display_nickname) < 0) |
| 662 |
{ |
{ |
| 663 |
log_error("section_list_draw_screen() error\n"); |
log_error("section_list_draw_screen() error\n"); |
| 664 |
|
return -2; |
| 665 |
|
} |
| 666 |
|
break; |
| 667 |
|
case SHOW_HELP: |
| 668 |
|
// Display help information |
| 669 |
|
display_file(DATA_READ_HELP, 1); |
| 670 |
|
if (section_list_draw_screen(sname, stitle, master_list, display_nickname) < 0) |
| 671 |
|
{ |
| 672 |
|
log_error("section_list_draw_screen() error\n"); |
| 673 |
return -2; |
return -2; |
| 674 |
} |
} |
| 675 |
break; |
break; |