Mon, 12 May 2025 20:25:16 -0500
Handle formatting in server messages
Testing Done:
Used the default motd on my local ergo server to verify that formatting was working.
Reviewed at https://reviews.imfreedom.org/r/3991/
| protocols/ircv3/purpleircv3connection.c | file | annotate | diff | comparison | revisions |
--- a/protocols/ircv3/purpleircv3connection.c Fri Apr 25 01:08:11 2025 -0500 +++ b/protocols/ircv3/purpleircv3connection.c Mon May 12 20:25:16 2025 -0500 @@ -22,6 +22,8 @@ #include <glib/gi18n-lib.h> +#include <pango/pango.h> + #include <birb.h> #include <hasl.h> @@ -1094,6 +1096,7 @@ PurpleContact *contact = NULL; PurpleConversationMember *author = NULL; PurpleMessage *purple_message = NULL; + PangoAttrList *attrs = NULL; GString *str = NULL; GStrv params = NULL; char *body = NULL; @@ -1111,9 +1114,16 @@ } } + params = ibis_message_get_params(ibis_message); body = g_strjoinv(" ", params); - stripped = ibis_formatting_strip(body); + + /* Grab the attributes and offset them for however many bytes are already + * in the string. + */ + stripped = ibis_formatting_parse(body, &attrs); + pango_attr_list_update(attrs, 0, 0, str->len); + g_free(body); g_string_append(str, stripped); g_free(stripped); @@ -1127,6 +1137,9 @@ purple_message = purple_message_new(author, str->str); g_string_free(str, TRUE); + purple_message_set_attributes(purple_message, attrs); + pango_attr_list_unref(attrs); + purple_message_set_event(purple_message, event); purple_conversation_write_message(connection->status_conversation,