From 8988d969a04ac273578372bc2ab1b4597935852b Mon Sep 17 00:00:00 2001 From: Tony Olagbaiye Date: Thu, 1 Jul 2021 23:08:12 +0100 Subject: [PATCH] hacky colours --- account.c | 4 ++-- channel.c | 6 ++++-- command.c | 9 ++++++--- connection.c | 12 +++++++++--- user.c | 32 +++++++++++++++++++++++--------- user.h | 17 ++++++++++------- 6 files changed, 54 insertions(+), 26 deletions(-) diff --git a/account.c b/account.c index 9b20bcc..c1d52ae 100644 --- a/account.c +++ b/account.c @@ -130,7 +130,7 @@ void account__log_emit_weechat(void *const userdata, const xmpp_log_level_t leve weechat_printf( account ? account->buffer : NULL, _("%s%s (%s): %s"), - weechat_prefix("error"), area, + weechat_prefix("network"), area, log_level_name[level], header); for (int i = 1; i < size; i++) weechat_printf( @@ -144,7 +144,7 @@ void account__log_emit_weechat(void *const userdata, const xmpp_log_level_t leve weechat_printf( account ? account->buffer : NULL, _("%s%s (%s): %s"), - weechat_prefix("error"), area, + weechat_prefix("network"), area, log_level_name[level], msg); } } diff --git a/channel.c b/channel.c index 09e56b1..9e92730 100644 --- a/channel.c +++ b/channel.c @@ -610,7 +610,9 @@ void channel__send_message(struct t_account *account, struct t_channel *channel, xmpp_send(account->connection, message); xmpp_stanza_release(message); if (channel->type != CHANNEL_TYPE_MUC) - weechat_printf(channel->buffer, "%s: %s", - weechat_config_string(account->options[ACCOUNT_OPTION_JID]), + weechat_printf(channel->buffer, "%s%s", + user__as_prefix_raw( + account, + weechat_config_string(account->options[ACCOUNT_OPTION_JID])), body); } diff --git a/command.c b/command.c index a5c5799..6c09ed3 100644 --- a/command.c +++ b/command.c @@ -11,6 +11,7 @@ //#include "oauth.h" //#include "teaminfo.h" #include "account.h" +#include "user.h" #include "channel.h" #include "buffer.h" #include "message.h" @@ -490,9 +491,11 @@ int command__me(const void *pointer, void *data, xmpp_message_set_body(message, text); xmpp_send(ptr_account->connection, message); xmpp_stanza_release(message); - weechat_printf(ptr_channel->buffer, "* %s %s", - weechat_config_string(ptr_account->options[ACCOUNT_OPTION_JID]), - text); + if (ptr_channel->type != CHANNEL_TYPE_MUC) + weechat_printf(ptr_channel->buffer, "%s%s %s", + weechat_prefix("action"), + weechat_config_string(ptr_account->options[ACCOUNT_OPTION_JID]), + text); } return WEECHAT_RC_OK; diff --git a/connection.c b/connection.c index 70f9457..c1013d4 100644 --- a/connection.c +++ b/connection.c @@ -10,6 +10,7 @@ #include "plugin.h" #include "config.h" #include "account.h" +#include "user.h" #include "channel.h" #include "connection.h" @@ -106,11 +107,16 @@ int message_handler(xmpp_conn_t *conn, xmpp_stanza_t *stanza, void *userdata) } if (strcmp(to, channel->id) == 0) - weechat_printf(channel->buffer, "%s [to %s]: %s", from, to, intext); + weechat_printf(channel->buffer, "%s[to %s]: %s", + user__as_prefix_raw(account->context, from), + to, intext); else if (weechat_string_match(intext, "/me *", 0)) - weechat_printf(channel->buffer, "* %s %s", from, intext+4); + weechat_printf(channel->buffer, "%s%s %s", + weechat_prefix("action"), from, intext+4); else - weechat_printf(channel->buffer, "%s: %s", from, intext); + weechat_printf(channel->buffer, "%s%s", + user__as_prefix_raw(account->context, from), + intext); xmpp_free(account->context, intext); diff --git a/user.c b/user.c index 2469af3..4cc62ac 100644 --- a/user.c +++ b/user.c @@ -23,11 +23,25 @@ const char *user__get_colour_for_nicklist(struct t_user *user) return weechat_info_get("nick_color_name", user->profile.display_name); } +const char *user__as_prefix_raw(struct t_account *account, + const char *name) +{ + static char result[2048]; + + (void) account; + + snprintf(result, sizeof(result), "%s%s\t", + weechat_info_get("nick_color", name), + name); + + return result; +} + const char *user__as_prefix(struct t_account *account, - struct t_user *user, - const char *name) + struct t_user *user, + const char *name) { - static char result[256]; + static char result[2048]; (void) account; @@ -39,7 +53,7 @@ const char *user__as_prefix(struct t_account *account, } struct t_user *user__bot_search(struct t_account *account, - const char *bot_id) + const char *bot_id) { struct t_user *ptr_user; @@ -58,7 +72,7 @@ struct t_user *user__bot_search(struct t_account *account, } struct t_user *user__search(struct t_account *account, - const char *id) + const char *id) { struct t_user *ptr_user; @@ -76,8 +90,8 @@ struct t_user *user__search(struct t_account *account, } void user__nicklist_add(struct t_account *account, - struct t_channel *channel, - struct t_user *user) + struct t_channel *channel, + struct t_user *user) { struct t_gui_nick_group *ptr_group; struct t_gui_buffer *ptr_buffer; @@ -89,7 +103,7 @@ void user__nicklist_add(struct t_account *account, "+" : "..."); weechat_nicklist_add_nick(ptr_buffer, ptr_group, user->profile.display_name, - user->is_away ? + user->is_away ? "weechat.color.nicklist_away" : user__get_colour_for_nicklist(user), user->is_away ? "+" : "", @@ -98,7 +112,7 @@ void user__nicklist_add(struct t_account *account, } struct t_user *user__new(struct t_account *account, - const char *id, const char *display_name) + const char *id, const char *display_name) { struct t_user *new_user, *ptr_user; diff --git a/user.h b/user.h index 88aaf96..624aaf2 100644 --- a/user.h +++ b/user.h @@ -53,23 +53,26 @@ struct t_channel; const char *user__get_colour(struct t_user *user); +const char *user__as_prefix_raw(struct t_account *account, + const char *name); + const char *user__as_prefix(struct t_account *account, - struct t_user *user, - const char *name); + struct t_user *user, + const char *name); struct t_user *user__bot_search(struct t_account *account, - const char *bot_id); + const char *bot_id); struct t_user *user__search(struct t_account *account, - const char *id); + const char *id); struct t_user *user__new(struct t_account *account, - const char *id, const char *display_name); + const char *id, const char *display_name); void user__free_all(struct t_account *account); void user__nicklist_add(struct t_account *account, - struct t_channel *channel, - struct t_user *user); + struct t_channel *channel, + struct t_user *user); #endif /*WEECHAT_XMPP_USER_H*/