mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-18 06:28:40 -09:00
Open Hyper config in the native desktop's default manner (#1784)
This commit is contained in:
parent
c491f7d2e1
commit
00693de12e
3 changed files with 7 additions and 66 deletions
19
app/menu.js
19
app/menu.js
|
|
@ -3,6 +3,7 @@ const path = require('path');
|
||||||
const {app, shell, dialog} = require('electron');
|
const {app, shell, dialog} = require('electron');
|
||||||
|
|
||||||
const {accelerators} = require('./accelerators');
|
const {accelerators} = require('./accelerators');
|
||||||
|
const {getConfigDir} = require('./config');
|
||||||
|
|
||||||
const isMac = process.platform === 'darwin';
|
const isMac = process.platform === 'darwin';
|
||||||
const appName = app.getName();
|
const appName = app.getName();
|
||||||
|
|
@ -25,12 +26,9 @@ module.exports = ({createWindow, updatePlugins}) => {
|
||||||
{
|
{
|
||||||
label: 'Preferences...',
|
label: 'Preferences...',
|
||||||
accelerator: accelerators.preferences,
|
accelerator: accelerators.preferences,
|
||||||
click(item, focusedWindow) {
|
click() {
|
||||||
if (focusedWindow) {
|
const configFile = path.resolve(getConfigDir(), '.hyper.js');
|
||||||
focusedWindow.rpc.emit('preferences');
|
shell.openItem(configFile);
|
||||||
} else {
|
|
||||||
createWindow(win => win.rpc.emit('preferences'));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -174,12 +172,9 @@ module.exports = ({createWindow, updatePlugins}) => {
|
||||||
{
|
{
|
||||||
label: 'Preferences...',
|
label: 'Preferences...',
|
||||||
accelerator: accelerators.preferences,
|
accelerator: accelerators.preferences,
|
||||||
click(item, focusedWindow) {
|
click() {
|
||||||
if (focusedWindow) {
|
const configFile = path.resolve(getConfigDir(), '.hyper.js');
|
||||||
focusedWindow.rpc.emit('preferences');
|
shell.openItem(configFile);
|
||||||
} else {
|
|
||||||
createWindow(win => win.rpc.emit('preferences'));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,3 @@
|
||||||
import {EOL} from 'os';
|
|
||||||
|
|
||||||
import {remote} from 'electron';
|
|
||||||
import * as shellEscape from 'php-escape-shell';
|
import * as shellEscape from 'php-escape-shell';
|
||||||
import last from '../utils/array';
|
import last from '../utils/array';
|
||||||
import isExecutable from '../utils/file';
|
import isExecutable from '../utils/file';
|
||||||
|
|
@ -24,7 +21,6 @@ import {
|
||||||
UI_MOVE_TO,
|
UI_MOVE_TO,
|
||||||
UI_MOVE_NEXT_PANE,
|
UI_MOVE_NEXT_PANE,
|
||||||
UI_MOVE_PREV_PANE,
|
UI_MOVE_PREV_PANE,
|
||||||
UI_SHOW_PREFERENCES,
|
|
||||||
UI_WINDOW_GEOMETRY_CHANGED,
|
UI_WINDOW_GEOMETRY_CHANGED,
|
||||||
UI_WINDOW_MOVE,
|
UI_WINDOW_MOVE,
|
||||||
UI_OPEN_FILE
|
UI_OPEN_FILE
|
||||||
|
|
@ -210,52 +206,6 @@ export function moveTo(i) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function getEditCommand(shell, isWin) {
|
|
||||||
if (isWin && shell.includes('bash')) {
|
|
||||||
return [
|
|
||||||
' echo Attempting to open .hyper.js with nano',
|
|
||||||
' nano .hyper.js'
|
|
||||||
];
|
|
||||||
} else if (isWin) {
|
|
||||||
return [
|
|
||||||
' echo Attempting to open .hyper.js with notepad',
|
|
||||||
' start notepad "%userprofile%\\.hyper.js"'
|
|
||||||
];
|
|
||||||
}
|
|
||||||
return [
|
|
||||||
' echo Attempting to open ~/.hyper.js with your \\$EDITOR',
|
|
||||||
// eslint-disable-next-line no-template-curly-in-string
|
|
||||||
' bash -c \'exec env ${EDITOR:=nano} ~/.hyper.js\''
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
export function showPreferences() {
|
|
||||||
const plugins = remote.require('./plugins');
|
|
||||||
const {shell} = plugins.getDecoratedConfig();
|
|
||||||
const message = getEditCommand(shell, process.platform === 'win32');
|
|
||||||
|
|
||||||
return dispatch => {
|
|
||||||
dispatch({
|
|
||||||
type: UI_SHOW_PREFERENCES,
|
|
||||||
effect() {
|
|
||||||
dispatch(requestSession());
|
|
||||||
// Replace this hack with an async action
|
|
||||||
rpc.once('session add', ({uid}) => {
|
|
||||||
rpc.once('session data', () => {
|
|
||||||
dispatch(sendSessionData(
|
|
||||||
uid,
|
|
||||||
[
|
|
||||||
...message,
|
|
||||||
''
|
|
||||||
].join(EOL)
|
|
||||||
));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function windowMove() {
|
export function windowMove() {
|
||||||
return dispatch => {
|
return dispatch => {
|
||||||
dispatch({
|
dispatch({
|
||||||
|
|
|
||||||
|
|
@ -126,10 +126,6 @@ rpc.on('prev pane req', () => {
|
||||||
store_.dispatch(uiActions.moveToPreviousPane());
|
store_.dispatch(uiActions.moveToPreviousPane());
|
||||||
});
|
});
|
||||||
|
|
||||||
rpc.on('preferences', () => {
|
|
||||||
store_.dispatch(uiActions.showPreferences());
|
|
||||||
});
|
|
||||||
|
|
||||||
rpc.on('open file', ({path}) => {
|
rpc.on('open file', ({path}) => {
|
||||||
store_.dispatch(uiActions.openFile(path));
|
store_.dispatch(uiActions.openFile(path));
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue