mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-13 04:28:41 -09:00
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:
parent
a8de019665
commit
961a39e8f3
4 changed files with 42 additions and 3 deletions
|
|
@ -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_;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
4
menu.js
4
menu.js
|
|
@ -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');
|
||||
|
|
|
|||
Loading…
Reference in a new issue