diff options
author | Michael Vetter <jubalh@iodoru.org> | 2020-03-25 12:54:25 +0100 |
---|---|---|
committer | Michael Vetter <jubalh@iodoru.org> | 2020-03-25 12:54:25 +0100 |
commit | 4fc938d80425f647a7db34ff2f23b05780552d49 (patch) | |
tree | fdc4574dcb5af58565834c770449f5cb254c4baa | |
parent | 4f19ea264218fc93f4bca00b1f5a901c0ddc1b44 (diff) | |
download | profani-tty-4fc938d80425f647a7db34ff2f23b05780552d49.tar.gz |
Add setting to not colorize own nick according to xep-0392
Some users might want there nick to always stay white (etc) for easier recognition. Now we can do `/color own off` to not generate the color based on xep-0392. The `me=` color (etc) from the theme will then be used. Once we run this command `theme_load()` is called again. And the theme looks totally wrong. We encountered this at other times already and I think it's nothing wrong with this new code here now but that there seems to be a missing closing attr for the color when drawing. Should be investigated seperately. Fix https://github.com/profanity-im/profanity/issues/1288
-rw-r--r-- | src/command/cmd_ac.c | 6 | ||||
-rw-r--r-- | src/command/cmd_defs.c | 11 | ||||
-rw-r--r-- | src/command/cmd_funcs.c | 4 | ||||
-rw-r--r-- | src/config/preferences.c | 4 | ||||
-rw-r--r-- | src/config/preferences.h | 1 | ||||
-rw-r--r-- | src/ui/console.c | 6 | ||||
-rw-r--r-- | src/ui/window.c | 4 |
7 files changed, 31 insertions, 5 deletions
diff --git a/src/command/cmd_ac.c b/src/command/cmd_ac.c index 652b9b16..43b2f9f2 100644 --- a/src/command/cmd_ac.c +++ b/src/command/cmd_ac.c @@ -958,6 +958,7 @@ cmd_ac_init(void) autocomplete_add(color_ac, "off"); autocomplete_add(color_ac, "redgreen"); autocomplete_add(color_ac, "blue"); + autocomplete_add(color_ac, "own"); correction_ac = autocomplete_new(); autocomplete_add(correction_ac, "on"); @@ -3758,6 +3759,11 @@ _color_autocomplete(ProfWin *window, const char *const input, gboolean previous) { char *result = NULL; + result = autocomplete_param_with_func(input, "/color own", prefs_autocomplete_boolean_choice, previous, NULL); + if (result) { + return result; + } + result = autocomplete_param_with_ac(input, "/color", color_ac, TRUE, previous); if (result) { return result; diff --git a/src/command/cmd_defs.c b/src/command/cmd_defs.c index 21e8f6f5..06904bbf 100644 --- a/src/command/cmd_defs.c +++ b/src/command/cmd_defs.c @@ -2322,22 +2322,25 @@ static struct cmd_t command_defs[] = }, { "/color", - parse_args, 1, 1, &cons_color_setting, + parse_args, 1, 2, &cons_color_setting, CMD_NOSUBFUNCS CMD_MAINFUNC(cmd_color) CMD_TAGS( CMD_TAG_UI) CMD_SYN( - "/color on|off|redgreen|blue") + "/color on|off|redgreen|blue", + "/color own on|off") CMD_DESC( "Settings for consistent color generation for nicks (XEP-0392). Including corrections for Color Vision Deficiencies. " "Your terminal needs to support 256 colors.") CMD_ARGS( - { "on|off|redgreen|blue", "Enable or disable nick colorization for MUC nicks. 'redgreen' is for people with red/green blindess and 'blue' for people with blue blindness."}) + { "on|off|redgreen|blue", "Enable or disable nick colorization for MUC nicks. 'redgreen' is for people with red/green blindess and 'blue' for people with blue blindness."}, + { "own on|off", "Enable color generation for own nick. If disabled the color from the color from the theme ('me') will get used."}) CMD_EXAMPLES( "/color off", "/color on", - "/color blue") + "/color blue", + "/color own off") }, { "/avatar", diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index 4313c6bb..815f8650 100644 --- a/src/command/cmd_funcs.c +++ b/src/command/cmd_funcs.c @@ -8694,6 +8694,10 @@ cmd_color(ProfWin *window, const char *const command, gchar **args) prefs_set_string(PREF_COLOR_NICK, "redgreen"); } else if (g_strcmp0(args[0], "blue") == 0) { prefs_set_string(PREF_COLOR_NICK, "blue"); + } else if (g_strcmp0(args[0], "own") == 0) { + if (g_strcmp0(args[1], "on") == 0) { + _cmd_set_boolean_preference(args[1], command, "Color generation for own nick", PREF_COLOR_NICK_OWN); + } } else { cons_bad_cmd_usage(command); return TRUE; diff --git a/src/config/preferences.c b/src/config/preferences.c index 164b420f..ba3b08e9 100644 --- a/src/config/preferences.c +++ b/src/config/preferences.c @@ -1745,6 +1745,7 @@ _get_group(preference_t pref) case PREF_CONSOLE_PRIVATE: case PREF_CONSOLE_CHAT: case PREF_COLOR_NICK: + case PREF_COLOR_NICK_OWN: case PREF_ROSTER_COLOR_NICK: case PREF_OCCUPANTS_COLOR_NICK: case PREF_STATUSBAR_SHOW_NAME: @@ -2033,6 +2034,8 @@ _get_key(preference_t pref) return "console.chat"; case PREF_COLOR_NICK: return "color.nick"; + case PREF_COLOR_NICK_OWN: + return "color.nick.own"; case PREF_ROSTER_COLOR_NICK: return "color.roster.nick"; case PREF_OCCUPANTS_COLOR_NICK: @@ -2123,6 +2126,7 @@ _get_default_boolean(preference_t pref) case PREF_STATES: case PREF_OUTTYPE: case PREF_TITLEBAR_MUC_TITLE_NAME: + case PREF_COLOR_NICK_OWN: return TRUE; default: return FALSE; diff --git a/src/config/preferences.h b/src/config/preferences.h index 570391af..ffc93a52 100644 --- a/src/config/preferences.h +++ b/src/config/preferences.h @@ -151,6 +151,7 @@ typedef enum { PREF_CONSOLE_PRIVATE, PREF_CONSOLE_CHAT, PREF_COLOR_NICK, + PREF_COLOR_NICK_OWN, PREF_ROSTER_COLOR_NICK, PREF_OCCUPANTS_COLOR_NICK, PREF_BOOKMARK_INVITE, diff --git a/src/ui/console.c b/src/ui/console.c index 360950a1..6b35cead 100644 --- a/src/ui/console.c +++ b/src/ui/console.c @@ -2010,6 +2010,12 @@ cons_color_setting(void) prefs_free_string(color_pref); + if (prefs_get_boolean(PREF_COLOR_NICK_OWN)) { + cons_show("Consistent color generation for own nick (/color own) : ON"); + } else { + cons_show("Consistent color generation for own nick (/color own) : OFF"); + } + if (prefs_get_boolean(PREF_ROSTER_COLOR_NICK)) { cons_show("Consistent color generation in roster (/roster color) : ON"); } else { diff --git a/src/ui/window.c b/src/ui/window.c index 7dc2f62d..7c093480 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -1522,7 +1522,9 @@ _win_print_internal(ProfWin *window, const char *show_char, int pad_indent, GDat char *color_pref = prefs_get_string(PREF_COLOR_NICK); if (color_pref != NULL && (strcmp(color_pref, "false") != 0)) { - colour = theme_hash_attrs(from); + if (flags & NO_ME || (!(flags & NO_ME) && prefs_get_boolean(PREF_COLOR_NICK_OWN))) { + colour = theme_hash_attrs(from); + } } prefs_free_string(color_pref); |