diff options
| author | cflip <cflip@cflip.net> | 2023-01-17 10:39:21 -0700 |
|---|---|---|
| committer | cflip <cflip@cflip.net> | 2023-01-17 10:39:21 -0700 |
| commit | 1a416a917d74d956469e6e80cf4bb519e9474c91 (patch) | |
| tree | 6e61b15d9cece1af0a64d3a9cd2a5d5dd73815b7 /file.c | |
| parent | 8be3915417bcafdbf2a8752980db96e06df096aa (diff) | |
Rename 'rows' to 'lines' everywhere
For whatever reason lines were called rows in the code, so this refactor
changes that name everywhere. The name 'row' is still used in some
places to refer to the unit of height in the screen.
Diffstat (limited to 'file.c')
| -rw-r--r-- | file.c | 18 |
1 files changed, 9 insertions, 9 deletions
@@ -8,25 +8,25 @@ #include <unistd.h> #include "error.h" -#include "row.h" +#include "line.h" #include "syntax.h" -char* editor_rows_to_string(struct editor_state* editor, int* buffer_length) +static char *lines_to_string(struct editor_state *editor, int *buffer_length) { int total_length = 0; int j; - for (j = 0; j < editor->row_count; j++) - total_length += editor->rows[j].size + 1; + for (j = 0; j < editor->num_lines; j++) + total_length += editor->lines[j].size + 1; *buffer_length = total_length; char* buffer = malloc(total_length); char* p = buffer; - for (j = 0; j < editor->row_count; j++) { - memcpy(p, editor->rows[j].chars, editor->rows[j].size); - p += editor->rows[j].size; + for (j = 0; j < editor->num_lines; j++) { + memcpy(p, editor->lines[j].chars, editor->lines[j].size); + p += editor->lines[j].size; *p = '\n'; p++; } @@ -60,7 +60,7 @@ void editor_open(struct editor_state* editor, char* filename) while (line_length > 0 && (line[line_length - 1] == '\n' || line[line_length - 1] == '\r')) line_length--; - insert_row(editor, editor->row_count, line, line_length); + editor_insert_line(editor, editor->num_lines, line, line_length); } free(line); @@ -81,7 +81,7 @@ void editor_save(struct editor_state* editor) } int length; - char* buffer = editor_rows_to_string(editor, &length); + char *buffer = lines_to_string(editor, &length); int fd = open(editor->filename, O_RDWR | O_CREAT, 0644); if (fd != -1) { |
