/[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.57 by sysadm, Sun Nov 9 11:18:07 2025 UTC Revision 1.62 by sysadm, Thu Dec 18 02:56:00 2025 UTC
# Line 6  Line 6 
6   * Copyright (C) 2004-2025  Leaflet <leaflet@leafok.com>   * Copyright (C) 2004-2025  Leaflet <leaflet@leafok.com>
7   */   */
8    
9    #ifdef HAVE_CONFIG_H
10    #include "config.h"
11    #endif
12    
13  #include "bbs.h"  #include "bbs.h"
14  #include "common.h"  #include "common.h"
15  #include "editor.h"  #include "editor.h"
# Line 268  int editor_data_insert(EDITOR_DATA *p_ed Line 272  int editor_data_insert(EDITOR_DATA *p_ed
272          {          {
273                  if (p_editor_data->display_line_total >= MAX_EDITOR_DATA_LINES)                  if (p_editor_data->display_line_total >= MAX_EDITOR_DATA_LINES)
274                  {                  {
275  #ifdef _DEBUG                          log_debug("Split line error, display_line_total(%ld) reach limit(%d)\n",
                         log_error("Split line error, display_line_total(%ld) reach limit(%d)\n",  
276                                            p_editor_data->display_line_total, MAX_EDITOR_DATA_LINES);                                            p_editor_data->display_line_total, MAX_EDITOR_DATA_LINES);
 #endif  
277    
278                          return -2;                          return -2;
279                  }                  }
# Line 365  int editor_data_insert(EDITOR_DATA *p_ed Line 367  int editor_data_insert(EDITOR_DATA *p_ed
367                          // Insert blank display line after last_display_line                          // Insert blank display line after last_display_line
368                          if (p_editor_data->display_line_total >= MAX_EDITOR_DATA_LINES)                          if (p_editor_data->display_line_total >= MAX_EDITOR_DATA_LINES)
369                          {                          {
370  #ifdef _DEBUG                                  log_debug("display_line_total over limit %d >= %d\n", p_editor_data->display_line_total, MAX_EDITOR_DATA_LINES);
                                 log_error("display_line_total over limit %d >= %d\n", p_editor_data->display_line_total, MAX_EDITOR_DATA_LINES);  
 #endif  
371    
372                                  // Terminate prior display line with \n, to avoid error on cleanup                                  // Terminate prior display line with \n, to avoid error on cleanup
373                                  if (display_line + i - 1 >= 0 && p_editor_data->display_line_lengths[display_line + i - 1] > 0)                                  if (display_line + i - 1 >= 0 && p_editor_data->display_line_lengths[display_line + i - 1] > 0)
# Line 679  int editor_display(EDITOR_DATA *p_editor Line 679  int editor_display(EDITOR_DATA *p_editor
679          int i, j;          int i, j;
680          char *p_str;          char *p_str;
681          int del_line;          int del_line;
682            int tab_width = 0;
683    
684          clrline(output_current_row, SCREEN_ROWS);          clrline(output_current_row, SCREEN_ROWS);
685    
# Line 717  int editor_display(EDITOR_DATA *p_editor Line 718  int editor_display(EDITOR_DATA *p_editor
718                          moveto((int)row_pos, (int)col_pos);                          moveto((int)row_pos, (int)col_pos);
719                          iflush();                          iflush();
720    
721                            tab_width = 0;
722                          str_len = 0;                          str_len = 0;
723                          ch = igetch_t(BBS_max_user_idle_time);                          ch = igetch_t(BBS_max_user_idle_time);
724                          while (!SYS_server_exit)                          while (!SYS_server_exit)
# Line 732  int editor_display(EDITOR_DATA *p_editor Line 734  int editor_display(EDITOR_DATA *p_editor
734                                          goto cleanup;                                          goto cleanup;
735                                  }                                  }
736    
737                                    if (ch == '\t')
738                                    {
739                                            ch = ' ';
740                                            tab_width = TAB_SIZE - ((int)(col_pos - 1) % TAB_SIZE) - 1;
741                                    }
742    
743                                  if (ch < 256 && (ch & 0x80)) // head of multi-byte character                                  if (ch < 256 && (ch & 0x80)) // head of multi-byte character
744                                  {                                  {
745                                          str_len = 0;                                          str_len = 0;
# Line 751  int editor_display(EDITOR_DATA *p_editor Line 759  int editor_display(EDITOR_DATA *p_editor
759                                                  ch = igetch(100);                                                // 0.1 second                                                  ch = igetch(100);                                                // 0.1 second
760                                                  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
761                                                  {                                                  {
762  #ifdef _DEBUG                                                          log_debug("Ignore %d bytes of incomplete UTF8 character\n", str_len);
                                                         log_error("Ignore %d bytes of incomplete UTF8 character\n", str_len);  
 #endif  
763                                                          str_len = 0;                                                          str_len = 0;
764                                                          break;                                                          break;
765                                                  }                                                  }
# Line 850  int editor_display(EDITOR_DATA *p_editor Line 856  int editor_display(EDITOR_DATA *p_editor
856                                                  break;                                                  break;
857                                          }                                          }
858    
859                                          ch = igetch(0);                                          if (ch == ' ' && tab_width > 0)
                                         if (ch == KEY_NULL || ch == KEY_TIMEOUT) // Output if no futher input  
860                                          {                                          {
861                                                  break;                                                  tab_width--;
862                                            }
863                                            else
864                                            {
865                                                    ch = igetch(0);
866                                                    if (ch == KEY_NULL || ch == KEY_TIMEOUT) // Output if no futher input
867                                                    {
868                                                            break;
869                                                    }
870                                          }                                          }
871    
872                                          str_len = 0;                                          str_len = 0;
# Line 955  int editor_display(EDITOR_DATA *p_editor Line 968  int editor_display(EDITOR_DATA *p_editor
968                                  switch (ch)                                  switch (ch)
969                                  {                                  {
970                                  case KEY_NULL:                                  case KEY_NULL:
971                                          log_error("KEY_NULL\n");                                          log_debug("KEY_NULL\n");
972                                          goto cleanup;                                          goto cleanup;
973                                  case KEY_TIMEOUT:                                  case KEY_TIMEOUT:
974                                          log_error("User input timeout\n");                                          log_error("User input timeout\n");


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

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