« get me outta code hell

mtui - Music Text User Interface - user-friendly command line music player
about summary refs log tree commit diff
path: root/client.js
diff options
context:
space:
mode:
Diffstat (limited to 'client.js')
-rw-r--r--client.js36
1 files changed, 15 insertions, 21 deletions
diff --git a/client.js b/client.js
index ec1ab60..0af45f6 100644
--- a/client.js
+++ b/client.js
@@ -1,22 +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 {
-  ui: {
-    Root
-  },
-  util: {
-    ansi,
-    Flushable,
-    TelnetInterfacer
-  }
-} = require('tui-lib')
+import AppElement from './ui.js'
+
+import {Root} from 'tui-lib/ui/primitives'
 
-const setupClient = async ({backend, writable, interfacer, appConfig}) => {
+import {Flushable} from 'tui-lib/util/interfaces'
+import * as ansi from 'tui-lib/util/ansi'
+
+export default async function setupClient({
+  backend,
+  writable,
+  screenInterface,
+  appConfig,
+}) {
   const cleanTerminal = () => {
     writable.write(ansi.cleanCursor())
     writable.write(ansi.disableAlternateScreen())
@@ -30,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()
@@ -42,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)
@@ -69,5 +65,3 @@ const setupClient = async ({backend, writable, interfacer, appConfig}) => {
 
   return {appElement, cleanTerminal, dirtyTerminal, flushable, root}
 }
-
-module.exports = setupClient