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 {