xC/xP: implement M-H in the web frontend
This commit is contained in:
parent
ee76186bef
commit
d5153fe354
14
xC-proto
14
xC-proto
@ -9,24 +9,28 @@ struct CommandMessage {
|
|||||||
union CommandData switch (enum Command {
|
union CommandData switch (enum Command {
|
||||||
HELLO,
|
HELLO,
|
||||||
ACTIVE,
|
ACTIVE,
|
||||||
BUFFER_INPUT,
|
|
||||||
BUFFER_ACTIVATE,
|
BUFFER_ACTIVATE,
|
||||||
|
BUFFER_INPUT,
|
||||||
|
BUFFER_TOGGLE_UNIMPORTANT,
|
||||||
PING_RESPONSE,
|
PING_RESPONSE,
|
||||||
PING,
|
PING,
|
||||||
BUFFER_COMPLETE,
|
BUFFER_COMPLETE,
|
||||||
BUFFER_LOG,
|
BUFFER_LOG,
|
||||||
} command) {
|
} 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:
|
case HELLO:
|
||||||
u32 version;
|
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:
|
case ACTIVE:
|
||||||
void;
|
void;
|
||||||
|
case BUFFER_ACTIVATE:
|
||||||
|
string buffer_name;
|
||||||
case BUFFER_INPUT:
|
case BUFFER_INPUT:
|
||||||
string buffer_name;
|
string buffer_name;
|
||||||
string text;
|
string text;
|
||||||
case BUFFER_ACTIVATE:
|
// XXX: Perhaps this should rather be handled through a /buffer command.
|
||||||
|
case BUFFER_TOGGLE_UNIMPORTANT:
|
||||||
string buffer_name;
|
string buffer_name;
|
||||||
case PING_RESPONSE:
|
case PING_RESPONSE:
|
||||||
u32 event_seq;
|
u32 event_seq;
|
||||||
|
32
xC.c
32
xC.c
@ -5235,6 +5235,18 @@ buffer_clear (struct app_context *ctx, struct buffer *buffer)
|
|||||||
buffer->lines_count = 0;
|
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 *
|
static struct buffer *
|
||||||
buffer_at_index (struct app_context *ctx, int n)
|
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) count;
|
||||||
(void) key;
|
(void) key;
|
||||||
struct app_context *ctx = user_data;
|
struct app_context *ctx = user_data;
|
||||||
ctx->current_buffer->hide_unimportant ^= true;
|
buffer_toggle_unimportant (ctx, ctx->current_buffer);
|
||||||
|
|
||||||
relay_prepare_buffer_update (ctx, ctx->current_buffer);
|
|
||||||
relay_broadcast (ctx);
|
|
||||||
|
|
||||||
buffer_print_backlog (ctx, ctx->current_buffer);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -15444,10 +15451,12 @@ client_message_buffer_name (const struct relay_command_message *m)
|
|||||||
{
|
{
|
||||||
case RELAY_COMMAND_BUFFER_COMPLETE:
|
case RELAY_COMMAND_BUFFER_COMPLETE:
|
||||||
return m->data.buffer_input.buffer_name.str;
|
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:
|
case RELAY_COMMAND_BUFFER_ACTIVATE:
|
||||||
return m->data.buffer_activate.buffer_name.str;
|
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:
|
case RELAY_COMMAND_BUFFER_LOG:
|
||||||
return m->data.buffer_log.buffer_name.str;
|
return m->data.buffer_log.buffer_name.str;
|
||||||
default:
|
default:
|
||||||
@ -15573,11 +15582,14 @@ client_process_message (struct client *c,
|
|||||||
client_process_buffer_complete (c, m->command_seq, buffer,
|
client_process_buffer_complete (c, m->command_seq, buffer,
|
||||||
&m->data.buffer_complete);
|
&m->data.buffer_complete);
|
||||||
break;
|
break;
|
||||||
|
case RELAY_COMMAND_BUFFER_ACTIVATE:
|
||||||
|
buffer_activate (c->ctx, buffer);
|
||||||
|
break;
|
||||||
case RELAY_COMMAND_BUFFER_INPUT:
|
case RELAY_COMMAND_BUFFER_INPUT:
|
||||||
process_input (c->ctx, buffer, m->data.buffer_input.text.str);
|
process_input (c->ctx, buffer, m->data.buffer_input.text.str);
|
||||||
break;
|
break;
|
||||||
case RELAY_COMMAND_BUFFER_ACTIVATE:
|
case RELAY_COMMAND_BUFFER_TOGGLE_UNIMPORTANT:
|
||||||
buffer_activate (c->ctx, buffer);
|
buffer_toggle_unimportant (c->ctx, buffer);
|
||||||
break;
|
break;
|
||||||
case RELAY_COMMAND_BUFFER_LOG:
|
case RELAY_COMMAND_BUFFER_LOG:
|
||||||
client_process_buffer_log (c, m->command_seq, buffer);
|
client_process_buffer_log (c, m->command_seq, buffer);
|
||||||
|
@ -194,6 +194,10 @@ function bufferActivate(name) {
|
|||||||
rpc.send({command: 'BufferActivate', bufferName: name})
|
rpc.send({command: 'BufferActivate', bufferName: name})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function bufferToggleUnimportant(name) {
|
||||||
|
rpc.send({command: 'BufferToggleUnimportant', bufferName: name})
|
||||||
|
}
|
||||||
|
|
||||||
function bufferToggleLog() {
|
function bufferToggleLog() {
|
||||||
if (bufferLog) {
|
if (bufferLog) {
|
||||||
setTimeout(() =>
|
setTimeout(() =>
|
||||||
@ -860,6 +864,10 @@ document.addEventListener('keydown', event => {
|
|||||||
case 'h':
|
case 'h':
|
||||||
bufferToggleLog()
|
bufferToggleLog()
|
||||||
break
|
break
|
||||||
|
case 'H':
|
||||||
|
if (bufferCurrent !== undefined)
|
||||||
|
bufferToggleUnimportant(bufferCurrent)
|
||||||
|
break
|
||||||
case 'a':
|
case 'a':
|
||||||
for (const name of names.slice(1))
|
for (const name of names.slice(1))
|
||||||
if (buffers.get(name).newMessages) {
|
if (buffers.get(name).newMessages) {
|
||||||
|
Loading…
Reference in New Issue
Block a user