xC/xP: support hiding unimportant messages at all
This commit is contained in:
parent
7d5e63be1f
commit
0015d26dc8
1
xC-proto
1
xC-proto
@ -63,6 +63,7 @@ struct EventMessage {
|
||||
void;
|
||||
case BUFFER_UPDATE:
|
||||
string buffer_name;
|
||||
bool hide_unimportant;
|
||||
case BUFFER_STATS:
|
||||
string buffer_name;
|
||||
// These are cumulative, even for lines flushed out from buffers.
|
||||
|
5
xC.c
5
xC.c
@ -3068,6 +3068,7 @@ relay_prepare_buffer_update (struct app_context *ctx, struct buffer *buffer)
|
||||
struct relay_event_data_buffer_update *e = &m->data.buffer_update;
|
||||
e->event = RELAY_EVENT_BUFFER_UPDATE;
|
||||
e->buffer_name = str_from_cstr (buffer->name);
|
||||
e->hide_unimportant = buffer->hide_unimportant;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -14202,6 +14203,10 @@ on_toggle_unimportant (int count, int key, void *user_data)
|
||||
(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);
|
||||
return true;
|
||||
}
|
||||
|
@ -171,6 +171,7 @@ rpc.addEventListener('BufferUpdate', event => {
|
||||
buffers.set(e.bufferName, (b = {lines: []}))
|
||||
resetBufferStats(b)
|
||||
}
|
||||
b.hideUnimportant = e.hideUnimportant
|
||||
})
|
||||
|
||||
rpc.addEventListener('BufferStats', event => {
|
||||
@ -465,6 +466,11 @@ let Buffer = {
|
||||
let markBefore = b.lines.length
|
||||
- b.newMessages - b.newUnimportantMessages
|
||||
b.lines.forEach((line, i) => {
|
||||
if (i == markBefore)
|
||||
lines.push(m('.unread'))
|
||||
if (line.isUnimportant && b.hideUnimportant)
|
||||
return
|
||||
|
||||
let date = new Date(line.when)
|
||||
let dateMark = date.toLocaleDateString()
|
||||
if (dateMark !== lastDateMark) {
|
||||
@ -472,14 +478,10 @@ let Buffer = {
|
||||
lastDateMark = dateMark
|
||||
}
|
||||
|
||||
if (i == markBefore)
|
||||
lines.push(m('.unread'))
|
||||
|
||||
let attrs = {}
|
||||
if (line.leaked)
|
||||
attrs.class = 'leaked'
|
||||
|
||||
// TODO: Make use of isUnimportant.
|
||||
lines.push(m('.time', {...attrs}, date.toLocaleTimeString()))
|
||||
lines.push(m(Content, {...attrs}, line))
|
||||
})
|
||||
@ -604,6 +606,7 @@ let Main = {
|
||||
return m('.xP', {}, [
|
||||
m('.title', {}, [`xP (${state})`, m(Toolbar)]),
|
||||
m('.middle', {}, [m(BufferList), m(BufferContainer)]),
|
||||
// TODO: Indicate hideUnimportant.
|
||||
m('.status', {}, bufferCurrent),
|
||||
m(Input),
|
||||
])
|
||||
|
Loading…
Reference in New Issue
Block a user