diff options
| author | Přemysl Eric Janouch <p@janouch.name> | 2022-09-10 18:58:55 +0200 | 
|---|---|---|
| committer | Přemysl Eric Janouch <p@janouch.name> | 2022-09-10 19:01:42 +0200 | 
| commit | 0015d26dc8a81ab17f4d84ebed3d0cce201e8e96 (patch) | |
| tree | 87a0f5fa15f65b937c0a6fbc6f1849b59d4311a8 | |
| parent | 7d5e63be1fd6602ab8e62316202924b316c7436f (diff) | |
| download | xK-0015d26dc8a81ab17f4d84ebed3d0cce201e8e96.tar.gz xK-0015d26dc8a81ab17f4d84ebed3d0cce201e8e96.tar.xz xK-0015d26dc8a81ab17f4d84ebed3d0cce201e8e96.zip  | |
xC/xP: support hiding unimportant messages at all
| -rw-r--r-- | xC-proto | 1 | ||||
| -rw-r--r-- | xC.c | 5 | ||||
| -rw-r--r-- | xP/public/xP.js | 11 | 
3 files changed, 13 insertions, 4 deletions
@@ -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. @@ -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;  } diff --git a/xP/public/xP.js b/xP/public/xP.js index 864323a..2e7732e 100644 --- a/xP/public/xP.js +++ b/xP/public/xP.js @@ -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),  		])  | 
