diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2023-05-13 21:54:52 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2023-05-13 21:54:52 -0300 |
commit | 4ea5e57d2b6c12f42ff21c4b43056021553f07a0 (patch) | |
tree | 175c5c662639496fc859fa9a4852c363a6bab11d /client.js | |
parent | 84c49e453336d6105655edd08e93bab071c0fc3b (diff) | |
parent | a36e372ba88b59e08fa938f76b261fdc2797bef2 (diff) |
Merge branch 'main' into socket-mtui
And also get most of it working wow.
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 |