mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-13 04:28:41 -09:00
* Bumping electron to 3.0.10 * Updating node version in travis and appveyor * Fixing incorrect require of electron-fetch * Fix zoom to match previous versions Additionally I'm removing a call to disable pinch-zoom, it's disable by default since Electron 2 (https://electronjs.org/releases#2.0.0) * Bumping electron to 4.0.0-beta.8 * Bumping electron to 4.0.0-beta.9 * Work around for Copy accelerator not firing on electron v4 * Fixing header/titlebar in MacOS * Upgrading to electron 4.0.0 and node-pty 0.8.0 * Adding yarn.lock changes for electron 4.0.0 * Adding comments for editor:copy workaround. Scaling issue is only on Linux * Upgrading node-abi to support electron 4.0.0 * popup now takes an object as input
132 lines
4.2 KiB
JavaScript
132 lines
4.2 KiB
JavaScript
const {app} = require('electron');
|
|
const {openConfig} = require('./config');
|
|
const {updatePlugins} = require('./plugins');
|
|
const {installCLI} = require('./utils/cli-install');
|
|
|
|
const commands = {
|
|
'window:new': () => {
|
|
// If window is created on the same tick, it will consume event too
|
|
setTimeout(app.createWindow, 0);
|
|
},
|
|
'tab:new': focusedWindow => {
|
|
if (focusedWindow) {
|
|
focusedWindow.rpc.emit('termgroup add req');
|
|
} else {
|
|
setTimeout(app.createWindow, 0);
|
|
}
|
|
},
|
|
'pane:splitVertical': focusedWindow => {
|
|
focusedWindow && focusedWindow.rpc.emit('split request vertical');
|
|
},
|
|
'pane:splitHorizontal': focusedWindow => {
|
|
focusedWindow && focusedWindow.rpc.emit('split request horizontal');
|
|
},
|
|
'pane:close': focusedWindow => {
|
|
focusedWindow && focusedWindow.rpc.emit('termgroup close req');
|
|
},
|
|
'window:preferences': () => {
|
|
openConfig();
|
|
},
|
|
'editor:clearBuffer': focusedWindow => {
|
|
focusedWindow && focusedWindow.rpc.emit('session clear req');
|
|
},
|
|
'editor:selectAll': focusedWindow => {
|
|
focusedWindow.rpc.emit('term selectAll');
|
|
},
|
|
'plugins:update': () => {
|
|
updatePlugins();
|
|
},
|
|
'window:reload': focusedWindow => {
|
|
focusedWindow && focusedWindow.rpc.emit('reload');
|
|
},
|
|
'window:reloadFull': focusedWindow => {
|
|
focusedWindow && focusedWindow.reload();
|
|
},
|
|
'window:devtools': focusedWindow => {
|
|
if (!focusedWindow) {
|
|
return;
|
|
}
|
|
const webContents = focusedWindow.webContents;
|
|
if (webContents.isDevToolsOpened()) {
|
|
webContents.closeDevTools();
|
|
} else {
|
|
webContents.openDevTools({mode: 'detach'});
|
|
}
|
|
},
|
|
'editor:copy': focusedWindow => {
|
|
// HACK: Had to add this because the "editor:copy" role is not firing with
|
|
// ctrl+shift+c after upgrading to electron 4
|
|
// Electron issue: https://github.com/electron/electron#16088
|
|
if (!focusedWindow) {
|
|
return;
|
|
}
|
|
const webContents = focusedWindow.webContents;
|
|
webContents.copy();
|
|
},
|
|
'zoom:reset': focusedWindow => {
|
|
focusedWindow && focusedWindow.rpc.emit('reset fontSize req');
|
|
},
|
|
'zoom:in': focusedWindow => {
|
|
focusedWindow && focusedWindow.rpc.emit('increase fontSize req');
|
|
},
|
|
'zoom:out': focusedWindow => {
|
|
focusedWindow && focusedWindow.rpc.emit('decrease fontSize req');
|
|
},
|
|
'tab:prev': focusedWindow => {
|
|
focusedWindow && focusedWindow.rpc.emit('move left req');
|
|
},
|
|
'tab:next': focusedWindow => {
|
|
focusedWindow && focusedWindow.rpc.emit('move right req');
|
|
},
|
|
'pane:prev': focusedWindow => {
|
|
focusedWindow && focusedWindow.rpc.emit('prev pane req');
|
|
},
|
|
'pane:next': focusedWindow => {
|
|
focusedWindow && focusedWindow.rpc.emit('next pane req');
|
|
},
|
|
'editor:movePreviousWord': focusedWindow => {
|
|
focusedWindow && focusedWindow.rpc.emit('session move word left req');
|
|
},
|
|
'editor:moveNextWord': focusedWindow => {
|
|
focusedWindow && focusedWindow.rpc.emit('session move word right req');
|
|
},
|
|
'editor:moveBeginningLine': focusedWindow => {
|
|
focusedWindow && focusedWindow.rpc.emit('session move line beginning req');
|
|
},
|
|
'editor:moveEndLine': focusedWindow => {
|
|
focusedWindow && focusedWindow.rpc.emit('session move line end req');
|
|
},
|
|
'editor:deletePreviousWord': focusedWindow => {
|
|
focusedWindow && focusedWindow.rpc.emit('session del word left req');
|
|
},
|
|
'editor:deleteNextWord': focusedWindow => {
|
|
focusedWindow && focusedWindow.rpc.emit('session del word right req');
|
|
},
|
|
'editor:deleteBeginningLine': focusedWindow => {
|
|
focusedWindow && focusedWindow.rpc.emit('session del line beginning req');
|
|
},
|
|
'editor:deleteEndLine': focusedWindow => {
|
|
focusedWindow && focusedWindow.rpc.emit('session del line end req');
|
|
},
|
|
'editor:break': focusedWindow => {
|
|
focusedWindow && focusedWindow.rpc.emit('session break req');
|
|
},
|
|
'cli:install': () => {
|
|
installCLI(true);
|
|
}
|
|
};
|
|
|
|
//Special numeric command
|
|
[1, 2, 3, 4, 5, 6, 7, 8, 'last'].forEach(cmdIndex => {
|
|
const index = cmdIndex === 'last' ? cmdIndex : cmdIndex - 1;
|
|
commands[`tab:jump:${cmdIndex}`] = focusedWindow => {
|
|
focusedWindow && focusedWindow.rpc.emit('move jump req', index);
|
|
};
|
|
});
|
|
|
|
exports.execCommand = (command, focusedWindow) => {
|
|
const fn = commands[command];
|
|
if (fn) {
|
|
fn(focusedWindow);
|
|
}
|
|
};
|