Compare commits
2 Commits
2992e41050
...
0abe4974df
| Author | SHA1 | Date | |
|---|---|---|---|
| 0abe4974df | |||
| fcfd5131ec |
@@ -22,16 +22,19 @@ extern "C" {
|
|||||||
|
|
||||||
#ifdef TART_RGB_COLORS
|
#ifdef TART_RGB_COLORS
|
||||||
#define NULL_CELL (struct tart_cell){{0,0,0},{0,0,0},0,0,0}
|
#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
|
#else
|
||||||
#define NULL_CELL (struct tart_cell){0,0,0,' '}
|
#define NULL_CELL (struct tart_cell){0,0,0,' '}
|
||||||
#define TART_CELL_DATA_SIZE 20
|
#define TART_CELL_DATA_SIZE 20
|
||||||
|
typedef char tart_display;
|
||||||
#endif
|
#endif
|
||||||
#define TART_OK 0
|
#define TART_OK 0
|
||||||
|
|
||||||
|
|
||||||
#define TART_STYLE_BOLD 1
|
#define TART_STYLE_BOLD 1
|
||||||
#define TART_STYLE_DIM 2
|
#define TART_STYLE_DIM 2
|
||||||
|
#define TART_STYLE_ITALIC 3
|
||||||
#define TART_STYLE_UNDERLINE 4
|
#define TART_STYLE_UNDERLINE 4
|
||||||
#define TART_STYLE_BLINKING 5
|
#define TART_STYLE_BLINKING 5
|
||||||
#define TART_STYLE_INVERSE 7
|
#define TART_STYLE_INVERSE 7
|
||||||
@@ -101,6 +104,14 @@ struct tart_cell {
|
|||||||
char display;
|
char display;
|
||||||
};
|
};
|
||||||
#else
|
#else
|
||||||
|
#ifdef TART_UTF8
|
||||||
|
struct tart_cell {
|
||||||
|
tart_byte foreground;
|
||||||
|
tart_byte background;
|
||||||
|
tart_byte style;
|
||||||
|
char[2] display;
|
||||||
|
};
|
||||||
|
#endif
|
||||||
struct tart_cell {
|
struct tart_cell {
|
||||||
tart_byte foreground;
|
tart_byte foreground;
|
||||||
tart_byte background;
|
tart_byte background;
|
||||||
|
|||||||
@@ -103,22 +103,44 @@ tart_byte tart_draw_window(struct tart_window * window, char* rend_buffer) {
|
|||||||
for (int b = 0;b < 0xFF; b++) {
|
for (int b = 0;b < 0xFF; b++) {
|
||||||
if(window->buffers[b].cell_count == 0)
|
if(window->buffers[b].cell_count == 0)
|
||||||
continue;
|
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;
|
bufferWidth = window->buffers[b].size.x;
|
||||||
for (int y = 0; y < window->buffers[b].size.y; y++) {
|
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++) {
|
for (int x = 0; x < window->buffers[b].size.x; x++) {
|
||||||
// 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];
|
|
||||||
// puts cell drawing data in pre
|
// 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,
|
(int)cell.style, cell.foreground,
|
||||||
cell.background, cell.display) -1;
|
cell.background, cell.display) -1;
|
||||||
for(int preIdx = 0; preIdx < size; preIdx++) {
|
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++;
|
offset++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//window->data[((y)*window->buffers[b].size.x) + offset + window->buffers[b].size.x] = '\n';
|
|
||||||
offset++;
|
offset++;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user