This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch main
in repository elaro.
View the commit online.
commit 1939714e16a90b59adac0df86ca21594b3e1c532
Author: Alastair Poole <[email protected]>
AuthorDate: Sat Nov 28 14:41:30 2026 +0000
history: use nickname colours for status msgs
---
NEWS | 2 ++
src/engine/elaro_engine.c | 41 +++++++++++++++++++++++++++++++---------
src/engine/elaro_engine.h | 1 +
src/fe-efl/ui/elaro_ui_buffers.c | 27 ++++++++++++++++++++++++--
src/fe-efl/ui/elaro_ui_history.c | 32 ++++++++++++++++++++++++++-----
tests/fe-efl/test-engine.c | 2 ++
tests/fe-efl/test-themes.c | 4 ++--
tests/fe-efl/test-ui-state.c | 16 +++++++++++-----
8 files changed, 102 insertions(+), 23 deletions(-)
diff --git a/NEWS b/NEWS
index a332887..ff3431e 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,8 @@ Elaro 0.1.4
* The chat history uses full-height themed dividers with padding between the timestamp, nickname, and message columns.
* Chat nicknames appear without angle brackets and use colors from the active theme’s palette.
+ * Nicknames in server messages use the same colors as chat nicknames.
+ * Chat history timestamps appear without square brackets.
* Default Elementary popups use a compact, flat close button in the top-right corner.
* Image previews fill the available space and can open the original image in the browser.
diff --git a/src/engine/elaro_engine.c b/src/engine/elaro_engine.c
index d4082c5..631a2e4 100644
--- a/src/engine/elaro_engine.c
+++ b/src/engine/elaro_engine.c
@@ -140,7 +140,8 @@ _nick_mentioned(IRC_SERVER_REC *server, const char *text)
static void
_emit_event_full(Elaro_Engine_Event_Type type, const char *server, const char *target,
const char *text, bool private_message, bool mention,
- const IRC_SERVER_REC *channel_server, const char *body)
+ const IRC_SERVER_REC *channel_server, const char *body,
+ const char *notice_nick)
{
Elaro_Engine_Event *e;
char *prefix;
@@ -163,13 +164,32 @@ _emit_event_full(Elaro_Engine_Event_Type type, const char *server, const char *t
e->nick_compare = channel_server->nick_comp_func;
g_free(prefix);
}
+ if (notice_nick && *notice_nick)
+ {
+ const char *nick_start = strstr(text, notice_nick);
+
+ if (nick_start)
+ {
+ g_autofree char *before = g_utf8_make_valid(text, nick_start - text);
+ g_autofree char *nick = g_utf8_make_valid(notice_nick, -1);
+
+ e->notice_nick_offset = strlen(before);
+ e->notice_nick_length = strlen(nick);
+ }
+ }
elaro_engine_event_push(e);
}
static void
_emit_event(Elaro_Engine_Event_Type type, const char *server, const char *target, const char *text)
{
- _emit_event_full(type, server, target, text, false, false, NULL, NULL);
+ _emit_event_full(type, server, target, text, false, false, NULL, NULL, NULL);
+}
+
+static void
+_emit_nick_notice(const char *server, const char *target, const char *text, const char *nick)
+{
+ _emit_event_full(ELARO_ENGINE_LINE, server, target, text, false, false, NULL, NULL, nick);
}
void
@@ -617,7 +637,7 @@ _action(IRC_SERVER_REC *s, const char *body, const char *nick, const char *addre
!channel && nick && address && *address && !s->nick_comp_func(target, s->nick)
&& s->nick_comp_func(nick, s->nick),
channel && nick && s->nick_comp_func(nick, s->nick)
- && _nick_mentioned(s, body), channel ? s : NULL, body);
+ && _nick_mentioned(s, body), channel ? s : NULL, body, NULL);
if (!channel && nick) _presence_known(SERVER(s), nick);
g_free(text);
}
@@ -665,18 +685,18 @@ _membership_event(IRC_SERVER_REC *s, const char *line, const char *nick, const c
for (node = matches; node; node = node->next->next)
{
channel = node->data;
- _emit_event(ELARO_ENGINE_LINE, s->tag, channel->name, text);
+ _emit_nick_notice(s->tag, channel->name, text, nick);
emitted = TRUE;
}
g_slist_free(matches);
query = query_find(SERVER(s), nick);
if (query)
{
- _emit_event(ELARO_ENGINE_LINE, s->tag, query->name, text);
+ _emit_nick_notice(s->tag, query->name, text, nick);
emitted = TRUE;
}
if (!emitted || !s->nick_comp_func(nick, s->nick))
- _emit_event(ELARO_ENGINE_LINE, s->tag, "", text);
+ _emit_nick_notice(s->tag, "", text, nick);
if (rename && strcmp(nick, value))
{
event = g_new0(Elaro_Engine_Event, 1);
@@ -716,6 +736,7 @@ _server_event(IRC_SERVER_REC *s, const char *line, const char *nick, const char
CHANNEL_REC *channel;
QUERY_REC *query;
char *reason;
+ const char *notice_nick = NULL;
gboolean own_part;
gboolean own_kick;
gboolean mention;
@@ -803,7 +824,7 @@ _server_event(IRC_SERVER_REC *s, const char *line, const char *nick, const char
if (query)
{
text = g_strdup_printf("%s: %s", victim, *body ? body : "No such nick");
- _emit_event(ELARO_ENGINE_LINE, s->tag, query->name, text);
+ _emit_nick_notice(s->tag, query->name, text, victim);
g_free(text);
g_free(params);
g_free(copy);
@@ -815,6 +836,7 @@ _server_event(IRC_SERVER_REC *s, const char *line, const char *nick, const char
else if (!g_ascii_strcasecmp(copy, "JOIN") || !g_ascii_strcasecmp(copy, "PART"))
{
join = !g_ascii_strcasecmp(copy, "JOIN");
+ notice_nick = nick;
membership_params = event_get_params(args, 2 | PARAM_FLAG_GETREST, &target, &reason);
if (join) text = g_strdup_printf(_("* %s has joined %s"), nick ? nick : "", target);
@@ -826,11 +848,12 @@ _server_event(IRC_SERVER_REC *s, const char *line, const char *nick, const char
if (nick && s->nick_comp_func(nick, s->nick))
{
query = query_find(SERVER(s), nick);
- if (query) _emit_event(ELARO_ENGINE_LINE, s->tag, query->name, text);
+ if (query) _emit_nick_notice(s->tag, query->name, text, nick);
}
}
else if (!g_ascii_strcasecmp(copy, "KICK") || !g_ascii_strcasecmp(copy, "TOPIC"))
{
+ notice_nick = nick;
target = args + (*args == ':');
end = strchr(target, ' ');
text = g_strdup_printf("* %s %s %s", nick ? nick : "", copy, args);
@@ -860,7 +883,7 @@ _server_event(IRC_SERVER_REC *s, const char *line, const char *nick, const char
_emit_event_full(ELARO_ENGINE_LINE, s->tag, own_part || own_kick ? NULL : target, text,
!g_ascii_strcasecmp(copy, "PRIVMSG") && target && nick && address && *address
&& !server_ischannel(SERVER(s), args) && !s->nick_comp_func(args, s->nick)
- && s->nick_comp_func(nick, s->nick), mention, channel_message ? s : NULL, body);
+ && s->nick_comp_func(nick, s->nick), mention, channel_message ? s : NULL, body, notice_nick);
if (target && !server_ischannel(SERVER(s), target)) _presence_known(SERVER(s), target);
diff --git a/src/engine/elaro_engine.h b/src/engine/elaro_engine.h
index dd59643..07ab292 100644
--- a/src/engine/elaro_engine.h
+++ b/src/engine/elaro_engine.h
@@ -100,6 +100,7 @@ typedef struct
/* Channel text formatting uses the nickname and casemapping at receipt. */
char *highlight_nick;
Elaro_Nick_Compare nick_compare;
+ size_t notice_nick_offset, notice_nick_length; /* Nickname span in a server notice. */
size_t body_offset; /* Byte offset into text, after the sender prefix. */
bool private_message;
bool mention; /* Incoming channel message mentioning our current nickname. */
diff --git a/src/fe-efl/ui/elaro_ui_buffers.c b/src/fe-efl/ui/elaro_ui_buffers.c
index 834cc9e..0190497 100644
--- a/src/fe-efl/ui/elaro_ui_buffers.c
+++ b/src/fe-efl/ui/elaro_ui_buffers.c
@@ -885,6 +885,26 @@ _query_rename(Elaro_Ui *ui, const Elaro_Engine_Event *event)
if (ui->current == query) elaro_ui_buffer_title_update(ui);
}
+static char *
+_notice_markup(const char *plain, size_t nick_offset, size_t nick_length)
+{
+ char *prefix, *nickname;
+ char *before, *escaped, *after, *markup;
+
+ prefix = strndup(plain, nick_offset);
+ nickname = strndup(plain + nick_offset, nick_length);
+ before = elaro_ui_text_markup(prefix);
+ escaped = elm_entry_utf8_to_markup(nickname);
+ after = elaro_ui_text_markup(plain + nick_offset + nick_length);
+ markup = elaro_string_printf("%s<history-nick>%s</history-nick>%s", before, escaped, after);
+ free(prefix);
+ free(nickname);
+ free(before);
+ free(escaped);
+ free(after);
+ return markup;
+}
+
void
elaro_ui_buffer_event(Elaro_Ui *ui, const Elaro_Engine_Event *e)
{
@@ -984,8 +1004,11 @@ elaro_ui_buffer_event(Elaro_Ui *ui, const Elaro_Engine_Event *e)
localtime_r(&now, &local);
strftime(stamp, sizeof(stamp), "%H:%M", &local);
plain = elaro_string_printf("[%s] %s", stamp, e->text);
- safe = elaro_ui_text_message_markup(plain, strlen(stamp) + 3 + e->body_offset,
- e->highlight_nick, e->nick_compare);
+ if (e->notice_nick_length)
+ safe = _notice_markup(plain, strlen(stamp) + 3 + e->notice_nick_offset, e->notice_nick_length);
+ else
+ safe = elaro_ui_text_message_markup(plain, strlen(stamp) + 3 + e->body_offset,
+ e->highlight_nick, e->nick_compare);
eina_strbuf_append(b->history, safe);
eina_strbuf_append(b->history, "<br/>");
diff --git a/src/fe-efl/ui/elaro_ui_history.c b/src/fe-efl/ui/elaro_ui_history.c
index 1395b7e..ea8e1a4 100644
--- a/src/fe-efl/ui/elaro_ui_history.c
+++ b/src/fe-efl/ui/elaro_ui_history.c
@@ -267,7 +267,8 @@ _history_cell_append(Eina_Strbuf *out, const char *prefix, size_t length,
{
eina_strbuf_append_printf(out, "%02x", (unsigned char) prefix[i]);
}
- if (nickname_slot >= 0) eina_strbuf_append_printf(out, "20:%d", nickname_slot);
+ if (length) eina_strbuf_append(out, "20");
+ if (nickname_slot >= 0) eina_strbuf_append_printf(out, ":%d", nickname_slot);
eina_strbuf_append(out, repeated ? ":repeat></item>" : "></item>");
}
@@ -283,6 +284,27 @@ _history_nickname_end(const char *line, const char *end)
return nick_end && nick_end + 5 <= end ? nick_end : NULL;
}
+static void
+_history_body_append(Evas_Object *history, History_Columns *columns, Eina_Strbuf *out,
+ const char *body, const char *end)
+{
+ const char *tag = strstr(body, "<history-nick>");
+ const char *nick_end = tag && tag < end ? strstr(tag, "</history-nick>") : NULL;
+
+ if (nick_end && nick_end + strlen("</history-nick>") <= end)
+ {
+ const char *nick = tag + strlen("<history-nick>");
+ unsigned int slot = _history_nickname_slot(columns, nick, nick_end - nick);
+
+ eina_strbuf_append_length(out, body, tag - body);
+ eina_strbuf_append_printf(out, "<color=%s>", _history_nickname_color(history, slot));
+ eina_strbuf_append_length(out, nick, nick_end - nick);
+ eina_strbuf_append(out, "</color>");
+ body = nick_end + strlen("</history-nick>");
+ }
+ eina_strbuf_append_length(out, body, end - body);
+}
+
static char *
_history_columns(Evas_Object *history, const char *markup, Eina_Bool reset)
{
@@ -320,7 +342,7 @@ _history_columns(Evas_Object *history, const char *markup, Eina_Bool reset)
_history_prefix_style(history, measure, EINA_TRUE, 0, 0);
for (char digit = '0'; digit <= '9'; digit++)
{
- char stamp[] = { '[', digit, digit, ':', digit, digit, ']', 0 };
+ char stamp[] = { digit, digit, ':', digit, digit, 0 };
Evas_Coord stamp_width;
evas_object_textblock_text_markup_set(measure, stamp);
@@ -376,6 +398,8 @@ _history_columns(Evas_Object *history, const char *markup, Eina_Bool reset)
if (end - line >= 8 && line[0] == '[' && line[6] == ']' && line[7] == ' ')
body = line + 8;
nick_end = _history_nickname_end(line, end);
+ _history_cell_append(out, body == line ? line : line + 1, body == line ? 0 : 5,
+ nick_end ? timestamp_width : gutter, height, -1, EINA_FALSE);
if (nick_end)
{
size_t length;
@@ -388,7 +412,6 @@ _history_columns(Evas_Object *history, const char *markup, Eina_Bool reset)
free(author);
author = strndup(nickname, length);
body = nick_end + 5;
- _history_cell_append(out, line, 8, timestamp_width, height, -1, EINA_FALSE);
_history_cell_append(out, nickname, length, gutter - timestamp_width,
height, slot, repeated);
}
@@ -396,10 +419,9 @@ _history_columns(Evas_Object *history, const char *markup, Eina_Bool reset)
{
free(author);
author = NULL;
- _history_cell_append(out, line, body - line, gutter, height, -1, EINA_FALSE);
}
eina_strbuf_append_printf(out, "<left_margin=+%d>", gutter);
- eina_strbuf_append_length(out, body, end - body);
+ _history_body_append(history, columns, out, body, end);
eina_strbuf_append(out, "</left_margin><ps/>");
if (!*end) break;
}
diff --git a/tests/fe-efl/test-engine.c b/tests/fe-efl/test-engine.c
index ed180da..1fb63d6 100644
--- a/tests/fe-efl/test-engine.c
+++ b/tests/fe-efl/test-engine.c
@@ -142,6 +142,8 @@ int main(int argc, char **argv)
!strcmp(event->text, "* alice has left #test (Taking a break)") ||
!strcmp(event->text, "* alice has quit (See you)"))) {
g_assert_false(event->private_message);
+ g_assert_cmpuint(event->notice_nick_offset, ==, 2);
+ g_assert_cmpuint(event->notice_nick_length, ==, strlen("alice"));
query_membership++;
}
if (!strcmp(event->text, "* alice waves")) {
diff --git a/tests/fe-efl/test-themes.c b/tests/fe-efl/test-themes.c
index 8edc758..2c8040b 100644
--- a/tests/fe-efl/test-themes.c
+++ b/tests/fe-efl/test-themes.c
@@ -224,7 +224,7 @@ static int _prefix_colors_check(Evas_Object *object, const char *color)
if (!strcmp(evas_object_type_get(object), "textblock"))
{
const char *markup = evas_object_textblock_text_markup_get(object);
- if (markup && (strstr(markup, "Alice") || strstr(markup, "[12:34]"))
+ if (markup && (strstr(markup, "Alice") || strstr(markup, "12:34"))
&& !strstr(markup, "Theme persistence"))
{
const Evas_Textblock_Style *style = evas_object_textblock_style_user_peek(object);
@@ -568,7 +568,7 @@ static int _visible_prefixes_check(Evas_Object *object, int top, int bottom, uns
const char *markup = evas_object_textblock_text_markup_get(object);
int x, y, w, h, width, height;
evas_object_geometry_get(object, &x, &y, &w, &h);
- if (markup && !strcmp(markup, "[12:34]") && y >= top && y + h <= bottom)
+ if (markup && !strcmp(markup, "12:34") && y >= top && y + h <= bottom)
{
evas_object_textblock_size_native_get(object, &width, &height);
assert(width > 0 && height > 0 && h >= height);
diff --git a/tests/fe-efl/test-ui-state.c b/tests/fe-efl/test-ui-state.c
index bf99a54..1609565 100644
--- a/tests/fe-efl/test-ui-state.c
+++ b/tests/fe-efl/test-ui-state.c
@@ -490,8 +490,11 @@ int main(int argc, char **argv)
elaro_ui_buffer_event(&ui, &line);
line.text = "<iii> Another consecutive message";
elaro_ui_buffer_event(&ui, &line);
- line.text = "* A system notice breaks the group";
+ line.text = "* iii has left #test (iii)";
+ line.notice_nick_offset = 2;
+ line.notice_nick_length = 3;
elaro_ui_buffer_event(&ui, &line);
+ line.notice_nick_length = 0;
line.text = "<iii> Visible after the notice";
elaro_ui_buffer_event(&ui, &line);
settle_layout();
@@ -504,6 +507,7 @@ int main(int argc, char **argv)
/* Exactly the two consecutive messages hide their nickname;
* rotation and a system notice restore it, also after reflow. */
const char *rendered = elm_entry_entry_get(ui.history);
+ assert(strstr(rendered, "* <color=#77d9c4>iii</color> has left #test (iii)"));
unsigned int repeats = 0;
for (const char *at = rendered; (at = strstr(at, ":repeat>")); at++) repeats++;
assert(repeats == 2);
@@ -548,11 +552,13 @@ int main(int argc, char **argv)
elm_entry_select_all(ui.history);
elm_entry_selection_copy(ui.history);
settle_layout();
- assert(clipboard_text && strstr(clipboard_text, "] iii First message"));
- assert(strstr(clipboard_text, "] WWWWWWWWWWWWWWW Second message https://example.org/"));
- assert(strstr(clipboard_text, "] WWWWWWWWWWWWWWW Same speaker again"));
- assert(strstr(clipboard_text, "] iii Another consecutive message"));
+ assert(clipboard_text && strstr(clipboard_text, " iii First message"));
+ assert(strstr(clipboard_text, " WWWWWWWWWWWWWWW Second message https://example.org/"));
+ assert(strstr(clipboard_text, " WWWWWWWWWWWWWWW Same speaker again"));
+ assert(strstr(clipboard_text, " iii Another consecutive message"));
+ assert(strstr(clipboard_text, "* iii has left #test (iii)"));
assert(!strstr(clipboard_text, "chat-prefix:"));
+ assert(!strchr(clipboard_text, '[') && !strchr(clipboard_text, ']'));
assert(strchr(clipboard_text, '\n'));
elm_entry_select_none(ui.history);
/* Exercise the keyboard path too: read-only Edje text does not
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.