--- lbbs/src/screen.c 2025/10/14 05:28:15 1.109 +++ lbbs/src/screen.c 2025/10/17 10:57:43 1.112 @@ -104,13 +104,24 @@ void clearscr() int press_any_key() { + int ch = 0; + int wait_seconds = 60; + int duration = 0; + time_t t_begin = time(NULL); + moveto(SCREEN_ROWS, 0); clrtoeol(); prints(" \033[1;33m按任意键继续...\033[0;37m"); iflush(); - return igetch_t(MIN(MAX_DELAY_TIME, 60)); + do + { + ch = igetch_t(wait_seconds - duration); + duration = (int)(time(NULL) - t_begin); + } while (!SYS_server_exit && ch == 0 && duration < 60); + + return ch; } void set_input_echo(int echo) @@ -118,16 +129,13 @@ void set_input_echo(int echo) if (echo) { outc('\x83'); // ASCII code 131 - iflush(); } else { - // outc ('\x85'); // ASCII code 133 + // outc ('\x85'); // ASCII code 133 prints("\xff\xfb\x01\xff\xfb\x03"); - iflush(); - igetch(0); - igetch_reset(); } + iflush(); } static int _str_input(char *buffer, int buf_size, int max_display_len, int echo_mode) @@ -151,7 +159,6 @@ static int _str_input(char *buffer, int if (ch == CR) { - igetch_reset(); break; } else if (ch == KEY_TIMEOUT || ch == KEY_NULL) // timeout or broken pipe @@ -322,7 +329,6 @@ int get_data(int row, int col, char *pro if (ch == CR) { - igetch_reset(); break; } else if (ch == KEY_TIMEOUT || ch == KEY_NULL) // timeout or broken pipe @@ -653,6 +659,11 @@ int display_data(const void *p_data, lon ch = igetch_t(MAX_DELAY_TIME); input_ok = 1; + if (ch != KEY_NULL && ch != KEY_TIMEOUT) + { + BBS_last_access_tm = time(NULL); + } + // extended key handler if (key_handler(&ch, &ctx) != 0) { @@ -662,7 +673,10 @@ int display_data(const void *p_data, lon switch (ch) { case KEY_NULL: + log_error("KEY_NULL\n"); + goto cleanup; case KEY_TIMEOUT: + log_error("User input timeout\n"); goto cleanup; case KEY_HOME: if (line_current - output_current_row < 0) // Reach begin @@ -696,7 +710,6 @@ int display_data(const void *p_data, lon output_end_row = SCREEN_ROWS - 1; // Legacy Fterm only works with this line break; case CR: - igetch_reset(); case KEY_SPACE: case KEY_DOWN: if (line_current + (screen_row_total - (output_current_row - screen_begin_row)) >= display_line_total) // Reach end @@ -765,8 +778,6 @@ int display_data(const void *p_data, lon input_ok = 0; break; } - - BBS_last_access_tm = time(NULL); } continue;