Cleanup and minor Fixes

This commit is contained in:
2026-01-28 18:46:44 +00:00
parent cca0177929
commit 6abdefa808
22 changed files with 343 additions and 371 deletions

View File

@@ -5,18 +5,21 @@
#include "utils/utils.h"
Editor *new_editor(const char *filename_arg, Coord position, Coord size,
bool unix_eol) {
uint8_t eol) {
Editor *editor = new Editor();
if (!editor)
return nullptr;
uint32_t len = 0;
std::string filename = path_abs(filename_arg);
char *str = load_file(filename.c_str(), &len);
editor->unix_eol = eol & 1;
char *str = load_file(filename.c_str(), &len, &editor->unix_eol);
if (!str) {
free_editor(editor);
return nullptr;
str = (char *)malloc(1);
*str = '\n';
len = 1;
}
editor->unix_eol = unix_eol;
if ((eol >> 1) & 1)
editor->unix_eol = eol & 1;
editor->filename = filename;
editor->uri = path_to_file_uri(filename);
editor->position = position;