| 233 |
return len; |
return len; |
| 234 |
} |
} |
| 235 |
|
|
| 236 |
int display_data(const void *p_data, long line_total, const long *p_line_offsets, int begin_line, int wait, |
int display_data(const void *p_data, long line_total, const long *p_line_offsets, int begin_line, int eof_exit, |
| 237 |
display_data_key_handler key_handler, const char *help_filename) |
display_data_key_handler key_handler, const char *help_filename) |
| 238 |
{ |
{ |
| 239 |
static int show_help = 1; |
static int show_help = 1; |
| 260 |
loop = 1; |
loop = 1; |
| 261 |
while (!SYS_server_exit && loop) |
while (!SYS_server_exit && loop) |
| 262 |
{ |
{ |
| 263 |
if (line_current >= line_total && line_total <= SCREEN_ROWS - 2) |
if (eof_exit > 0 && line_current >= line_total && line_total <= SCREEN_ROWS - 2) |
| 264 |
{ |
{ |
| 265 |
if (wait) |
if (eof_exit == 1) |
| 266 |
{ |
{ |
| 267 |
ch = press_any_key(); |
ch = press_any_key(); |
| 268 |
} |
} |
| 269 |
else |
else // if (eof_exit == 2) |
| 270 |
{ |
{ |
| 271 |
iflush(); |
iflush(); |
| 272 |
} |
} |
| 445 |
|
|
| 446 |
static int display_file_key_handler(int *key, char *msg, size_t msg_len) |
static int display_file_key_handler(int *key, char *msg, size_t msg_len) |
| 447 |
{ |
{ |
|
static int topic_view = 0; |
|
|
|
|
| 448 |
switch (*key) |
switch (*key) |
| 449 |
{ |
{ |
| 450 |
case 0: // Set msg |
case 0: // Set msg |
| 453 |
"移动[\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] │ " |
| 454 |
"帮助[\033[32mh\033[33m] |"); |
"帮助[\033[32mh\033[33m] |"); |
| 455 |
break; |
break; |
|
case 'p': |
|
|
break; |
|
|
topic_view = !topic_view; |
|
|
if (topic_view) |
|
|
{ |
|
|
snprintf(msg, msg_len, |
|
|
"| 返回[\033[32m←\033[33m,\033[32mESC\033[33m] │ " |
|
|
"同主题阅读[\033[32m↑\033[33m/\033[32m↓\033[33m] │ " |
|
|
"帮助[\033[32mh\033[33m] |"); |
|
|
} |
|
|
else |
|
|
{ |
|
|
snprintf(msg, msg_len, |
|
|
"| 返回[\033[32m←\033[33m,\033[32mESC\033[33m] │ " |
|
|
"移动[\033[32m↑\033[33m/\033[32m↓\033[33m/\033[32mPgUp\033[33m/\033[32mPgDn\033[33m] │ " |
|
|
"帮助[\033[32mh\033[33m] |"); |
|
|
} |
|
|
*key = 0; |
|
|
break; |
|
| 456 |
case 'H': |
case 'H': |
| 457 |
*key = 'h'; |
*key = 'h'; |
| 458 |
return 0; |
return 0; |
| 461 |
return 0; |
return 0; |
| 462 |
} |
} |
| 463 |
|
|
| 464 |
int display_file(const char *filename, int begin_line, int wait) |
int display_file(const char *filename, int begin_line, int eof_exit) |
| 465 |
{ |
{ |
| 466 |
int ret; |
int ret; |
| 467 |
const void *p_shm; |
const void *p_shm; |
| 476 |
return KEY_NULL; |
return KEY_NULL; |
| 477 |
} |
} |
| 478 |
|
|
| 479 |
ret = display_data(p_data, line_total, p_line_offsets, begin_line, wait, display_file_key_handler, DATA_READ_HELP); |
ret = display_data(p_data, line_total, p_line_offsets, begin_line, eof_exit, display_file_key_handler, DATA_READ_HELP); |
| 480 |
|
|
| 481 |
if (detach_file_shm(p_shm) < 0) |
if (detach_file_shm(p_shm) < 0) |
| 482 |
{ |
{ |