summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main.c37
1 files changed, 16 insertions, 21 deletions
diff --git a/main.c b/main.c
index 31261b9..a94c446 100644
--- a/main.c
+++ b/main.c
@@ -155,11 +155,9 @@ typedef struct {
typedef struct {
struct {
int help;
- } cbink;
- struct {
int pfp, pronouns, date;
const char *datefmt;
- } post;
+ } cbink;
struct {
int left, right, top, bottom;
int text_x, text_y;
@@ -172,7 +170,8 @@ typedef struct {
regex_t re_mention;
Options opt = {
- .post = {
+ .cbink = {
+ .help = 1,
.pfp = 1,
.pronouns = 1,
.date = 1,
@@ -508,7 +507,7 @@ typedef struct {
int post_left_margin(Post *post) {
int lm = opt.margin.left;
- if (opt.post.pfp) lm += post->user->pfp.cols + opt.margin.pfp;
+ if (opt.cbink.pfp) lm += post->user->pfp.cols + opt.margin.pfp;
return lm;
}
@@ -556,7 +555,7 @@ int gfx_post_text_height(GfxPost *post) {
int gfx_post_height(GfxPost *post) {
int base = gfx_post_text_height(post);
int l = MIN(post->src->user->pfp.lines, GFX_PFP_MAX_LINES);
- if (opt.post.pfp && l > base) return l;
+ if (opt.cbink.pfp && l > base) return l;
return base;
}
@@ -633,14 +632,14 @@ void gfx_draw_post(GfxPost *post, int y, int x, int width, Arena *scratch) {
gfx_draw_box(top, left, height, width);
- if (opt.post.date) {
+ if (opt.cbink.date) {
use_color(CPAIR_DATE);
char time_buf[256] = { 0 };
Str time_str = { 0 };
time_t timep = post->src->timestamp.tv_sec;
- if (opt.post.datefmt) {
+ if (opt.cbink.datefmt) {
struct tm *p = localtime(&timep);
- strftime(time_buf, 255, opt.post.datefmt, p);
+ strftime(time_buf, 255, opt.cbink.datefmt, p);
time_str = str_from_cstr(time_buf);
} else {
time_str = str_from_cstr(ctime(&timep));
@@ -649,7 +648,7 @@ void gfx_draw_post(GfxPost *post, int y, int x, int width, Arena *scratch) {
mvaddnstr(top, right - fast_utf8_width(time_str), time_str.s, time_str.n);
}
- if (opt.post.pfp) {
+ if (opt.cbink.pfp) {
use_color(self ? CPAIR_PFP_SELF : CPAIR_PFP);
Pic *pfp = &u->pfp;
int pfpy = y;
@@ -666,7 +665,7 @@ void gfx_draw_post(GfxPost *post, int y, int x, int width, Arena *scratch) {
use_color(CPAIR_USER);
mvaddnstr(top, left + 2, u->name.s, u->name.n);
- if (opt.post.pronouns && u->pronouns.n) {
+ if (opt.cbink.pronouns && u->pronouns.n) {
use_color(CPAIR_PRONOUNS);
mvaddstr(top, left + 2 + fast_utf8_width(u->name) + GFX_PRONOUNS_MARGIN, cstr_fmt(scratch, GFX_PRONOUNS_FMT, u->pronouns));
}
@@ -972,6 +971,11 @@ int prop_cstr(Str name, Str key, Str value, const char **ptr, Arena *perm) {
int sect_cbink(Str k, Str v, Arena *perm) {
(void)perm;
PROP_BOOL("help", &opt.cbink.help);
+ PROP_CSTR("datefmt", &opt.cbink.datefmt);
+ PROP_BOOL("pfp", &opt.cbink.pfp);
+ PROP_BOOL("pronouns", &opt.cbink.pronouns);
+ PROP_BOOL("date", &opt.cbink.date);
+ return -1;
return -1;
}
@@ -987,14 +991,6 @@ int sect_margin(Str k, Str v, Arena *perm) {
return -1;
}
-int sect_post(Str k, Str v, Arena *perm) {
- PROP_CSTR("datefmt", &opt.post.datefmt);
- PROP_BOOL("pfp", &opt.post.pfp);
- PROP_BOOL("pronouns", &opt.post.pronouns);
- PROP_BOOL("date", &opt.post.date);
- return -1;
-}
-
#define BAD_COLOR -2
/* i can't tell if RGB colors are broken, or just the terminal doesn't support it */
@@ -1100,7 +1096,6 @@ int sect_color(Str k, Str v, Arena *perm) {
Section sections[] = {
{ "cbink", &sect_cbink },
{ "margin", &sect_margin },
- { "post", &sect_post },
{ "color", &sect_color },
};
@@ -1251,7 +1246,7 @@ refresh:
post_stats.gather_ns / 1000000);
goto resize;
case '\t':
- opt.post.pfp = !opt.post.pfp;
+ opt.cbink.pfp = !opt.cbink.pfp;
/* fallthrough */
case KEY_RESIZE: