diff options
Diffstat (limited to 'client.js')
-rw-r--r-- | client.js | 46 |
1 files changed, 15 insertions, 31 deletions
diff --git a/client.js b/client.js index aa854ed..0af45f6 100644 --- a/client.js +++ b/client.js @@ -1,23 +1,18 @@ // Generic code for setting up mtui and the UI for any command line client. -'use strict' - -const AppElement = require('./ui') -const processSmartPlaylist = require('./smart-playlist') -const os = require('os') - -const { - ui: { - Root - }, - util: { - ansi, - Flushable, - TelnetInterfacer - } -} = require('tui-lib') +import AppElement from './ui.js' + +import {Root} from 'tui-lib/ui/primitives' + +import {Flushable} from 'tui-lib/util/interfaces' +import * as ansi from 'tui-lib/util/ansi' -const setupClient = async ({backend, writable, interfacer, appConfig}) => { +export default async function setupClient({ + backend, + writable, + screenInterface, + appConfig, +}) { const cleanTerminal = () => { writable.write(ansi.cleanCursor()) writable.write(ansi.disableAlternateScreen()) @@ -31,10 +26,10 @@ const setupClient = async ({backend, writable, interfacer, appConfig}) => { dirtyTerminal() const flushable = new Flushable(writable, true) - const root = new Root(interfacer, flushable) + const root = new Root(screenInterface, flushable) root.on('rendered', () => flushable.flush()) - const size = await interfacer.getScreenSize() + const size = await screenInterface.getScreenSize() root.w = size.width root.h = size.height root.fixAllLayout() @@ -43,7 +38,7 @@ const setupClient = async ({backend, writable, interfacer, appConfig}) => { flushable.write(ansi.clearScreen()) flushable.flush() - interfacer.on('resize', newSize => { + screenInterface.on('resize', newSize => { root.w = newSize.width root.h = newSize.height flushable.resizeScreen(newSize) @@ -63,15 +58,6 @@ const setupClient = async ({backend, writable, interfacer, appConfig}) => { cleanTerminal() }) - let grouplike = { - name: 'My ~/Music Library', - comment: ( - '(Add tracks and folders to ~/Music to make them show up here,' + - ' or pass mtui your own playlist.json file!)'), - source: ['crawl-local', os.homedir() + '/Music'] - } - await appElement.loadPlaylistOrSource(grouplike, true) - root.select(appElement) // Load up initial state @@ -79,5 +65,3 @@ const setupClient = async ({backend, writable, interfacer, appConfig}) => { return {appElement, cleanTerminal, dirtyTerminal, flushable, root} } - -module.exports = setupClient |