xC/xP: fix unseen message counting

xC: advance unread message counters even with leaked messages,
and don't unnecessarily set the highlighted flag.  Plus clean up.

xP: make leaked non-unimportant messages advance the counter
for unimportant messages, so that the buffer doesn't get emboldened.
This commit is contained in:
Přemysl Eric Janouch 2022-09-28 16:25:16 +02:00
parent 4d99690b89
commit 5b57e9b41b
Signed by: p
GPG Key ID: A0420B94F92B9493
2 changed files with 16 additions and 20 deletions

34
xC.c
View File

@ -4612,35 +4612,31 @@ log_formatter (struct app_context *ctx, struct buffer *buffer,
&& buffer->type == BUFFER_SERVER) && buffer->type == BUFFER_SERVER)
|| (ctx->current_buffer->type != BUFFER_GLOBAL || (ctx->current_buffer->type != BUFFER_GLOBAL
&& buffer == ctx->current_buffer->server->buffer)) && buffer == ctx->current_buffer->server->buffer))
can_leak = true; can_leak = !ctx->isolate_buffers;
relay_prepare_buffer_line (ctx, buffer, line, bool leak_to_active = buffer != ctx->current_buffer && can_leak;
buffer != ctx->current_buffer && !ctx->isolate_buffers && can_leak); relay_prepare_buffer_line (ctx, buffer, line, leak_to_active);
relay_broadcast (ctx); relay_broadcast (ctx);
bool displayed = true; bool visible = (buffer == ctx->current_buffer || leak_to_active)
if (ctx->terminal_suspended > 0) && ctx->terminal_suspended <= 0;
// Another process is using the terminal
displayed = false;
else if (buffer == ctx->current_buffer)
buffer_line_display (ctx, buffer, line, false);
else if (!ctx->isolate_buffers && can_leak)
buffer_line_display (ctx, buffer, line, true);
else
displayed = false;
// Advance the unread marker in active buffers but don't create a new one // Advance the unread marker but don't create a new one
if (!displayed if (!visible || buffer->new_messages_count)
|| (buffer == ctx->current_buffer && buffer->new_messages_count))
{ {
buffer->new_messages_count++; buffer->new_messages_count++;
if (flags & BUFFER_LINE_UNIMPORTANT) if ((flags & BUFFER_LINE_UNIMPORTANT) || leak_to_active)
buffer->new_unimportant_count++; buffer->new_unimportant_count++;
buffer->highlighted |= important;
} }
if (!displayed)
if (visible)
buffer_line_display (ctx, buffer, line, leak_to_active);
else
{
buffer->highlighted |= important;
refresh_prompt (ctx); refresh_prompt (ctx);
} }
}
static void static void
log_full (struct app_context *ctx, struct server *s, struct buffer *buffer, log_full (struct app_context *ctx, struct server *s, struct buffer *buffer,

View File

@ -288,7 +288,7 @@ rpcEventHandlers.set(Relay.Event.BufferLine, e => {
b.lines.push({...line}) b.lines.push({...line})
if (!(visible || e.leakToActive) || if (!(visible || e.leakToActive) ||
b.newMessages || b.newUnimportantMessages) { b.newMessages || b.newUnimportantMessages) {
if (line.isUnimportant) if (line.isUnimportant || e.leakToActive)
b.newUnimportantMessages++ b.newUnimportantMessages++
else else
b.newMessages++ b.newMessages++