diff options
author | Přemysl Eric Janouch <p@janouch.name> | 2022-09-07 15:33:38 +0200 |
---|---|---|
committer | Přemysl Eric Janouch <p@janouch.name> | 2022-09-07 15:34:52 +0200 |
commit | 2341228efd02bcd4c99214885a5214826bfffa5c (patch) | |
tree | edab812d3e72c6b6e689db704c4ffb4dfbdbae0d | |
parent | 2e3005d88b6ee65689f5cf71905b014a56523160 (diff) | |
download | xK-2341228efd02bcd4c99214885a5214826bfffa5c.tar.gz xK-2341228efd02bcd4c99214885a5214826bfffa5c.tar.xz xK-2341228efd02bcd4c99214885a5214826bfffa5c.zip |
xP: implement buffer line leakage
Rather than on redisplay, these get cleared on reconnect.
-rw-r--r-- | xC-proto | 1 | ||||
-rw-r--r-- | xC.c | 14 | ||||
-rw-r--r-- | xP/public/xP.css | 3 | ||||
-rw-r--r-- | xP/public/xP.js | 20 |
4 files changed, 25 insertions, 13 deletions
@@ -60,6 +60,7 @@ struct EventMessage { string buffer_name; case BUFFER_LINE: string buffer_name; + bool leak_to_active; bool is_unimportant; bool is_highlight; enum Rendition { @@ -3097,7 +3097,7 @@ relay_prepare_buffer_activate (struct app_context *ctx, struct buffer *buffer) static void relay_prepare_buffer_line (struct app_context *ctx, struct buffer *buffer, - struct buffer_line *line) + struct buffer_line *line, bool leak_to_active) { struct relay_event_message *m = relay_prepare (ctx); struct relay_event_data_buffer_line *e = &m->data.buffer_line; @@ -3107,6 +3107,7 @@ relay_prepare_buffer_line (struct app_context *ctx, struct buffer *buffer, e->is_highlight = !!(line->flags & BUFFER_LINE_HIGHLIGHT); e->rendition = 1 + line->r; e->when = line->when * 1000; + e->leak_to_active = leak_to_active; size_t len = 0; for (size_t i = 0; line->items[i].type; i++) @@ -4588,9 +4589,6 @@ log_formatter (struct app_context *ctx, struct buffer *buffer, if (buffer->log_file) buffer_line_write_to_log (ctx, line, buffer->log_file); - relay_prepare_buffer_line (ctx, buffer, line); - relay_broadcast (ctx); - bool unseen_pm = buffer->type == BUFFER_PM && buffer != ctx->current_buffer && !(flags & BUFFER_LINE_UNIMPORTANT); @@ -4607,6 +4605,10 @@ log_formatter (struct app_context *ctx, struct buffer *buffer, && buffer == ctx->current_buffer->server->buffer)) can_leak = true; + relay_prepare_buffer_line + (ctx, buffer, line, can_leak && !ctx->isolate_buffers); + relay_broadcast (ctx); + bool displayed = true; if (ctx->terminal_suspended > 0) // Another process is using the terminal @@ -5011,7 +5013,7 @@ buffer_merge (struct app_context *ctx, // And since there is no log_*() call, send them to relays manually LIST_FOR_EACH (struct buffer_line, line, start) { - relay_prepare_buffer_line (ctx, buffer, line); + relay_prepare_buffer_line (ctx, buffer, line, false); relay_broadcast (ctx); } @@ -15166,7 +15168,7 @@ client_resync (struct client *c) LIST_FOR_EACH (struct buffer_line, line, buffer->lines) { - relay_prepare_buffer_line (c->ctx, buffer, line); + relay_prepare_buffer_line (c->ctx, buffer, line, false); relay_send (c); } } diff --git a/xP/public/xP.css b/xP/public/xP.css index 77e89fc..05badb0 100644 --- a/xP/public/xP.css +++ b/xP/public/xP.css @@ -63,6 +63,9 @@ body { overflow-y: auto; } +.leaked { + opacity: 50%; +} .date { padding: .3rem; grid-column: span 2; diff --git a/xP/public/xP.js b/xP/public/xP.js index 7bcfeb2..1322a9b 100644 --- a/xP/public/xP.js +++ b/xP/public/xP.js @@ -195,10 +195,12 @@ rpc.addEventListener('BufferActivate', event => { }) rpc.addEventListener('BufferLine', event => { - let e = event.detail, b = buffers.get(e.bufferName) - if (b === undefined) - return - b.lines.push({when: e.when, rendition: e.rendition, items: e.items}) + let e = event.detail, b = buffers.get(e.bufferName), + line = {when: e.when, rendition: e.rendition, items: e.items} + if (b !== undefined) + b.lines.push({...line}) + if (e.leakToActive && (b = buffers.get(bufferCurrent)) !== undefined) + b.lines.push({leaked: true, ...line}) }) rpc.addEventListener('BufferClear', event => { @@ -327,7 +329,7 @@ let Content = { classes.add(c) } let fg = -1, bg = -1, inverse = false - return m('.content', {}, [mark, line.items.flatMap(item => { + return m('.content', vnode.attrs, [mark, line.items.flatMap(item => { switch (item.kind) { case 'Text': return Content.linkify(item.text, { @@ -393,8 +395,12 @@ let Buffer = { lastDateMark = dateMark } - lines.push(m('.time', {}, date.toLocaleTimeString())) - lines.push(m(Content, {}, line)) + let attrs = {} + if (line.leaked) + attrs.class = 'leaked' + + lines.push(m('.time', {...attrs}, date.toLocaleTimeString())) + lines.push(m(Content, {...attrs}, line)) }) return m('.buffer', {}, lines) }, |