commit 6b750ca116a04d7e5d5e0b98c1886a73fb863cb1
parent 56d4addb8be92427d2d03360f56d448f274c1975
Author: citbl <citbl@citbl.org>
Date: Fri, 10 Oct 2025 20:35:59 +1000
show domain
Diffstat:
2 files changed, 17 insertions(+), 4 deletions(-)
diff --git a/config.h b/config.h
@@ -20,6 +20,7 @@
#define LINE_COLOR (TB_WHITE | TB_DIM)
#define FEED_COLOR TB_CYAN
#define POST_COLOR (TB_YELLOW)
+#define DOMAIN_COLOR (TB_RED | TB_DIM)
#define SEEN_COLOR (TB_YELLOW | TB_DIM)
// how many posts we want to see per feed
@@ -29,4 +30,5 @@
#define POSTS_CAP 128
#define FEEDS_CAP 32
#define TITLE_CAP 128
+#define DOMAIN_CAP 64
#define URL_CAP 8192
diff --git a/render.c b/render.c
@@ -3,6 +3,7 @@
#include "termbox2.h"
#include "tui.h"
#include "config.h"
+#include "utils.h"
#define HORIZ_LINE 0x2500
#define VERT_LINE 0x2502
@@ -60,12 +61,14 @@ render(app_t* app)
{
int i;
uintattr_t color;
- size_t title_len;
+ int title_len, domain_len;
char title[TITLE_CAP] = { 0 };
+ char domain[DOMAIN_CAP] = { 0 };
db_post_t* post;
feed_t* feed;
feed_t* selected_feed = app->feeds[app->selected_feed];
int buffer_height = tb_height() - 3 - 3;
+ int width = tb_width();
draw_background();
draw_bars();
@@ -89,10 +92,17 @@ render(app_t* app)
for (i = 0; i < visible_len; i++) {
post = selected_feed->posts[i];
- title_len = MIN(TITLE_CAP, strlen(post->title));
- strncpy(title, post->title, title_len);
+
+ title_len = MIN(TITLE_CAP, strlen(post->title)) + 1;
+ strncpy(title, post->title, title_len - 1);
+ title[title_len - 1] = ' '; // overlapping with domain
title[title_len] = '\0';
+ const char* domain_host = host_from_url(post->link);
+ domain_len = MIN(DOMAIN_CAP, strlen(domain_host));
+ strncpy(domain, domain_host, domain_len);
+ domain[domain_len] = '\0';
+
if (app->selected_panel == 1 && i == app->selected_post)
if (post->seen)
color = (POST_COLOR | TB_REVERSE | TB_DIM);
@@ -103,7 +113,8 @@ render(app_t* app)
else
color = (POST_COLOR);
- tb_print(FEED_CAP + 10, 3 + i, color, BACK_COLOR, title);
+ tb_print(width - domain_len - 2, 3 + i, DOMAIN_COLOR, BACK_COLOR, domain);
+ tb_print(FEED_CAP + 7, 3 + i, color, BACK_COLOR, title);
}
tb_present();