/[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.20 by sysadm, Fri Jun 13 15:50:21 2025 UTC Revision 1.21 by sysadm, Sat Jun 14 11:15:46 2025 UTC
# Line 227  int editor_data_insert(EDITOR_DATA *p_ed Line 227  int editor_data_insert(EDITOR_DATA *p_ed
227                  return -1;                  return -1;
228          }          }
229    
230            // Validate str
231            if ((str_len == 1 && str[0] <= 0) ||
232                    (str_len == 2 && (str[0] >= 0 || str[1] >= 0)))
233            {
234                    log_error("Invalid input str, len=%d\n", str_len);
235                    return -2;
236            }
237    
238          // Get accurate offset of first character of CJK at offset position          // Get accurate offset of first character of CJK at offset position
239          for (i = 0; i < offset; i++)          for (i = 0; i < offset; i++)
240          {          {
# Line 678  int editor_display(EDITOR_DATA *p_editor Line 686  int editor_display(EDITOR_DATA *p_editor
686                                          input_str[str_len] = (char)(ch - 256);                                          input_str[str_len] = (char)(ch - 256);
687                                          str_len++;                                          str_len++;
688                                  }                                  }
689                                  else                                  else if (str_len > 0)
690                                  {                                  {
691                                            log_error("Received %d character over 127 followed by character less than 127\n", str_len);
692                                          str_len = 0;                                          str_len = 0;
693                                  }                                  }
694    
695                                  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
696                                          ch == CR || ch == KEY_ESC)                                                                                       // Special character                                          ch == CR || ch == KEY_ESC)                                                                                       // Special character
697                                  {                                  {
698                                          if (str_len == 0)                                          if (str_len == 0) // ch >= 32 && ch < 127
699                                          {                                          {
700                                                  input_str[0] = (char)ch;                                                  input_str[0] = (char)ch;
701                                                  str_len = 1;                                                  str_len = 1;
# Line 711  int editor_display(EDITOR_DATA *p_editor Line 720  int editor_display(EDITOR_DATA *p_editor
720                                                                                     input_str, str_len, &last_updated_line) < 0)                                                                                     input_str, str_len, &last_updated_line) < 0)
721                                          {                                          {
722                                                  log_error("editor_data_insert(str_len=%d) error\n", str_len);                                                  log_error("editor_data_insert(str_len=%d) error\n", str_len);
                                                 str_len = 0;  
723                                          }                                          }
724                                          else                                          else
725                                          {                                          {
                                                 str_len = 0;  
   
726                                                  output_end_row = MIN(SCREEN_ROWS - 1, output_current_row + (int)(last_updated_line - line_current));                                                  output_end_row = MIN(SCREEN_ROWS - 1, output_current_row + (int)(last_updated_line - line_current));
727                                                  line_current -= (output_current_row - row_pos);                                                  line_current -= (output_current_row - row_pos);
728                                                  output_current_row = (int)row_pos;                                                  output_current_row = (int)row_pos;
# Line 747  int editor_display(EDITOR_DATA *p_editor Line 753  int editor_display(EDITOR_DATA *p_editor
753                                                  col_pos = offset_out + 1;                                                  col_pos = offset_out + 1;
754                                          }                                          }
755    
756                                            str_len = 0;
757                                          continue;                                          continue;
758                                  }                                  }
759                                  else if (ch == KEY_DEL || ch == BACKSPACE) // Del                                  else if (ch == KEY_DEL || ch == BACKSPACE) // Del
# Line 814  int editor_display(EDITOR_DATA *p_editor Line 821  int editor_display(EDITOR_DATA *p_editor
821                                                  clrline(output_current_row, output_end_row);                                                  clrline(output_current_row, output_end_row);
822                                          }                                          }
823    
824                                            str_len = 0;
825                                          continue;                                          continue;
826                                  }                                  }
827    


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

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