From 1a416a917d74d956469e6e80cf4bb519e9474c91 Mon Sep 17 00:00:00 2001 From: cflip Date: Tue, 17 Jan 2023 10:39:21 -0700 Subject: 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. --- file.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'file.c') diff --git a/file.c b/file.c index 7604618..606fcc3 100644 --- a/file.c +++ b/file.c @@ -8,25 +8,25 @@ #include #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) { -- cgit v1.2.3