From 7473ad4227772295570299873e75032431d1cf41 Mon Sep 17 00:00:00 2001 From: Florrie Date: Wed, 30 May 2018 10:44:59 -0300 Subject: UI UI UI UI UI --- index.js | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'index.js') 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)) -- cgit 1.3.0-6-gf8a5