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 ++++++++-- todo.txt | 3 +++ tui-lib | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) 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) diff --git a/todo.txt b/todo.txt index b912de1..4b8f1e8 100644 --- a/todo.txt +++ b/todo.txt @@ -14,3 +14,6 @@ TODO: "Queue to play next"... maybe also a cursor in the queue list, which TODO: Scroll to the selected track once it starts playing when selected from the queue. + +TODO: process.on('SIGWINCH', () => ...) -- detect terminal resize!! + (Done!) diff --git a/tui-lib b/tui-lib index 23dc4b2..3386ff9 160000 --- a/tui-lib +++ b/tui-lib @@ -1 +1 @@ -Subproject commit 23dc4b24d92eb2e19c55029522acabfccb701915 +Subproject commit 3386ff9428997fdcebab1f67cb83c82e4636be89 -- cgit 1.3.0-6-gf8a5