« get me outta code hell

A long-due cleanup + examples + things - 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:
authorliam4 <towerofnix@gmail.com>2017-07-03 18:59:57 -0300
committerliam4 <towerofnix@gmail.com>2017-07-03 19:00:01 -0300
commit769413468e88acba1a180baa0113139d929a3b9f (patch)
treef29af36826077178259b7bcc8bf9927cebfe71e3 /examples/interfacer-command-line.js
parent489e4d0c78d5f393729cda0e1f6ac9a0a1237b4a (diff)
A long-due cleanup + examples + things
..Obviously this breaks old things (particularly, see changes in
FocusElement).
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)
+})