From 65b4aaa97d4d1a0c5346472995b522a167daecc7 Mon Sep 17 00:00:00 2001 From: Tor Hveem Date: Wed, 3 Aug 2016 15:05:25 +0200 Subject: [PATCH] Ability to pin buffers. Fixes #778. This introduces ability to pin buffers using localvar storage in WeeChat. At a later stage some UI should be introduced for this, like discussed in #604 . --- index.html | 13 ++++++++++++- js/glowingbear.js | 5 +++++ js/handlers.js | 1 + js/models.js | 6 +++++- 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index 11b6eb5..e948af9 100644 --- a/index.html +++ b/index.html @@ -152,10 +152,21 @@
  • ALT-<: Switch to previous active buffer
  • ALT-g: Focus on buffer list filter
  • Esc-Esc: Disconnect (double-tap)
  • -
  • Arrow keys: Navigate history
  • +
  • Arrow keys: Navigate history, or navigate quick search buffer results.
  • Tab: Complete nick
  • The following readline/emacs style keybindings can be enabled with a setting: Ctrl-a, Ctrl-e, Ctrl-u, Ctrl-k, Ctrl-w
  • +

    Pinning buffers

    +

    + The option "Only show buffers with unread messages" is useful when you have a lot of buffers and cant meaningfully look at all of them at the same time. However, often you have a select few buffers that you use more frequently and would like to have displayed permanently. +

    +

    + To pin a buffer, type /buffer set localvar_set_pinned true. Note: Local variables on buffers are not persisted across WeeChat restarts, so either use script buffer_autoset.py to automatically apply that upon buffer creation or use a trigger if you want automatic repinning when buffer gets recreated. To unpin you can use the same command and set anything other than true. +

    +

    + Helpful trigger for automatically repin buffer: /trigger add autopin signal "buffer_opened" "${buffer[${tg_signal_data}].full_name} =~ irc.freenode.#weechat" "" "/command -buffer ${buffer[${tg_signal_data}].full_name} * /buffer set localvar_set_pinned true" +

    + diff --git a/js/glowingbear.js b/js/glowingbear.js index c4bda15..0ebca25 100644 --- a/js/glowingbear.js +++ b/js/glowingbear.js @@ -680,6 +680,11 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', if (buffer.fullName === "core.weechat" || (settings.orderbyserver && buffer.type === 'server')) { return true; } + + // Always show pinned buffers + if (buffer.pinned) { + return true; + } return (buffer.unread > 0 || buffer.notification > 0) && !buffer.hidden; } return !buffer.hidden; diff --git a/js/handlers.js b/js/handlers.js index f87376d..2867d8e 100644 --- a/js/handlers.js +++ b/js/handlers.js @@ -306,6 +306,7 @@ weechat.factory('handlers', ['$rootScope', '$log', 'models', 'plugins', 'notific old.server = localvars.server; old.serverSortKey = old.plugin + "." + old.server + (old.type === "server" ? "" : ("." + old.shortName)); + old.pinned = localvars.pinned === "true"; } }; diff --git a/js/models.js b/js/models.js index ba091c6..d650f30 100644 --- a/js/models.js +++ b/js/models.js @@ -95,6 +95,9 @@ models.service('models', ['$rootScope', '$filter', 'bufferResume', function($roo var plugin = message.local_variables.plugin; var server = message.local_variables.server; + + var pinned = message.local_variables.pinned === "true"; + // Server buffers have this "irc.server.freenode" naming schema, which // messes the sorting up. We need it to be "irc.freenode" instead. var serverSortKey = plugin + "." + server + @@ -335,7 +338,8 @@ models.service('models', ['$rootScope', '$filter', 'bufferResume', function($roo getHistoryUp: getHistoryUp, getHistoryDown: getHistoryDown, isNicklistEmpty: isNicklistEmpty, - nicklistRequested: nicklistRequested + nicklistRequested: nicklistRequested, + pinned: pinned, }; };