--- lbbs/src/editor.c 2025/06/27 12:54:31 1.33 +++ lbbs/src/editor.c 2025/07/02 03:08:10 1.38 @@ -93,7 +93,7 @@ EDITOR_DATA *editor_data_load(const char return NULL; } - p_editor_data->display_line_total = split_data_lines(p_data, SCREEN_COLS, line_offsets, MAX_EDITOR_DATA_LINES + 1, 0); + p_editor_data->display_line_total = split_data_lines(p_data, SCREEN_COLS, line_offsets, MAX_EDITOR_DATA_LINES + 1, 0, NULL); for (i = 0; i < p_editor_data->display_line_total; i++) { @@ -274,7 +274,7 @@ int editor_data_insert(EDITOR_DATA *p_ed } // Split current data line if over-length - if (len_data_line + str_len + 1 > MAX_EDITOR_DATA_LINE_LENGTH || str[0] == CR) + if (len_data_line + str_len + 2 > MAX_EDITOR_DATA_LINE_LENGTH || str[0] == CR) { if (p_editor_data->display_line_total >= MAX_EDITOR_DATA_LINES) { @@ -294,7 +294,7 @@ int editor_data_insert(EDITOR_DATA *p_ed return -2; } - if (offset_data_line + str_len + 1 >= MAX_EDITOR_DATA_LINE_LENGTH || str[0] == CR) + if (offset_data_line + str_len + 2 >= MAX_EDITOR_DATA_LINE_LENGTH || str[0] == CR) { if (str[0] == CR) { @@ -362,7 +362,7 @@ int editor_data_insert(EDITOR_DATA *p_ed } // Split current data line since beginning of current display line - split_line_total = split_data_lines(p_data_line, SCREEN_COLS, line_offsets, split_line_total, 0); + split_line_total = split_data_lines(p_data_line, SCREEN_COLS, line_offsets, split_line_total, 0, NULL); for (i = 0; i < split_line_total; i++) { @@ -578,7 +578,7 @@ int editor_data_delete(EDITOR_DATA *p_ed split_line_total = last_display_line - display_line + 2; // Split current data line since beginning of current display line - split_line_total = split_data_lines(p_data_line, SCREEN_COLS, line_offsets, split_line_total, 0); + split_line_total = split_data_lines(p_data_line, SCREEN_COLS, line_offsets, split_line_total, 0, NULL); for (i = 0; i < split_line_total; i++) { @@ -675,8 +675,7 @@ int editor_display(EDITOR_DATA *p_editor return ch; } - loop = 1; - while (!SYS_server_exit && loop) + for (loop = 1; !SYS_server_exit && loop;) { if (line_current >= p_editor_data->display_line_total || output_current_row > output_end_row) { @@ -772,7 +771,8 @@ int editor_display(EDITOR_DATA *p_editor clrtoeol(); for (i = 0; i < scroll_rows; i++) { - prints("\033[S"); // Scroll up 1 line + // prints("\033[S"); // Scroll up 1 line + prints("\n"); // Legacy Cterm only works with this line } output_current_row -= scroll_rows; @@ -812,8 +812,7 @@ int editor_display(EDITOR_DATA *p_editor { if (line_current - output_current_row + row_pos <= 0 && col_pos <= 1) // Forbidden { - ch = igetch_t(MAX_DELAY_TIME); - continue; + break; // force output prior operation result if any } col_pos--; @@ -1028,7 +1027,8 @@ int editor_display(EDITOR_DATA *p_editor col_pos = MIN(col_pos, MAX(1, p_editor_data->display_line_lengths[line_current - output_current_row + row_pos])); moveto(SCREEN_ROWS, 0); clrtoeol(); - prints("\033[S"); // Scroll up 1 line + // prints("\033[S"); // Scroll up 1 line + prints("\n"); // Legacy Cterm only works with this line break; case KEY_PGUP: if (line_current - output_current_row < 0) // Reach begin