Added tags to printed messages.
This commit is contained in:
parent
3fb416adb0
commit
d45167971d
@ -30,6 +30,10 @@
|
|||||||
|
|
||||||
#include "tox-weechat-chats.h"
|
#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,
|
int tox_weechat_buffer_input_callback(void *data,
|
||||||
struct t_gui_buffer *buffer,
|
struct t_gui_buffer *buffer,
|
||||||
const char *input_data);
|
const char *input_data);
|
||||||
@ -174,17 +178,19 @@ tox_weechat_get_chat_for_buffer(struct t_gui_buffer *buffer)
|
|||||||
void
|
void
|
||||||
tox_weechat_chat_print_message(struct t_tox_weechat_chat *chat,
|
tox_weechat_chat_print_message(struct t_tox_weechat_chat *chat,
|
||||||
const char *sender,
|
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
|
void
|
||||||
tox_weechat_chat_print_action(struct t_tox_weechat_chat *chat,
|
tox_weechat_chat_print_action(struct t_tox_weechat_chat *chat,
|
||||||
const char *sender,
|
const char *sender,
|
||||||
const char *message)
|
const char *message,
|
||||||
|
const char *tags)
|
||||||
{
|
{
|
||||||
weechat_printf(chat->buffer,
|
weechat_printf_tags(chat->buffer, tags,
|
||||||
"%s%s %s",
|
"%s%s %s",
|
||||||
weechat_prefix("action"),
|
weechat_prefix("action"),
|
||||||
sender, message);
|
sender, message);
|
||||||
@ -196,12 +202,12 @@ tox_weechat_buffer_input_callback(void *data,
|
|||||||
const char *input_data)
|
const char *input_data)
|
||||||
{
|
{
|
||||||
struct t_tox_weechat_chat *chat = data;
|
struct t_tox_weechat_chat *chat = data;
|
||||||
tox_weechat_send_friend_message(chat->identity,
|
int rc = tox_weechat_send_friend_message(chat->identity,
|
||||||
chat->friend_number,
|
chat->friend_number,
|
||||||
input_data);
|
input_data);
|
||||||
|
|
||||||
char *name = tox_weechat_get_self_name_nt(chat->identity->tox);
|
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);
|
free(name);
|
||||||
|
|
||||||
return WEECHAT_RC_OK;
|
return WEECHAT_RC_OK;
|
||||||
|
@ -24,6 +24,10 @@
|
|||||||
|
|
||||||
#include <tox/tox.h>
|
#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_tox_weechat_chat
|
||||||
{
|
{
|
||||||
struct t_gui_buffer *buffer;
|
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,
|
void tox_weechat_chat_print_message(struct t_tox_weechat_chat *chat,
|
||||||
const char *sender,
|
const char *sender,
|
||||||
const char *message);
|
const char *message,
|
||||||
|
const char *tags);
|
||||||
|
|
||||||
void tox_weechat_chat_print_action(struct t_tox_weechat_chat *chat,
|
void tox_weechat_chat_print_action(struct t_tox_weechat_chat *chat,
|
||||||
const char *sender,
|
const char *sender,
|
||||||
const char *message);
|
const char *message,
|
||||||
|
const char *tags);
|
||||||
|
|
||||||
void
|
void
|
||||||
tox_weechat_chat_refresh(struct t_tox_weechat_chat *chat);
|
tox_weechat_chat_refresh(struct t_tox_weechat_chat *chat);
|
||||||
|
@ -341,7 +341,7 @@ tox_weechat_cmd_me(void *data, struct t_gui_buffer *buffer,
|
|||||||
strlen(argv_eol[1]));
|
strlen(argv_eol[1]));
|
||||||
|
|
||||||
char *name = tox_weechat_get_self_name_nt(identity->tox);
|
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);
|
free(name);
|
||||||
|
|
||||||
@ -385,7 +385,7 @@ tox_weechat_cmd_msg(void *data, struct t_gui_buffer *buffer,
|
|||||||
(uint8_t *)argv_eol[2],
|
(uint8_t *)argv_eol[2],
|
||||||
strlen(argv_eol[2]));
|
strlen(argv_eol[2]));
|
||||||
char *name = tox_weechat_get_self_name_nt(identity->tox);
|
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);
|
free(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ tox_weechat_friend_message_callback(Tox *tox,
|
|||||||
char *name = tox_weechat_get_name_nt(identity->tox, friend_number);
|
char *name = tox_weechat_get_name_nt(identity->tox, friend_number);
|
||||||
char *message_nt = tox_weechat_null_terminate(message, length);
|
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(name);
|
||||||
free(message_nt);
|
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 *name = tox_weechat_get_name_nt(identity->tox, friend_number);
|
||||||
char *message_nt = tox_weechat_null_terminate(message, length);
|
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(name);
|
||||||
free(message_nt);
|
free(message_nt);
|
||||||
|
Loading…
Reference in New Issue
Block a user