Add initial support for XEP-0392

The last 3 commits added basic support.
Thanks @aaptel!

This commit adds basic settings interface to use it.
See `/color on|off`.

We still have to enable settings for color blindness.
And maybe another setting to decide whether to color the
occupantslist/roster with the same algo.

Regards https://github.com/profanity-im/profanity/issues/1191
This commit is contained in:
Michael Vetter
2019-12-09 16:12:54 +01:00
parent 7a0a578a8a
commit ddf6ada3d1
6 changed files with 35 additions and 1 deletions

View File

@@ -1479,7 +1479,7 @@ _cmd_ac_complete_params(ProfWin *window, const char *const input, gboolean previ
// autocomplete boolean settings
gchar *boolean_choices[] = { "/beep", "/intype", "/states", "/outtype", "/flash", "/splash",
"/history", "/vercheck", "/privileges", "/wrap", "/carbons", "/lastactivity" };
"/history", "/vercheck", "/privileges", "/wrap", "/carbons", "/lastactivity", "/color" };
for (i = 0; i < ARRAY_SIZE(boolean_choices); i++) {
result = autocomplete_param_with_func(input, boolean_choices[i], prefs_autocomplete_boolean_choice, previous);

View File

@@ -2294,6 +2294,21 @@ static struct cmd_t command_defs[] =
CMD_NOARGS
CMD_NOEXAMPLES
},
{ "/color",
parse_args, 1, 1, &cons_color_setting,
CMD_NOSUBFUNCS
CMD_MAINFUNC(cmd_color)
CMD_TAGS(
CMD_TAG_UI)
CMD_SYN(
"/color on|off")
CMD_DESC(
"Settings for consistent color generation for nicks (XEP-0392).")
CMD_ARGS(
{ "on|off", "Enable or disable nick colorization for MUC nicks." })
CMD_NOEXAMPLES
},
};
static GHashTable *search_index;

View File

@@ -8626,3 +8626,10 @@ cmd_paste(ProfWin *window, const char *const command, gchar **args)
return TRUE;
}
gboolean
cmd_color(ProfWin *window, const char *const command, gchar **args)
{
_cmd_set_boolean_preference(args[0], command, "Consistent color generation for nicks", PREF_COLOR_NICK);
return TRUE;
}

View File

@@ -223,4 +223,6 @@ gboolean cmd_save(ProfWin *window, const char *const command, gchar **args);
gboolean cmd_reload(ProfWin *window, const char *const command, gchar **args);
gboolean cmd_paste(ProfWin *window, const char *const command, gchar **args);
gboolean cmd_color(ProfWin *window, const char *const command, gchar **args);
#endif