--- lbbs/src/screen.c 2025/05/03 10:11:37 1.27 +++ lbbs/src/screen.c 2025/05/04 01:44:00 1.29 @@ -76,8 +76,6 @@ void clearscr() int press_any_key() { - igetch(1); - moveto(screen_rows, 0); clrtoeol(); @@ -114,12 +112,11 @@ static int _str_input(char *buffer, int offset++; } - igetch(1); - while (c = igetch_t(60)) { if (c == KEY_NULL || c == KEY_TIMEOUT || c == CR) { + igetch(1); // Cleanup remaining '\n' in the buffer break; } if (c == LF) @@ -256,7 +253,7 @@ int display_file_ex(const char *filename while (loop) { - if (c_line_current >= c_line_total) + if (c_line_current >= c_line_total && c_line_total <= screen_rows - 2) { if (wait) { @@ -271,7 +268,7 @@ int display_file_ex(const char *filename break; } - if (line >= max_lines) + if (c_line_current >= c_line_total || line >= max_lines) { if (c_line_current - (line - 1) + (screen_rows - 2) < c_line_total) { @@ -279,13 +276,13 @@ int display_file_ex(const char *filename } else { - log_error("P100 reached\n"); percentile = 100; } moveto(screen_rows, 0); - prints("\033[1;44;32m下面还有喔 (%d%%)\033[33m │ 结束 ← │ ↑/↓/PgUp/PgDn 移动 │ ? 辅助说明 │ \033[m", - percentile); + prints("\033[1;44;32m%s (%d%%)%s\033[33m │ 结束 ← │ ↑/↓/PgUp/PgDn 移动 │ ? 辅助说明 │ \033[m", + (percentile < 100 ? "下面还有喔" : "没有更多了"), percentile, + (percentile < 10 ? " " : (percentile < 100 ? " " : ""))); iflush(); input_ok = 0; @@ -303,7 +300,8 @@ int display_file_ex(const char *filename c_line_current -= line; line = begin_line; max_lines = begin_line + 1; - prints("\033[1T"); // Scroll down 1 line + prints("\033[T"); // Scroll down 1 line + // max_lines = screen_rows - 1; // Legacy Fterm only works with this line break; case KEY_DOWN: case CR: @@ -316,7 +314,7 @@ int display_file_ex(const char *filename max_lines = screen_rows - 1; moveto(screen_rows, 0); clrtoeol(); - prints("\033[1S"); // Scroll up 1 line + prints("\033[S"); // Scroll up 1 line break; case KEY_PGUP: case Ctrl('B'):