/[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.48 by sysadm, Sat Oct 18 12:06:10 2025 UTC Revision 1.49 by sysadm, Sun Oct 19 07:08:29 2025 UTC
# Line 445  int editor_data_insert(EDITOR_DATA *p_ed Line 445  int editor_data_insert(EDITOR_DATA *p_ed
445  }  }
446    
447  int editor_data_delete(EDITOR_DATA *p_editor_data, long *p_display_line, long *p_offset,  int editor_data_delete(EDITOR_DATA *p_editor_data, long *p_display_line, long *p_offset,
448                                             long *p_last_updated_line)                                             long *p_last_updated_line, int del_line)
449  {  {
450          long display_line = *p_display_line;          long display_line = *p_display_line;
451          long offset = *p_offset;          long offset = *p_offset;
# Line 500  int editor_data_delete(EDITOR_DATA *p_ed Line 500  int editor_data_delete(EDITOR_DATA *p_ed
500          }          }
501    
502          // Check str to be deleted          // Check str to be deleted
503          if (p_data_line[offset_data_line] > 0 && p_data_line[offset_data_line] < 127)          if (del_line)
504            {
505                    str_len = (int)(p_editor_data->display_line_lengths[display_line] - offset);
506            }
507            else if (p_data_line[offset_data_line] > 0 && p_data_line[offset_data_line] < 127)
508          {          {
509                  str_len = 1;                  str_len = 1;
510          }          }
# Line 523  int editor_data_delete(EDITOR_DATA *p_ed Line 527  int editor_data_delete(EDITOR_DATA *p_ed
527    
528          // Current display line is (almost) empty          // Current display line is (almost) empty
529          if (offset_data_line + str_len > len_data_line ||          if (offset_data_line + str_len > len_data_line ||
530                  (offset_data_line + str_len == len_data_line && p_data_line[offset_data_line] == '\n'))                  (offset_data_line + str_len == len_data_line &&
531                     p_data_line[del_line ? len_data_line - 1 : offset_data_line] == '\n'))
532          {          {
533                  if (display_line + 1 >= p_editor_data->display_line_total) // No additional display line (data line)                  if (display_line + 1 >= p_editor_data->display_line_total) // No additional display line (data line)
534                  {                  {
# Line 663  int editor_display(EDITOR_DATA *p_editor Line 668  int editor_display(EDITOR_DATA *p_editor
668          int key_insert = 1;          int key_insert = 1;
669          int i, j;          int i, j;
670          char *p_str;          char *p_str;
671            int del_line;
672    
673          clrline(output_current_row, SCREEN_ROWS);          clrline(output_current_row, SCREEN_ROWS);
674    
# Line 769  int editor_display(EDITOR_DATA *p_editor Line 775  int editor_display(EDITOR_DATA *p_editor
775                                          if (!key_insert) // overwrite                                          if (!key_insert) // overwrite
776                                          {                                          {
777                                                  if (editor_data_delete(p_editor_data, &display_line_out, &offset_out,                                                  if (editor_data_delete(p_editor_data, &display_line_out, &offset_out,
778                                                                                             &last_updated_line) < 0)                                                                                             &last_updated_line, 0) < 0)
779                                                  {                                                  {
780                                                          log_error("editor_data_delete() error\n");                                                          log_error("editor_data_delete() error\n");
781                                                  }                                                  }
# Line 838  int editor_display(EDITOR_DATA *p_editor Line 844  int editor_display(EDITOR_DATA *p_editor
844                                          str_len = 0;                                          str_len = 0;
845                                          continue;                                          continue;
846                                  }                                  }
847                                  else if (ch == KEY_DEL || ch == BACKSPACE) // Del                                  else if (ch == KEY_DEL || ch == BACKSPACE || ch == Ctrl('K') || ch == Ctrl('Y')) // Del
848                                  {                                  {
849                                          // Refresh current action while user input                                          // Refresh current action while user input
850                                          if (user_online_update(NULL) < 0)                                          if (user_online_update(NULL) < 0)
# Line 846  int editor_display(EDITOR_DATA *p_editor Line 852  int editor_display(EDITOR_DATA *p_editor
852                                                  log_error("user_online_update(NULL) error\n");                                                  log_error("user_online_update(NULL) error\n");
853                                          }                                          }
854    
855                                            del_line = 0;
856    
857                                          if (ch == BACKSPACE)                                          if (ch == BACKSPACE)
858                                          {                                          {
859                                                  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 870  int editor_display(EDITOR_DATA *p_editor Line 878  int editor_display(EDITOR_DATA *p_editor
878                                                          col_pos = MAX(1, p_editor_data->display_line_widths[line_current - output_current_row + row_pos]);                                                          col_pos = MAX(1, p_editor_data->display_line_widths[line_current - output_current_row + row_pos]);
879                                                  }                                                  }
880                                          }                                          }
881                                            else if (ch == Ctrl('K'))
882                                            {
883                                                    del_line = 1;
884                                            }
885                                            else if (ch == Ctrl('Y'))
886                                            {
887                                                    col_pos = 1;
888                                                    del_line = 1;
889                                            }
890    
891                                          display_line_in = line_current - output_current_row + row_pos;                                          display_line_in = line_current - output_current_row + row_pos;
892                                          offset_in = split_line(p_editor_data->p_display_lines[display_line_in], (int)col_pos - 1, &eol, &display_len, 0);                                          offset_in = split_line(p_editor_data->p_display_lines[display_line_in], (int)col_pos - 1, &eol, &display_len, 0);
# Line 877  int editor_display(EDITOR_DATA *p_editor Line 894  int editor_display(EDITOR_DATA *p_editor
894                                          offset_out = offset_in;                                          offset_out = offset_in;
895    
896                                          if ((str_len = editor_data_delete(p_editor_data, &display_line_out, &offset_out,                                          if ((str_len = editor_data_delete(p_editor_data, &display_line_out, &offset_out,
897                                                                                                            &last_updated_line)) < 0)                                                                                                            &last_updated_line, del_line)) < 0)
898                                          {                                          {
899                                                  log_error("editor_data_delete() error\n");                                                  log_error("editor_data_delete() error: %d\n", str_len);
900                                          }                                          }
901                                          else                                          else
902                                          {                                          {


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

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