« get me outta code hell

label.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/label.js
blob: f9599c64e7d84d1c813f4718f52a3db0391691f1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// An example of basic label usage.

import {Label} from 'tui-lib/ui/presentation'

import * as ansi from 'tui-lib/util/ansi'

const label1 = new Label('Hello, world!')
const label2 = new Label('I love labels.')

label1.x = 3
label1.y = 2

label2.x = label1.x
label2.y = label1.y + 1

process.stdout.write(ansi.clearScreen())
label1.drawTo(process.stdout)
label2.drawTo(process.stdout)

process.stdin.once('data', () => {
  process.stdout.write(ansi.clearScreen())
  process.exit(0)
})