diff --git a/src/tox-weechat-chats.c b/src/tox-weechat-chats.c index fc2367f..3241446 100644 --- a/src/tox-weechat-chats.c +++ b/src/tox-weechat-chats.c @@ -30,6 +30,10 @@ #include "tox-weechat-chats.h" +const char *tox_weechat_tag_unsent_message = "tox_unsent"; +const char *tox_weechat_tag_sent_message = "tox_sent"; +const char *tox_weechat_tag_received_message = "tox_received"; + int tox_weechat_buffer_input_callback(void *data, struct t_gui_buffer *buffer, const char *input_data); @@ -174,20 +178,22 @@ tox_weechat_get_chat_for_buffer(struct t_gui_buffer *buffer) void tox_weechat_chat_print_message(struct t_tox_weechat_chat *chat, const char *sender, - const char *message) + const char *message, + const char *tags) { - weechat_printf(chat->buffer, "%s\t%s", sender, message); + weechat_printf_tags(chat->buffer, tags, "%s\t%s", sender, message); } void tox_weechat_chat_print_action(struct t_tox_weechat_chat *chat, const char *sender, - const char *message) + const char *message, + const char *tags) { - weechat_printf(chat->buffer, - "%s%s %s", - weechat_prefix("action"), - sender, message); + weechat_printf_tags(chat->buffer, tags, + "%s%s %s", + weechat_prefix("action"), + sender, message); } int @@ -196,12 +202,12 @@ tox_weechat_buffer_input_callback(void *data, const char *input_data) { struct t_tox_weechat_chat *chat = data; - tox_weechat_send_friend_message(chat->identity, - chat->friend_number, - input_data); + int rc = tox_weechat_send_friend_message(chat->identity, + chat->friend_number, + input_data); char *name = tox_weechat_get_self_name_nt(chat->identity->tox); - tox_weechat_chat_print_message(chat, name, input_data); + tox_weechat_chat_print_message(chat, "", name, input_data); free(name); return WEECHAT_RC_OK; diff --git a/src/tox-weechat-chats.h b/src/tox-weechat-chats.h index 68976b1..9f6711e 100644 --- a/src/tox-weechat-chats.h +++ b/src/tox-weechat-chats.h @@ -24,6 +24,10 @@ #include +extern const char *tox_weechat_tag_unsent_message; +extern const char *tox_weechat_tag_sent_message; +extern const char *tox_weechat_tag_received_message; + struct t_tox_weechat_chat { struct t_gui_buffer *buffer; @@ -49,11 +53,13 @@ tox_weechat_get_chat_for_buffer(struct t_gui_buffer *target_buffer); void tox_weechat_chat_print_message(struct t_tox_weechat_chat *chat, const char *sender, - const char *message); + const char *message, + const char *tags); void tox_weechat_chat_print_action(struct t_tox_weechat_chat *chat, const char *sender, - const char *message); + const char *message, + const char *tags); void tox_weechat_chat_refresh(struct t_tox_weechat_chat *chat); diff --git a/src/tox-weechat-commands.c b/src/tox-weechat-commands.c index f2585fe..b5bf666 100644 --- a/src/tox-weechat-commands.c +++ b/src/tox-weechat-commands.c @@ -341,7 +341,7 @@ tox_weechat_cmd_me(void *data, struct t_gui_buffer *buffer, strlen(argv_eol[1])); char *name = tox_weechat_get_self_name_nt(identity->tox); - tox_weechat_chat_print_action(chat, name, argv_eol[1]); + tox_weechat_chat_print_action(chat, "", name, argv_eol[1]); free(name); @@ -385,7 +385,7 @@ tox_weechat_cmd_msg(void *data, struct t_gui_buffer *buffer, (uint8_t *)argv_eol[2], strlen(argv_eol[2])); char *name = tox_weechat_get_self_name_nt(identity->tox); - tox_weechat_chat_print_message(chat, name, argv_eol[2]); + tox_weechat_chat_print_message(chat, "", name, argv_eol[2]); free(name); } diff --git a/src/tox-weechat-tox-callbacks.c b/src/tox-weechat-tox-callbacks.c index 31ec3ef..50b227f 100644 --- a/src/tox-weechat-tox-callbacks.c +++ b/src/tox-weechat-tox-callbacks.c @@ -65,7 +65,7 @@ tox_weechat_friend_message_callback(Tox *tox, char *name = tox_weechat_get_name_nt(identity->tox, friend_number); char *message_nt = tox_weechat_null_terminate(message, length); - tox_weechat_chat_print_message(chat, name, message_nt); + tox_weechat_chat_print_message(chat, "", name, message_nt); free(name); free(message_nt); @@ -85,7 +85,7 @@ tox_weechat_friend_action_callback(Tox *tox, char *name = tox_weechat_get_name_nt(identity->tox, friend_number); char *message_nt = tox_weechat_null_terminate(message, length); - tox_weechat_chat_print_action(chat, name, message_nt); + tox_weechat_chat_print_action(chat, "", name, message_nt); free(name); free(message_nt);