« get me outta code hell

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
diff options
context:
space:
mode:
Diffstat (limited to 'examples/interfacer-command-line.js')
-rw-r--r--examples/interfacer-command-line.js24
1 files changed, 24 insertions, 0 deletions
diff --git a/examples/interfacer-command-line.js b/examples/interfacer-command-line.js
new file mode 100644
index 0000000..1da6adf
--- /dev/null
+++ b/examples/interfacer-command-line.js
@@ -0,0 +1,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)
+})