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).
weechat-hashes
Klemens Nanni 2021-07-17 20:04:15 +00:00 committed by C. McEnroe
parent 773d5bbdc0
commit f8e3414af0
4 changed files with 13 additions and 3 deletions

View File

@ -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 .

2
chat.c
View File

@ -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;

1
chat.h
View File

@ -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;

4
ui.c
View File

@ -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);