diff options
-rw-r--r-- | xC-proto | 14 | ||||
-rw-r--r-- | xC.c | 32 | ||||
-rw-r--r-- | xP/public/xP.js | 8 |
3 files changed, 39 insertions, 15 deletions
@@ -9,24 +9,28 @@ struct CommandMessage { union CommandData switch (enum Command { HELLO, ACTIVE, - BUFFER_INPUT, BUFFER_ACTIVATE, + BUFFER_INPUT, + BUFFER_TOGGLE_UNIMPORTANT, PING_RESPONSE, PING, BUFFER_COMPLETE, BUFFER_LOG, } command) { + // If the version check succeeds, the client will receive + // an initial stream of SERVER_UPDATE, BUFFER_UPDATE, BUFFER_STATS, + // BUFFER_LINE, and finally a BUFFER_ACTIVATE message. case HELLO: u32 version; - // If the version check succeeds, the client will receive - // an initial stream of SERVER_UPDATE, BUFFER_UPDATE, BUFFER_STATS, - // BUFFER_LINE, and finally a BUFFER_ACTIVATE message. case ACTIVE: void; + case BUFFER_ACTIVATE: + string buffer_name; case BUFFER_INPUT: string buffer_name; string text; - case BUFFER_ACTIVATE: + // XXX: Perhaps this should rather be handled through a /buffer command. + case BUFFER_TOGGLE_UNIMPORTANT: string buffer_name; case PING_RESPONSE: u32 event_seq; @@ -5235,6 +5235,18 @@ buffer_clear (struct app_context *ctx, struct buffer *buffer) buffer->lines_count = 0; } +static void +buffer_toggle_unimportant (struct app_context *ctx, struct buffer *buffer) +{ + buffer->hide_unimportant ^= true; + + relay_prepare_buffer_update (ctx, buffer); + relay_broadcast (ctx); + + if (buffer == ctx->current_buffer) + buffer_print_backlog (ctx, buffer); +} + static struct buffer * buffer_at_index (struct app_context *ctx, int n) { @@ -14372,12 +14384,7 @@ on_toggle_unimportant (int count, int key, void *user_data) (void) count; (void) key; struct app_context *ctx = user_data; - ctx->current_buffer->hide_unimportant ^= true; - - relay_prepare_buffer_update (ctx, ctx->current_buffer); - relay_broadcast (ctx); - - buffer_print_backlog (ctx, ctx->current_buffer); + buffer_toggle_unimportant (ctx, ctx->current_buffer); return true; } @@ -15444,10 +15451,12 @@ client_message_buffer_name (const struct relay_command_message *m) { case RELAY_COMMAND_BUFFER_COMPLETE: return m->data.buffer_input.buffer_name.str; - case RELAY_COMMAND_BUFFER_INPUT: - return m->data.buffer_input.buffer_name.str; case RELAY_COMMAND_BUFFER_ACTIVATE: return m->data.buffer_activate.buffer_name.str; + case RELAY_COMMAND_BUFFER_INPUT: + return m->data.buffer_input.buffer_name.str; + case RELAY_COMMAND_BUFFER_TOGGLE_UNIMPORTANT: + return m->data.buffer_toggle_unimportant.buffer_name.str; case RELAY_COMMAND_BUFFER_LOG: return m->data.buffer_log.buffer_name.str; default: @@ -15573,11 +15582,14 @@ client_process_message (struct client *c, client_process_buffer_complete (c, m->command_seq, buffer, &m->data.buffer_complete); break; + case RELAY_COMMAND_BUFFER_ACTIVATE: + buffer_activate (c->ctx, buffer); + break; case RELAY_COMMAND_BUFFER_INPUT: process_input (c->ctx, buffer, m->data.buffer_input.text.str); break; - case RELAY_COMMAND_BUFFER_ACTIVATE: - buffer_activate (c->ctx, buffer); + case RELAY_COMMAND_BUFFER_TOGGLE_UNIMPORTANT: + buffer_toggle_unimportant (c->ctx, buffer); break; case RELAY_COMMAND_BUFFER_LOG: client_process_buffer_log (c, m->command_seq, buffer); diff --git a/xP/public/xP.js b/xP/public/xP.js index 1362e22..a5f1218 100644 --- a/xP/public/xP.js +++ b/xP/public/xP.js @@ -194,6 +194,10 @@ function bufferActivate(name) { rpc.send({command: 'BufferActivate', bufferName: name}) } +function bufferToggleUnimportant(name) { + rpc.send({command: 'BufferToggleUnimportant', bufferName: name}) +} + function bufferToggleLog() { if (bufferLog) { setTimeout(() => @@ -860,6 +864,10 @@ document.addEventListener('keydown', event => { case 'h': bufferToggleLog() break + case 'H': + if (bufferCurrent !== undefined) + bufferToggleUnimportant(bufferCurrent) + break case 'a': for (const name of names.slice(1)) if (buffers.get(name).newMessages) { |