mirror of
https://github.com/microsoft/vscode-extension-samples.git
synced 2026-06-13 07:10:26 +08:00
Add Terminal.onData example
This commit is contained in:
@ -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"
|
||||
|
||||
@ -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> {
|
||||
|
||||
Reference in New Issue
Block a user