Add basic nick coloring functionality.

This commit is contained in:
Håvard Pettersson 2016-05-10 11:29:50 +02:00
parent 174f00eccd
commit 4aa054aada
3 changed files with 18 additions and 6 deletions

View File

@ -279,6 +279,7 @@ twc_chat_search_buffer(struct t_gui_buffer *buffer)
void
twc_chat_print_message(struct t_twc_chat *chat,
const char *tags,
const char *color,
const char *sender,
const char *message,
enum TWC_MESSAGE_TYPE message_type)
@ -287,14 +288,16 @@ twc_chat_print_message(struct t_twc_chat *chat,
{
case TWC_MESSAGE_TYPE_MESSAGE:
weechat_printf_tags(chat->buffer, tags,
"%s\t%s",
sender, message);
"%s%s%s\t%s",
color, sender,
weechat_color("reset"), message);
break;
case TWC_MESSAGE_TYPE_ACTION:
weechat_printf_tags(chat->buffer, tags,
"%s%s %s",
weechat_prefix("action"),
sender, message);
color, sender,
weechat_color("reset"), message);
break;
}
}
@ -312,7 +315,9 @@ twc_chat_send_message(struct t_twc_chat *chat, const char *message,
chat->friend_number,
message, message_type);
char *name = twc_get_self_name_nt(chat->profile->tox);
twc_chat_print_message(chat, "", name, message, message_type);
twc_chat_print_message(chat, "",
weechat_color("chat_nick_self"), name,
message, message_type);
free(name);
}
else if (chat->group_number >= 0)

View File

@ -61,6 +61,7 @@ twc_chat_search_buffer(struct t_gui_buffer *target_buffer);
void
twc_chat_print_message(struct t_twc_chat *chat,
const char *tags,
const char *color,
const char *sender,
const char *message,
enum TWC_MESSAGE_TYPE message_type);

View File

@ -67,7 +67,7 @@ twc_friend_message_callback(Tox *tox, uint32_t friend_number,
char *name = twc_get_name_nt(profile->tox, friend_number);
char *message_nt = twc_null_terminate(message, length);
twc_chat_print_message(chat, "", name,
twc_chat_print_message(chat, "", weechat_color("chat_nick_other"), name,
message_nt, type);
free(name);
@ -256,7 +256,13 @@ twc_handle_group_message(Tox *tox,
char *name = twc_get_peer_name_nt(profile->tox, group_number, peer_number);
char *message_nt = twc_null_terminate(message, length);
twc_chat_print_message(chat, "", name,
const char *nick_color;
if (tox_group_peernumber_is_ours(tox, group_number, peer_number))
nick_color = weechat_color("chat_nick_self");
else
nick_color = weechat_info_get("nick_color", name);
twc_chat_print_message(chat, "", nick_color, name,
message_nt, message_type);
free(name);