commit 1e4f573

uint  ·  2026-05-14 17:20:13 +0000 UTC
parent c719485
make caret inverted colours
2 files changed,  +7, -16
+7, -10
 1@@ -340,19 +340,23 @@ static void run(void)
 2 		if (!dirty)
 3 			continue;
 4 
 5-		if (redraw_all)
 6+		if (redraw_all) {
 7 			draw_clear(pixels, winw, winh, rgba(0, 0, 0, 255));
 8+		}
 9 
10 		for (int y = 0; y < term.rows; y++) {
11 			for (int x = 0; x < term.cols; x++) {
12 				Rune* r = &RUNE(&term, x, y);
13+				bool cursor = x == car.x && y == car.y;
14+				uint32_t fg = cursor ? r->bg : r->fg;
15+				uint32_t bg = cursor ? r->fg : r->bg;
16 
17 				if (!r->dmg)
18 					continue;
19 
20 				draw_rune(
21 					pixels, winw, winh, x, y,
22-					font.cellw, font.cellh, r->bg
23+					font.cellw, font.cellh, bg
24 				);
25 
26 				if (r->cp != ' ') {
27@@ -361,7 +365,7 @@ static void run(void)
28 						x * font.cellw,
29 						y * font.cellh + (int)font.asc,
30 						r->cp,
31-						r->fg
32+						fg
33 					);
34 				}
35 
36@@ -369,13 +373,6 @@ static void run(void)
37 			}
38 		}
39 
40-		draw_caret(
41-			pixels, winw, winh,
42-			car.x, car.y,
43-			font.cellw, font.cellh,
44-			rgba(255, 255, 255, 255)
45-		);
46-
47 		RGFW_window_blitSurface(win, surf);
48 
49 		ocar = car;
+0, -6
 1@@ -121,12 +121,6 @@ void draw_rune(uint32_t* dst, int w, int h, int cl, int rw, int cw, int ch,
 2 	}
 3 }
 4 
 5-void draw_caret(uint32_t* dst, int w, int h, int cl, int rw, int cw, int ch,
 6-                 uint32_t fg)
 7-{
 8-	draw_rune(dst, w, h, cl, rw, cw, ch, fg);
 9-}
10-
11 void draw_codepoint(Fontface* f, uint32_t* dst, int w, int h, int x,
12                     int baseline, uint32_t cp, uint32_t fg)
13 {