Merge pull request #373 from glowing-bear/readline
Add some emacs keybindings. Fixes #371
This commit is contained in:
commit
95c9969e71
|
@ -114,12 +114,14 @@
|
|||
<ul>
|
||||
<li>ALT-n: Toggle nicklist</li>
|
||||
<li>ALT-l: Focus on input bar</li>
|
||||
<li>ALT-[0-9]: Focus on buffer</li>
|
||||
<li>ALT-[0-9]: Switch to buffer number N</li>
|
||||
<li>ALT-a: Focus on next buffer with activity</li>
|
||||
<li>ALT-<: Switch to previous buffer</li>
|
||||
<li>ALT-<: Switch to previous active buffer</li>
|
||||
<li>ALT-g: Focus on buffer list filter</li>
|
||||
<li>Esc-Esc: disconnect (double-tap)</li>
|
||||
<li>arrow keys: history navigation</li>
|
||||
<li>Arrow keys: history navigation</li>
|
||||
<li>Tab key: nick complete</li>
|
||||
<li>The following readline/emacs style keybindings works: <span title="Move cursor to beginning of line">Ctrl-a</span>, <span title="Move cursor to te end of the line">Ctrl-e</span>, <span title="Delete from cursor to beginning of the line">Ctrl-u</span>, <span title="Delete from cursor to the end of the line">Ctrl-k</span>, <span title="Delete from cursor to previous space">Ctrl-w</span></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1517,12 +1517,45 @@ weechat.directive('inputBar', function() {
|
|||
}
|
||||
|
||||
// Enter to submit, shift-enter for newline
|
||||
//
|
||||
if (code == 13 && !$event.shiftKey && document.activeElement === inputNode) {
|
||||
$event.preventDefault();
|
||||
$scope.sendMessage();
|
||||
return true;
|
||||
}
|
||||
// Some readline keybindings
|
||||
if ($event.ctrlKey && !$event.altKey && !$event.shiftKey && document.activeElement === inputNode) {
|
||||
// Ctrl-a
|
||||
if (code == 65) {
|
||||
inputNode.setSelectionRange(0, 0);
|
||||
// Ctrl-e
|
||||
} else if (code == 69) {
|
||||
inputNode.setSelectionRange($scope.command.length, $scope.command.length);
|
||||
// Ctrl-u
|
||||
} else if (code == 85) {
|
||||
$scope.command = $scope.command.slice(caretPos);
|
||||
setTimeout(function() {
|
||||
inputNode.setSelectionRange(0, 0);
|
||||
});
|
||||
// Ctrl-k
|
||||
} else if (code == 75) {
|
||||
$scope.command = $scope.command.slice(0, caretPos);
|
||||
setTimeout(function() {
|
||||
inputNode.setSelectionRange($scope.command.length, $scope.command.length);
|
||||
});
|
||||
// Ctrl-w
|
||||
} else if (code == 87) {
|
||||
var trimmedValue = $scope.command.slice(0, caretPos);
|
||||
var lastSpace = trimmedValue.lastIndexOf(' ') + 1;
|
||||
$scope.command = $scope.command.slice(0, lastSpace) + $scope.command.slice(caretPos, $scope.command.length);
|
||||
setTimeout(function() {
|
||||
inputNode.setSelectionRange(lastSpace, lastSpace);
|
||||
});
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
$event.preventDefault();
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue