Skip to content

Commit

Permalink
relay/remote: fix highlight on lines received from remote
Browse files Browse the repository at this point in the history
  • Loading branch information
flashcode committed May 18, 2024
1 parent 2423fdb commit 8949a65
Showing 1 changed file with 26 additions and 6 deletions.
32 changes: 26 additions & 6 deletions src/plugins/relay/api/remote/relay-remote-event.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,16 +134,17 @@ relay_remote_event_get_buffer_id (struct t_gui_buffer *buffer)
RELAY_REMOTE_EVENT_CALLBACK(line)
{
cJSON *json_obj, *json_tags, *json_tag;
const char *date, *prefix, *message;
const char *date, *prefix, *message, *ptr_tag;
char **tags;
int y;
int y, highlight, tag_notify_highlight;
struct timeval tv_date;

if (!event->buffer || !event->json)
return WEECHAT_RC_OK;

JSON_GET_NUM(event->json, y, -1);
JSON_GET_STR(event->json, date);
JSON_GET_BOOL(event->json, highlight);
JSON_GET_STR(event->json, prefix);
JSON_GET_STR(event->json, message);

Expand All @@ -153,6 +154,8 @@ RELAY_REMOTE_EVENT_CALLBACK(line)
tv_date.tv_usec = 0;
}

tag_notify_highlight = 0;

tags = weechat_string_dyn_alloc (256);
if (tags)
{
Expand All @@ -161,12 +164,29 @@ RELAY_REMOTE_EVENT_CALLBACK(line)
{
cJSON_ArrayForEach (json_tag, json_tags)
{
if (*tags[0])
weechat_string_dyn_concat (tags, ",", -1);
weechat_string_dyn_concat (
tags, cJSON_GetStringValue (json_tag), -1);
ptr_tag = cJSON_GetStringValue (json_tag);
if (ptr_tag)
{
if (*tags[0])
weechat_string_dyn_concat (tags, ",", -1);
if (highlight && (strncmp (ptr_tag, "notify_", 7) == 0))
{
weechat_string_dyn_concat (tags, "notify_highlight", -1);
tag_notify_highlight = 1;
}
else
{
weechat_string_dyn_concat (tags, ptr_tag, -1);
}
}
}
}
if (highlight && !tag_notify_highlight)
{
if (*tags[0])
weechat_string_dyn_concat (tags, ",", -1);
weechat_string_dyn_concat (tags, "notify_highlight", -1);
}
}

if (y >= 0)
Expand Down

0 comments on commit 8949a65

Please sign in to comment.