| 182 |
offset--; |
offset--; |
| 183 |
if (buffer[offset] < 0 || buffer[offset] > 127) // UTF8 |
if (buffer[offset] < 0 || buffer[offset] > 127) // UTF8 |
| 184 |
{ |
{ |
| 185 |
while (offset > 0 && (buffer[offset] & 0b11000000) != 0b11000000) |
while (offset > 0 && (buffer[offset] & 0xc0) != 0xc0) |
| 186 |
{ |
{ |
| 187 |
offset--; |
offset--; |
| 188 |
} |
} |
| 203 |
else if ((ch & 0xff80) == 0x80) // head of multi-byte character |
else if ((ch & 0xff80) == 0x80) // head of multi-byte character |
| 204 |
{ |
{ |
| 205 |
str_len = 0; |
str_len = 0; |
| 206 |
c = (char)(ch & 0b11110000); |
c = (char)(ch & 0xf0); |
| 207 |
while (c & 0b10000000) |
while (c & 0x80) |
| 208 |
{ |
{ |
| 209 |
input_str[str_len] = (char)(ch - 256); |
input_str[str_len] = (char)(ch - 256); |
| 210 |
str_len++; |
str_len++; |
| 211 |
c = (c & 0b01111111) << 1; |
c = (c & 0x7f) << 1; |
| 212 |
|
|
| 213 |
if ((c & 0b10000000) == 0) // Input completed |
if ((c & 0x80) == 0) // Input completed |
| 214 |
{ |
{ |
| 215 |
break; |
break; |
| 216 |
} |
} |
| 300 |
iflush(); |
iflush(); |
| 301 |
|
|
| 302 |
return len; |
return len; |
| 303 |
}; |
} |
| 304 |
|
|
| 305 |
int get_data(int row, int col, char *prompt, char *buffer, int buf_size, int max_display_len) |
int get_data(int row, int col, char *prompt, char *buffer, int buf_size, int max_display_len) |
| 306 |
{ |
{ |
| 353 |
offset--; |
offset--; |
| 354 |
if (buffer[offset] < 0 || buffer[offset] > 127) // UTF8 |
if (buffer[offset] < 0 || buffer[offset] > 127) // UTF8 |
| 355 |
{ |
{ |
| 356 |
while (offset > 0 && (buffer[offset] & 0b11000000) != 0b11000000) |
while (offset > 0 && (buffer[offset] & 0xc0) != 0xc0) |
| 357 |
{ |
{ |
| 358 |
str_len++; |
str_len++; |
| 359 |
offset--; |
offset--; |
| 383 |
if ((buffer[offset] & 0x80) == 0x80) // head of multi-byte character |
if ((buffer[offset] & 0x80) == 0x80) // head of multi-byte character |
| 384 |
{ |
{ |
| 385 |
str_len = 0; |
str_len = 0; |
| 386 |
c = (char)(buffer[offset] & 0b11110000); |
c = (char)(buffer[offset] & 0xf0); |
| 387 |
while (c & 0b10000000) |
while (c & 0x80) |
| 388 |
{ |
{ |
| 389 |
str_len++; |
str_len++; |
| 390 |
c = (c & 0b01111111) << 1; |
c = (c & 0x7f) << 1; |
| 391 |
} |
} |
| 392 |
display_len--; |
display_len--; |
| 393 |
} |
} |
| 417 |
offset--; |
offset--; |
| 418 |
if (buffer[offset] < 0 || buffer[offset] > 127) // UTF8 |
if (buffer[offset] < 0 || buffer[offset] > 127) // UTF8 |
| 419 |
{ |
{ |
| 420 |
while (offset > 0 && (buffer[offset] & 0b11000000) != 0b11000000) |
while (offset > 0 && (buffer[offset] & 0xc0) != 0xc0) |
| 421 |
{ |
{ |
| 422 |
str_len++; |
str_len++; |
| 423 |
offset--; |
offset--; |
| 438 |
str_len = 0; |
str_len = 0; |
| 439 |
if ((buffer[offset] & 0x80) == 0x80) // head of multi-byte character |
if ((buffer[offset] & 0x80) == 0x80) // head of multi-byte character |
| 440 |
{ |
{ |
| 441 |
c = (char)(buffer[offset] & 0b11110000); |
c = (char)(buffer[offset] & 0xf0); |
| 442 |
while (c & 0b10000000) |
while (c & 0x80) |
| 443 |
{ |
{ |
| 444 |
str_len++; |
str_len++; |
| 445 |
c = (c & 0b01111111) << 1; |
c = (c & 0x7f) << 1; |
| 446 |
} |
} |
| 447 |
col_cur++; |
col_cur++; |
| 448 |
} |
} |
| 490 |
else if ((ch & 0xff80) == 0x80) // head of multi-byte character |
else if ((ch & 0xff80) == 0x80) // head of multi-byte character |
| 491 |
{ |
{ |
| 492 |
str_len = 0; |
str_len = 0; |
| 493 |
c = (char)(ch & 0b11110000); |
c = (char)(ch & 0xf0); |
| 494 |
while (c & 0b10000000) |
while (c & 0x80) |
| 495 |
{ |
{ |
| 496 |
input_str[str_len] = (char)(ch - 256); |
input_str[str_len] = (char)(ch - 256); |
| 497 |
str_len++; |
str_len++; |
| 498 |
c = (c & 0b01111111) << 1; |
c = (c & 0x7f) << 1; |
| 499 |
|
|
| 500 |
if ((c & 0b10000000) == 0) // Input completed |
if ((c & 0x80) == 0) // Input completed |
| 501 |
{ |
{ |
| 502 |
break; |
break; |
| 503 |
} |
} |
| 716 |
output_end_row = SCREEN_ROWS - 1; // Legacy Fterm only works with this line |
output_end_row = SCREEN_ROWS - 1; // Legacy Fterm only works with this line |
| 717 |
break; |
break; |
| 718 |
case CR: |
case CR: |
|
case KEY_SPACE: |
|
| 719 |
case KEY_DOWN: |
case KEY_DOWN: |
| 720 |
if (line_current + (screen_row_total - (output_current_row - screen_begin_row)) >= display_line_total) // Reach end |
if (line_current + (screen_row_total - (output_current_row - screen_begin_row)) >= display_line_total) // Reach end |
| 721 |
{ |
{ |
| 743 |
output_end_row = SCREEN_ROWS - 1; |
output_end_row = SCREEN_ROWS - 1; |
| 744 |
clrline(output_current_row, SCREEN_ROWS); |
clrline(output_current_row, SCREEN_ROWS); |
| 745 |
break; |
break; |
| 746 |
|
case KEY_SPACE: |
| 747 |
case KEY_PGDN: |
case KEY_PGDN: |
| 748 |
if (line_current + screen_row_total - (output_current_row - screen_begin_row) >= display_line_total) // Reach end |
if (line_current + screen_row_total - (output_current_row - screen_begin_row) >= display_line_total) // Reach end |
| 749 |
{ |
{ |
| 925 |
|
|
| 926 |
time_online = time(NULL) - BBS_login_tm; |
time_online = time(NULL) - BBS_login_tm; |
| 927 |
tm_online = gmtime(&time_online); |
tm_online = gmtime(&time_online); |
| 928 |
if (tm_online->tm_mday > 1) |
if (tm_online->tm_mday > 0) |
| 929 |
{ |
{ |
| 930 |
snprintf(str_tm_online, sizeof(str_tm_online), |
snprintf(str_tm_online, sizeof(str_tm_online), |
| 931 |
"\033[36m%2d\033[33m天\033[36m%2d\033[33m时", |
"\033[36m%2d\033[33m天\033[36m%2d\033[33m时", |
| 932 |
tm_online->tm_mday - 1, tm_online->tm_hour); |
tm_online->tm_yday, tm_online->tm_hour); |
| 933 |
} |
} |
| 934 |
else |
else |
| 935 |
{ |
{ |