commit 2512b6a

uint  ·  2026-10-22 11:48:32 +0000 UTC
parent 8cf3807
add window padding
2 files changed,  +5, -7
+1, -3
 1@@ -11,9 +11,7 @@ static const int   win_width = 80;  /* in columns */
 2 static const int   win_height = 24; /* in rows */
 3 static const char  win_title[] = "cterm";
 4 static const int   win_fps = 60;
 5-
 6-static const int   pad_x = 8;
 7-static const int   pad_y = 8;
 8+static const int   padding = 8;
 9 
10 static const char* const shell = NULL; /* NULL uses $SHELL */
11 static const char term_name[] = "vt100";
+4, -4
 1@@ -133,8 +133,8 @@ static void init(void)
 2 	if (font_load(&font, font_path) < 0)
 3 		die(1, "failed to load font");
 4 
 5-	winw = win_width*font.cellw;
 6-	winh = win_height*font.cellh;
 7+	winw = win_width * font.cellw + 2 * padding;
 8+	winh = win_height * font.cellh + 2 * padding;
 9 
10 	if (term_resize(&term, &car, win_width, win_height) < 0)
11 		die(1, "failed to resize terminal");
12@@ -270,8 +270,8 @@ static int resize_window(int w, int h)
13 /* TODO */
14 static void resize_terminal(int w, int h)
15 {
16-	int cols = w / font.cellw;
17-	int rows = h / font.cellh;
18+	int cols = (w - 2 * padding) / font.cellw;
19+	int rows = (h - 2 * padding) / font.cellh;
20 
21 	if (cols < 1)
22 		cols = 1;