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

const ansi = require('../util/ansi')
const Label = require('../ui/Label')

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)
})