| 33 |
|
|
| 34 |
#define ACTIVE_BOARD_HEIGHT 8 |
#define ACTIVE_BOARD_HEIGHT 8 |
| 35 |
|
|
|
int screen_rows = 24; |
|
|
int screen_cols = 80; |
|
|
|
|
| 36 |
void moveto(int row, int col) |
void moveto(int row, int col) |
| 37 |
{ |
{ |
| 38 |
if (row >= 0) |
if (row >= 0) |
| 76 |
|
|
| 77 |
int press_any_key() |
int press_any_key() |
| 78 |
{ |
{ |
| 79 |
moveto(screen_rows, 0); |
moveto(SCREEN_ROWS, 0); |
| 80 |
clrtoeol(); |
clrtoeol(); |
| 81 |
|
|
| 82 |
prints(" \033[1;33m按任意键继续...\033[0;37m"); |
prints(" \033[1;33m按任意键继续...\033[0;37m"); |
| 267 |
|
|
| 268 |
p_line_offsets = (long *)malloc(sizeof(long) * MAX_FILE_LINES); |
p_line_offsets = (long *)malloc(sizeof(long) * MAX_FILE_LINES); |
| 269 |
|
|
| 270 |
c_line_total = split_data_lines(p_data, screen_cols, p_line_offsets, MAX_FILE_LINES); |
c_line_total = split_data_lines(p_data, SCREEN_COLS, p_line_offsets, MAX_FILE_LINES); |
| 271 |
|
|
| 272 |
clrline(begin_line, screen_rows); |
clrline(begin_line, SCREEN_ROWS); |
| 273 |
line = begin_line; |
line = begin_line; |
| 274 |
max_lines = screen_rows - 1; |
max_lines = SCREEN_ROWS - 1; |
| 275 |
|
|
| 276 |
while (!SYS_server_exit && loop) |
while (!SYS_server_exit && loop) |
| 277 |
{ |
{ |
| 278 |
if (c_line_current >= c_line_total && c_line_total <= screen_rows - 2) |
if (c_line_current >= c_line_total && c_line_total <= SCREEN_ROWS - 2) |
| 279 |
{ |
{ |
| 280 |
if (wait) |
if (wait) |
| 281 |
{ |
{ |
| 292 |
|
|
| 293 |
if (c_line_current >= c_line_total || line >= max_lines) |
if (c_line_current >= c_line_total || line >= max_lines) |
| 294 |
{ |
{ |
| 295 |
if (c_line_current - (line - 1) + (screen_rows - 2) < c_line_total) |
if (c_line_current - (line - 1) + (SCREEN_ROWS - 2) < c_line_total) |
| 296 |
{ |
{ |
| 297 |
percentile = (c_line_current - (line - 1) + (screen_rows - 2)) * 100 / c_line_total; |
percentile = (c_line_current - (line - 1) + (SCREEN_ROWS - 2)) * 100 / c_line_total; |
| 298 |
} |
} |
| 299 |
else |
else |
| 300 |
{ |
{ |
| 301 |
percentile = 100; |
percentile = 100; |
| 302 |
} |
} |
| 303 |
|
|
| 304 |
moveto(screen_rows, 0); |
moveto(SCREEN_ROWS, 0); |
| 305 |
prints("\033[1;44;32m%s (%d%%)%s\033[33m │ 结束 ← <q> │ ↑/↓/PgUp/PgDn 移动 │ ? 辅助说明 │ \033[m", |
prints("\033[1;44;32m%s (%d%%)%s\033[33m │ 结束 ← <q> │ ↑/↓/PgUp/PgDn 移动 │ ? 辅助说明 │ \033[m", |
| 306 |
(percentile < 100 ? "下面还有喔" : "没有更多了"), percentile, |
(percentile < 100 ? "下面还有喔" : "没有更多了"), percentile, |
| 307 |
(percentile < 10 ? " " : (percentile < 100 ? " " : ""))); |
(percentile < 10 ? " " : (percentile < 100 ? " " : ""))); |
| 320 |
case KEY_HOME: |
case KEY_HOME: |
| 321 |
c_line_current = 0; |
c_line_current = 0; |
| 322 |
line = begin_line; |
line = begin_line; |
| 323 |
max_lines = screen_rows - 1; |
max_lines = SCREEN_ROWS - 1; |
| 324 |
clrline(begin_line, screen_rows); |
clrline(begin_line, SCREEN_ROWS); |
| 325 |
break; |
break; |
| 326 |
case KEY_END: |
case KEY_END: |
| 327 |
c_line_current = c_line_total - (screen_rows - 2); |
c_line_current = c_line_total - (SCREEN_ROWS - 2); |
| 328 |
line = begin_line; |
line = begin_line; |
| 329 |
max_lines = screen_rows - 1; |
max_lines = SCREEN_ROWS - 1; |
| 330 |
clrline(begin_line, screen_rows); |
clrline(begin_line, SCREEN_ROWS); |
| 331 |
break; |
break; |
| 332 |
case KEY_UP: |
case KEY_UP: |
| 333 |
if (c_line_current - line < 0) // Reach top |
if (c_line_current - line < 0) // Reach top |
| 338 |
line = begin_line; |
line = begin_line; |
| 339 |
// max_lines = begin_line + 1; |
// max_lines = begin_line + 1; |
| 340 |
// prints("\033[T"); // Scroll down 1 line |
// prints("\033[T"); // Scroll down 1 line |
| 341 |
max_lines = screen_rows - 1; // Legacy Fterm only works with this line |
max_lines = SCREEN_ROWS - 1; // Legacy Fterm only works with this line |
| 342 |
break; |
break; |
| 343 |
case CR: |
case CR: |
| 344 |
igetch_reset(); |
igetch_reset(); |
| 345 |
case KEY_DOWN: |
case KEY_DOWN: |
| 346 |
if (c_line_current + ((screen_rows - 2) - (line - 1)) >= c_line_total) // Reach bottom |
if (c_line_current + ((SCREEN_ROWS - 2) - (line - 1)) >= c_line_total) // Reach bottom |
| 347 |
{ |
{ |
| 348 |
break; |
break; |
| 349 |
} |
} |
| 350 |
c_line_current += ((screen_rows - 2) - (line - 1)); |
c_line_current += ((SCREEN_ROWS - 2) - (line - 1)); |
| 351 |
line = screen_rows - 2; |
line = SCREEN_ROWS - 2; |
| 352 |
max_lines = screen_rows - 1; |
max_lines = SCREEN_ROWS - 1; |
| 353 |
moveto(screen_rows, 0); |
moveto(SCREEN_ROWS, 0); |
| 354 |
clrtoeol(); |
clrtoeol(); |
| 355 |
prints("\033[S"); // Scroll up 1 line |
prints("\033[S"); // Scroll up 1 line |
| 356 |
break; |
break; |
| 360 |
{ |
{ |
| 361 |
break; |
break; |
| 362 |
} |
} |
| 363 |
c_line_current -= ((screen_rows - 3) + (line - 1)); |
c_line_current -= ((SCREEN_ROWS - 3) + (line - 1)); |
| 364 |
if (c_line_current < 0) |
if (c_line_current < 0) |
| 365 |
{ |
{ |
| 366 |
c_line_current = 0; |
c_line_current = 0; |
| 367 |
} |
} |
| 368 |
line = begin_line; |
line = begin_line; |
| 369 |
max_lines = screen_rows - 1; |
max_lines = SCREEN_ROWS - 1; |
| 370 |
clrline(begin_line, screen_rows); |
clrline(begin_line, SCREEN_ROWS); |
| 371 |
break; |
break; |
| 372 |
case KEY_RIGHT: |
case KEY_RIGHT: |
| 373 |
case KEY_PGDN: |
case KEY_PGDN: |
| 374 |
case Ctrl('F'): |
case Ctrl('F'): |
| 375 |
case KEY_SPACE: |
case KEY_SPACE: |
| 376 |
if (c_line_current + (screen_rows - 2) - (line - 1) >= c_line_total) // Reach bottom |
if (c_line_current + (SCREEN_ROWS - 2) - (line - 1) >= c_line_total) // Reach bottom |
| 377 |
{ |
{ |
| 378 |
break; |
break; |
| 379 |
} |
} |
| 380 |
c_line_current += (screen_rows - 3) - (line - 1); |
c_line_current += (SCREEN_ROWS - 3) - (line - 1); |
| 381 |
if (c_line_current + screen_rows - 2 > c_line_total) // No enough lines to display |
if (c_line_current + SCREEN_ROWS - 2 > c_line_total) // No enough lines to display |
| 382 |
{ |
{ |
| 383 |
c_line_current = c_line_total - (screen_rows - 2); |
c_line_current = c_line_total - (SCREEN_ROWS - 2); |
| 384 |
} |
} |
| 385 |
line = begin_line; |
line = begin_line; |
| 386 |
max_lines = screen_rows - 1; |
max_lines = SCREEN_ROWS - 1; |
| 387 |
clrline(begin_line, screen_rows); |
clrline(begin_line, SCREEN_ROWS); |
| 388 |
break; |
break; |
| 389 |
case KEY_LEFT: |
case KEY_LEFT: |
| 390 |
case 'q': |
case 'q': |
| 407 |
// Refresh after display help information |
// Refresh after display help information |
| 408 |
c_line_current -= (line - 1); |
c_line_current -= (line - 1); |
| 409 |
line = begin_line; |
line = begin_line; |
| 410 |
max_lines = screen_rows - 1; |
max_lines = SCREEN_ROWS - 1; |
| 411 |
clrline(begin_line, screen_rows); |
clrline(begin_line, SCREEN_ROWS); |
| 412 |
break; |
break; |
| 413 |
default: |
default: |
| 414 |
log_std("Input: %d\n", ch); |
log_std("Input: %d\n", ch); |
| 495 |
time_online = time(0) - BBS_login_tm; |
time_online = time(0) - BBS_login_tm; |
| 496 |
tm_online = gmtime(&time_online); |
tm_online = gmtime(&time_online); |
| 497 |
|
|
| 498 |
moveto(screen_rows, 0); |
moveto(SCREEN_ROWS, 0); |
| 499 |
clrtoeol(); |
clrtoeol(); |
| 500 |
prints("\033[1;44;33m[\033[36m%s\033[33m]%s帐号[\033[36m%s\033[33m]" |
prints("\033[1;44;33m[\033[36m%s\033[33m]%s帐号[\033[36m%s\033[33m]" |
| 501 |
"[\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", |
| 542 |
break; |
break; |
| 543 |
} |
} |
| 544 |
line++; |
line++; |
| 545 |
len = split_line(buffer, screen_cols, &end_of_line, &display_len); |
len = split_line(buffer, SCREEN_COLS, &end_of_line, &display_len); |
| 546 |
buffer[len] = '\0'; // Truncate over-length line |
buffer[len] = '\0'; // Truncate over-length line |
| 547 |
moveto(3 + i, 0); |
moveto(3 + i, 0); |
| 548 |
prints("%s", buffer); |
prints("%s", buffer); |