--- lbbs/src/editor.c 2025/07/02 04:17:33 1.39 +++ lbbs/src/editor.c 2025/10/16 11:26:16 1.47 @@ -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; } @@ -704,6 +705,11 @@ int editor_display(EDITOR_DATA *p_editor ch = igetch_t(MAX_DELAY_TIME); while (!SYS_server_exit) { + if (ch != KEY_NULL && ch != KEY_TIMEOUT) + { + BBS_last_access_tm = time(NULL); + } + // extended key handler if (editor_display_key_handler(&ch, &ctx) != 0) { @@ -729,7 +735,9 @@ int editor_display(EDITOR_DATA *p_editor ch = igetch(100); // 0.1 second if (ch == KEY_NULL || ch == KEY_TIMEOUT) // Ignore received bytes if no futher input { +#ifdef _DEBUG log_error("Ignore %d bytes of incomplete UTF8 character\n", str_len); +#endif str_len = 0; break; } @@ -739,7 +747,11 @@ int editor_display(EDITOR_DATA *p_editor if ((ch >= 32 && ch < 127) || str_len >= 2 || // Printable character or multi-byte character ch == CR || ch == KEY_ESC) // Special character { - 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 { @@ -805,7 +817,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); } @@ -828,7 +840,11 @@ int editor_display(EDITOR_DATA *p_editor } else if (ch == KEY_DEL || ch == BACKSPACE) // Del { - 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) { @@ -915,9 +931,13 @@ int editor_display(EDITOR_DATA *p_editor switch (ch) { case KEY_NULL: + log_error("KEY_NULL\n"); + goto cleanup; case KEY_TIMEOUT: + log_error("User input timeout\n"); goto cleanup; case Ctrl('W'): + case Ctrl('X'): loop = 0; break; case Ctrl('S'): // Start of line @@ -1094,6 +1114,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 { @@ -1117,7 +1138,11 @@ int editor_display(EDITOR_DATA *p_editor break; } - 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) {