summaryrefslogtreecommitdiff
path: root/src/fruits/cmc/ui/widgets/now_playing.c
diff options
context:
space:
mode:
authorAndrew Opalach <andrew@akon.city> 2026-09-07 15:06:14 -0400
committerAndrew Opalach <andrew@akon.city> 2026-09-07 15:06:14 -0400
commitc66c7c64ebd16287b892f8a780cffcabafba3799 (patch)
treeb2195902ef055147878b591cf1171be7e6133c97 /src/fruits/cmc/ui/widgets/now_playing.c
parent1758ae9e860bd3b65b661e3c804288c3599f4fd4 (diff)
downloadcamu-c66c7c64ebd16287b892f8a780cffcabafba3799.tar.gz
camu-c66c7c64ebd16287b892f8a780cffcabafba3799.tar.bz2
camu-c66c7c64ebd16287b892f8a780cffcabafba3799.zip
Better OSD behavior, lots of build stuff
Signed-off-by: Andrew Opalach <andrew@akon.city>
Diffstat (limited to 'src/fruits/cmc/ui/widgets/now_playing.c')
-rw-r--r--src/fruits/cmc/ui/widgets/now_playing.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/fruits/cmc/ui/widgets/now_playing.c b/src/fruits/cmc/ui/widgets/now_playing.c
index 56405b3..1a4303d 100644
--- a/src/fruits/cmc/ui/widgets/now_playing.c
+++ b/src/fruits/cmc/ui/widgets/now_playing.c
@@ -162,23 +162,28 @@ void cmc_now_playing_render(struct cmc_now_playing *np, struct cmc_list_entry *e
ncplane_putstr_yx(np->n, 1, x1 + 2, timestr);
if (entry) {
- u32 rslash = al_str_rfind(&entry->brief, '/');
str part;
+ u32 rslash = al_str_rfind(&entry->brief, '/');
if (rslash != AL_STR_NO_POS) {
part = al_str_substr(&entry->brief, rslash + 1, entry->brief.length);
} else {
part = entry->brief;
}
- char *c_str = al_str_to_c_str(&part);
+ // x1 = Position of right side "|".
+ // x2 = First character of entry brief.
s32 x2 = 6 + width1;
- // @TODO: Can mid be negative.
s32 mid = x1 - x2;
- ncplane_putnstr_yx(np->n, 1, x2, MIN(al_strlen(c_str), (size_t)mid), c_str);
- if (part.length >= mid) {
- ncplane_putnstr_yx(np->n, 1, x2 + mid - 1, 1, ".");
- ncplane_putnstr_yx(np->n, 1, x2 + mid - 2, 1, ".");
+ if (mid >= 1) {
+ char *c_str = al_str_to_c_str(&part);
+ ncplane_putnstr_yx(np->n, 1, x2, MIN(al_strlen(c_str), (size_t)mid), c_str);
+ if (part.length >= (u32)mid) {
+ ncplane_putnstr_yx(np->n, 1, x2 + mid - 1, 1, ".");
+ if (mid >= 2) {
+ ncplane_putnstr_yx(np->n, 1, x2 + mid - 2, 1, ".");
+ }
+ }
+ al_free(c_str);
}
- al_free(c_str);
bool visual_cached = false;
struct cmc_now_playing_visual *visual;