hirc

IRC client
Log | Files | Refs

commit 1c910d9f230e7547cc021e5e837512abbaf35e93
parent 00cac2c89024f2cc6c668b56d969ca0fda73927c
Author: hhvn <dev@hhvn.uk>
Date:   Tue, 19 Apr 2022 17:47:08 +0100

Add -noact option for /ignore

Diffstat:
Msrc/commands.c | 22++++++++++++++++------
Msrc/config.c | 4++--
Msrc/hist.c | 6++++--
Msrc/struct.h | 1+
4 files changed, 23 insertions(+), 10 deletions(-)

diff --git a/src/commands.c b/src/commands.c @@ -367,7 +367,7 @@ struct Command commands[] = { "usage: /close [id]", "Forget about selected buffer, or a buffer by id.", NULL}}, {"ignore", command_ignore, 0, { - "usage: /ignore [[-server] [-format format] regex]", + "usage: /ignore [[-server] [-noact] [-format format] regex]", " /ignore -delete id", " /ignore -hide|-show", "Hide future messages matching regex.", @@ -380,6 +380,9 @@ struct Command commands[] = { " -i case insensitive match", " -server only ignore for the current server", " or server provided by /server.", + " -noact set activity to Activity_ignore,", + " but don't hide the message.", + " -format only ignore messages with >format<", "See also: regex.extended, regex.icase", NULL}}, {NULL, NULL}, }; @@ -1873,14 +1876,16 @@ command_ignore) { char errbuf[BUFSIZ], *format = NULL; size_t len; long id; - int ret, raw = 0, i, regopt = 0, serv = 0; - enum { opt_show, opt_hide, opt_extended, opt_icase, opt_server, opt_delete, opt_format }; + int ret, noact = 0, i, regopt = 0, serv = 0; + enum { opt_show, opt_hide, opt_extended, opt_icase, + opt_server, opt_delete, opt_format, opt_noact }; static struct CommandOpts opts[] = { {"E", CMD_NARG, opt_extended}, {"i", CMD_NARG, opt_icase}, {"show", CMD_NARG, opt_show}, {"hide", CMD_NARG, opt_hide}, {"server", CMD_NARG, opt_server}, + {"noact", CMD_NARG, opt_noact}, {"delete", CMD_NARG, opt_delete}, {"format", CMD_ARG, opt_format}, {NULL, 0, 0}, @@ -1890,8 +1895,8 @@ command_ignore) { hist_format(selected.history, Activity_none, HIST_UI, "SELF_IGNORES_START :Ignoring:"); for (p = ignores, i = 1; p; p = p->next, i++) if (!serv || !p->server || strcmp(server->name, p->server) == 0) - hist_format(selected.history, Activity_none, HIST_UI|HIST_NIGN, "SELF_IGNORES_LIST %d %s %s :%s", - i, p->server ? p->server : "ANY", p->format ? p->format : "ANY", p->text); + hist_format(selected.history, Activity_none, HIST_UI|HIST_NIGN, "SELF_IGNORES_LIST %d %s %s %s :%s", + i, p->server ? p->server : "ANY", noact ? "yes" : "no", p->format ? p->format : "ANY", p->text); hist_format(selected.history, Activity_none, HIST_UI, "SELF_IGNORES_END :End of ignore list"); return; } @@ -1949,6 +1954,9 @@ idrange: return; } break; + case opt_noact: + noact = 1; + break; case opt_extended: regopt |= REG_EXTENDED; break; @@ -1982,10 +1990,12 @@ idrange: ign->text = strdup(str); ign->format = format; ign->regopt = regopt; + ign->noact = noact; ign->server = serv ? strdup(server->name) : NULL; if (!nouich) - hist_format(selected.history, Activity_none, HIST_UI, "SELF_IGNORES_ADDED %s %s :%s", serv ? server->name : "ANY", format ? format : "ANY", str); + hist_format(selected.history, Activity_none, HIST_UI, "SELF_IGNORES_ADDED %s %s %s :%s", + serv ? server->name : "ANY", noact ? "yes" : "no", format ? format : "ANY", str); if (!ignores) { ignores = ign; diff --git a/src/config.c b/src/config.c @@ -347,7 +347,7 @@ struct Config config[] = { .description = { "Format of ignore list header.", NULL}}, {"format.ui.ignores", 1, Val_string, - .str = " %{pad:-3,${1}} (server: ${2}, format: ${3}) ${4}", + .str = " %{pad:-3,${1}} (server: ${2}, noact: ${3}, format: ${4}) ${5}", .strhandle = config_redraws, .description = { "Format of ignore list messages.", NULL}}, @@ -357,7 +357,7 @@ struct Config config[] = { .description = { "Format of ignore list footer.", NULL}}, {"format.ui.ignores.added", 1, Val_string, - .str = "Ignore added: ${3} (server: ${1}, format: ${2})", + .str = "Ignore added: ${4} (server: ${1}, noact: ${2}, format: ${3})", .strhandle = config_redraws, .description = { "Format of new ignores.", NULL}}, diff --git a/src/hist.c b/src/hist.c @@ -155,8 +155,10 @@ hist_add(struct HistInfo *histinfo, for (ign = ignores; ign; ign = ign->next) { if (!ign->server || (histinfo->server && strcmp_n(ign->server, histinfo->server->name))) { if ((!ign->format || strcmp_n(format_get(new), ign->format) == 0) && regexec(&ign->regex, msg, 0, NULL, 0) == 0) { - options |= HIST_IGN; - new->options = options; + if (!ign->noact) { + options |= HIST_IGN; + new->options = options; + } activity = Activity_ignore; break; } diff --git a/src/struct.h b/src/struct.h @@ -302,6 +302,7 @@ struct Ignore { char *text; regex_t regex; int regopt; + int noact; char *server; struct Ignore *next; };