Skip to content

Commit

Permalink
Merge pull request #85 from haeferer/main
Browse files Browse the repository at this point in the history
Patch to correct closing StdIn
  • Loading branch information
Elius94 authored Feb 16, 2024
2 parents 77cc785 + 176afcb commit 5f92479
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 5f92479

Please sign in to comment.