summary refs log tree commit diff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--catgirl.111
-rw-r--r--chat.c12
-rw-r--r--chat.h3
3 files changed, 19 insertions, 7 deletions
diff --git a/catgirl.1 b/catgirl.1
index 1c782cf..04216a6 100644
--- a/catgirl.1
+++ b/catgirl.1
@@ -1,4 +1,4 @@
-.Dd December 30, 2020
+.Dd January  9, 2021
 .Dt CATGIRL 1
 .Os
 .
@@ -77,9 +77,14 @@ The default is the first available of
 .Xr xclip 1 ,
 .Xr xsel 1 .
 .
-.It Fl H Ar hash , Cm hash = Ar hash
+.It Fl H Ar init,bound , Cm hash = Ar init,bound
 Set the initial value of
-the nick color hash function.
+the nick color hash function
+and the maximum IRC color value used.
+The default is 0,75.
+To use only colors from
+the 16-color terminal set,
+use 0,15.
 .
 .It Fl N Ar util , Cm notify = Ar util
 Send notifications using a utility.
diff --git a/chat.c b/chat.c
index 016d604..fd2b89a 100644
--- a/chat.c
+++ b/chat.c
@@ -87,8 +87,6 @@ static void exitSave(void) {
 	}
 }
 
-uint32_t hashInit;
-
 uint execID;
 int execPipe[2] = { -1, -1 };
 int utilPipe[2] = { -1, -1 };
@@ -117,6 +115,14 @@ static void utilRead(void) {
 	}
 }
 
+uint32_t hashInit;
+uint32_t hashBound = 75;
+
+static void parseHash(char *str) {
+	hashInit = strtoul(str, &str, 0);
+	if (*str) hashBound = strtoul(&str[1], NULL, 0);
+}
+
 static volatile sig_atomic_t signals[NSIG];
 static void signalHandler(int signal) {
 	signals[signal] = 1;
@@ -179,7 +185,7 @@ int main(int argc, char *argv[]) {
 		switch (opt) {
 			break; case '!': insecure = true;
 			break; case 'C': utilPush(&urlCopyUtil, optarg);
-			break; case 'H': hashInit = strtoul(optarg, NULL, 0);
+			break; case 'H': parseHash(optarg);
 			break; case 'N': utilPush(&uiNotifyUtil, optarg);
 			break; case 'O': utilPush(&urlOpenUtil, optarg);
 			break; case 'R': self.restricted = true;
diff --git a/chat.h b/chat.h
index b06d383..8de5d55 100644
--- a/chat.h
+++ b/chat.h
@@ -137,6 +137,7 @@ static inline uint idFor(const char *name) {
 }
 
 extern uint32_t hashInit;
+extern uint32_t hashBound;
 static inline enum Color hash(const char *str) {
 	if (*str == '~') str++;
 	uint32_t hash = hashInit;
@@ -145,7 +146,7 @@ static inline enum Color hash(const char *str) {
 		hash ^= *str;
 		hash *= 0x27220A95;
 	}
-	return Blue + hash % 74;
+	return Blue + hash % (hashBound + 1 - Blue);
 }
 
 extern struct Network {
June McEnroe My system is probably such a mess now... 2020-09-11Add debian VM name to sshJune McEnroe 2020-09-11Add influencer tweetJune McEnroe 2020-09-10Add The Kingdom of GodsJune McEnroe Reading has really slowed down :( 2020-09-07Add SunglassesJune McEnroe An IRC find. 2020-09-06Add Between the BreathsJune McEnroe One of those good songs from a soundtrack of a film that probably isn't? The summary sounds a lot more interesting than the title implies, at least. 2020-09-04Open /dev/tty in nudgeJune McEnroe This makes it work even when it's run connected to a pipe, i.e. as the notify command of catgirl... 2020-09-04Add nudgeJune McEnroe 2020-09-03Build fbclock with -lzJune McEnroe I guess this got lost somewhere, long ago... 2020-08-29Add tweets from retweetsJune McEnroe