From fd2acc348797982e0c4ec7702eac1fa47c690648 Mon Sep 17 00:00:00 2001 From: Florrie Date: Thu, 17 Oct 2019 10:04:50 -0300 Subject: Make tui-app work with draw dependencies ...instead of using the old loop system. --- util/tui-app.js | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) (limited to 'util/tui-app.js') diff --git a/util/tui-app.js b/util/tui-app.js index 0b845ea..a695e57 100644 --- a/util/tui-app.js +++ b/util/tui-app.js @@ -20,6 +20,7 @@ module.exports = async function tuiApp(callback) { root.w = size.width; root.h = size.height; flushable.resizeScreen(size); + root.on('rendered', () => flushable.flush()); interfacer.on('resize', newSize => { root.w = newSize.width; @@ -48,26 +49,18 @@ module.exports = async function tuiApp(callback) { process.kill(process.pid, 'SIGTSTP'); }; - const startRenderLoop = function () { + process.on('SIGCONT', () => { + flushable.clearLastFrame(); + process.stdin.setRawMode(false); + process.stdin.setRawMode(true); dirtyTerminal(); + }); - process.on('SIGCONT', () => { - flushable.clearLastFrame(); - process.stdin.setRawMode(false); - process.stdin.setRawMode(true); - dirtyTerminal(); - }); - - setInterval(() => { - root.renderTo(flushable); - flushable.flush(); - }); - }; + dirtyTerminal(); try { return await callback({ root, - startRenderLoop, suspendProgram, quitProgram }); -- cgit 1.3.0-6-gf8a5