From 176afcb0ad65f6a235b9b43c5c1c59afdd9c4ba8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20H=C3=A4ferer?= Date: Mon, 5 Feb 2024 15:27:03 +0100 Subject: [PATCH] Patch Closing mechanic --- src/ConsoleGui.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ConsoleGui.ts b/src/ConsoleGui.ts index dc8fde8..c199c84 100644 --- a/src/ConsoleGui.ts +++ b/src/ConsoleGui.ts @@ -181,12 +181,15 @@ class ConsoleManager extends EventEmitter { this.updateLayout() this.addGenericListeners() + // Create a Interface from STDIN so this interface can be close later otherwise the Process hangs + this.inputInterface = readline.createInterface ({ input: process.stdin, escapeCodeTimeout: 50 }) // I use readline to manage the keypress event - readline.emitKeypressEvents(this.Input) + readline.emitKeypressEvents(this.Input, this.inputInterface) this.Input.setRawMode(true) // With this I only get the key value } return ConsoleManager.instance } + private inputInterface : readline.Interface | undefined /** * @description This method is used to change the layout options. @@ -388,6 +391,7 @@ class ConsoleManager extends EventEmitter { } if (key.ctrl && key.name === "c") { + this.inputInterface?.close() this.emit("exit") } else { if (Object.keys(this.popupCollection).length === 0) {