--- lbbs/src/editor.c 2025/06/16 01:36:56 1.24 +++ lbbs/src/editor.c 2025/06/17 13:17:04 1.28 @@ -24,8 +24,6 @@ #include #include #include - -#define _POSIX_C_SOURCE 200809L #include #define EDITOR_ESC_DISPLAY_STR "\033[32m*\033[m" @@ -138,7 +136,7 @@ EDITOR_DATA *editor_data_load(const char p_data_line[current_data_line_length] = '\0'; } - bzero(p_editor_data->p_display_lines + p_editor_data->display_line_total, MAX_EDITOR_DATA_LINES - (size_t)p_editor_data->display_line_total); + memset(p_editor_data->p_display_lines + p_editor_data->display_line_total, 0, MAX_EDITOR_DATA_LINES - (size_t)p_editor_data->display_line_total); return p_editor_data; } @@ -609,7 +607,7 @@ static int editor_display_key_handler(in { case 0: // Set msg snprintf(p_ctx->msg, sizeof(p_ctx->msg), - "| Í˳ö[\033[32mCtrl-W\033[33m] | °ïÖú[\033[32mh\033[33m] |"); + "| Í˳ö[\033[32mCtrl-W\033[33m] |"); break; case KEY_CSI: *p_key = KEY_ESC; @@ -683,12 +681,11 @@ int editor_display(EDITOR_DATA *p_editor moveto((int)row_pos, (int)col_pos); iflush(); + str_len = 0; input_ok = 0; + ch = igetch_t(MAX_DELAY_TIME); while (!SYS_server_exit && !input_ok) { - ch = igetch_t(MAX_DELAY_TIME); - input_ok = 1; - // extended key handler if (editor_display_key_handler(&ch, &ctx) != 0) { @@ -709,6 +706,8 @@ int editor_display(EDITOR_DATA *p_editor if ((ch >= 32 && ch < 127) || (ch > 127 && ch <= 255 && str_len == 2) || // Printable character or GBK ch == CR || ch == KEY_ESC) // Special character { + BBS_last_access_tm = time(NULL); + if (str_len == 0) // ch >= 32 && ch < 127 { input_str[0] = (char)ch; @@ -767,16 +766,29 @@ int editor_display(EDITOR_DATA *p_editor col_pos = offset_out + 1; // Set col_pos to accurate pos } + if (display_line_out != display_line_in) // Output on line change + { + break; + } + + ch = igetch(0); + if (ch == KEY_NULL || ch == KEY_TIMEOUT) // Output if no futher input + { + break; + } + str_len = 0; continue; } else if (ch == KEY_DEL || ch == BACKSPACE) // Del { + BBS_last_access_tm = time(NULL); + if (ch == BACKSPACE) { if (line_current - output_current_row + row_pos <= 0 && col_pos <= 1) // Forbidden { - input_ok = 0; + ch = igetch_t(MAX_DELAY_TIME); continue; } @@ -835,10 +847,22 @@ int editor_display(EDITOR_DATA *p_editor clrline(output_current_row, output_end_row); } + if (display_line_out != display_line_in) // Output on line change + { + break; + } + + ch = igetch(0); + if (ch == KEY_NULL || ch == KEY_TIMEOUT) // Output if no futher input + { + break; + } + str_len = 0; continue; } + input_ok = 1; switch (ch) { case KEY_NULL: @@ -1035,12 +1059,14 @@ int editor_display(EDITOR_DATA *p_editor break; } - BBS_last_access_tm = time(0); + BBS_last_access_tm = time(NULL); if (input_ok) { break; } + + ch = igetch_t(MAX_DELAY_TIME); } continue;