Add cursor actions (#217)

* Add cursor actions

* Use Command+Option+Left shortcuts to change tabs

This changes the behavior the ones of sublime & chrome
This commit is contained in:
Marc Bachmann 2016-07-19 19:48:11 +02:00 committed by Guillermo Rauch
parent a8de019665
commit 961a39e8f3
4 changed files with 42 additions and 3 deletions

View file

@ -95,6 +95,34 @@ export default class Term extends Component {
}
}
moveWordLeft () {
this.term.onVTKeystroke('\x1bb');
}
moveWordRight () {
this.term.onVTKeystroke('\x1bf');
}
deleteWordLeft () {
this.term.onVTKeystroke('\x1b\x7f');
}
deleteWordRight () {
this.term.onVTKeystroke('\x1bd');
}
deleteLine () {
this.term.onVTKeystroke('\x1bw');
}
moveToStart () {
this.term.onVTKeystroke('\x01');
}
moveToEnd () {
this.term.onVTKeystroke('\x05');
}
getTermDocument () {
return this.term.document_;
}

View file

@ -49,6 +49,17 @@ class HyperTerm extends Component {
keys.bind('command+shift+]', moveRight);
keys.bind('command+alt+left', moveLeft);
keys.bind('command+alt+right', moveRight);
const bound = method => { return term[method].bind(term) }
keys.bind('alt+left', bound('moveWordLeft'));
keys.bind('alt+right', bound('moveWordRight'));
keys.bind('alt+backspace', bound('deleteWordLeft'));
keys.bind('alt+del', bound('deleteWordRight'));
keys.bind('command+left', bound('deleteWordLeft'));
keys.bind('command+right', bound('deleteWordRight'));
keys.bind('command+backspace', bound('deleteLine'));
keys.bind('command+left', bound('moveToStart'));
keys.bind('command+right', bound('moveToEnd'));
this.keys = keys;
}

View file

@ -29,7 +29,7 @@ hterm.Terminal.prototype.copySelectionToClipboard = function () {
// hyperterm and not the terminal itself
const oldKeyDown = hterm.Keyboard.prototype.onKeyDown_;
hterm.Keyboard.prototype.onKeyDown_ = function (e) {
if (e.metaKey) {
if (e.metaKey || e.altKey) {
return;
}
return oldKeyDown.call(this, e);

View file

@ -216,7 +216,7 @@ module.exports = function createMenu ({ createWindow, updatePlugins }) {
},
{
label: 'Show Previous Tab',
accelerator: 'CmdOrCtrl+Left',
accelerator: 'CmdOrCtrl+Option+Left',
click (item, focusedWindow) {
if (focusedWindow) {
focusedWindow.rpc.emit('move left req');
@ -225,7 +225,7 @@ module.exports = function createMenu ({ createWindow, updatePlugins }) {
},
{
label: 'Show Next Tab',
accelerator: 'CmdOrCtrl+Right',
accelerator: 'CmdOrCtrl+Option+Right',
click (item, focusedWindow) {
if (focusedWindow) {
focusedWindow.rpc.emit('move right req');