« get me outta code hell

command-line-interface.js « examples - tui-lib - Pure Node.js library for making visual command-line programs (ala vim, ncdu)
about summary refs log tree commit diff
path: root/examples/command-line-interface.js
blob: ba1d936796eab0fb6d9c22799e3ac66f8ec16fdb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import {Root} from 'tui-lib/ui/primitives'
import {CommandLineInterface} from 'tui-lib/util/interfaces'

import AppElement from './basic-app.js'

const clInterface = new CommandLineInterface()

clInterface.getScreenSize().then(size => {
  const root = new Root(clInterface)
  root.w = size.width
  root.h = size.height

  const appElement = new AppElement()
  root.addChild(appElement)
  root.select(appElement)

  appElement.on('quitRequested', () => {
    process.exit(0)
  })

  setInterval(() => root.render(), 100)
}).catch(error => {
  console.error(error)
  process.exit(1)
})