Compare commits
2 Commits
8cef088b61
...
0a8c4eed82
| Author | SHA1 | Date | |
|---|---|---|---|
| 0a8c4eed82 | |||
| b2839b4cd1 |
@@ -24,5 +24,5 @@ enable_testing()
|
|||||||
add_subdirectory(externals)
|
add_subdirectory(externals)
|
||||||
# PROJECT
|
# PROJECT
|
||||||
add_subdirectory(source)
|
add_subdirectory(source)
|
||||||
add_subdirectory(testing)
|
#add_subdirectory(testing)
|
||||||
|
|
||||||
|
|||||||
@@ -167,8 +167,22 @@ struct tart_cell tart_create_cell(char display, tart_byte style, struct tart_rgb
|
|||||||
struct tart_cell tart_create_cell(char display, tart_byte style, tart_byte foreground, tart_byte background);
|
struct tart_cell tart_create_cell(char display, tart_byte style, tart_byte foreground, tart_byte background);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* tart_add_buffer
|
||||||
|
*
|
||||||
|
* This adds a buffer to the window.
|
||||||
|
*
|
||||||
|
* tart_byte tart_add_buffer(struct tart_window*, struct struct tart_buffer*)
|
||||||
|
*/
|
||||||
tart_byte tart_add_buffer(struct tart_window*, struct tart_buffer);
|
tart_byte tart_add_buffer(struct tart_window*, struct tart_buffer);
|
||||||
|
/* tart_remove_buffer
|
||||||
|
*
|
||||||
|
* This will remove the buffer using the *tart_id*.
|
||||||
|
*/
|
||||||
tart_byte tart_remove_buffer(struct tart_window*, tart_id);
|
tart_byte tart_remove_buffer(struct tart_window*, tart_id);
|
||||||
|
/* tart_set_buffer
|
||||||
|
*
|
||||||
|
* This will replace the the buffer at the index *(tart_byte)*.
|
||||||
|
*/
|
||||||
tart_byte tart_set_buffer(struct tart_window*, struct tart_buffer, tart_byte);
|
tart_byte tart_set_buffer(struct tart_window*, struct tart_buffer, tart_byte);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -15,14 +15,19 @@ struct tart_window tart_create_window() {
|
|||||||
struct tart_window window;
|
struct tart_window window;
|
||||||
window.buffer_count = 0;
|
window.buffer_count = 0;
|
||||||
for(int i = 0; i < 0xFF; i++) {
|
for(int i = 0; i < 0xFF; i++) {
|
||||||
window.buffers[i] = tart_create_buffer(0, (struct tart_vec2){0,0},(struct tart_vec2){0,0});
|
window.buffers[i] = tart_create_buffer(0, (struct tart_vec2){0,0},
|
||||||
|
(struct tart_vec2){0,0});
|
||||||
}
|
}
|
||||||
window.size = term_current_size();
|
window.size = term_current_size();
|
||||||
window.data = malloc((window.size.x * window.size.y * sizeof(char) * TART_CELL_DATA_SIZE)+ 100 );
|
|
||||||
for(int g = 0; g < (window.size.x * window.size.y * sizeof(char) * TART_CELL_DATA_SIZE)+ 100; g++) {
|
int dataSize = (window.size.x * window.size.y * sizeof(char) *
|
||||||
|
TART_CELL_DATA_SIZE) + 100;
|
||||||
|
|
||||||
|
window.data = malloc(dataSize);
|
||||||
|
for(int g = 0; g < dataSize; g++) {
|
||||||
window.data[g] = '\0';
|
window.data[g] = '\0';
|
||||||
}
|
}
|
||||||
window.data_count = (window.size.x * window.size.y * sizeof(char) * TART_CELL_DATA_SIZE)+ 100;
|
window.data_count = dataSize;
|
||||||
return window;
|
return window;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -33,10 +38,11 @@ tart_byte tart_restore_window(struct tart_window* window) {
|
|||||||
return TART_OK;
|
return TART_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct tart_buffer tart_create_buffer(tart_id id, struct tart_vec2 size, struct tart_vec2 position) {
|
struct tart_buffer tart_create_buffer(tart_id id, struct tart_vec2 size,
|
||||||
|
struct tart_vec2 position) {
|
||||||
unsigned int cell_count = size.x * size.y;
|
unsigned int cell_count = size.x * size.y;
|
||||||
|
|
||||||
struct tart_cell* cells = (struct tart_cell*)malloc((size.x * size.y) * sizeof(struct tart_cell));
|
struct tart_cell* cells = (struct tart_cell*)malloc(cell_count * sizeof(struct tart_cell));
|
||||||
|
|
||||||
for (int i = 0;i < cell_count;i++) {
|
for (int i = 0;i < cell_count;i++) {
|
||||||
cells[i] = NULL_CELL;
|
cells[i] = NULL_CELL;
|
||||||
@@ -59,7 +65,8 @@ struct tart_cell tart_create_cell(char display, tart_byte style,
|
|||||||
return (struct tart_cell){foreground,background,style,display};
|
return (struct tart_cell){foreground,background,style,display};
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
tart_byte tart_add_buffer(struct tart_window* window, struct tart_buffer buffer) {
|
tart_byte tart_add_buffer(struct tart_window* window,
|
||||||
|
struct tart_buffer buffer) {
|
||||||
if(window->buffer_count <= 0xFF) {
|
if(window->buffer_count <= 0xFF) {
|
||||||
window->buffers[window->buffer_count] = buffer;
|
window->buffers[window->buffer_count] = buffer;
|
||||||
window->buffer_count++;
|
window->buffer_count++;
|
||||||
@@ -102,11 +109,13 @@ tart_byte tart_draw_window(struct tart_window * window, char* rend_buffer) {
|
|||||||
// add data to window c buffer.
|
// add data to window c buffer.
|
||||||
struct tart_cell cell = window->buffers[b].cells[(y*window->buffers[b].size.x) + x];
|
struct tart_cell cell = window->buffers[b].cells[(y*window->buffers[b].size.x) + x];
|
||||||
char pre[TART_CELL_DATA_SIZE];
|
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) - 1;
|
// puts cell drawing data in pre
|
||||||
|
int size = sprintf(pre, "\033[%d;%d;%dm%c\033[0;0m",
|
||||||
|
(int)cell.style, cell.foreground,
|
||||||
|
cell.background, cell.display) -1;
|
||||||
for(int preIdx = 0; preIdx < size; preIdx++) {
|
for(int preIdx = 0; preIdx < size; preIdx++) {
|
||||||
window->data[(y * bufferWidth) + x + offset] = pre[preIdx];
|
window->data[(y*window->buffers[b].size.x) + x + offset] = pre[preIdx];
|
||||||
offset++;
|
offset++;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//window->data[((y)*window->buffers[b].size.x) + offset + window->buffers[b].size.x] = '\n';
|
//window->data[((y)*window->buffers[b].size.x) + offset + window->buffers[b].size.x] = '\n';
|
||||||
|
|||||||
Reference in New Issue
Block a user