« get me outta code hell

UI UI UI UI UI - 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>2018-05-30 10:44:59 -0300
committerFlorrie <towerofnix@gmail.com>2018-05-30 10:44:59 -0300
commit7473ad4227772295570299873e75032431d1cf41 (patch)
tree4169b2bb6a7a5ee40c832dd8faa219270ba733b4 /index.js
parenta5dd84ec0e46f20954feafa83aea507c2da79a41 (diff)
UI UI UI UI UI
Diffstat (limited to 'index.js')
-rw-r--r--index.js49
1 files changed, 49 insertions, 0 deletions
diff --git a/index.js b/index.js
index f85d101..a86918a 100644
--- a/index.js
+++ b/index.js
@@ -2,7 +2,12 @@
 
 const { getPlayer } = require('./players')
 const { getDownloaderFor } = require('./downloaders')
+const { AppElement } = require('./ui')
+const ansi = require('./tui-lib/util/ansi')
+const CommandLineInterfacer = require('./tui-lib/util/CommandLineInterfacer')
 const EventEmitter = require('events')
+const Flushable = require('./tui-lib/util/Flushable')
+const Root = require('./tui-lib/ui/Root')
 
 class InternalApp extends EventEmitter {
   constructor() {
@@ -53,9 +58,53 @@ async function main() {
   internalApp.stopPlaying()
   */
 
+  /*
   for (const item of require('./flat.json').items) {
     await internalApp.download(item.downloaderArg)
   }
+  */
+
+  const interfacer = new CommandLineInterfacer()
+  const size = await interfacer.getScreenSize()
+
+  const flushable = new Flushable(process.stdout, true)
+  flushable.screenLines = size.lines
+  flushable.screenCols = size.cols
+  flushable.shouldShowCompressionStatistics = process.argv.includes('--show-ansi-stats')
+  flushable.write(ansi.clearScreen())
+  flushable.flush()
+
+  const root = new Root(interfacer)
+  root.w = size.width
+  root.h = size.height
+
+  const appElement = new AppElement()
+  root.addChild(appElement)
+  root.select(appElement)
+
+  appElement.on('quitRequested', () => {
+    process.stdout.write(ansi.cleanCursor())
+    process.exit(0)
+  })
+
+  const grouplike = {
+    items: [
+      {name: 'Nice'},
+      {name: 'W00T!'},
+      {name: 'All-star'}
+    ]
+  }
+
+  appElement.recordStore.getRecord(grouplike.items[2]).downloading = true
+
+  appElement.grouplikeListingElement.loadGrouplike(grouplike)
+
+  root.select(appElement.grouplikeListingElement)
+
+  setInterval(() => {
+    root.renderTo(flushable)
+    flushable.flush()
+  }, 50)
 }
 
 main().catch(err => console.error(err))