mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-16 05:38:41 -09:00
split panes: set hotkeys based on OS (#771)
This commit is contained in:
parent
a7595c1a45
commit
540414f59d
3 changed files with 11 additions and 32 deletions
17
app/menu.js
17
app/menu.js
|
|
@ -2,6 +2,7 @@ const os = require('os');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const {app, shell, dialog} = require('electron');
|
const {app, shell, dialog} = require('electron');
|
||||||
|
|
||||||
|
const isMac = process.platform === 'darwin';
|
||||||
const appName = app.getName();
|
const appName = app.getName();
|
||||||
|
|
||||||
// based on and inspired by
|
// based on and inspired by
|
||||||
|
|
@ -59,7 +60,7 @@ module.exports = function createMenu({createWindow, updatePlugins}) {
|
||||||
};
|
};
|
||||||
|
|
||||||
const shellOrFileMenu = {
|
const shellOrFileMenu = {
|
||||||
label: process.platform === 'darwin' ? 'Shell' : 'File',
|
label: isMac ? 'Shell' : 'File',
|
||||||
submenu: [
|
submenu: [
|
||||||
{
|
{
|
||||||
label: 'New Window',
|
label: 'New Window',
|
||||||
|
|
@ -84,7 +85,7 @@ module.exports = function createMenu({createWindow, updatePlugins}) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Split Vertically',
|
label: 'Split Vertically',
|
||||||
accelerator: 'Ctrl+Shift+E',
|
accelerator: isMac ? 'Cmd+D' : 'Ctrl+Shift+E',
|
||||||
click(item, focusedWindow) {
|
click(item, focusedWindow) {
|
||||||
if (focusedWindow) {
|
if (focusedWindow) {
|
||||||
focusedWindow.rpc.emit('split request vertical');
|
focusedWindow.rpc.emit('split request vertical');
|
||||||
|
|
@ -93,7 +94,7 @@ module.exports = function createMenu({createWindow, updatePlugins}) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Split Horizontally',
|
label: 'Split Horizontally',
|
||||||
accelerator: 'Ctrl+Shift+O',
|
accelerator: isMac ? 'Cmd+Shift+D' : 'Ctrl+Shift+O',
|
||||||
click(item, focusedWindow) {
|
click(item, focusedWindow) {
|
||||||
if (focusedWindow) {
|
if (focusedWindow) {
|
||||||
focusedWindow.rpc.emit('split request horizontal');
|
focusedWindow.rpc.emit('split request horizontal');
|
||||||
|
|
@ -113,7 +114,7 @@ module.exports = function createMenu({createWindow, updatePlugins}) {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: process.platform === 'darwin' ? 'Close Terminal Window' : 'Quit',
|
label: isMac ? 'Close Terminal Window' : 'Quit',
|
||||||
role: 'close',
|
role: 'close',
|
||||||
accelerator: 'CmdOrCtrl+Shift+W'
|
accelerator: 'CmdOrCtrl+Shift+W'
|
||||||
}
|
}
|
||||||
|
|
@ -159,7 +160,7 @@ module.exports = function createMenu({createWindow, updatePlugins}) {
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
if (process.platform !== 'darwin') {
|
if (!isMac) {
|
||||||
editMenu.submenu.push(
|
editMenu.submenu.push(
|
||||||
{type: 'separator'},
|
{type: 'separator'},
|
||||||
{
|
{
|
||||||
|
|
@ -199,7 +200,7 @@ module.exports = function createMenu({createWindow, updatePlugins}) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Toggle Developer Tools',
|
label: 'Toggle Developer Tools',
|
||||||
accelerator: process.platform === 'darwin' ? 'Alt+Command+I' : 'Ctrl+Shift+I',
|
accelerator: isMac ? 'Alt+Command+I' : 'Ctrl+Shift+I',
|
||||||
click(item, focusedWindow) {
|
click(item, focusedWindow) {
|
||||||
if (focusedWindow) {
|
if (focusedWindow) {
|
||||||
focusedWindow.webContents.toggleDevTools();
|
focusedWindow.webContents.toggleDevTools();
|
||||||
|
|
@ -342,7 +343,7 @@ ${process.platform} ${process.arch} ${os.release()}`;
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
if (process.platform !== 'darwin') {
|
if (!isMac) {
|
||||||
helpMenu.submenu.push(
|
helpMenu.submenu.push(
|
||||||
{type: 'separator'},
|
{type: 'separator'},
|
||||||
{
|
{
|
||||||
|
|
@ -361,7 +362,7 @@ ${process.platform} ${process.arch} ${os.release()}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
const menu = [].concat(
|
const menu = [].concat(
|
||||||
process.platform === 'darwin' ? osxApplicationMenu : [],
|
isMac ? osxApplicationMenu : [],
|
||||||
shellOrFileMenu,
|
shellOrFileMenu,
|
||||||
editMenu,
|
editMenu,
|
||||||
viewMenu,
|
viewMenu,
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@ import React from 'react';
|
||||||
import Component from '../component';
|
import Component from '../component';
|
||||||
import {connect} from '../utils/plugins';
|
import {connect} from '../utils/plugins';
|
||||||
import * as uiActions from '../actions/ui';
|
import * as uiActions from '../actions/ui';
|
||||||
import * as termGroupActions from '../actions/term-groups';
|
|
||||||
|
|
||||||
import HeaderContainer from './header';
|
import HeaderContainer from './header';
|
||||||
import TermsContainer from './terms';
|
import TermsContainer from './terms';
|
||||||
|
|
@ -35,7 +34,7 @@ class HyperTerm extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
attachKeyListeners() {
|
attachKeyListeners() {
|
||||||
const {moveTo, moveLeft, moveRight, splitHorizontal, splitVertical} = this.props;
|
const {moveTo, moveLeft, moveRight} = this.props;
|
||||||
const term = this.terms.getActiveTerm();
|
const term = this.terms.getActiveTerm();
|
||||||
if (!term) {
|
if (!term) {
|
||||||
return;
|
return;
|
||||||
|
|
@ -43,11 +42,6 @@ class HyperTerm extends Component {
|
||||||
const lastIndex = this.terms.getLastTermIndex();
|
const lastIndex = this.terms.getLastTermIndex();
|
||||||
const document = term.getTermDocument();
|
const document = term.getTermDocument();
|
||||||
const keys = new Mousetrap(document);
|
const keys = new Mousetrap(document);
|
||||||
if (process.platform === 'darwin') {
|
|
||||||
keys.bind('command+d', splitVertical);
|
|
||||||
keys.bind('command+shift+d', splitHorizontal);
|
|
||||||
}
|
|
||||||
|
|
||||||
keys.bind('command+1', moveTo.bind(this, 0));
|
keys.bind('command+1', moveTo.bind(this, 0));
|
||||||
keys.bind('command+2', moveTo.bind(this, 1));
|
keys.bind('command+2', moveTo.bind(this, 1));
|
||||||
keys.bind('command+3', moveTo.bind(this, 2));
|
keys.bind('command+3', moveTo.bind(this, 2));
|
||||||
|
|
@ -158,14 +152,6 @@ const HyperTermContainer = connect(
|
||||||
|
|
||||||
moveRight: () => {
|
moveRight: () => {
|
||||||
dispatch(uiActions.moveRight());
|
dispatch(uiActions.moveRight());
|
||||||
},
|
|
||||||
|
|
||||||
splitHorizontal: () => {
|
|
||||||
dispatch(termGroupActions.requestHorizontalSplit());
|
|
||||||
},
|
|
||||||
|
|
||||||
splitVertical: () => {
|
|
||||||
dispatch(termGroupActions.requestVerticalSplit());
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
|
||||||
10
lib/hterm.js
10
lib/hterm.js
|
|
@ -3,14 +3,6 @@ import fromCharCode from './utils/key-code';
|
||||||
|
|
||||||
const selection = require('./utils/selection');
|
const selection = require('./utils/selection');
|
||||||
|
|
||||||
// Keys that are used in combination
|
|
||||||
// with ctrl based hotkeys:
|
|
||||||
const IGNORED_CTRL_KEYS = [
|
|
||||||
'Tab',
|
|
||||||
'KeyO',
|
|
||||||
'KeyE'
|
|
||||||
];
|
|
||||||
|
|
||||||
hterm.defaultStorage = new lib.Storage.Memory();
|
hterm.defaultStorage = new lib.Storage.Memory();
|
||||||
|
|
||||||
// Provide selectAll to terminal viewport
|
// Provide selectAll to terminal viewport
|
||||||
|
|
@ -137,7 +129,7 @@ hterm.Keyboard.prototype.onKeyDown_ = function (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (e.metaKey || e.altKey || (e.ctrlKey && IGNORED_CTRL_KEYS.includes(e.code))) {
|
if (e.metaKey || e.altKey || (e.ctrlKey && e.code === 'Tab')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ((!e.ctrlKey || e.code !== 'ControlLeft') && !e.shiftKey && e.code !== 'CapsLock') {
|
if ((!e.ctrlKey || e.code !== 'ControlLeft') && !e.shiftKey && e.code !== 'CapsLock') {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue