hirc

IRC client
Log | Files | Refs

commit 8da44e0095085cb98ac3a33b9d5769a956abad9b
parent 7054c8948d2aa7800cd78844cfc37134c267b492
Author: hhvn <dev@hhvn.uk>
Date:   Sun, 12 Dec 2021 14:51:41 +0000

s/ui.c s/config.c s/struct.h s/hist.c: buffer indicators

Diffstat:
Msrc/config.c | 25+++++++++++++++++++++++++
Msrc/hist.c | 6++++--
Msrc/struct.h | 12++++++------
Msrc/ui.c | 54++++++++++++++++++++++++++++++++++++++++++++++--------
4 files changed, 81 insertions(+), 16 deletions(-)

diff --git a/src/config.c b/src/config.c @@ -272,6 +272,31 @@ struct Config config[] = { .strhandle = config_redraws, .description = { "Format of footer of /alias output", NULL}}, + {"format.ui.buflist.activity.none", 1, Val_string, + .str = "", + .strhandle = config_redraws, + .description = { + "Indicator for buffer with activity of level `none`", NULL}}, + {"format.ui.buflist.activity.status", 1, Val_string, + .str = "%{c:95}", + .strhandle = config_redraws, + .description = { + "Indicator for buffer with activity of level `status`", NULL}}, + {"format.ui.buflist.activity.error", 1, Val_string, + .str = "%{c:28}", + .strhandle = config_redraws, + .description = { + "Indicator for buffer with activity of level `error`", NULL}}, + {"format.ui.buflist.activity.message", 1, Val_string, + .str = "%{c:45}", + .strhandle = config_redraws, + .description = { + "Indicator for buffer with activity of level `message`", NULL}}, + {"format.ui.buflist.activity.hilight", 1, Val_string, + .str = "%{c:45}%{r}", + .strhandle = config_redraws, + .description = { + "Indicator for buffer with activity of level `hilight`", NULL}}, {"format.privmsg", 1, Val_string, .str = "%{nick:${nick}}${nick}%{o}%{=}${2}", .strhandle = config_redraws, diff --git a/src/hist.c b/src/hist.c @@ -83,9 +83,11 @@ hist_add(struct HistInfo *histinfo, struct Nick *from, new = hist_create(histinfo, from, msg, params, activity, timestamp, options); - if (histinfo && options & HIST_SHOW && activity > histinfo->activity) + if (histinfo && options & HIST_SHOW && activity > histinfo->activity && histinfo != selected.history) { histinfo->activity = activity; - if (histinfo && options & HIST_SHOW && !chan_selected(histinfo->channel) && !serv_selected(histinfo->server)) + windows[Win_buflist].refresh = 1; + } + if (histinfo && options & HIST_SHOW && histinfo != selected.history) histinfo->unread++; if (!histinfo->history) { diff --git a/src/struct.h b/src/struct.h @@ -21,14 +21,14 @@ struct Nick { }; enum Activity { - Activity_ignore, - Activity_none, + Activity_ignore = 0, Activity_self = Activity_ignore, - Activity_status, + Activity_none = 1, + Activity_status = 2, Activity_notice = Activity_status, - Activity_error, - Activity_message, - Activity_hilight, + Activity_error = 3, + Activity_message = 4, + Activity_hilight = 5, }; enum HistOpt { diff --git a/src/ui.c b/src/ui.c @@ -657,6 +657,7 @@ ui_draw_buflist(void) { struct Channel *chp; int i = 1, len, tmp; int sc, cc, y; + char *indicator; ui_wclear(&windows[Win_buflist]); @@ -665,7 +666,7 @@ ui_draw_buflist(void) { if (selected.history == main_buf) wattron(windows[Win_buflist].window, A_BOLD); - len = wprintw(windows[Win_buflist].window, "%02d: %s\n", i++, "hirc"); + len = ui_wprintc(&windows[Win_buflist], 1, "%02d: %s\n", i++, "hirc"); wattroff(windows[Win_buflist].window, A_BOLD); for (sc = cc = 0, sp = servers; sp; sp = sp->next, sc++) { @@ -674,9 +675,26 @@ ui_draw_buflist(void) { else if (sp->status != ConnStatus_connected) wattron(windows[Win_buflist].window, A_DIM); - len = wprintw(windows[Win_buflist].window, "%02d: %s─ %s\n", i++, sp->next ? "├" : "└", sp->name); - wattroff(windows[Win_buflist].window, A_BOLD); - wattroff(windows[Win_buflist].window, A_DIM); + switch (sp->history->activity) { + case Activity_status: + indicator = ui_format(config_gets("format.ui.buflist.activity.status"), NULL); + break; + case Activity_error: + indicator = ui_format(config_gets("format.ui.buflist.activity.error"), NULL); + break; + case Activity_message: + indicator = ui_format(config_gets("format.ui.buflist.activity.message"), NULL); + break; + case Activity_hilight: + indicator = ui_format(config_gets("format.ui.buflist.activity.hilight"), NULL); + break; + default: + indicator = ui_format(config_gets("format.ui.buflist.activity.none"), NULL); + break; + } + + len = ui_wprintc(&windows[Win_buflist], 1, "%02d: %s─ %s%s\n", i++, sp->next ? "├" : "└", indicator, sp->name); + wattrset(windows[Win_buflist].window, A_NORMAL); for (chp = sp->channels; chp; chp = chp->next, cc++) { if (selected.channel == chp) @@ -684,10 +702,27 @@ ui_draw_buflist(void) { else if (chp->old) wattron(windows[Win_buflist].window, A_DIM); - len = wprintw(windows[Win_buflist].window, "%02d: %s %s─ %s\n", i++, - sp->next ? "│" : " ", chp->next ? "├" : "└", chp->name); - wattroff(windows[Win_buflist].window, A_BOLD); - wattroff(windows[Win_buflist].window, A_DIM); + switch (chp->history->activity) { + case Activity_status: + indicator = ui_format(config_gets("format.ui.buflist.activity.status"), NULL); + break; + case Activity_error: + indicator = ui_format(config_gets("format.ui.buflist.activity.error"), NULL); + break; + case Activity_message: + indicator = ui_format(config_gets("format.ui.buflist.activity.message"), NULL); + break; + case Activity_hilight: + indicator = ui_format(config_gets("format.ui.buflist.activity.hilight"), NULL); + break; + default: + indicator = ui_format(config_gets("format.ui.buflist.activity.none"), NULL); + break; + } + + len = ui_wprintc(&windows[Win_buflist], 1, "%02d: %s %s─ %s%s\n", i++, + sp->next ? "│" : " ", chp->next ? "├" : "└", indicator, chp->name); + wattrset(windows[Win_buflist].window, A_NORMAL); } } @@ -1021,6 +1056,9 @@ ui_select(struct Server *server, struct Channel *channel) { selected.history = channel ? channel->history : server ? server->history : main_buf; selected.name = channel ? channel->name : server ? server->name : "hirc"; + selected.history->activity = Activity_none; + selected.history->unread = 0; + hist_purgeopt(selected.history, HIST_TMP); }