--- lbbs/src/editor.c 2025/07/20 02:04:21 1.40 +++ lbbs/src/editor.c 2025/10/14 02:39:34 1.46 @@ -19,6 +19,7 @@ #include "editor.h" #include "io.h" #include "log.h" +#include "login.h" #include "memory_pool.h" #include "str_process.h" #include @@ -48,7 +49,7 @@ int editor_memory_pool_init(void) } p_mp_editor_data = memory_pool_init(sizeof(EDITOR_DATA), 1, 1); - if (p_mp_data_line == NULL) + if (p_mp_editor_data == NULL) { log_error("Memory pool init error\n"); return -3; @@ -82,7 +83,7 @@ EDITOR_DATA *editor_data_load(const char if (p_data == NULL) { - log_error("editor_data_load() error: NULL pointer\n"); + log_error("NULL pointer error\n"); return NULL; } @@ -149,7 +150,7 @@ long editor_data_save(const EDITOR_DATA if (p_editor_data == NULL || p_data == NULL) { - log_error("editor_data_save() error: NULL pointer\n"); + log_error("NULL pointer error\n"); return -1; } @@ -223,7 +224,7 @@ int editor_data_insert(EDITOR_DATA *p_ed if (p_editor_data == NULL || p_last_updated_line == NULL) { - log_error("editor_data_op() error: NULL pointer\n"); + log_error("NULL pointer error\n"); return -1; } @@ -461,7 +462,7 @@ int editor_data_delete(EDITOR_DATA *p_ed if (p_editor_data == NULL || p_last_updated_line == NULL) { - log_error("editor_data_op() error: NULL pointer\n"); + log_error("NULL pointer error\n"); return -1; } @@ -743,6 +744,12 @@ int editor_display(EDITOR_DATA *p_editor { BBS_last_access_tm = time(NULL); + // Refresh current action while user input + if (user_online_update(NULL) < 0) + { + log_error("user_online_update(NULL) error\n"); + } + if (str_len == 0) // ch >= 32 && ch < 127 { input_str[0] = (char)ch; @@ -807,7 +814,7 @@ int editor_display(EDITOR_DATA *p_editor { col_pos = 1; } - if (ch != CR) + if (offset_out > 0) { col_pos += (str_len == 1 ? 1 : 2); } @@ -832,6 +839,12 @@ int editor_display(EDITOR_DATA *p_editor { BBS_last_access_tm = time(NULL); + // Refresh current action while user input + if (user_online_update(NULL) < 0) + { + log_error("user_online_update(NULL) error\n"); + } + if (ch == BACKSPACE) { if (line_current - output_current_row + row_pos <= 0 && col_pos <= 1) // Forbidden @@ -920,6 +933,7 @@ int editor_display(EDITOR_DATA *p_editor case KEY_TIMEOUT: goto cleanup; case Ctrl('W'): + case Ctrl('X'): loop = 0; break; case Ctrl('S'): // Start of line @@ -1096,6 +1110,7 @@ int editor_display(EDITOR_DATA *p_editor col_pos = MIN(col_pos, MAX(1, p_editor_data->display_line_widths[line_current - output_current_row + row_pos])); clrline(output_current_row, SCREEN_ROWS); break; + case Ctrl('Q'): case KEY_F1: if (!show_help) // Not reentrant { @@ -1121,6 +1136,12 @@ int editor_display(EDITOR_DATA *p_editor BBS_last_access_tm = time(NULL); + // Refresh current action while user input + if (user_online_update(NULL) < 0) + { + log_error("user_online_update(NULL) error\n"); + } + if (input_ok) { break;