about summary refs log tree commit diff stats
path: root/src/command
diff options
context:
space:
mode:
authorMichael Vetter <jubalh@iodoru.org>2020-02-20 08:11:58 +0100
committerMichael Vetter <jubalh@iodoru.org>2020-02-20 08:11:58 +0100
commit80dd3fdbb2ee8c453f5828d8cacb029d222d3779 (patch)
tree9e15b43097a1da577035f2df477feeb32b211e34 /src/command
parent6aa793fca6c3ec74e04d28ce209dd460252e1079 (diff)
downloadprofani-tty-80dd3fdbb2ee8c453f5828d8cacb029d222d3779.tar.gz
Add option to color MUC history like regular messages
`/logging group color` has:
* `unanimous` which will color it with one unanimous color. Like it was
done always.
* `regular` which colors it like regular incoming messages.

Regards https://github.com/profanity-im/profanity/issues/1261
Diffstat (limited to 'src/command')
-rw-r--r--src/command/cmd_ac.c22
-rw-r--r--src/command/cmd_defs.c18
-rw-r--r--src/command/cmd_funcs.c18
3 files changed, 46 insertions, 12 deletions
diff --git a/src/command/cmd_ac.c b/src/command/cmd_ac.c
index 4d6c1d90..c80c058d 100644
--- a/src/command/cmd_ac.c
+++ b/src/command/cmd_ac.c
@@ -238,6 +238,8 @@ static Autocomplete invite_ac;
 static Autocomplete status_ac;
 static Autocomplete status_state_ac;
 static Autocomplete logging_ac;
+static Autocomplete logging_group_ac;
+static Autocomplete logging_group_color_ac;
 static Autocomplete color_ac;
 static Autocomplete correction_ac;
 
@@ -944,6 +946,15 @@ cmd_ac_init(void)
     autocomplete_add(logging_ac, "chat");
     autocomplete_add(logging_ac, "group");
 
+    logging_group_ac = autocomplete_new();
+    autocomplete_add(logging_group_ac, "on");
+    autocomplete_add(logging_group_ac, "off");
+    autocomplete_add(logging_group_ac, "color");
+
+    logging_group_color_ac = autocomplete_new();
+    autocomplete_add(logging_group_color_ac, "unanimous");
+    autocomplete_add(logging_group_color_ac, "regular");
+
     color_ac = autocomplete_new();
     autocomplete_add(color_ac, "on");
     autocomplete_add(color_ac, "off");
@@ -1261,6 +1272,8 @@ cmd_ac_reset(ProfWin *window)
     autocomplete_reset(status_ac);
     autocomplete_reset(status_state_ac);
     autocomplete_reset(logging_ac);
+    autocomplete_reset(logging_group_ac);
+    autocomplete_reset(logging_group_color_ac);
     autocomplete_reset(color_ac);
     autocomplete_reset(correction_ac);
 
@@ -1412,6 +1425,8 @@ cmd_ac_uninit(void)
     autocomplete_free(status_ac);
     autocomplete_free(status_state_ac);
     autocomplete_free(logging_ac);
+    autocomplete_free(logging_group_ac);
+    autocomplete_free(logging_group_color_ac);
     autocomplete_free(color_ac);
     autocomplete_free(correction_ac);
 }
@@ -3727,7 +3742,12 @@ _logging_autocomplete(ProfWin *window, const char *const input, gboolean previou
         return result;
     }
 
-    result = autocomplete_param_with_func(input, "/logging group", prefs_autocomplete_boolean_choice, previous, NULL);
+    result = autocomplete_param_with_ac(input, "/logging group", logging_group_ac, TRUE, previous);
+    if (result) {
+        return result;
+    }
+
+    result = autocomplete_param_with_ac(input, "/logging group color", logging_group_color_ac, TRUE, previous);
     if (result) {
         return result;
     }
diff --git a/src/command/cmd_defs.c b/src/command/cmd_defs.c
index f105fcd6..2de11c4d 100644
--- a/src/command/cmd_defs.c
+++ b/src/command/cmd_defs.c
@@ -1607,24 +1607,28 @@ static struct cmd_t command_defs[] =
     },
 
     { "/logging",
-        parse_args, 2, 2, &cons_logging_setting,
+        parse_args, 2, 3, &cons_logging_setting,
         CMD_NOSUBFUNCS
         CMD_MAINFUNC(cmd_logging)
         CMD_TAGS(
             CMD_TAG_CHAT)
         CMD_SYN(
-            "/logging chat|group on|off")
+            "/logging chat|group on|off",
+            "/logging group color unanimous|regular")
         CMD_DESC(
+            "Configure chat logging. "
             "Switch logging on or off. "
             "Chat logging will be enabled if /history is set to on. "
-            "When disabling this option, /history will also be disabled. ")
+            "When disabling this option, /history will also be disabled. "
+            "Color MUC history unanimously or like regular MUC messages.")
         CMD_ARGS(
-            { "chat", "Regular chat logging" },
-            { "group", "Groupchat (room) logging" },
-            { "on|off", "Enable or disable logging." })
+            { "chat on|off",             "Enable/Disable regular chat logging" },
+            { "group on|off",            "Enable/Disable groupchat (room) logging" },
+            { "group color unanimous|regular", "Color MUC history unanimous or like regular MUC messages." })
         CMD_EXAMPLES(
             "/logging chat on",
-            "/logging group off" )
+            "/logging group off",
+            "/logging group color regular" )
     },
 
     { "/states",
diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c
index 4f617ffe..c65bf10a 100644
--- a/src/command/cmd_funcs.c
+++ b/src/command/cmd_funcs.c
@@ -6721,12 +6721,22 @@ cmd_logging(ProfWin *window, const char *const command, gchar **args)
         if (strcmp(args[1], "off") == 0) {
             prefs_set_boolean(PREF_HISTORY, FALSE);
         }
-    } else if (strcmp(args[0], "group") == 0) {
-        _cmd_set_boolean_preference(args[1], command, "Groupchat logging", PREF_GRLOG);
-    } else {
-        cons_bad_cmd_usage(command);
+
+        return TRUE;
+    } else if (g_strcmp0(args[0], "group") == 0) {
+        if (g_strcmp0(args[1], "on") == 0 || g_strcmp0(args[1], "off") == 0) {
+            _cmd_set_boolean_preference(args[1], command, "Groupchat logging", PREF_GRLOG);
+            return TRUE;
+        } else if (strcmp(args[1], "color") == 0 && args[2] != NULL) {
+            if (g_strcmp0(args[2], "unanimous") == 0 || g_strcmp0(args[2], "regular") == 0) {
+                prefs_set_string(PREF_HISTORY_COLOR_MUC, args[2]);
+                cons_show("Groupchat logging color set to: %s", args[2]);
+                return TRUE;
+            }
+        }
     }
 
+    cons_bad_cmd_usage(command);
     return TRUE;
 }