added loading files

This commit is contained in:
FantasyPvP
2024-11-08 10:36:07 +00:00
parent be32741af2
commit e7ecffa65a
8 changed files with 283 additions and 29 deletions
+4 -5
View File
@@ -11,7 +11,7 @@ typedef struct {
String_t* buffer;
} Editor;
Editor editor_from(char* input_string) {
Editor editor_from(String_t input_string) {
Editor e;
e.lines = 0;
e.screen_line = 0;
@@ -19,10 +19,9 @@ Editor editor_from(char* input_string) {
e.editmode = false;
int linenum = 0;
String_t lines = str_from_chars(input_string);
e.buffer = str_lines(&lines, &linenum);
e.buffer = str_lines(&input_string, &linenum);
e.lines = (size_t)linenum;
str_dealloc(&lines);
str_dealloc(&input_string);
for (size_t i = 0; i < e.lines; i++) {
// adding the line number
@@ -38,7 +37,7 @@ Editor editor_from(char* input_string) {
}
Editor new_editor() {
return editor_from("");
return editor_from(str_new());
}
void move_cursor(Editor* self, int x, int y) {