Skip to content

Commit

Permalink
Add ITerminalInstance.onData internal API
Browse files Browse the repository at this point in the history
Part of #15584
Related #13337
  • Loading branch information
Tyriar committed Jan 11, 2017
1 parent c936b0f commit 7900f25
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/vs/workbench/parts/terminal/common/terminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,4 +234,11 @@ export interface ITerminalInstance {
* @param visible Whether the element is visible.
*/
setVisible(visible: boolean): void;

/**
* Attach a listener to the data stream from the terminal's pty process.
*
* @param listener The listener function.
*/
onData(listener: (data: string) => void): void;
}
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,14 @@ export class TerminalInstance implements ITerminalInstance {
return env;
}

public onData(listener: (data: string) => void): void {
this._process.on('message', (message) => {
if (message.type === 'data') {
listener(message.content);
}
});
}

private static _sanitizeCwd(cwd: string) {
// Make the drive letter uppercase on Windows (see #9448)
if (platform.platform === platform.Platform.Windows && cwd && cwd[1] === ':') {
Expand Down

0 comments on commit 7900f25

Please sign in to comment.