aboutsummaryrefslogtreecommitdiff
path: root/xC.c
diff options
context:
space:
mode:
Diffstat (limited to 'xC.c')
-rw-r--r--xC.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/xC.c b/xC.c
index 61be087..7f06083 100644
--- a/xC.c
+++ b/xC.c
@@ -1541,6 +1541,7 @@ struct formatter
struct app_context *ctx; ///< Application context
struct server *s; ///< Server
+ bool clean; ///< Assume ATTR_RESET
struct formatter_item *items; ///< Items
size_t items_len; ///< Items used
size_t items_alloc; ///< Items allocated
@@ -1549,7 +1550,7 @@ struct formatter
static struct formatter
formatter_make (struct app_context *ctx, struct server *s)
{
- struct formatter self = { .ctx = ctx, .s = s };
+ struct formatter self = { .ctx = ctx, .s = s, .clean = true };
self.items = xcalloc (sizeof *self.items, (self.items_alloc = 16));
return self;
}
@@ -3811,7 +3812,7 @@ irc_to_utf8 (const char *text)
// #d inserts a signed integer
// #l inserts a locale-encoded string
//
-// #S inserts a string from the server with unknown encoding
+// #S inserts a string from the server in an unknown encoding
// #m inserts an IRC-formatted string (auto-resets at boundaries)
// #n cuts the nickname from a string and automatically colours it
// #N is like #n but also appends userhost, if present
@@ -3827,6 +3828,17 @@ irc_to_utf8 (const char *text)
static void
formatter_add_item (struct formatter *self, struct formatter_item template_)
{
+ // Auto-resetting tends to create unnecessary items,
+ // which also end up being relayed to frontends, so filter them out.
+ bool reset =
+ template_.type == FORMATTER_ITEM_ATTR &&
+ template_.attribute == ATTR_RESET;
+ if (self->clean && reset)
+ return;
+
+ self->clean = reset ||
+ (self->clean && template_.type == FORMATTER_ITEM_TEXT);
+
if (template_.text)
template_.text = xstrdup (template_.text);