hirc

IRC client
Log | Files | Refs

commit 2d43646fa6af8dad47f92c54a2b32ec72f76d463
parent 6d4126715afc2265dcf963c8f1b73711405a4564
Author: hhvn <dev@hhvn.uk>
Date:   Wed, 27 Oct 2021 18:42:53 +0100

hirc.h ui.c: count buffers without needing to draw buflist

Diffstat:
Mhirc.h | 1+
Mui.c | 18++++++++++++++++++
2 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/hirc.h b/hirc.h @@ -96,6 +96,7 @@ void ui_redraw(void); void ui_draw_input(void); void ui_draw_nicklist(void); void ui_draw_buflist(void); +int ui_buflist_count(int *ret_servers, int *ret_channels); void ui_select(struct Server *server, struct Channel *channel); void ui_error_(char *file, int line, char *format, ...); #define ui_error(format, ...) ui_error_(__FILE__, __LINE__, format, __VA_ARGS__); diff --git a/ui.c b/ui.c @@ -263,6 +263,24 @@ ui_draw_nicklist(void) { } } +int +ui_buflist_count(int *ret_servers, int *ret_channels) { + struct Server *sp; + struct Channel *chp; + int sc, cc; + + for (sc = cc = 0, sp = servers; sp; sp = sp->next, sc++) + for (chp = sp->channels; chp; chp = chp->next, cc++) + ; + + if (ret_servers) + *ret_servers = sc; + if (ret_channels) + *ret_channels = cc; + + return sc + cc; +} + void ui_draw_buflist(void) { struct Server *sp;