From f8e3414af06df95b18b8e29caa74a7eea3022c92 Mon Sep 17 00:00:00 2001 From: Klemens Nanni Date: Sat, 17 Jul 2021 20:04:15 +0000 Subject: Add -q/quiet option to raise default message visibility threshold Silencing all windows with `M-+' (across multiple catgirl instances) can be cumbersome, so provide an option to hide events, JOIN/PART noise, etc. by default (each window's threshold will persist across load/save cycles, i.e. when using the `-s/save' option). Started out as `-v | visibility = threshold' to set a specific level, the idea of a simpler toggle comes from june, who also squashed other bugs (as usual). --- catgirl.1 | 9 +++++++-- chat.c | 2 ++ chat.h | 1 + ui.c | 4 +++- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/catgirl.1 b/catgirl.1 index 1b74b6c..bb425cc 100644 --- a/catgirl.1 +++ b/catgirl.1 @@ -1,4 +1,4 @@ -.Dd July 2, 2021 +.Dd July 20, 2021 .Dt CATGIRL 1 .Os . @@ -8,7 +8,7 @@ . .Sh SYNOPSIS .Nm -.Op Fl KRelv +.Op Fl KRelqv .Op Fl C Ar copy .Op Fl H Ar hash .Op Fl I Ar highlight @@ -323,6 +323,11 @@ Connect to .Ar port . The default port is 6697. . +.It Fl q | Cm quiet +Raise the default message visibility threshold +for new windows, +hiding general events. +. .It Fl r Ar real | Cm real No = Ar real Set realname to .Ar real . diff --git a/chat.c b/chat.c index 106e05f..3141052 100644 --- a/chat.c +++ b/chat.c @@ -257,6 +257,7 @@ int main(int argc, char *argv[]) { { .val = 'n', .name = "nick", required_argument }, { .val = 'o', .name = "print-chain", no_argument }, { .val = 'p', .name = "port", required_argument }, + { .val = 'q', .name = "quiet", no_argument }, { .val = 'r', .name = "real", required_argument }, { .val = 's', .name = "save", required_argument }, { .val = 't', .name = "trust", required_argument }, @@ -300,6 +301,7 @@ int main(int argc, char *argv[]) { break; case 'n': nick = optarg; break; case 'o': printCert = true; break; case 'p': port = optarg; + break; case 'q': uiThreshold = Warm; break; case 'r': real = optarg; break; case 's': save = optarg; break; case 't': trust = optarg; diff --git a/chat.h b/chat.h index c247dd7..dd9c823 100644 --- a/chat.h +++ b/chat.h @@ -292,6 +292,7 @@ void commandCompleteAdd(void); enum Heat { Ice, Cold, Warm, Hot }; enum { TimeCap = 64 }; +extern enum Heat uiThreshold; extern struct Time { bool enable; const char *format; diff --git a/ui.c b/ui.c index da06342..3604057 100644 --- a/ui.c +++ b/ui.c @@ -127,6 +127,8 @@ static struct Window *windowRemove(uint num) { return window; } +enum Heat uiThreshold = Cold; + static uint windowFor(uint id) { for (uint num = 0; num < windows.len; ++num) { if (windows.ptrs[num]->id == id) return num; @@ -136,7 +138,7 @@ static uint windowFor(uint id) { window->id = id; window->mark = true; window->time = uiTime.enable; - window->thresh = Cold; + window->thresh = uiThreshold; window->buffer = bufferAlloc(); completeAdd(None, idNames[id], idColors[id]); return windowPush(window); -- cgit 1.4.1-2-gfad0