Code

screen_chat: add an option to set the message prefix
authorJonathan Neuschäfer <j.neuschaefer@gmx.net>
Wed, 23 May 2012 01:21:05 +0000 (03:21 +0200)
committerJonathan Neuschäfer <j.neuschaefer@gmx.net>
Wed, 23 May 2012 02:04:26 +0000 (04:04 +0200)
src/conf.c
src/options.c
src/options.h
src/screen_chat.c

index 50feefee6e2807f3b5c5e9331e8291b6ad0eba3b..f9b6918e3df70cce1ba7ac5d0f5e717c6f4328bf 100644 (file)
@@ -80,6 +80,7 @@
 #define CONF_LYRICS_SHOW_PLUGIN "lyrics-show-plugin"
 #define CONF_TEXT_EDITOR "text-editor"
 #define CONF_TEXT_EDITOR_ASK "text-editor-ask"
+#define CONF_CHAT_PREFIX "chat-prefix"
 #define CONF_SECOND_COLUMN "second-column"
 
 static bool
@@ -543,6 +544,12 @@ parse_line(char *line)
                options.text_editor_ask = str2bool(value);
 #else
                {}
+#endif
+       else if (!strcasecmp(name, CONF_CHAT_PREFIX))
+#ifdef ENABLE_CHAT_SCREEN
+               options.chat_prefix = get_format(value);
+#else
+               {}
 #endif
        else if (!strcasecmp(CONF_SECOND_COLUMN, name))
 #ifdef NCMPC_MINI
index 0129b235eb31f554cd24a91d7d980b0ec91fff2d..6f674c6cd61b9d3736dfd27ebfd87d2ea224813b 100644 (file)
@@ -409,4 +409,7 @@ options_deinit(void)
 #ifdef ENABLE_LYRICS_SCREEN
        g_free(options.text_editor);
 #endif
+#ifdef ENABLE_CHAT_SCREEN
+       g_free(options.chat_prefix);
+#endif
 }
index c1a833d01066c3157e5badfd5421ac84f87d1213..74dfd4284657a31d3066742ea040c69b6b17d823 100644 (file)
@@ -51,6 +51,9 @@ typedef struct {
        bool lyrics_show_plugin;
        char *text_editor;
        bool text_editor_ask;
+#endif
+#ifdef ENABLE_CHAT_SCREEN
+       char *chat_prefix;
 #endif
        bool find_wrap;
        bool find_show_last_pattern;
index 6daca65aecd25f31fc3788b887f08b04e39c9f8c..2b887bafbe3a6208cd2758e4521bd60fbe93eb89 100644 (file)
@@ -147,6 +147,12 @@ screen_chat_get_prefix(void)
        if (prefix)
                return prefix;
 
+       if (options.chat_prefix) {
+               /* Options are encoded in the "locale" charset */
+               prefix = locale_to_utf8(options.chat_prefix);
+               return prefix;
+       }
+
        prefix = g_strconcat("<", g_get_user_name(), "> ", NULL);
        return prefix;
 }