fixed the TART_CELL_DATA_SIZE and used malloc in the test

This commit is contained in:
2025-02-11 12:34:19 -08:00
parent 73aa50446b
commit 2ad63d785f
3 changed files with 14 additions and 10 deletions

View File

@@ -22,6 +22,7 @@ struct tart_window tart_create_window() {
for(int g = 0; g < (window.size.x * window.size.y * sizeof(char) * TART_CELL_DATA_SIZE)+ 100; g++) {
window.data[g] = '\0';
}
window.data_count = (window.size.x * window.size.y * sizeof(char) * TART_CELL_DATA_SIZE)+ 100;
return window;
}
@@ -90,7 +91,7 @@ tart_byte tart_draw_window(struct tart_window * window, char* rend_buffer) {
for (int x = 0; x < window->buffers[b].size.x; x++) {
// add data to window c buffer.
struct tart_cell cell = window->buffers[b].cells[(y*window->buffers[b].size.x) + x];
char pre[20];
char pre[TART_CELL_DATA_SIZE];
int size = sprintf(pre, "\033[%d;%d;%dm%c\033[0;0m", (int)cell.style, cell.foreground, cell.background, cell.display);
for(int preIdx = 0; preIdx < size; preIdx++) {
window->data[(y*window->buffers[b].size.x) + x + offset] = pre[preIdx];
@@ -106,7 +107,7 @@ tart_byte tart_draw_window(struct tart_window * window, char* rend_buffer) {
i++;
}
}
fwrite(window->data, sizeof(char), (window->size.x * window->size.y * sizeof(char))+ 100 , stdout);
fwrite(window->data, sizeof(char), window->data_count, stdout);
return TART_OK;
};