From 5377a58583c023077bd7587228964d0f03c6cff4 Mon Sep 17 00:00:00 2001 From: Kelvin Schoofs Date: Sat, 16 Jan 2021 19:23:33 +0100 Subject: [PATCH] Add (create)TextTerminal to pseudoTerminal.ts --- src/pseudoTerminal.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/pseudoTerminal.ts b/src/pseudoTerminal.ts index c4ef2d1..7c6a2aa 100644 --- a/src/pseudoTerminal.ts +++ b/src/pseudoTerminal.ts @@ -116,3 +116,24 @@ export async function createTerminal(options: TerminalOptions): Promise; // Redeclaring that it isn't undefined + onDidOpen: vscode.Event; +} + +export function createTextTerminal(initialText?: string): TextTerminal { + const onDidWrite = new vscode.EventEmitter(); + const onDidClose = new vscode.EventEmitter(); + const onDidOpen = new vscode.EventEmitter(); + return { + write: onDidWrite.fire.bind(onDidWrite), + close: onDidClose.fire.bind(onDidClose), + onDidWrite: onDidWrite.event, + onDidClose: onDidClose.event, + onDidOpen: onDidOpen.event, + open: () => initialText && (onDidWrite.fire(initialText), onDidClose.fire(1)), + }; +}