/[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.11 by sysadm, Wed Jun 11 11:55:50 2025 UTC Revision 1.12 by sysadm, Wed Jun 11 12:56:52 2025 UTC
# Line 27  Line 27 
27  #define _POSIX_C_SOURCE 200809L  #define _POSIX_C_SOURCE 200809L
28  #include <string.h>  #include <string.h>
29    
30    #define EDITOR_ESC_DISPLAY_STR "\033[32m*\033[m"
31    
32  EDITOR_DATA *editor_data_load(const char *p_data)  EDITOR_DATA *editor_data_load(const char *p_data)
33  {  {
34          EDITOR_DATA *p_editor_data;          EDITOR_DATA *p_editor_data;
# Line 546  int editor_display(EDITOR_DATA *p_editor Line 548  int editor_display(EDITOR_DATA *p_editor
548          int scroll_rows;          int scroll_rows;
549          long last_updated_line = 0;          long last_updated_line = 0;
550          int key_insert = 1;          int key_insert = 1;
551          int i;          int i, j;
552            char *p_str;
553    
554          screen_current_row = screen_begin_row;          screen_current_row = screen_begin_row;
555          clrline(screen_begin_row, SCREEN_ROWS);          clrline(screen_begin_row, SCREEN_ROWS);
# Line 607  int editor_display(EDITOR_DATA *p_editor Line 610  int editor_display(EDITOR_DATA *p_editor
610                                          str_len = 0;                                          str_len = 0;
611                                  }                                  }
612    
613                                  if ((ch >= 32 && ch < 127) || (ch > 127 && ch <= 255 && str_len == 2) || ch == CR) // printable character or GBK                                  if ((ch >= 32 && ch < 127) || (ch > 127 && ch <= 255 && str_len == 2) || // Printable character or GBK
614                                            ch == CR || ch == KEY_ESC)                                                                                       // Special character
615                                  {                                  {
616                                          if (str_len == 0)                                          if (str_len == 0)
617                                          {                                          {
# Line 868  int editor_display(EDITOR_DATA *p_editor Line 872  int editor_display(EDITOR_DATA *p_editor
872                                          col_pos = MIN(col_pos, MAX(1, p_editor_data->display_line_lengths[line_current - screen_current_row + row_pos]));                                          col_pos = MIN(col_pos, MAX(1, p_editor_data->display_line_lengths[line_current - screen_current_row + row_pos]));
873                                          clrline(screen_begin_row, SCREEN_ROWS);                                          clrline(screen_begin_row, SCREEN_ROWS);
874                                          break;                                          break;
                                 case KEY_ESC:  
                                         break;  
875                                  case KEY_F1:                                  case KEY_F1:
876                                          if (!show_help) // Not reentrant                                          if (!show_help) // Not reentrant
877                                          {                                          {
# Line 915  int editor_display(EDITOR_DATA *p_editor Line 917  int editor_display(EDITOR_DATA *p_editor
917                          len = 0;                          len = 0;
918                  }                  }
919    
920                  memcpy(buffer, (const char *)p_editor_data->p_display_lines[line_current], (size_t)len);                  // memcpy(buffer, p_editor_data->p_display_lines[line_current], (size_t)len);
921                  buffer[len] = '\0';                  // Replace '\033' with '*'
922                    p_str = p_editor_data->p_display_lines[line_current];
923                    for (i = 0, j = 0; i < len; i++)
924                    {
925                            if (p_str[i] == '\033')
926                            {
927                                    memcpy(buffer + j, EDITOR_ESC_DISPLAY_STR, sizeof(EDITOR_ESC_DISPLAY_STR) - 1);
928                                    j += (int)(sizeof(EDITOR_ESC_DISPLAY_STR) - 1);
929                            }
930                            else
931                            {
932                                    buffer[j] = p_str[i];
933                                    j++;
934                            }
935                    }
936                    buffer[j] = '\0';
937    
938                  moveto(screen_current_row, 0);                  moveto(screen_current_row, 0);
939                  clrtoeol();                  clrtoeol();


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

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