Compare commits

...

2 Commits

Author SHA1 Message Date
0abe4974df made the renderer escapecode based 2025-08-20 21:54:26 -07:00
fcfd5131ec working on adding utf8 2025-07-21 16:37:28 -07:00
2 changed files with 38 additions and 5 deletions

View File

@@ -22,16 +22,19 @@ extern "C" {
#ifdef TART_RGB_COLORS
#define NULL_CELL (struct tart_cell){{0,0,0},{0,0,0},0,0,0}
#define TART_CELL_DATA_SIZE 16 // todo add number
#define TART_CELL_DATA_SIZE 32 // todo add number
typedef char tart_display[2];
#else
#define NULL_CELL (struct tart_cell){0,0,0,' '}
#define TART_CELL_DATA_SIZE 20
typedef char tart_display;
#endif
#define TART_OK 0
#define TART_STYLE_BOLD 1
#define TART_STYLE_DIM 2
#define TART_STYLE_ITALIC 3
#define TART_STYLE_UNDERLINE 4
#define TART_STYLE_BLINKING 5
#define TART_STYLE_INVERSE 7
@@ -101,6 +104,14 @@ struct tart_cell {
char display;
};
#else
#ifdef TART_UTF8
struct tart_cell {
tart_byte foreground;
tart_byte background;
tart_byte style;
char[2] display;
};
#endif
struct tart_cell {
tart_byte foreground;
tart_byte background;

View File

@@ -103,22 +103,44 @@ tart_byte tart_draw_window(struct tart_window * window, char* rend_buffer) {
for (int b = 0;b < 0xFF; b++) {
if(window->buffers[b].cell_count == 0)
continue;
char bufferSetPre[16];
int bufferSetSize = sprintf(bufferSetPre, "\033[%d;%dH", window->buffers[b].position.y, window->buffers[b].position.x);
for(int preIdx = 0; preIdx < bufferSetSize; preIdx++) {
//window->data[(y*window->buffers[b].size.x) + offset] = movePre[preIdx];
window->data[offset] = bufferSetPre[preIdx];
offset++;
}
offset++;
bufferWidth = window->buffers[b].size.x;
for (int y = 0; y < window->buffers[b].size.y; y++) {
char movePre[16];
int moveSize = sprintf(movePre, "\033[%dB\033[%dG", 1, window->buffers[b].position.x);
for(int preIdx = 0; preIdx < moveSize; preIdx++) {
//window->data[(y*window->buffers[b].size.x) + offset] = movePre[preIdx];
window->data[offset] = movePre[preIdx];
offset++;
}
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[TART_CELL_DATA_SIZE];
// puts cell drawing data in pre
int size = sprintf(pre, "\033[%d;%d;%dm%c\033[0;0m",
#ifdef TART_RGB_COLORS
char pre[TART_CELL_DATA_SIZE+4];
int size = sprintf(pre, "\033[0m\033[38;2;%d;%d;%dm\033[0m\033[48;2;%d;%d;%dm%\033[%dmc\033[0;0m",
// TODO add rgb
(int)cell.style, cell.foreground,
cell.background, cell.display) -1;
#endif
char pre[TART_CELL_DATA_SIZE+4];
int size = sprintf(pre, "\033[0m\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++) {
window->data[(y*window->buffers[b].size.x) + x + offset] = pre[preIdx];
window->data[offset] = pre[preIdx];
offset++;
}
}
//window->data[((y)*window->buffers[b].size.x) + offset + window->buffers[b].size.x] = '\n';
offset++;