Merge pull request #691 from 20after4/switch-to-adjacent-buffers

Switch to adjacent buffer with alt+arrow up/down
This commit is contained in:
Lorenz Hübschle-Schneider 2015-12-04 15:46:56 +01:00
commit 73123fd0dd
3 changed files with 21 additions and 1 deletions

View file

@ -727,6 +727,18 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
settings.nonicklist = !settings.nonicklist; settings.nonicklist = !settings.nonicklist;
}; };
$rootScope.switchToAdjacentBuffer = function(direction) {
// direction is +1 for next buffer, -1 for previous buffer
var sortedBuffers = _.sortBy($scope.getBuffers(), $rootScope.predicate);
var activeBuffer = models.getActiveBuffer();
var index = sortedBuffers.indexOf(activeBuffer);
if (index >= 0) {
var newBuffer = sortedBuffers[index + direction];
if (newBuffer) {
$scope.setActiveBuffer(newBuffer.id);
}
}
};
$scope.handleSearchBoxKey = function($event) { $scope.handleSearchBoxKey = function($event) {
// Support different browser quirks // Support different browser quirks

View file

@ -294,6 +294,14 @@ weechat.directive('inputBar', function() {
return true; return true;
} }
// Alt+Arrow up/down -> switch to prev/next adjacent buffer
if ($event.altKey && !$event.ctrlKey && (code === 38 || code === 40)) {
$event.preventDefault();
var direction = code - 39;
$rootScope.switchToAdjacentBuffer(direction);
return true;
}
// Alt+L -> focus on input bar // Alt+L -> focus on input bar
if ($event.altKey && (code === 76 || code === 108)) { if ($event.altKey && (code === 76 || code === 108)) {
$event.preventDefault(); $event.preventDefault();

View file

@ -84,7 +84,7 @@ models.service('models', ['$rootScope', '$filter', function($rootScope, $filter)
var notification = 0; var notification = 0;
var unread = 0; var unread = 0;
var lastSeen = -1; var lastSeen = -1;
var serverSortKey = fullName.replace(/^irc\.server\.(\w+)/, "irc.$1"); var serverSortKey = fullName.replace(/^irc\.server\.(\w+)/, "irc.$1").toLowerCase();
// There are two kinds of types: bufferType (free vs formatted) and // There are two kinds of types: bufferType (free vs formatted) and
// the kind of type that distinguishes queries from channels etc // the kind of type that distinguishes queries from channels etc
var bufferType = message.type; var bufferType = message.type;