Added tags to printed messages.

This commit is contained in:
Håvard Pettersson 2014-09-26 18:33:17 +02:00
parent 3fb416adb0
commit d45167971d
4 changed files with 29 additions and 17 deletions

View File

@ -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;

View File

@ -24,6 +24,10 @@
#include <tox/tox.h>
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);

View File

@ -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);
}

View File

@ -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);