1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-28 22:06:38 +02:00

core: make nick prefix/suffix dynamic (move options from irc plugin to core, add logger options) (bug #37531)

This commit is contained in:
Sebastien Helleu
2013-04-29 18:30:59 +02:00
parent cf8a125ef2
commit 16cc0b6088
16 changed files with 251 additions and 101 deletions
-2
View File
@@ -73,8 +73,6 @@
#define IRC_COLOR_NICK_PREFIX_HALFOP weechat_color(weechat_config_string(irc_config_color_nick_prefix_halfop))
#define IRC_COLOR_NICK_PREFIX_VOICE weechat_color(weechat_config_string(irc_config_color_nick_prefix_voice))
#define IRC_COLOR_NICK_PREFIX_USER weechat_color(weechat_config_string(irc_config_color_nick_prefix_user))
#define IRC_COLOR_NICK_PREFIX weechat_color(weechat_config_string(irc_config_color_nick_prefix))
#define IRC_COLOR_NICK_SUFFIX weechat_color(weechat_config_string(irc_config_color_nick_suffix))
#define IRC_COLOR_NOTICE weechat_color(weechat_config_string(irc_config_color_notice))
#define IRC_COLOR_STATUS_NUMBER weechat_color("status_number")
#define IRC_COLOR_STATUS_NAME weechat_color("status_name")
-28
View File
@@ -59,8 +59,6 @@ struct t_config_option *irc_config_look_server_buffer;
struct t_config_option *irc_config_look_pv_buffer;
struct t_config_option *irc_config_look_new_channel_position;
struct t_config_option *irc_config_look_new_pv_position;
struct t_config_option *irc_config_look_nick_prefix;
struct t_config_option *irc_config_look_nick_suffix;
struct t_config_option *irc_config_look_nick_mode;
struct t_config_option *irc_config_look_nick_mode_empty;
struct t_config_option *irc_config_look_nick_color_force;
@@ -107,8 +105,6 @@ struct t_config_option *irc_config_color_message_join;
struct t_config_option *irc_config_color_message_quit;
struct t_config_option *irc_config_color_mirc_remap;
struct t_config_option *irc_config_color_nick_prefixes;
struct t_config_option *irc_config_color_nick_prefix;
struct t_config_option *irc_config_color_nick_suffix;
struct t_config_option *irc_config_color_notice;
struct t_config_option *irc_config_color_input_nick;
struct t_config_option *irc_config_color_item_away;
@@ -2209,16 +2205,6 @@ irc_config_init ()
"of server)"),
"none|next|near_server", 0, 0, "none",
NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
irc_config_look_nick_prefix = weechat_config_new_option (
irc_config_file, ptr_section,
"nick_prefix", "string",
N_("text to display before nick in chat window"),
NULL, 0, 0, "", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
irc_config_look_nick_suffix = weechat_config_new_option (
irc_config_file, ptr_section,
"nick_suffix", "string",
N_("text to display after nick in chat window"),
NULL, 0, 0, "", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
irc_config_look_nick_mode = weechat_config_new_option (
irc_config_file, ptr_section,
"nick_mode", "integer",
@@ -2551,20 +2537,6 @@ irc_config_init ()
NULL, 0, 0, "q:lightred;a:lightcyan;o:lightgreen;h:lightmagenta;"
"v:yellow;*:lightblue", NULL, 0, NULL, NULL,
&irc_config_change_color_nick_prefixes, NULL, NULL, NULL);
irc_config_color_nick_prefix = weechat_config_new_option (
irc_config_file, ptr_section,
"nick_prefix", "color",
N_("color for nick prefix (prefix is custom string displayed "
"before nick)"),
NULL, -1, 0, "green", NULL, 0, NULL, NULL,
NULL, NULL, NULL, NULL);
irc_config_color_nick_suffix = weechat_config_new_option (
irc_config_file, ptr_section,
"nick_suffix", "color",
N_("color for nick suffix (suffix is custom string displayed "
"after nick)"),
NULL, -1, 0, "green", NULL, 0, NULL, NULL,
NULL, NULL, NULL, NULL);
irc_config_color_notice = weechat_config_new_option (
irc_config_file, ptr_section,
"notice", "color",
-4
View File
@@ -101,8 +101,6 @@ extern struct t_config_option *irc_config_look_server_buffer;
extern struct t_config_option *irc_config_look_pv_buffer;
extern struct t_config_option *irc_config_look_new_channel_position;
extern struct t_config_option *irc_config_look_new_pv_position;
extern struct t_config_option *irc_config_look_nick_prefix;
extern struct t_config_option *irc_config_look_nick_suffix;
extern struct t_config_option *irc_config_look_nick_mode;
extern struct t_config_option *irc_config_look_nick_mode_empty;
extern struct t_config_option *irc_config_look_nick_color_force;
@@ -147,8 +145,6 @@ extern struct t_config_option *irc_config_color_message_join;
extern struct t_config_option *irc_config_color_message_quit;
extern struct t_config_option *irc_config_color_mirc_remap;
extern struct t_config_option *irc_config_color_nick_prefixes;
extern struct t_config_option *irc_config_color_nick_prefix;
extern struct t_config_option *irc_config_color_nick_suffix;
extern struct t_config_option *irc_config_color_notice;
extern struct t_config_option *irc_config_color_input_nick;
extern struct t_config_option *irc_config_color_item_away;
+2 -14
View File
@@ -956,22 +956,10 @@ irc_nick_as_prefix (struct t_irc_server *server, struct t_irc_nick *nick,
{
static char result[256];
snprintf (result, sizeof (result), "%s%s%s%s%s%s%s\t",
(weechat_config_string (irc_config_look_nick_prefix)
&& weechat_config_string (irc_config_look_nick_prefix)[0]) ?
IRC_COLOR_NICK_PREFIX : "",
(weechat_config_string (irc_config_look_nick_prefix)
&& weechat_config_string (irc_config_look_nick_prefix)[0]) ?
weechat_config_string (irc_config_look_nick_prefix) : "",
snprintf (result, sizeof (result), "%s%s%s\t",
irc_nick_mode_for_display (server, nick, 1),
(force_color) ? force_color : ((nick) ? nick->color : ((nickname) ? irc_nick_find_color (nickname) : IRC_COLOR_CHAT_NICK)),
(nick) ? nick->name : nickname,
(weechat_config_string (irc_config_look_nick_suffix)
&& weechat_config_string (irc_config_look_nick_suffix)[0]) ?
IRC_COLOR_NICK_SUFFIX : "",
(weechat_config_string (irc_config_look_nick_suffix)
&& weechat_config_string (irc_config_look_nick_suffix)[0]) ?
weechat_config_string (irc_config_look_nick_suffix) : "");
(nick) ? nick->name : nickname);
return result;
}
+12
View File
@@ -52,6 +52,8 @@ struct t_config_option *logger_config_file_mask;
struct t_config_option *logger_config_file_replacement_char;
struct t_config_option *logger_config_file_info_lines;
struct t_config_option *logger_config_file_time_format;
struct t_config_option *logger_config_file_nick_prefix;
struct t_config_option *logger_config_file_nick_suffix;
/*
@@ -474,6 +476,16 @@ logger_config_init ()
N_("timestamp used in log files (see man strftime for date/time "
"specifiers)"),
NULL, 0, 0, "%Y-%m-%d %H:%M:%S", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
logger_config_file_nick_prefix = weechat_config_new_option (
logger_config_file, ptr_section,
"nick_prefix", "string",
N_("text to write before nick in prefix of message, example: \"<\""),
NULL, 0, 0, "", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
logger_config_file_nick_suffix = weechat_config_new_option (
logger_config_file, ptr_section,
"nick_suffix", "string",
N_("text to write after nick in prefix of message, example: \">\""),
NULL, 0, 0, "", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
/* level */
ptr_section = weechat_config_new_section (logger_config_file, "level",
+2
View File
@@ -35,6 +35,8 @@ extern struct t_config_option *logger_config_file_mask;
extern struct t_config_option *logger_config_file_replacement_char;
extern struct t_config_option *logger_config_file_info_lines;
extern struct t_config_option *logger_config_file_time_format;
extern struct t_config_option *logger_config_file_nick_prefix;
extern struct t_config_option *logger_config_file_nick_suffix;
extern struct t_config_option *logger_config_get_level (const char *name);
extern int logger_config_set_level (const char *name, const char *value);
+41 -18
View File
@@ -1172,32 +1172,52 @@ logger_day_changed_signal_cb (void *data, const char *signal,
}
/*
* Gets log level for a line (using its tags).
* Gets info with tags of line: log level and if prefix is a nick.
*/
int
logger_line_log_level (int tags_count, const char **tags)
void
logger_get_line_tag_info (int tags_count, const char **tags,
int *log_level, int *prefix_is_nick)
{
int i;
int i, log_level_set, prefix_is_nick_set;
if (log_level)
*log_level = LOGGER_LEVEL_DEFAULT;
if (prefix_is_nick)
*prefix_is_nick = 0;
log_level_set = 0;
prefix_is_nick_set = 0;
for (i = 0; i < tags_count; i++)
{
/* log disabled on line? return -1 */
if (strcmp (tags[i], "no_log") == 0)
return -1;
/* log level for line? return it */
if (strncmp (tags[i], "log", 3) == 0)
if (log_level && !log_level_set)
{
if (isdigit ((unsigned char)tags[i][3]))
if (strcmp (tags[i], "no_log") == 0)
{
return (tags[i][3] - '0');
/* log disabled on line: set level to -1 */
*log_level = -1;
log_level_set = 1;
}
else if (strncmp (tags[i], "log", 3) == 0)
{
/* set log level for line */
if (isdigit ((unsigned char)tags[i][3]))
{
*log_level = (tags[i][3] - '0');
log_level_set = 1;
}
}
}
if (prefix_is_nick && !prefix_is_nick_set)
{
if (strncmp (tags[i], "prefix_nick", 11) == 0)
{
*prefix_is_nick = 1;
prefix_is_nick_set = 1;
}
}
}
/* return default log level for line */
return LOGGER_LEVEL_DEFAULT;
}
/*
@@ -1213,14 +1233,15 @@ logger_print_cb (void *data, struct t_gui_buffer *buffer, time_t date,
struct t_logger_buffer *ptr_logger_buffer;
struct tm *date_tmp;
char buf_time[256];
int line_log_level;
int line_log_level, prefix_is_nick;
/* make C compiler happy */
(void) data;
(void) displayed;
(void) highlight;
line_log_level = logger_line_log_level (tags_count, tags);
logger_get_line_tag_info (tags_count, tags, &line_log_level,
&prefix_is_nick);
if (line_log_level >= 0)
{
ptr_logger_buffer = logger_buffer_search_buffer (buffer);
@@ -1239,9 +1260,11 @@ logger_print_cb (void *data, struct t_gui_buffer *buffer, time_t date,
}
logger_write_line (ptr_logger_buffer,
"%s\t%s\t%s",
"%s\t%s%s%s\t%s",
buf_time,
(prefix && prefix_is_nick) ? weechat_config_string (logger_config_file_nick_prefix) : "",
(prefix) ? prefix : "",
(prefix && prefix_is_nick) ? weechat_config_string (logger_config_file_nick_suffix) : "",
message);
}
}