mirror of
https://github.com/Eugeny/tabby.git
synced 2025-06-13 07:59:59 +00:00
Merge branch 'master' of github.com:Eugeny/terminus
This commit is contained in:
commit
ecf5297bc3
@ -147,7 +147,7 @@ export class Application {
|
|||||||
|
|
||||||
handleSecondInstance (argv: string[], cwd: string): void {
|
handleSecondInstance (argv: string[], cwd: string): void {
|
||||||
this.presentAllWindows()
|
this.presentAllWindows()
|
||||||
this.windows[this.windows.length - 1].handleSecondInstance(argv, cwd)
|
this.windows[this.windows.length - 1].passCliArguments(argv, cwd, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
private setupMenu () {
|
private setupMenu () {
|
||||||
|
@ -53,7 +53,7 @@ if (argv.d) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
app.on('ready', () => {
|
app.on('ready', async () => {
|
||||||
if (process.platform === 'darwin') {
|
if (process.platform === 'darwin') {
|
||||||
app.dock.setMenu(Menu.buildFromTemplate([
|
app.dock.setMenu(Menu.buildFromTemplate([
|
||||||
{
|
{
|
||||||
@ -65,5 +65,8 @@ app.on('ready', () => {
|
|||||||
]))
|
]))
|
||||||
}
|
}
|
||||||
application.init()
|
application.init()
|
||||||
application.newWindow({ hidden: argv.hidden })
|
|
||||||
|
const window = await application.newWindow({ hidden: argv.hidden })
|
||||||
|
await window.ready
|
||||||
|
window.passCliArguments(process.argv, process.cwd(), false)
|
||||||
})
|
})
|
||||||
|
@ -65,6 +65,7 @@ export class Window {
|
|||||||
enableRemoteModule: true,
|
enableRemoteModule: true,
|
||||||
contextIsolation: false,
|
contextIsolation: false,
|
||||||
},
|
},
|
||||||
|
maximizable: true,
|
||||||
frame: false,
|
frame: false,
|
||||||
show: false,
|
show: false,
|
||||||
backgroundColor: '#00000000',
|
backgroundColor: '#00000000',
|
||||||
@ -229,8 +230,8 @@ export class Window {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
handleSecondInstance (argv: string[], cwd: string): void {
|
passCliArguments (argv: string[], cwd: string, secondInstance: boolean): void {
|
||||||
this.send('host:second-instance', parseArgs(argv, cwd), cwd)
|
this.send('cli', parseArgs(argv, cwd), cwd, secondInstance)
|
||||||
}
|
}
|
||||||
|
|
||||||
private setupWindowManagement () {
|
private setupWindowManagement () {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import type { BrowserWindow, TouchBar, MenuItemConstructorOptions } from 'electron'
|
import type { BrowserWindow, TouchBar, MenuItemConstructorOptions } from 'electron'
|
||||||
import * as path from 'path'
|
import * as path from 'path'
|
||||||
|
import * as fs from 'mz/fs'
|
||||||
import shellEscape from 'shell-escape'
|
import shellEscape from 'shell-escape'
|
||||||
import { Observable, Subject } from 'rxjs'
|
import { Observable, Subject } from 'rxjs'
|
||||||
import { Injectable, NgZone, EventEmitter } from '@angular/core'
|
import { Injectable, NgZone, EventEmitter } from '@angular/core'
|
||||||
@ -150,9 +151,10 @@ export class HostAppService {
|
|||||||
this.zone.run(() => this.displaysChanged.next())
|
this.zone.run(() => this.displaysChanged.next())
|
||||||
})
|
})
|
||||||
|
|
||||||
electron.ipcRenderer.on('host:second-instance', (_$event, argv: any, cwd: string) => this.zone.run(() => {
|
electron.ipcRenderer.on('cli', (_$event, argv: any, cwd: string, secondInstance: boolean) => this.zone.run(async () => {
|
||||||
this.logger.info('Second instance', argv)
|
this.logger.info('Second instance', argv)
|
||||||
const op = argv._[0]
|
const op = argv._[0]
|
||||||
|
const opAsPath = path.resolve(cwd, op)
|
||||||
if (op === 'open') {
|
if (op === 'open') {
|
||||||
this.cliOpenDirectory.next(path.resolve(cwd, argv.directory))
|
this.cliOpenDirectory.next(path.resolve(cwd, argv.directory))
|
||||||
} else if (op === 'run') {
|
} else if (op === 'run') {
|
||||||
@ -167,7 +169,11 @@ export class HostAppService {
|
|||||||
this.cliOpenProfile.next(argv.profileName)
|
this.cliOpenProfile.next(argv.profileName)
|
||||||
} else if (op === undefined) {
|
} else if (op === undefined) {
|
||||||
this.newWindow()
|
this.newWindow()
|
||||||
} else {
|
} else if ((await fs.lstat(opAsPath)).isDirectory()) {
|
||||||
|
this.cliOpenDirectory.next(opAsPath)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (secondInstance) {
|
||||||
this.secondInstance.next()
|
this.secondInstance.next()
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
|
@ -194,6 +194,9 @@ export default class TerminalModule { // eslint-disable-line @typescript-eslint/
|
|||||||
})
|
})
|
||||||
|
|
||||||
hostApp.cliOpenDirectory$.subscribe(async directory => {
|
hostApp.cliOpenDirectory$.subscribe(async directory => {
|
||||||
|
if (directory.length > 1 && (directory.endsWith('/') || directory.endsWith('\\'))) {
|
||||||
|
directory = directory.substring(0, directory.length - 1)
|
||||||
|
}
|
||||||
if (await fs.exists(directory)) {
|
if (await fs.exists(directory)) {
|
||||||
if ((await fs.stat(directory)).isDirectory()) {
|
if ((await fs.stat(directory)).isDirectory()) {
|
||||||
terminal.openTab(undefined, directory)
|
terminal.openTab(undefined, directory)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user