offer shell selection in the terminal context menu

This commit is contained in:
Eugene Pankov 2018-12-23 21:03:09 +01:00
parent 120e2a2cd5
commit 88bb40f94b

View File

@ -203,7 +203,8 @@ export class TerminalTabComponent extends BaseTabComponent {
this.frontend.focus() this.frontend.focus()
} }
buildContextMenu (): Electron.MenuItemConstructorOptions[] { async buildContextMenu (): Promise<Electron.MenuItemConstructorOptions[]> {
let shells = await this.terminalService.shells$.toPromise()
return [ return [
{ {
label: 'New terminal', label: 'New terminal',
@ -212,7 +213,16 @@ export class TerminalTabComponent extends BaseTabComponent {
}) })
}, },
{ {
label: 'New from profile', label: 'New with shell',
submenu: shells.map(shell => ({
label: shell.name,
click: () => this.zone.run(async () => {
this.terminalService.openTab(shell, await this.session.getWorkingDirectory())
}),
})),
},
{
label: 'New with profile',
submenu: this.config.store.terminal.profiles.length ? this.config.store.terminal.profiles.map(profile => ({ submenu: this.config.store.terminal.profiles.length ? this.config.store.terminal.profiles.map(profile => ({
label: profile.name, label: profile.name,
click: () => this.zone.run(() => { click: () => this.zone.run(() => {
@ -223,6 +233,9 @@ export class TerminalTabComponent extends BaseTabComponent {
enabled: false, enabled: false,
}], }],
}, },
{
type: 'separator',
},
{ {
label: 'Copy', label: 'Copy',
click: () => { click: () => {
@ -260,11 +273,11 @@ export class TerminalTabComponent extends BaseTabComponent {
this.focused$.subscribe(() => this.frontend.enableResizing = true), this.focused$.subscribe(() => this.frontend.enableResizing = true),
this.blurred$.subscribe(() => this.frontend.enableResizing = false), this.blurred$.subscribe(() => this.frontend.enableResizing = false),
this.frontend.mouseEvent$.subscribe(event => { this.frontend.mouseEvent$.subscribe(async event => {
if (event.type === 'mousedown') { if (event.type === 'mousedown') {
if (event.which === 3) { if (event.which === 3) {
if (this.config.store.terminal.rightClick === 'menu') { if (this.config.store.terminal.rightClick === 'menu') {
this.hostApp.popupContextMenu(this.buildContextMenu()) this.hostApp.popupContextMenu(await this.buildContextMenu())
} else if (this.config.store.terminal.rightClick === 'paste') { } else if (this.config.store.terminal.rightClick === 'paste') {
this.paste() this.paste()
} }