« get me outta code hell

Only render when stuff on-screen actually changes! - mtui - Music Text User Interface - user-friendly command line music player
about summary refs log tree commit diff
path: root/index.js
diff options
context:
space:
mode:
authorFlorrie <towerofnix@gmail.com>2019-09-15 17:17:31 -0300
committerFlorrie <towerofnix@gmail.com>2019-09-15 17:17:31 -0300
commit8053f12b63e272cc9119a30f9ddc480b5ea75641 (patch)
treee52eee3680eef45032cbc5acc3e49838b9fc6378 /index.js
parent6be85bb511f9e3e55ab503c9b8b44afb31b84f2d (diff)
Only render when stuff on-screen actually changes!
This means we can basically guarantee 0% CPU usage when nothing on the
screen is changing! There may still be some kinks to work out, but I've
tested most features and fixed any apparent bugs (including an unrelated
bug in the suspend feature which made it crash when resuming the process).
Diffstat (limited to 'index.js')
-rwxr-xr-xindex.js5
1 files changed, 2 insertions, 3 deletions
diff --git a/index.js b/index.js
index 2b6978b..26f0fbb 100755
--- a/index.js
+++ b/index.js
@@ -67,9 +67,8 @@ async function main() {
     }
   })
 
-  const { appElement, renderInterval } = await setupClient({
+  const { appElement, dirtyTerminal, flushable, root } = await setupClient({
     backend,
-    frameRate: 50,
     interfacer: new CommandLineInterfacer(),
     writable: process.stdout
   })
@@ -78,7 +77,6 @@ async function main() {
     if (telnetServer) {
       telnetServer.disconnectAllSockets('User closed mtui - see you!')
     }
-    clearInterval(renderInterval)
     process.exit(0)
   })
 
@@ -91,6 +89,7 @@ async function main() {
     process.stdin.setRawMode(false)
     process.stdin.setRawMode(true)
     dirtyTerminal()
+    root.renderNow()
   })
 
   const loadPlaylists = async () => {