123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- import {Root} from 'tui-lib/ui/primitives'
- import {Button, ListScrollForm} from 'tui-lib/ui/controls'
- import {CommandLineInterface} from 'tui-lib/util/interfaces'
- import * as ansi from 'tui-lib/util/ansi'
- const clInterface = new CommandLineInterface()
- clInterface.getScreenSize().then(size => {
- const root = new Root(clInterface)
- root.w = size.width
- root.h = size.height
- const list = new ListScrollForm()
- root.addChild(list)
- list.x = 2
- list.y = 2
- list.w = root.contentW - 4
- list.h = root.contentH - 4
- for (const item of ['Foo', 'Bar', 'Baz']) {
- const button = new Button(item)
- list.addInput(button)
- button.on('pressed', () => {
- process.stdout.write(ansi.cleanCursor())
- process.stdout.write(ansi.clearScreen())
- console.log(item)
- process.exit(0)
- })
- button.fixLayout()
- }
- list.fixLayout()
- root.select(list)
- setInterval(() => root.render(), 100)
- }).catch(error => {
- console.error(error)
- process.exit(1)
- })
|