« get me outta code hell

CommandLineInterfacer/Flushable resize support - tui-lib - Pure Node.js library for making visual command-line programs (ala vim, ncdu)
about summary refs log tree commit diff
path: root/util/CommandLineInterfacer.js
diff options
context:
space:
mode:
authorFlorrie <towerofnix@gmail.com>2018-06-02 23:28:01 -0300
committerFlorrie <towerofnix@gmail.com>2018-06-02 23:28:01 -0300
commit3386ff9428997fdcebab1f67cb83c82e4636be89 (patch)
tree52447d24325e52a592829c1f8b4475b1eaa03ca7 /util/CommandLineInterfacer.js
parent23dc4b24d92eb2e19c55029522acabfccb701915 (diff)
CommandLineInterfacer/Flushable resize support
Diffstat (limited to 'util/CommandLineInterfacer.js')
-rw-r--r--util/CommandLineInterfacer.js7
1 files changed, 6 insertions, 1 deletions
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() {