mirror of
https://github.com/microsoft/vscode.git
synced 2026-07-15 00:14:20 +01:00
Pass through shutdown and resize
This commit is contained in:
@@ -105,7 +105,9 @@ export class MainThreadTerminalService implements MainThreadTerminalServiceShape
|
||||
this._terminalProcesses[proxy.terminalId] = proxy;
|
||||
this._proxy.$createProcess(proxy.terminalId, null, 0, 0);
|
||||
// TODO: Dispose of this properly when the terminal/process dies
|
||||
this._toDispose.push(proxy.onInput(data => this._onTerminalProcessWrite(proxy.terminalId, data)));
|
||||
this._toDispose.push(proxy.onInput(data => this._proxy.$acceptTerminalProcessInput(proxy.terminalId, data)));
|
||||
this._toDispose.push(proxy.onResize((cols, rows) => this._proxy.$acceptTerminalProcessResize(proxy.terminalId, cols, rows)));
|
||||
this._toDispose.push(proxy.onShutdown(() => this._proxy.$acceptTerminalProcessShutdown(proxy.terminalId)));
|
||||
}
|
||||
|
||||
public $sendProcessTitle(terminalId: number, title: string): void {
|
||||
@@ -119,8 +121,4 @@ export class MainThreadTerminalService implements MainThreadTerminalServiceShape
|
||||
public $sendProcessPid(terminalId: number, pid: number): void {
|
||||
this._terminalProcesses[terminalId].emitPid(pid);
|
||||
}
|
||||
|
||||
private _onTerminalProcessWrite(terminalId: number, data: string): void {
|
||||
this._proxy.$acceptTerminalProcessWrite(terminalId, data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -748,7 +748,9 @@ export interface ExtHostTerminalServiceShape {
|
||||
$acceptTerminalOpened(id: number, name: string): void;
|
||||
$acceptTerminalProcessId(id: number, processId: number): void;
|
||||
$createProcess(id: number, shellLaunchConfig: ShellLaunchConfigDto, cols: number, rows: number): void;
|
||||
$acceptTerminalProcessWrite(id: number, data: string): void;
|
||||
$acceptTerminalProcessInput(id: number, data: string): void;
|
||||
$acceptTerminalProcessResize(id: number, cols: number, rows: number): void;
|
||||
$acceptTerminalProcessShutdown(id: number): void;
|
||||
}
|
||||
|
||||
export interface ExtHostSCMShape {
|
||||
|
||||
@@ -212,10 +212,19 @@ export class ExtHostTerminalService implements ExtHostTerminalServiceShape {
|
||||
console.log('$createProcess terminal: ' + terminal.name);
|
||||
}
|
||||
|
||||
public $acceptTerminalProcessWrite(id: number, data: string): void {
|
||||
public $acceptTerminalProcessInput(id: number, data: string): void {
|
||||
this._terminalProcesses[id].send({ event: 'input', data });
|
||||
}
|
||||
|
||||
public $acceptTerminalProcessResize(id: number, cols: number, rows: number): void {
|
||||
console.log('resize' + cols + ',' + rows);
|
||||
this._terminalProcesses[id].send({ event: 'resize', cols, rows });
|
||||
}
|
||||
|
||||
public $acceptTerminalProcessShutdown(id: number): void {
|
||||
this._terminalProcesses[id].send({ event: 'shutdown' });
|
||||
}
|
||||
|
||||
private _getTerminalById(id: number): ExtHostTerminal {
|
||||
let index = this._getTerminalIndexById(id);
|
||||
return index !== null ? this._terminals[index] : null;
|
||||
|
||||
@@ -530,4 +530,6 @@ export interface ITerminalProcessExtHostProxy {
|
||||
emitTitle(title: string): void;
|
||||
emitPid(pid: number): void;
|
||||
onInput(listener: (data: string) => void): IDisposable;
|
||||
onResize(listener: (cols: number, rows: number) => void): IDisposable;
|
||||
onShutdown(listener: () => void): IDisposable;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,8 @@ import { ITerminalService, ITerminalProcessExtHostProxy } from 'vs/workbench/par
|
||||
import { IDisposable } from '../../../../base/common/lifecycle';
|
||||
|
||||
export class TerminalProcessExtHostProxy extends EventEmitter implements ITerminalChildProcess, ITerminalProcessExtHostProxy {
|
||||
public connected: boolean;
|
||||
// TODO: Set this properly
|
||||
public connected: boolean = true;
|
||||
|
||||
constructor(
|
||||
public terminalId: number,
|
||||
@@ -32,21 +33,29 @@ export class TerminalProcessExtHostProxy extends EventEmitter implements ITermin
|
||||
}
|
||||
|
||||
public send(message: IMessageToTerminalProcess): boolean {
|
||||
console.log('TerminalProcessExtHostProxy#send');
|
||||
if (message.event === 'input') {
|
||||
console.log('emit input', message.data);
|
||||
this.emit('input', message.data);
|
||||
switch (message.event) {
|
||||
case 'input': this.emit('input', message.data); break;
|
||||
case 'resize': this.emit('resize', message.cols, message.rows); break;
|
||||
case 'shutdown': this.emit('shutdown'); break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public onInput(listener: (data: string) => void): IDisposable {
|
||||
console.log('TerminalProcessExtHostProxy#onInput', arguments);
|
||||
// TODO: Dispose of me
|
||||
this.on('input', data => {
|
||||
console.log('TerminalProcessExtHostProxy#onInput - listener');
|
||||
listener(data);
|
||||
});
|
||||
this.on('input', data => listener(data));
|
||||
return null;
|
||||
}
|
||||
|
||||
public onResize(listener: (cols: number, rows: number) => void): IDisposable {
|
||||
// TODO: Dispose of me
|
||||
this.on('resize', (cols, rows) => listener(cols, rows));
|
||||
return null;
|
||||
}
|
||||
|
||||
public onShutdown(listener: () => void): IDisposable {
|
||||
// TODO: Dispose of me
|
||||
this.on('shutdown', () => listener());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user