« get me outta code hell

interfacer-command-line.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/interfacer-command-line.js
blob: 1da6adfef2e8d43352b0f94d004feceafd633c4b (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
const Root = require('../ui/Root')
const CommandLineInterfacer = require('../util/CommandLineInterfacer')
const AppElement = require('./basic-app')

const interfacer = new CommandLineInterfacer()

interfacer.getScreenSize().then(size => {
  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.exit(0)
  })

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