/[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.24 by sysadm, Mon Jun 16 01:36:56 2025 UTC Revision 1.28 by sysadm, Tue Jun 17 13:17:04 2025 UTC
# Line 24  Line 24 
24  #include <stdlib.h>  #include <stdlib.h>
25  #include <sys/param.h>  #include <sys/param.h>
26  #include <strings.h>  #include <strings.h>
   
 #define _POSIX_C_SOURCE 200809L  
27  #include <string.h>  #include <string.h>
28    
29  #define EDITOR_ESC_DISPLAY_STR "\033[32m*\033[m"  #define EDITOR_ESC_DISPLAY_STR "\033[32m*\033[m"
# Line 138  EDITOR_DATA *editor_data_load(const char Line 136  EDITOR_DATA *editor_data_load(const char
136                  p_data_line[current_data_line_length] = '\0';                  p_data_line[current_data_line_length] = '\0';
137          }          }
138    
139          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);
140    
141          return p_editor_data;          return p_editor_data;
142  }  }
# Line 609  static int editor_display_key_handler(in Line 607  static int editor_display_key_handler(in
607          {          {
608          case 0: // Set msg          case 0: // Set msg
609                  snprintf(p_ctx->msg, sizeof(p_ctx->msg),                  snprintf(p_ctx->msg, sizeof(p_ctx->msg),
610                                   "| Í˳ö[\033[32mCtrl-W\033[33m] | °ïÖú[\033[32mh\033[33m] |");                                   "| Í˳ö[\033[32mCtrl-W\033[33m] |");
611                  break;                  break;
612          case KEY_CSI:          case KEY_CSI:
613                  *p_key = KEY_ESC;                  *p_key = KEY_ESC;
# Line 683  int editor_display(EDITOR_DATA *p_editor Line 681  int editor_display(EDITOR_DATA *p_editor
681                          moveto((int)row_pos, (int)col_pos);                          moveto((int)row_pos, (int)col_pos);
682                          iflush();                          iflush();
683    
684                            str_len = 0;
685                          input_ok = 0;                          input_ok = 0;
686                            ch = igetch_t(MAX_DELAY_TIME);
687                          while (!SYS_server_exit && !input_ok)                          while (!SYS_server_exit && !input_ok)
688                          {                          {
                                 ch = igetch_t(MAX_DELAY_TIME);  
                                 input_ok = 1;  
   
689                                  // extended key handler                                  // extended key handler
690                                  if (editor_display_key_handler(&ch, &ctx) != 0)                                  if (editor_display_key_handler(&ch, &ctx) != 0)
691                                  {                                  {
# Line 709  int editor_display(EDITOR_DATA *p_editor Line 706  int editor_display(EDITOR_DATA *p_editor
706                                  if ((ch >= 32 && ch < 127) || (ch > 127 && ch <= 255 && str_len == 2) || // Printable character or GBK                                  if ((ch >= 32 && ch < 127) || (ch > 127 && ch <= 255 && str_len == 2) || // Printable character or GBK
707                                          ch == CR || ch == KEY_ESC)                                                                                       // Special character                                          ch == CR || ch == KEY_ESC)                                                                                       // Special character
708                                  {                                  {
709                                            BBS_last_access_tm = time(NULL);
710    
711                                          if (str_len == 0) // ch >= 32 && ch < 127                                          if (str_len == 0) // ch >= 32 && ch < 127
712                                          {                                          {
713                                                  input_str[0] = (char)ch;                                                  input_str[0] = (char)ch;
# Line 767  int editor_display(EDITOR_DATA *p_editor Line 766  int editor_display(EDITOR_DATA *p_editor
766                                                  col_pos = offset_out + 1; // Set col_pos to accurate pos                                                  col_pos = offset_out + 1; // Set col_pos to accurate pos
767                                          }                                          }
768    
769                                            if (display_line_out != display_line_in) // Output on line change
770                                            {
771                                                    break;
772                                            }
773    
774                                            ch = igetch(0);
775                                            if (ch == KEY_NULL || ch == KEY_TIMEOUT) // Output if no futher input
776                                            {
777                                                    break;
778                                            }
779    
780                                          str_len = 0;                                          str_len = 0;
781                                          continue;                                          continue;
782                                  }                                  }
783                                  else if (ch == KEY_DEL || ch == BACKSPACE) // Del                                  else if (ch == KEY_DEL || ch == BACKSPACE) // Del
784                                  {                                  {
785                                            BBS_last_access_tm = time(NULL);
786    
787                                          if (ch == BACKSPACE)                                          if (ch == BACKSPACE)
788                                          {                                          {
789                                                  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
790                                                  {                                                  {
791                                                          input_ok = 0;                                                          ch = igetch_t(MAX_DELAY_TIME);
792                                                          continue;                                                          continue;
793                                                  }                                                  }
794    
# Line 835  int editor_display(EDITOR_DATA *p_editor Line 847  int editor_display(EDITOR_DATA *p_editor
847                                                  clrline(output_current_row, output_end_row);                                                  clrline(output_current_row, output_end_row);
848                                          }                                          }
849    
850                                            if (display_line_out != display_line_in) // Output on line change
851                                            {
852                                                    break;
853                                            }
854    
855                                            ch = igetch(0);
856                                            if (ch == KEY_NULL || ch == KEY_TIMEOUT) // Output if no futher input
857                                            {
858                                                    break;
859                                            }
860    
861                                          str_len = 0;                                          str_len = 0;
862                                          continue;                                          continue;
863                                  }                                  }
864    
865                                    input_ok = 1;
866                                  switch (ch)                                  switch (ch)
867                                  {                                  {
868                                  case KEY_NULL:                                  case KEY_NULL:
# Line 1035  int editor_display(EDITOR_DATA *p_editor Line 1059  int editor_display(EDITOR_DATA *p_editor
1059                                          break;                                          break;
1060                                  }                                  }
1061    
1062                                  BBS_last_access_tm = time(0);                                  BBS_last_access_tm = time(NULL);
1063    
1064                                  if (input_ok)                                  if (input_ok)
1065                                  {                                  {
1066                                          break;                                          break;
1067                                  }                                  }
1068    
1069                                    ch = igetch_t(MAX_DELAY_TIME);
1070                          }                          }
1071    
1072                          continue;                          continue;


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

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