summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwrmr2025-06-23 17:11:49 -0400
committerwrmr2025-06-23 17:11:49 -0400
commit4eba2a6000403ec819e3444304feca7cb12622ac (patch)
treef0ee6534a6410bea1dcc102a9e02c457397f7b88
parent8e6ccd40afc09548ab0ef21d1b9782996c7db689 (diff)
clean up wrap width and margins stuff a little
-rw-r--r--main.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/main.c b/main.c
index c5d17c2..c315085 100644
--- a/main.c
+++ b/main.c
@@ -262,15 +262,19 @@ int str_cat_wrap(Str *out, Str s, int width, Arena *a) {
return lines;
}
+int gfx_post_width(void) {
+ return getmaxx(stdscr) - GFX_MARGIN_X * 2 - 2;
+}
+
int gfx_wrap_width(void) {
- return getmaxx(stdscr) - 2 - GFX_MARGIN_X * 2 - GFX_TEXT_MARGIN_X * 2;
+ return gfx_post_width() - GFX_TEXT_MARGIN_X * 2;
}
void gfx_load_post(GfxPost *post, Post *src, int width, Arena *a) {
memset(post, 0, sizeof(GfxPost));
post->src = src;
/* subtract two to make room for border */
- post->lines = str_cat_wrap(&post->text, src->text, width - 2, a);
+ post->lines = str_cat_wrap(&post->text, src->text, width, a);
str_catc(&post->text, '\0', a);
post->text.n--;
}
@@ -338,10 +342,10 @@ void gfx_draw_post(GfxPost *post, int y, int x, int width) {
}
void gfx_draw(Gfx *gfx, int cur) {
- int wrap_width = gfx_wrap_width();
+ int width = gfx_post_width();
erase();
for (int i = cur, y = GFX_MARGIN_Y; i < gfx->len && y < getmaxy(stdscr) - GFX_MARGIN_Y; i++) {
- gfx_draw_post(&gfx->posts[i], y, GFX_MARGIN_X, wrap_width);
+ gfx_draw_post(&gfx->posts[i], y, GFX_MARGIN_X, width);
y += gfx_post_height(&gfx->posts[i]) + 1;
}
}