-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
implemented support for mutliple shell definitions #1347
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,4 +10,3 @@ npm-debug.log | |
# optional dev config file and plugins directory | ||
.hyper.js | ||
.hyper_plugins | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,16 @@ | ||
'use strict'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't need There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To use ES6 features on node properly it is required There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If anyone else is confused try this in node 5
vs
Removing the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, it's OK now since hyper is running on node 7.4 since #1848 👌 |
||
|
||
const os = require('os'); | ||
const path = require('path'); | ||
const {app, shell, dialog} = require('electron'); | ||
|
||
const {accelerators} = require('./accelerators'); | ||
const {getConfigDir} = require('./config'); | ||
const {getConfig,getConfigDir} = require('./config'); | ||
|
||
const isMac = process.platform === 'darwin'; | ||
const appName = app.getName(); | ||
const shells = getConfig().shells || {}; | ||
const shellKeys = Object.keys(shells); | ||
|
||
// based on and inspired by | ||
// https://github.com/sindresorhus/anatine/blob/master/menu.js | ||
|
@@ -59,6 +63,56 @@ module.exports = ({createWindow, updatePlugins}) => { | |
] | ||
}; | ||
|
||
const otherShellsMenu = { | ||
label: 'Other Shells', | ||
submenu: [] | ||
}; | ||
|
||
for (const shellName of shellKeys) { | ||
const shellOpts = shells[shellName]; | ||
|
||
otherShellsMenu.submenu.push({ | ||
label: shellName, | ||
submenu: [ | ||
{ | ||
label: 'New Window', | ||
click() { | ||
createWindow(null, {shellOpts}); | ||
} | ||
}, | ||
{ | ||
label: 'New Tab', | ||
click(item, focusedWindow) { | ||
if (focusedWindow) { | ||
focusedWindow.rpc.emit('termgroup add req', {shellOpts}); | ||
} else { | ||
createWindow(null, {shellOpts}); | ||
} | ||
} | ||
}, | ||
{ | ||
type: 'separator' | ||
}, | ||
{ | ||
label: 'Split Vertically', | ||
click(item, focusedWindow) { | ||
if (focusedWindow) { | ||
focusedWindow.rpc.emit('split request vertical', {shellOpts}); | ||
} | ||
} | ||
}, | ||
{ | ||
label: 'Split Horizontally', | ||
click(item, focusedWindow) { | ||
if (focusedWindow) { | ||
focusedWindow.rpc.emit('split request horizontal', {shellOpts}); | ||
} | ||
} | ||
} | ||
] | ||
}); | ||
} | ||
|
||
const shellOrFileMenu = { | ||
label: isMac ? 'Shell' : 'File', | ||
submenu: [ | ||
|
@@ -101,6 +155,11 @@ module.exports = ({createWindow, updatePlugins}) => { | |
} | ||
} | ||
}, | ||
...( | ||
shellKeys.length > 0 ? | ||
[{type: 'separator'}, otherShellsMenu] : | ||
[] | ||
), | ||
{ | ||
type: 'separator' | ||
}, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -86,16 +86,16 @@ rpc.on('session clear req', () => { | |
store_.dispatch(sessionActions.clearActiveSession()); | ||
}); | ||
|
||
rpc.on('termgroup add req', () => { | ||
store_.dispatch(termGroupActions.requestTermGroup()); | ||
rpc.on('termgroup add req', options => { | ||
store_.dispatch(termGroupActions.requestTermGroup(options)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what do you mean??? that's a function call |
||
}); | ||
|
||
rpc.on('split request horizontal', () => { | ||
store_.dispatch(termGroupActions.requestHorizontalSplit()); | ||
rpc.on('split request horizontal', options => { | ||
store_.dispatch(termGroupActions.requestHorizontalSplit(options)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what do you mean??? that's a function call |
||
}); | ||
|
||
rpc.on('split request vertical', () => { | ||
store_.dispatch(termGroupActions.requestVerticalSplit()); | ||
rpc.on('split request vertical', options => { | ||
store_.dispatch(termGroupActions.requestVerticalSplit(options)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what do you mean??? that's a function call |
||
}); | ||
|
||
rpc.on('reset fontSize req', () => { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you move it up there where it was before? There's no need for this change 🙌
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually there is a need for this change, the createMenu file now relies on configuration options, therefore must be required after the config is initialised.