diff options
author | June McEnroe <june@causal.agency> | 2020-07-30 14:37:46 -0400 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2020-07-30 14:37:46 -0400 |
commit | 4c1b1fc6a32061e86dedd6f34ed352cfda380feb (patch) | |
tree | e2710681e8d7101dea097e1a13fac6c91f6dc8ad /ui.c | |
parent | Remove dependency on libcrypto for compat (diff) | |
download | test-4c1b1fc6a32061e86dedd6f34ed352cfda380feb.tar.gz test-4c1b1fc6a32061e86dedd6f34ed352cfda380feb.zip |
Replace catf with something that tracks len
Also the old catf would be broken with -DNDEBUG oops!
Diffstat (limited to '')
-rw-r--r-- | ui.c | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/ui.c b/ui.c index c92fb01..b6aaafc 100644 --- a/ui.c +++ b/ui.c @@ -465,45 +465,38 @@ static void statusUpdate(void) { if (window->heat > others.heat) others.heat = window->heat; } char buf[256] = ""; + struct Cat cat = { buf, sizeof(buf), 0 }; catf( - buf, sizeof(buf), "\3%d%s %u ", + &cat, "\3%d%s %u ", idColors[window->id], (num == windows.show ? "\26" : ""), num ); if (!window->ignore || window->mute) { - catf( - buf, sizeof(buf), "%s%s ", - &"-"[window->ignore], &"="[!window->mute] - ); + catf(&cat, "%s%s ", &"-"[window->ignore], &"="[!window->mute]); } - catf(buf, sizeof(buf), "%s ", idNames[window->id]); + catf(&cat, "%s ", idNames[window->id]); if (window->mark && window->unreadWarm) { catf( - buf, sizeof(buf), "\3%d+%d\3%d%s", + &cat, "\3%d+%d\3%d%s", (window->heat > Warm ? White : idColors[window->id]), window->unreadWarm, idColors[window->id], (window->scroll ? "" : " ") ); } if (window->scroll) { - catf(buf, sizeof(buf), "~%d ", window->scroll); + catf(&cat, "~%d ", window->scroll); } statusAdd(buf); } wclrtoeol(status); + struct Cat cat = { title, sizeof(title), 0 }; const struct Window *window = windows.ptrs[windows.show]; - snprintf(title, sizeof(title), "%s %s", network.name, idNames[window->id]); + catf(&cat, "%s %s", network.name, idNames[window->id]); if (window->mark && window->unreadWarm) { - catf( - title, sizeof(title), " +%d%s", - window->unreadWarm, &"!"[window->heat < Hot] - ); + catf(&cat, " +%d%s", window->unreadWarm, &"!"[window->heat < Hot]); } if (others.unread) { - catf( - title, sizeof(title), " (+%d%s)", - others.unread, &"!"[others.heat < Hot] - ); + catf(&cat, " (+%d%s)", others.unread, &"!"[others.heat < Hot]); } } @@ -638,10 +631,11 @@ static void notify(uint id, const char *str) { struct Util util = uiNotifyUtil; utilPush(&util, idNames[id]); char buf[1024] = ""; + struct Cat cat = { buf, sizeof(buf), 0 }; while (*str) { struct Style style = Reset; size_t len = styleParse(&style, &str); - catf(buf, sizeof(buf), "%.*s", (int)len, str); + catf(&cat, "%.*s", (int)len, str); str += len; } utilPush(&util, buf); |