| 48 |
|
|
| 49 |
void clrtoeol() |
void clrtoeol() |
| 50 |
{ |
{ |
| 51 |
prints("\033[K"); |
prints(CTRL_SEQ_CLR_LINE); |
| 52 |
} |
} |
| 53 |
|
|
| 54 |
void clrline(int line_begin, int line_end) |
void clrline(int line_begin, int line_end) |
| 58 |
for (i = line_begin; i <= line_end; i++) |
for (i = line_begin; i <= line_end; i++) |
| 59 |
{ |
{ |
| 60 |
moveto(i, 0); |
moveto(i, 0); |
| 61 |
prints("\033[K"); |
prints(CTRL_SEQ_CLR_LINE); |
| 62 |
} |
} |
| 63 |
} |
} |
| 64 |
|
|
| 293 |
input_ok = 1; |
input_ok = 1; |
| 294 |
switch (ch) |
switch (ch) |
| 295 |
{ |
{ |
| 296 |
// case KEY_NULL: |
case KEY_NULL: |
| 297 |
case KEY_TIMEOUT: |
case KEY_TIMEOUT: |
| 298 |
goto cleanup; |
goto cleanup; |
| 299 |
case KEY_HOME: |
case KEY_HOME: |
| 403 |
len = p_line_offsets[line_current + 1] - p_line_offsets[line_current]; |
len = p_line_offsets[line_current + 1] - p_line_offsets[line_current]; |
| 404 |
if (len >= LINE_BUFFER_LEN) |
if (len >= LINE_BUFFER_LEN) |
| 405 |
{ |
{ |
| 406 |
log_error("Error length exceeds buffer size: %d\n", len); |
log_error("buffer overflow: len=%ld(%ld - %ld) line=%ld \n", |
| 407 |
|
len, p_line_offsets[line_current + 1], p_line_offsets[line_current], line_current); |
| 408 |
len = LINE_BUFFER_LEN - 1; |
len = LINE_BUFFER_LEN - 1; |
| 409 |
} |
} |
| 410 |
|
|
| 440 |
status_f[len] = '\0'; |
status_f[len] = '\0'; |
| 441 |
} |
} |
| 442 |
|
|
| 443 |
len = split_line(BBS_current_section_name, 20, &truncate, §ion_name_len); |
len = split_line(BBS_current_section_name, BBS_section_name_max_len, &truncate, §ion_name_len); |
| 444 |
if (truncate) |
if (truncate) |
| 445 |
{ |
{ |
| 446 |
log_error("Section name is truncated\n"); |
log_error("Section name is truncated\n"); |
| 449 |
moveto(1, 0); |
moveto(1, 0); |
| 450 |
clrtoeol(); |
clrtoeol(); |
| 451 |
prints("\033[1;44;33m%s\033[37m%*s%*s\033[33m 讨论区 [%s]\033[m", |
prints("\033[1;44;33m%s\033[37m%*s%*s\033[33m 讨论区 [%s]\033[m", |
| 452 |
status_f, 32, BBS_name, 26, "", BBS_current_section_name); |
status_f, 44 - status_len, BBS_name, 26 - section_name_len, "", BBS_current_section_name); |
|
iflush(); |
|
| 453 |
|
|
| 454 |
return 0; |
return 0; |
| 455 |
} |
} |
| 485 |
moveto(SCREEN_ROWS, 0); |
moveto(SCREEN_ROWS, 0); |
| 486 |
clrtoeol(); |
clrtoeol(); |
| 487 |
prints("\033[1;44;33m[\033[36m%s\033[33m]%*s%*s帐号[\033[36m%s\033[33m]" |
prints("\033[1;44;33m[\033[36m%s\033[33m]%*s%*s帐号[\033[36m%s\033[33m]" |
| 488 |
"[\033[36m%1d\033[33m:\033[36m%2d\033[33m:\033[36m%2d\033[33m]\033[m", |
"[\033[36m%1d\033[33m天\033[36m%2d\033[33m时\033[36m%2d\033[33m分]\033[m", |
| 489 |
str_time, 21, msg_f, 13 - len_username, "", BBS_username, |
str_time, 21, msg_f, 9 - len_username, "", BBS_username, |
| 490 |
tm_online->tm_mday - 1, tm_online->tm_hour, tm_online->tm_min); |
tm_online->tm_mday - 1, tm_online->tm_hour, tm_online->tm_min); |
|
iflush(); |
|
| 491 |
|
|
| 492 |
return 0; |
return 0; |
| 493 |
} |
} |
| 501 |
static const void *p_data; |
static const void *p_data; |
| 502 |
static const long *p_line_offsets; |
static const long *p_line_offsets; |
| 503 |
|
|
| 504 |
|
static time_t t_last_show = 0; |
| 505 |
|
static int line_last = 0; |
| 506 |
|
|
| 507 |
char buffer[LINE_BUFFER_LEN]; |
char buffer[LINE_BUFFER_LEN]; |
| 508 |
long int len; |
long int len; |
| 509 |
|
|
| 516 |
} |
} |
| 517 |
} |
} |
| 518 |
|
|
| 519 |
clrline(3, 2 + ACTIVE_BOARD_HEIGHT); |
if (time(0) - t_last_show >= 10) |
| 520 |
|
{ |
| 521 |
|
line_last = line_current; |
| 522 |
|
t_last_show = time(0); |
| 523 |
|
} |
| 524 |
|
else |
| 525 |
|
{ |
| 526 |
|
line_current = line_last; |
| 527 |
|
} |
| 528 |
|
|
| 529 |
|
clrline(2, 2 + ACTIVE_BOARD_HEIGHT); |
| 530 |
|
|
| 531 |
for (int i = 0; i < ACTIVE_BOARD_HEIGHT; i++) |
for (int i = 0; i < ACTIVE_BOARD_HEIGHT; i++) |
| 532 |
{ |
{ |
| 533 |
len = p_line_offsets[line_current + 1] - p_line_offsets[line_current]; |
len = p_line_offsets[line_current + 1] - p_line_offsets[line_current]; |
| 534 |
if (len >= LINE_BUFFER_LEN) |
if (len >= LINE_BUFFER_LEN) |
| 535 |
{ |
{ |
| 536 |
log_error("Error length exceeds buffer size: %d\n", len); |
log_error("buffer overflow: len=%ld(%ld - %ld) line=%ld \n", |
| 537 |
|
len, p_line_offsets[line_current + 1], p_line_offsets[line_current], line_current); |
| 538 |
len = LINE_BUFFER_LEN - 1; |
len = LINE_BUFFER_LEN - 1; |
| 539 |
} |
} |
| 540 |
|
|
| 551 |
break; |
break; |
| 552 |
} |
} |
| 553 |
} |
} |
|
iflush(); |
|
| 554 |
|
|
| 555 |
return 0; |
return 0; |
| 556 |
} |
} |