From 3386ff9428997fdcebab1f67cb83c82e4636be89 Mon Sep 17 00:00:00 2001 From: Florrie Date: Sat, 2 Jun 2018 23:28:01 -0300 Subject: CommandLineInterfacer/Flushable resize support --- util/CommandLineInterfacer.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'util/CommandLineInterfacer.js') diff --git a/util/CommandLineInterfacer.js b/util/CommandLineInterfacer.js index 743ff5c..d2007fb 100644 --- a/util/CommandLineInterfacer.js +++ b/util/CommandLineInterfacer.js @@ -3,17 +3,22 @@ const waitForData = require('./waitForData') const ansi = require('./ansi') module.exports = class CommandLineInterfacer extends EventEmitter { - constructor(inStream = process.stdin, outStream = process.stdout) { + constructor(inStream = process.stdin, outStream = process.stdout, proc = process) { super() this.inStream = inStream this.outStream = outStream + this.process = proc inStream.on('data', buffer => { this.emit('inputData', buffer) }) inStream.setRawMode(true) + + proc.on('SIGWINCH', async buffer => { + this.emit('resize', await this.getScreenSize()) + }) } async getScreenSize() { -- cgit 1.3.0-6-gf8a5