/[LeafOK_CVS]/lbbs/src/editor.c
ViewVC logotype

Diff of /lbbs/src/editor.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.39 by sysadm, Wed Jul 2 04:17:33 2025 UTC Revision 1.46 by sysadm, Tue Oct 14 02:39:34 2025 UTC
# Line 19  Line 19 
19  #include "editor.h"  #include "editor.h"
20  #include "io.h"  #include "io.h"
21  #include "log.h"  #include "log.h"
22    #include "login.h"
23  #include "memory_pool.h"  #include "memory_pool.h"
24  #include "str_process.h"  #include "str_process.h"
25  #include <stdlib.h>  #include <stdlib.h>
# Line 48  int editor_memory_pool_init(void) Line 49  int editor_memory_pool_init(void)
49          }          }
50    
51          p_mp_editor_data = memory_pool_init(sizeof(EDITOR_DATA), 1, 1);          p_mp_editor_data = memory_pool_init(sizeof(EDITOR_DATA), 1, 1);
52          if (p_mp_data_line == NULL)          if (p_mp_editor_data == NULL)
53          {          {
54                  log_error("Memory pool init error\n");                  log_error("Memory pool init error\n");
55                  return -3;                  return -3;
# Line 82  EDITOR_DATA *editor_data_load(const char Line 83  EDITOR_DATA *editor_data_load(const char
83    
84          if (p_data == NULL)          if (p_data == NULL)
85          {          {
86                  log_error("editor_data_load() error: NULL pointer\n");                  log_error("NULL pointer error\n");
87                  return NULL;                  return NULL;
88          }          }
89    
# Line 149  long editor_data_save(const EDITOR_DATA Line 150  long editor_data_save(const EDITOR_DATA
150    
151          if (p_editor_data == NULL || p_data == NULL)          if (p_editor_data == NULL || p_data == NULL)
152          {          {
153                  log_error("editor_data_save() error: NULL pointer\n");                  log_error("NULL pointer error\n");
154                  return -1;                  return -1;
155          }          }
156    
# Line 223  int editor_data_insert(EDITOR_DATA *p_ed Line 224  int editor_data_insert(EDITOR_DATA *p_ed
224    
225          if (p_editor_data == NULL || p_last_updated_line == NULL)          if (p_editor_data == NULL || p_last_updated_line == NULL)
226          {          {
227                  log_error("editor_data_op() error: NULL pointer\n");                  log_error("NULL pointer error\n");
228                  return -1;                  return -1;
229          }          }
230    
# Line 461  int editor_data_delete(EDITOR_DATA *p_ed Line 462  int editor_data_delete(EDITOR_DATA *p_ed
462    
463          if (p_editor_data == NULL || p_last_updated_line == NULL)          if (p_editor_data == NULL || p_last_updated_line == NULL)
464          {          {
465                  log_error("editor_data_op() error: NULL pointer\n");                  log_error("NULL pointer error\n");
466                  return -1;                  return -1;
467          }          }
468    
# Line 729  int editor_display(EDITOR_DATA *p_editor Line 730  int editor_display(EDITOR_DATA *p_editor
730                                                  ch = igetch(100);                                                // 0.1 second                                                  ch = igetch(100);                                                // 0.1 second
731                                                  if (ch == KEY_NULL || ch == KEY_TIMEOUT) // Ignore received bytes if no futher input                                                  if (ch == KEY_NULL || ch == KEY_TIMEOUT) // Ignore received bytes if no futher input
732                                                  {                                                  {
733    #ifdef _DEBUG
734                                                          log_error("Ignore %d bytes of incomplete UTF8 character\n", str_len);                                                          log_error("Ignore %d bytes of incomplete UTF8 character\n", str_len);
735    #endif
736                                                          str_len = 0;                                                          str_len = 0;
737                                                          break;                                                          break;
738                                                  }                                                  }
# Line 741  int editor_display(EDITOR_DATA *p_editor Line 744  int editor_display(EDITOR_DATA *p_editor
744                                  {                                  {
745                                          BBS_last_access_tm = time(NULL);                                          BBS_last_access_tm = time(NULL);
746    
747                                            // Refresh current action while user input
748                                            if (user_online_update(NULL) < 0)
749                                            {
750                                                    log_error("user_online_update(NULL) error\n");
751                                            }
752    
753                                          if (str_len == 0) // ch >= 32 && ch < 127                                          if (str_len == 0) // ch >= 32 && ch < 127
754                                          {                                          {
755                                                  input_str[0] = (char)ch;                                                  input_str[0] = (char)ch;
# Line 805  int editor_display(EDITOR_DATA *p_editor Line 814  int editor_display(EDITOR_DATA *p_editor
814                                                          {                                                          {
815                                                                  col_pos = 1;                                                                  col_pos = 1;
816                                                          }                                                          }
817                                                          if (ch != CR)                                                          if (offset_out > 0)
818                                                          {                                                          {
819                                                                  col_pos += (str_len == 1 ? 1 : 2);                                                                  col_pos += (str_len == 1 ? 1 : 2);
820                                                          }                                                          }
# Line 830  int editor_display(EDITOR_DATA *p_editor Line 839  int editor_display(EDITOR_DATA *p_editor
839                                  {                                  {
840                                          BBS_last_access_tm = time(NULL);                                          BBS_last_access_tm = time(NULL);
841    
842                                            // Refresh current action while user input
843                                            if (user_online_update(NULL) < 0)
844                                            {
845                                                    log_error("user_online_update(NULL) error\n");
846                                            }
847    
848                                          if (ch == BACKSPACE)                                          if (ch == BACKSPACE)
849                                          {                                          {
850                                                  if (line_current - output_current_row + row_pos <= 0 && col_pos <= 1) // Forbidden                                                  if (line_current - output_current_row + row_pos <= 0 && col_pos <= 1) // Forbidden
# Line 918  int editor_display(EDITOR_DATA *p_editor Line 933  int editor_display(EDITOR_DATA *p_editor
933                                  case KEY_TIMEOUT:                                  case KEY_TIMEOUT:
934                                          goto cleanup;                                          goto cleanup;
935                                  case Ctrl('W'):                                  case Ctrl('W'):
936                                    case Ctrl('X'):
937                                          loop = 0;                                          loop = 0;
938                                          break;                                          break;
939                                  case Ctrl('S'): // Start of line                                  case Ctrl('S'): // Start of line
# Line 1094  int editor_display(EDITOR_DATA *p_editor Line 1110  int editor_display(EDITOR_DATA *p_editor
1110                                          col_pos = MIN(col_pos, MAX(1, p_editor_data->display_line_widths[line_current - output_current_row + row_pos]));                                          col_pos = MIN(col_pos, MAX(1, p_editor_data->display_line_widths[line_current - output_current_row + row_pos]));
1111                                          clrline(output_current_row, SCREEN_ROWS);                                          clrline(output_current_row, SCREEN_ROWS);
1112                                          break;                                          break;
1113                                    case Ctrl('Q'):
1114                                  case KEY_F1:                                  case KEY_F1:
1115                                          if (!show_help) // Not reentrant                                          if (!show_help) // Not reentrant
1116                                          {                                          {
# Line 1119  int editor_display(EDITOR_DATA *p_editor Line 1136  int editor_display(EDITOR_DATA *p_editor
1136    
1137                                  BBS_last_access_tm = time(NULL);                                  BBS_last_access_tm = time(NULL);
1138    
1139                                    // Refresh current action while user input
1140                                    if (user_online_update(NULL) < 0)
1141                                    {
1142                                            log_error("user_online_update(NULL) error\n");
1143                                    }
1144    
1145                                  if (input_ok)                                  if (input_ok)
1146                                  {                                  {
1147                                          break;                                          break;


Legend:
Removed lines/characters  
Changed lines/characters
  Added lines/characters

webmaster@leafok.com
ViewVC Help
Powered by ViewVC 1.3.0-beta1