Some changes

This commit is contained in:
2025-02-16 17:28:10 +01:00
parent 0fc4040ad7
commit 4d3755e2ce
18 changed files with 562 additions and 80 deletions

View File

@@ -49,8 +49,9 @@ void init_editor(TextEditor *editor, BitmapFont *font, int x, int y, SDL_Rendere
}
// Allocate output and display strings.
editor->outputString = (char *) malloc(sizeof(char) * (editor->max_line_width * editor->maxLines + 1));
editor->displayString = (char *) malloc(sizeof(char) * (editor->max_line_width * editor->displayLineCount + 1));
editor->outputString = (char *) malloc(sizeof(char) * ((editor->max_line_width + 1) * editor->maxLines + 1) + 1);
editor->displayString = (char *) malloc(
sizeof(char) * ((editor->max_line_width + 1) * editor->displayLineCount + 1) + 1);
if (!editor->outputString || !editor->displayString) {
fprintf(stderr, "Failed to allocate memory for output/display strings.\n");
exit(EXIT_FAILURE);
@@ -301,9 +302,9 @@ void generate_string_display(TextEditor *editor, SDL_Renderer *renderer) {
charDstRect.x += charDstRect.w + 1;
linePTR++;
}
strcat(editor->displayString, "\n");
charDstRect.x = 4;
charDstRect.y += charDstRect.h + 1;
strcat(editor->displayString, "\n");
}
}
SDL_SetRenderTarget(renderer, NULL);