|
|
|
@ -251,40 +251,47 @@ weechat.directive('inputBar', function() { |
|
|
|
|
var filteredBufferNum; |
|
|
|
|
var activeBufferId; |
|
|
|
|
|
|
|
|
|
// if Alt+J was pressed last, we expect two numbers now
|
|
|
|
|
if ($rootScope.showJumpKeys && !$event.altKey && (code > 47 && code < 58) && $scope.jumpDecimal === undefined) { |
|
|
|
|
$scope.jumpDecimal = code - 48; |
|
|
|
|
$event.preventDefault(); |
|
|
|
|
} else if ($rootScope.showJumpKeys && !$event.altKey && (code > 47 && code < 58) && $scope.jumpDecimal !== undefined) { |
|
|
|
|
bufferNumber = ($scope.jumpDecimal * 10) + (code - 48) - 1; |
|
|
|
|
// quick select filtered entries
|
|
|
|
|
if (($scope.$parent.search.length || $scope.$parent.onlyUnread) && $scope.$parent.filteredBuffers.length) { |
|
|
|
|
filteredBufferNum = $scope.$parent.filteredBuffers[bufferNumber]; |
|
|
|
|
if (filteredBufferNum !== undefined) { |
|
|
|
|
activeBufferId = [filteredBufferNum.number, filteredBufferNum.id]; |
|
|
|
|
// if Alt+J was pressed last...
|
|
|
|
|
if ($rootScope.showJumpKeys) { |
|
|
|
|
// ... we expect two digits now
|
|
|
|
|
if (!$event.altKey && (code > 47 && code < 58)) { |
|
|
|
|
// first digit
|
|
|
|
|
if ($scope.jumpDecimal === undefined) { |
|
|
|
|
$scope.jumpDecimal = code - 48; |
|
|
|
|
$event.preventDefault(); |
|
|
|
|
// second digit
|
|
|
|
|
} else { |
|
|
|
|
bufferNumber = ($scope.jumpDecimal * 10) + (code - 48) - 1; |
|
|
|
|
// quick select filtered entries
|
|
|
|
|
if (($scope.$parent.search.length || $scope.$parent.onlyUnread) && $scope.$parent.filteredBuffers.length) { |
|
|
|
|
filteredBufferNum = $scope.$parent.filteredBuffers[bufferNumber]; |
|
|
|
|
if (filteredBufferNum !== undefined) { |
|
|
|
|
activeBufferId = [filteredBufferNum.number, filteredBufferNum.id]; |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
// Map the buffers to only their numbers and IDs so we don't have to
|
|
|
|
|
// copy the entire (possibly very large) buffer object, and then sort
|
|
|
|
|
// the buffers according to their WeeChat number
|
|
|
|
|
sortedBuffers = _.map(models.getBuffers(), function (buffer) { |
|
|
|
|
return [buffer.number, buffer.id]; |
|
|
|
|
}).sort(function (left, right) { |
|
|
|
|
// By default, Array.prototype.sort() sorts alphabetically.
|
|
|
|
|
// Pass an ordering function to sort by first element.
|
|
|
|
|
return left[0] - right[0]; |
|
|
|
|
}); |
|
|
|
|
activeBufferId = sortedBuffers[bufferNumber]; |
|
|
|
|
} |
|
|
|
|
if (activeBufferId) { |
|
|
|
|
$scope.$parent.setActiveBuffer(activeBufferId[1]); |
|
|
|
|
} |
|
|
|
|
$event.preventDefault(); |
|
|
|
|
$rootScope.showJumpKeys = false; |
|
|
|
|
$scope.jumpDecimal = undefined; |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
// Map the buffers to only their numbers and IDs so we don't have to
|
|
|
|
|
// copy the entire (possibly very large) buffer object, and then sort
|
|
|
|
|
// the buffers according to their WeeChat number
|
|
|
|
|
sortedBuffers = _.map(models.getBuffers(), function(buffer) { |
|
|
|
|
return [buffer.number, buffer.id]; |
|
|
|
|
}).sort(function(left, right) { |
|
|
|
|
// By default, Array.prototype.sort() sorts alphabetically.
|
|
|
|
|
// Pass an ordering function to sort by first element.
|
|
|
|
|
return left[0] - right[0]; |
|
|
|
|
}); |
|
|
|
|
activeBufferId = sortedBuffers[bufferNumber]; |
|
|
|
|
$rootScope.showJumpKeys = false; |
|
|
|
|
$scope.jumpDecimal = undefined; |
|
|
|
|
} |
|
|
|
|
if (activeBufferId) { |
|
|
|
|
$scope.$parent.setActiveBuffer(activeBufferId[1]); |
|
|
|
|
} |
|
|
|
|
$event.preventDefault(); |
|
|
|
|
$rootScope.showJumpKeys = false; |
|
|
|
|
$scope.jumpDecimal = undefined; |
|
|
|
|
} else { |
|
|
|
|
$rootScope.showJumpKeys = false; |
|
|
|
|
$scope.jumpDecimal = undefined; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Left Alt+[0-9] -> jump to buffer
|
|
|
|
@ -414,9 +421,7 @@ weechat.directive('inputBar', function() { |
|
|
|
|
// Alt+J -> Jump to buffer
|
|
|
|
|
if ($event.altKey && (code === 106 || code === 74)) { |
|
|
|
|
$event.preventDefault(); |
|
|
|
|
|
|
|
|
|
$rootScope.showJumpKeys = true; |
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|