From dc248b8840b1d6b8fdce1f4e7dced7fa6b06ae72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=99emysl=20Janouch?= Date: Tue, 8 Mar 2016 22:27:59 +0100 Subject: [PATCH] degesch: add goto activity and highlight --- NEWS | 3 +++ degesch.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/NEWS b/NEWS index aad76d2..047c527 100644 --- a/NEWS +++ b/NEWS @@ -18,6 +18,9 @@ * degesch: added logging of messages sent from /quote and plugins + * degesch: M-! and M-@ to go to the next buffer in order with + a highlight or new activity respectively + * kike: add support for IRCv3.2 server-time * ZyklonB: plugins now run in a dedicated data directory diff --git a/degesch.c b/degesch.c index c433733..29909d5 100644 --- a/degesch.c +++ b/degesch.c @@ -11758,6 +11758,45 @@ on_switch_buffer (int count, int key, void *user_data) return true; } +static bool +on_goto_highlight (int count, int key, void *user_data) +{ + (void) count; + (void) key; + + struct app_context *ctx = user_data; + struct buffer *new_buffer = ctx->current_buffer; + while (!new_buffer->highlighted) + { + if (!(new_buffer = new_buffer->next)) + new_buffer = ctx->buffers; + if (new_buffer == ctx->current_buffer) + return false; + } + buffer_activate (ctx, new_buffer); + return true; +} + +static bool +on_goto_activity (int count, int key, void *user_data) +{ + (void) count; + (void) key; + + struct app_context *ctx = user_data; + struct buffer *new_buffer = ctx->current_buffer; + while (new_buffer->unseen_messages_count + == new_buffer->unseen_unimportant_count) + { + if (!(new_buffer = new_buffer->next)) + new_buffer = ctx->buffers; + if (new_buffer == ctx->current_buffer) + return false; + } + buffer_activate (ctx, new_buffer); + return true; +} + static bool on_redraw_screen (int count, int key, void *user_data) { @@ -11799,6 +11838,8 @@ bind_common_keys (struct app_context *ctx) XX ("next-buffer", "Next buffer", on_next_buffer) XX ("goto-buffer", "Go to buffer", on_goto_buffer) XX ("switch-buffer", "Switch buffer", on_switch_buffer) + XX ("goto-highlight", "Go to highlight", on_goto_highlight) + XX ("goto-activity", "Go to activity", on_goto_activity) XX ("display-backlog", "Show backlog", on_display_backlog) XX ("display-full-log", "Show full log", on_display_full_log) XX ("edit-input", "Edit input", on_edit_input) @@ -11815,6 +11856,8 @@ bind_common_keys (struct app_context *ctx) CALL_ (self, bind_meta, '0' + i, "goto-buffer"); CALL_ (self, bind_meta, '\t', "switch-buffer"); + CALL_ (self, bind_meta, '!', "goto-highlight"); + CALL_ (self, bind_meta, '@', "goto-activity"); CALL_ (self, bind_meta, 'm', "insert-attribute"); CALL_ (self, bind_meta, 'h', "display-full-log"); CALL_ (self, bind_meta, 'e', "edit-input");