|
|
@ -81,7 +81,9 @@ export class XtermPlugin extends ElectronBasePlugin { |
|
|
|
|
|
|
|
|
|
|
|
new(webContentsId: any): void { |
|
|
|
new(webContentsId: any): void { |
|
|
|
const client = this.clients.find((c) => c.webContentsId === webContentsId) |
|
|
|
const client = this.clients.find((c) => c.webContentsId === webContentsId) |
|
|
|
|
|
|
|
console.log('new terminal', webContentsId) |
|
|
|
if (client) { |
|
|
|
if (client) { |
|
|
|
|
|
|
|
console.log('client exists') |
|
|
|
client.new() |
|
|
|
client.new() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -137,6 +139,7 @@ class XtermPluginClient extends ElectronBasePluginClient { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async createTerminal(path?: string, shell?: string): Promise<number> { |
|
|
|
async createTerminal(path?: string, shell?: string): Promise<number> { |
|
|
|
|
|
|
|
console.log('createTerminal', path, shell || defaultShell) |
|
|
|
let parsedEnv: any = null |
|
|
|
let parsedEnv: any = null |
|
|
|
if (!(process.platform === 'win32')) { |
|
|
|
if (!(process.platform === 'win32')) { |
|
|
|
const { stdout } = spawnSync(defaultShell, getShellEnvArgs, { |
|
|
|
const { stdout } = spawnSync(defaultShell, getShellEnvArgs, { |
|
|
@ -153,10 +156,12 @@ class XtermPluginClient extends ElectronBasePluginClient { |
|
|
|
rows: 20, |
|
|
|
rows: 20, |
|
|
|
cwd: path || process.cwd(), |
|
|
|
cwd: path || process.cwd(), |
|
|
|
env: env, |
|
|
|
env: env, |
|
|
|
}) |
|
|
|
encoding: 'utf8', |
|
|
|
|
|
|
|
}); |
|
|
|
const dataBatcher = new DataBatcher(ptyProcess.pid) |
|
|
|
const dataBatcher = new DataBatcher(ptyProcess.pid) |
|
|
|
this.dataBatchers[ptyProcess.pid] = dataBatcher |
|
|
|
this.dataBatchers[ptyProcess.pid] = dataBatcher |
|
|
|
ptyProcess.onData((data: string) => { |
|
|
|
ptyProcess.onData((data: string) => { |
|
|
|
|
|
|
|
//console.log('data', data)
|
|
|
|
dataBatcher.write(Buffer.from(data)) |
|
|
|
dataBatcher.write(Buffer.from(data)) |
|
|
|
}) |
|
|
|
}) |
|
|
|
ptyProcess.onExit(() => { |
|
|
|
ptyProcess.onExit(() => { |
|
|
@ -213,8 +218,9 @@ class XtermPluginClient extends ElectronBasePluginClient { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async new(): Promise<void> { |
|
|
|
async new(): Promise<void> { |
|
|
|
console.log('new terminal') |
|
|
|
console.log('new terminal in client') |
|
|
|
const pid = await this.createTerminal(this.workingDir) |
|
|
|
const pid = await this.createTerminal(this.workingDir) |
|
|
|
|
|
|
|
console.log('new terminal in client', pid) |
|
|
|
this.emit('new', pid) |
|
|
|
this.emit('new', pid) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|