--- lbbs/src/screen.c 2025/05/10 15:23:42 1.44 +++ lbbs/src/screen.c 2025/05/13 10:41:31 1.48 @@ -98,7 +98,7 @@ void set_input_echo(int echo) prints("\xff\xfb\x01\xff\xfb\x03"); iflush(); igetch(0); - igetch(1); + igetch_reset(); } } @@ -112,18 +112,22 @@ static int _str_input(char *buffer, int for (offset = 0; offset < buf_size - 1 && buffer[offset] != '\0'; offset++) ; - while (!SYS_server_exit && (c = igetch_t(MIN(MAX_DELAY_TIME, 60)))) + igetch_reset(); + + while (!SYS_server_exit) { + c = igetch_t(MIN(MAX_DELAY_TIME, 60)); + if (c == CR) { - igetch(1); // Cleanup remaining '\n' in the buffer + igetch_reset(); break; } - else if (c == KEY_TIMEOUT) + else if (c == KEY_TIMEOUT || c == KEY_NULL) // timeout or broken pipe { return -1; } - else if (c == KEY_NULL || c == LF) + else if (c == LF || c == '\0') { continue; } @@ -156,7 +160,7 @@ static int _str_input(char *buffer, int { if (!hz && offset + 2 > buf_size - 1) // No enough space for Chinese character { - igetch(1); // Cleanup remaining input + igetch(0); // Ignore 1 character outc('\a'); iflush(); continue; @@ -210,8 +214,6 @@ int get_data(int row, int col, char *pro { int len; - igetch(1); // Cleanup input buffer - moveto(row, col); prints(prompt); prints(buffer); @@ -319,6 +321,7 @@ int display_file_ex(const char *filename input_ok = 1; switch (ch) { + case KEY_NULL: case KEY_TIMEOUT: goto cleanup; case KEY_UP: