Skip to content

Commit

Permalink
Patch Closing mechanic
Browse files Browse the repository at this point in the history
  • Loading branch information
Andreas Häferer authored and Andreas Häferer committed Feb 5, 2024
1 parent 77cc785 commit 176afcb
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/ConsoleGui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 176afcb

Please sign in to comment.