From 60131bd74b505803bba2db7bef78d9945d4087bd Mon Sep 17 00:00:00 2001 From: Florrie Date: Sat, 2 Jun 2018 23:28:57 -0300 Subject: Terminal resize detection --- index.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'index.js') diff --git a/index.js b/index.js index ca62f17..b46edb6 100644 --- a/index.js +++ b/index.js @@ -23,8 +23,7 @@ async function main() { const size = await interfacer.getScreenSize() const flushable = new Flushable(process.stdout, true) - flushable.screenLines = size.lines - flushable.screenCols = size.cols + flushable.resizeScreen(size) flushable.shouldShowCompressionStatistics = process.argv.includes('--show-ansi-stats') flushable.write(ansi.clearScreen()) flushable.flush() @@ -33,6 +32,13 @@ async function main() { root.w = size.width root.h = size.height + interfacer.on('resize', newSize => { + root.w = newSize.width + root.h = newSize.height + flushable.resizeScreen(newSize) + root.fixAllLayout() + }) + const appElement = new AppElement() root.addChild(appElement) root.select(appElement) -- cgit 1.3.0-6-gf8a5