commit 8cf3807

uint  ·  2026-10-22 11:44:51 +0000 UTC
parent 5e63864
keep cells centerd in window
2 files changed,  +10, -5
+8, -3
 1@@ -344,6 +344,9 @@ static void run(void)
 2 			term_damage_all(&term);
 3 		}
 4 
 5+		int grid_x = (winw - term.cols * font.cellw) / 2;
 6+		int grid_y = (winh - term.rows * font.cellh) / 2;
 7+
 8 		for (int y = 0; y < term.rows; y++) {
 9 			for (int x = 0; x < term.cols; x++) {
10 				Rune* r = &RUNE(&term, x, y);
11@@ -363,15 +366,17 @@ static void run(void)
12 					continue;
13 
14 				draw_rune(
15-					win->bfb, win->stride, winh, x, y,
16+					win->bfb, win->stride, winh,
17+					grid_x + x * font.cellw,
18+					grid_y + y * font.cellh,
19 					font.cellw, font.cellh, bg
20 				);
21 
22 				if (r->cp != ' ') {
23 					draw_codepoint(
24 						&font, win->bfb, win->stride, winh,
25-						x * font.cellw,
26-						y * font.cellh + (int)font.asc,
27+						grid_x + x * font.cellw,
28+						grid_y + y * font.cellh + (int)font.asc,
29 						r->cp,
30 						fg
31 					);
+2, -2
 1@@ -48,8 +48,8 @@ static void blend(uint32_t* dst, int w, int h, int x, int y, uint8_t alpha,
 2 void draw_rune(uint32_t* dst, int w, int h, int cl, int rw, int cw, int ch,
 3                uint32_t bg)
 4 {
 5-	int x0 = cl * cw; /* x origin of cell */
 6-	int y0 = rw * ch; /* y origin of cell */
 7+	int x0 = cl; /* x origin of cell */
 8+	int y0 = rw; /* y origin of cell */
 9 	int x;
10 	int y;
11