add pgup/pgdn keys and fix history in multiline edits
This commit is contained in:
parent
38be11fd24
commit
a63150e697
1 changed files with 42 additions and 3 deletions
|
@ -240,8 +240,14 @@ weechat.directive('inputBar', function() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var caretPos;
|
||||||
|
|
||||||
// Arrow up -> go up in history
|
// Arrow up -> go up in history
|
||||||
if ($event.type === "keydown" && code === 38) {
|
if ($event.type === "keydown" && code === 38 && document.activeElement === inputNode) {
|
||||||
|
caretPos = inputNode.selectionStart;
|
||||||
|
if ($scope.command.slice(0, caretPos).indexOf("\n") !== -1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
$scope.command = models.getActiveBuffer().getHistoryUp($scope.command);
|
$scope.command = models.getActiveBuffer().getHistoryUp($scope.command);
|
||||||
// Set cursor to last position. Need 0ms timeout because browser sets cursor
|
// Set cursor to last position. Need 0ms timeout because browser sets cursor
|
||||||
// position to the beginning after this key handler returns.
|
// position to the beginning after this key handler returns.
|
||||||
|
@ -254,7 +260,11 @@ weechat.directive('inputBar', function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Arrow down -> go down in history
|
// Arrow down -> go down in history
|
||||||
if ($event.type === "keydown" && code === 40) {
|
if ($event.type === "keydown" && code === 40 && document.activeElement === inputNode) {
|
||||||
|
caretPos = inputNode.selectionStart;
|
||||||
|
if ($scope.command.slice(caretPos).indexOf("\n") !== -1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
$scope.command = models.getActiveBuffer().getHistoryDown($scope.command);
|
$scope.command = models.getActiveBuffer().getHistoryDown($scope.command);
|
||||||
// We don't need to set the cursor to the rightmost position here, the browser does that for us
|
// We don't need to set the cursor to the rightmost position here, the browser does that for us
|
||||||
return true;
|
return true;
|
||||||
|
@ -266,10 +276,39 @@ weechat.directive('inputBar', function() {
|
||||||
$scope.sendMessage();
|
$scope.sendMessage();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var bufferlines = document.getElementById("bufferlines");
|
||||||
|
var lines;
|
||||||
|
var i;
|
||||||
|
|
||||||
|
// Page up -> scroll up
|
||||||
|
if ($event.type === "keydown" && code === 33 && document.activeElement === inputNode && !$event.ctrlKey && !$event.altKey && !$event.shiftKey) {
|
||||||
|
lines = bufferlines.querySelectorAll("tr");
|
||||||
|
for (i = lines.length - 1; i >= 0; i--) {
|
||||||
|
if ((lines[i].offsetTop-bufferlines.scrollTop)<bufferlines.clientHeight/2) {
|
||||||
|
lines[i].scrollIntoView(false);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Page down -> scroll down
|
||||||
|
if ($event.type === "keydown" && code === 34 && document.activeElement === inputNode && !$event.ctrlKey && !$event.altKey && !$event.shiftKey) {
|
||||||
|
lines = bufferlines.querySelectorAll("tr");
|
||||||
|
for (i = 0; i < lines.length; i++) {
|
||||||
|
if ((lines[i].offsetTop-bufferlines.scrollTop)>bufferlines.clientHeight/2) {
|
||||||
|
lines[i].scrollIntoView(true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// Some readline keybindings
|
// Some readline keybindings
|
||||||
if ($rootScope.readlineBindings && $event.ctrlKey && !$event.altKey && !$event.shiftKey && document.activeElement === inputNode) {
|
if ($rootScope.readlineBindings && $event.ctrlKey && !$event.altKey && !$event.shiftKey && document.activeElement === inputNode) {
|
||||||
// get current caret position
|
// get current caret position
|
||||||
var caretPos = inputNode.selectionStart;
|
caretPos = inputNode.selectionStart;
|
||||||
// Ctrl-a
|
// Ctrl-a
|
||||||
if (code == 65) {
|
if (code == 65) {
|
||||||
inputNode.setSelectionRange(0, 0);
|
inputNode.setSelectionRange(0, 0);
|
||||||
|
|
Loading…
Reference in a new issue