--- lbbs/src/screen.c 2025/05/10 11:09:02 1.41 +++ lbbs/src/screen.c 2025/05/10 14:37:04 1.43 @@ -114,20 +114,20 @@ static int _str_input(char *buffer, int while ((c = igetch_t(MIN(MAX_DELAY_TIME, 60)))) { - if (c == KEY_NULL || c == CR) + if (c == CR) { igetch(1); // Cleanup remaining '\n' in the buffer break; } - if (c == KEY_TIMEOUT) + else if (c == KEY_TIMEOUT) { return -1; } - if (c == LF) + else if (c == KEY_NULL || c == LF) { continue; } - if (c == BACKSPACE) + else if (c == BACKSPACE) { if (offset > 0) { @@ -148,11 +148,11 @@ static int _str_input(char *buffer, int } continue; } - if (c > 255 || iscntrl(c)) + else if (c > 255 || iscntrl(c)) { continue; } - if (c > 127 && c <= 255) + else if (c > 127 && c <= 255) { if (!hz && offset + 2 > buf_size - 1) // No enough space for Chinese character { @@ -163,14 +163,17 @@ static int _str_input(char *buffer, int } hz = (!hz); } + if (offset + 1 > buf_size - 1) { outc('\a'); iflush(); continue; } + buffer[offset++] = (char)c; buffer[offset] = '\0'; + switch (echo_mode) { case DOECHO: @@ -316,7 +319,6 @@ int display_file_ex(const char *filename input_ok = 1; switch (ch) { - case KEY_NULL: case KEY_TIMEOUT: goto cleanup; case KEY_UP: