/[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.21 by sysadm, Sat Jun 14 11:15:46 2025 UTC Revision 1.22 by sysadm, Sun Jun 15 04:43:33 2025 UTC
# Line 79  EDITOR_DATA *editor_data_load(const char Line 79  EDITOR_DATA *editor_data_load(const char
79  {  {
80          EDITOR_DATA *p_editor_data;          EDITOR_DATA *p_editor_data;
81          char *p_data_line = NULL;          char *p_data_line = NULL;
82          long line_offsets[MAX_EDITOR_DATA_LINES];          long line_offsets[MAX_EDITOR_DATA_LINES + 1];
83          long current_data_line_length = 0;          long current_data_line_length = 0;
84          long i;          long i;
85    
# Line 96  EDITOR_DATA *editor_data_load(const char Line 96  EDITOR_DATA *editor_data_load(const char
96                  return NULL;                  return NULL;
97          }          }
98    
99          p_editor_data->display_line_total = split_data_lines(p_data, SCREEN_COLS, line_offsets, MAX_EDITOR_DATA_LINES);          p_editor_data->display_line_total = split_data_lines(p_data, SCREEN_COLS, line_offsets, MAX_EDITOR_DATA_LINES + 1);
100    
101          for (i = 0; i < p_editor_data->display_line_total; i++)          for (i = 0; i < p_editor_data->display_line_total; i++)
102          {          {
# Line 417  int editor_data_insert(EDITOR_DATA *p_ed Line 417  int editor_data_insert(EDITOR_DATA *p_ed
417                          *p_offset -= p_editor_data->display_line_lengths[*p_display_line];                          *p_offset -= p_editor_data->display_line_lengths[*p_display_line];
418                          (*p_display_line)++;                          (*p_display_line)++;
419                  }                  }
420                  else if (*p_display_line + 1 >= MAX_EDITOR_DATA_LINES)          }
421    
422            // Prevent the last display line from being over-length
423            if (p_editor_data->display_line_total == MAX_EDITOR_DATA_LINES)
424            {
425                    len = split_line(p_editor_data->p_display_lines[p_editor_data->display_line_total - 1], SCREEN_COLS - 1, &eol, &display_len);
426                    p_editor_data->p_display_lines[p_editor_data->display_line_total - 1][len] = '\0';
427                    p_editor_data->display_line_lengths[p_editor_data->display_line_total - 1] = len;
428                    if (*p_display_line + 1 >= p_editor_data->display_line_total)
429                  {                  {
430                          len = split_line(p_editor_data->p_display_lines[*p_display_line], SCREEN_COLS - 1, &eol, &display_len);                          *p_offset = MIN(*p_offset, len);
431                          p_editor_data->p_display_lines[*p_display_line][len] = '\0';                          *p_display_line = p_editor_data->display_line_total - 1;
                         p_editor_data->display_line_lengths[*p_display_line] = len;  
                         *p_offset = len;  
432                  }                  }
433          }          }
434    
# Line 839  int editor_display(EDITOR_DATA *p_editor Line 845  int editor_display(EDITOR_DATA *p_editor
845                                          break;                                          break;
846                                  case Ctrl('E'): // End of line                                  case Ctrl('E'): // End of line
847                                  case KEY_CTRL_RIGHT:                                  case KEY_CTRL_RIGHT:
848                                            if (line_current + (screen_row_total - (output_current_row - screen_begin_row)) >= p_editor_data->display_line_total) // Reach end
849                                            {
850                                                    // last display line does NOT have \n in the end
851                                                    col_pos = p_editor_data->display_line_lengths[line_current - output_current_row + row_pos] + 1;
852                                                    break;
853                                            }
854                                          col_pos = MAX(1, p_editor_data->display_line_lengths[line_current - output_current_row + row_pos]);                                          col_pos = MAX(1, p_editor_data->display_line_lengths[line_current - output_current_row + row_pos]);
855                                          break;                                          break;
856                                  case Ctrl('T'): // Top of screen                                  case Ctrl('T'): // Top of screen


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

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