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