| 102 |
moveto(0, 0); |
moveto(0, 0); |
| 103 |
} |
} |
| 104 |
|
|
| 105 |
int press_any_key() |
inline int press_any_key() |
| 106 |
{ |
{ |
| 107 |
|
return press_any_key_ex(" \033[1;33m按任意键继续...\033[m", 60); |
| 108 |
|
} |
| 109 |
|
|
| 110 |
|
int press_any_key_ex(const char *msg, int sec) |
| 111 |
|
{ |
| 112 |
|
int ch = 0; |
| 113 |
|
int duration = 0; |
| 114 |
|
time_t t_begin = time(NULL); |
| 115 |
|
|
| 116 |
moveto(SCREEN_ROWS, 0); |
moveto(SCREEN_ROWS, 0); |
| 117 |
clrtoeol(); |
clrtoeol(); |
| 118 |
|
|
| 119 |
prints(" \033[1;33m按任意键继续...\033[0;37m"); |
prints(msg); |
| 120 |
iflush(); |
iflush(); |
| 121 |
|
|
| 122 |
return igetch_t(MIN(MAX_DELAY_TIME, 60)); |
igetch_reset(); |
| 123 |
|
|
| 124 |
|
do |
| 125 |
|
{ |
| 126 |
|
ch = igetch_t(sec - duration); |
| 127 |
|
duration = (int)(time(NULL) - t_begin); |
| 128 |
|
} while (!SYS_server_exit && ch == 0 && duration < 60); |
| 129 |
|
|
| 130 |
|
return ch; |
| 131 |
} |
} |
| 132 |
|
|
| 133 |
void set_input_echo(int echo) |
void set_input_echo(int echo) |
| 135 |
if (echo) |
if (echo) |
| 136 |
{ |
{ |
| 137 |
outc('\x83'); // ASCII code 131 |
outc('\x83'); // ASCII code 131 |
|
iflush(); |
|
| 138 |
} |
} |
| 139 |
else |
else |
| 140 |
{ |
{ |
| 141 |
// outc ('\x85'); // ASCII code 133 |
// outc ('\x85'); // ASCII code 133 |
| 142 |
prints("\xff\xfb\x01\xff\xfb\x03"); |
prints("\xff\xfb\x01\xff\xfb\x03"); |
|
iflush(); |
|
|
igetch(0); |
|
|
igetch_reset(); |
|
| 143 |
} |
} |
| 144 |
|
iflush(); |
| 145 |
} |
} |
| 146 |
|
|
| 147 |
static int _str_input(char *buffer, int buf_size, int max_display_len, int echo_mode) |
static int _str_input(char *buffer, int buf_size, int max_display_len, int echo_mode) |
| 165 |
|
|
| 166 |
if (ch == CR) |
if (ch == CR) |
| 167 |
{ |
{ |
|
igetch_reset(); |
|
| 168 |
break; |
break; |
| 169 |
} |
} |
| 170 |
else if (ch == KEY_TIMEOUT || ch == KEY_NULL) // timeout or broken pipe |
else if (ch == KEY_TIMEOUT || ch == KEY_NULL) // timeout or broken pipe |
| 335 |
|
|
| 336 |
if (ch == CR) |
if (ch == CR) |
| 337 |
{ |
{ |
|
igetch_reset(); |
|
| 338 |
break; |
break; |
| 339 |
} |
} |
| 340 |
else if (ch == KEY_TIMEOUT || ch == KEY_NULL) // timeout or broken pipe |
else if (ch == KEY_TIMEOUT || ch == KEY_NULL) // timeout or broken pipe |
| 665 |
ch = igetch_t(MAX_DELAY_TIME); |
ch = igetch_t(MAX_DELAY_TIME); |
| 666 |
input_ok = 1; |
input_ok = 1; |
| 667 |
|
|
| 668 |
|
if (ch != KEY_NULL && ch != KEY_TIMEOUT) |
| 669 |
|
{ |
| 670 |
|
BBS_last_access_tm = time(NULL); |
| 671 |
|
} |
| 672 |
|
|
| 673 |
// extended key handler |
// extended key handler |
| 674 |
if (key_handler(&ch, &ctx) != 0) |
if (key_handler(&ch, &ctx) != 0) |
| 675 |
{ |
{ |
| 679 |
switch (ch) |
switch (ch) |
| 680 |
{ |
{ |
| 681 |
case KEY_NULL: |
case KEY_NULL: |
| 682 |
|
log_error("KEY_NULL\n"); |
| 683 |
|
goto cleanup; |
| 684 |
case KEY_TIMEOUT: |
case KEY_TIMEOUT: |
| 685 |
|
log_error("User input timeout\n"); |
| 686 |
goto cleanup; |
goto cleanup; |
| 687 |
case KEY_HOME: |
case KEY_HOME: |
| 688 |
if (line_current - output_current_row < 0) // Reach begin |
if (line_current - output_current_row < 0) // Reach begin |
| 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: |
|
igetch_reset(); |
|
| 719 |
case KEY_SPACE: |
case KEY_SPACE: |
| 720 |
case KEY_DOWN: |
case KEY_DOWN: |
| 721 |
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 |
| 784 |
input_ok = 0; |
input_ok = 0; |
| 785 |
break; |
break; |
| 786 |
} |
} |
|
|
|
|
BBS_last_access_tm = time(NULL); |
|
| 787 |
} |
} |
| 788 |
|
|
| 789 |
continue; |
continue; |