Add Terminal.onData example

This commit is contained in:
Daniel Imms
2018-04-20 11:23:05 -07:00
parent 60919f5438
commit b3babe0eee
2 changed files with 13 additions and 0 deletions

View File

@ -16,6 +16,7 @@
"onCommand:terminalTest.createZshLoginShell",
"onCommand:terminalTest.dispose",
"onCommand:terminalTest.hide",
"onCommand:terminalTest.onData",
"onCommand:terminalTest.processId",
"onCommand:terminalTest.sendText",
"onCommand:terminalTest.sendTextNoNewLine",
@ -46,6 +47,10 @@
"command": "terminalTest.hide",
"title": "Terminal API: Hide"
},
{
"command": "terminalTest.onData",
"title": "Terminal API: Attach data listener"
},
{
"command": "terminalTest.processId",
"title": "Terminal API: Get process ID"

View File

@ -92,6 +92,14 @@ export function activate(context: vscode.ExtensionContext) {
vscode.window.showInformationMessage(`onDidOpenTerminal, name: ${terminal.name}`);
});
}
context.subscriptions.push(vscode.commands.registerCommand('terminalTest.onData', () => {
selectTerminal().then(terminal => {
vscode.window.showInformationMessage(`onData listener attached for terminal: ${terminal.name}, check the devtools console to see events`);
(<any>terminal).onData((data: string) => {
console.log('onData: ' + data);
});
});
}));
}
function selectTerminal(): Thenable<vscode.Terminal> {