From 71252fb4d548311ed5063583e538ee303b48d640 Mon Sep 17 00:00:00 2001 From: Daniel Kessler Date: Thu, 4 Oct 2018 23:50:09 -0700 Subject: [PATCH] Handle buffer_moved --- js/handlers.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/js/handlers.js b/js/handlers.js index 2867d8e..08978d0 100644 --- a/js/handlers.js +++ b/js/handlers.js @@ -277,6 +277,27 @@ weechat.factory('handlers', ['$rootScope', '$log', 'models', 'plugins', 'notific } }; + var handleBufferMoved = function(message) { + var obj = message.objects[0].content[0]; + var buffer = obj.pointers[0]; + var old = models.getBuffer(buffer); + + var old_number = old.number; + var new_number = obj.number; + + _.each(models.getBuffers(), function(buffer) { + if (buffer.number > old_number && buffer.number <= new_number) { + buffer.number -= 1; + } + + if (buffer.number < old_number && buffer.number >= new_number) { + buffer.number += 1; + } + }); + + old.number = new_number; + } + var handleBufferHidden = function(message) { var obj = message.objects[0].content[0]; var buffer = obj.pointers[0]; @@ -438,6 +459,7 @@ weechat.factory('handlers', ['$rootScope', '$log', 'models', 'plugins', 'notific _buffer_localvar_added: handleBufferLocalvarChanged, _buffer_localvar_removed: handleBufferLocalvarChanged, _buffer_localvar_changed: handleBufferLocalvarChanged, + _buffer_moved: handleBufferMoved, _buffer_opened: handleBufferOpened, _buffer_title_changed: handleBufferTitleChanged, _buffer_type_changed: handleBufferTypeChanged,