We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 37594f1 commit 234969dCopy full SHA for 234969d
3 files changed
src/cell.c
@@ -2,11 +2,12 @@
2
3
#include "cell.h"
4
5
-void cells_clear(Cell *buf, int w, int h) {
+void cells_fill(Cell *buf, int w, int h, uint32_t ch, uint32_t fg,
6
+ uint32_t bg) {
7
for (int i = 0; i < w * h; i++) {
- buf[i].ch = ' ';
8
- buf[i].fg = ATTR_DEFAULT;
9
- buf[i].bg = ATTR_DEFAULT;
+ buf[i].ch = ch;
+ buf[i].fg = fg;
10
+ buf[i].bg = bg;
11
}
12
13
src/cell.h
@@ -24,7 +24,7 @@ typedef struct {
24
#define ATTR_MASK 0xFF000000
25
#define COLOR_MASK 0x00FFFFFF
26
27
-void cells_clear(Cell *buf, int w, int h);
+void cells_fill(Cell *buf, int w, int h, uint32_t ch, uint32_t fg, uint32_t bg);
28
int cell_cmp(Cell *a, Cell *b);
29
30
#endif
src/clayterm.c
@@ -416,8 +416,11 @@ struct Clayterm *init(void *mem, int w, int h, int row) {
416
.lasty = -1,
417
};
418
419
- cells_clear(ct->front, w, h);
420
- cells_clear(ct->back, w, h);
+ // initialize back buffer with spaces and default fg/bg
+ cells_fill(ct->back, w, h, ' ', ATTR_DEFAULT, ATTR_DEFAULT);
421
+
422
+ // initialize front buffer with zeros. Every cell will be
423
+ cells_fill(ct->front, w, h, 0, 0, 0);
424
return ct;
425
426
@@ -551,7 +554,7 @@ void reduce(struct Clayterm *ct, uint32_t *buf, int len, int mode) {
551
554
ct->lastfg = ct->lastbg = 0xffffffff;
552
555
ct->lastx = ct->lasty = -1;
553
556
- cells_clear(ct->back, ct->w, ct->h);
557
+ cells_fill(ct->back, ct->w, ct->h, ' ', ATTR_DEFAULT, ATTR_DEFAULT);
558
559
/* walk Clay render commands into back buffer */
560
for (int32_t j = 0; j < cmds.length; j++) {
0 commit comments