UI Toolkit for node.js console apps
npm install node-term-ui
|2|| downloads in the last week|
|7|| downloads in the last month|
TermUI is a library for Node.js that makes it easier to create rich console
## General Usage
- `out(text)` - prints text to the screen from the current cursor position
- `clear()` - clears the screen
- `pos(x,y)` - positions the cursor
- `home()` - sends the cursor to the top left corner
- `end()` - sends the cursor to the bottom right corner
- `fg(color)` - sets the foreground color
- `bg(color)` - sets the background color
- `hifg(color)` - sets the foreground color for 256 color terminals
- `hibg(color)` - sets the background color for 256 color terminals
- `enableMouse()` - enables mouse event handling
- `disableMouse()` - disables mouse event handling
- `eraseLine()` - erases the entire line that the cursor is on
- `hideCursor()` - hides the cursor
- `showCursor()` - shows the cursor
The following will print "Hello, world!" at 10, 20 in the terminal in white text
on a red background:
As you can see, pretty much everything is chainable.
### Handy Rendering Shortcuts
The `C` object contains definitions for common colors so that you don't have
to remember the numeric values.
- k: black
- r: red
- g: green
- y: yellow
- b: blue
- m: magenta
- c: cyan
- w: white
- x: the terminal's default color
The `S` object is similar: it contains the text style definitions -- normal,
bold, underline, blink, and inverse.
The `SYM` object contains shortcuts for some handy UTF8 characters: star, check
x, triUp, triDown, triLeft, triRight, fn, arrowUp, arrowDown, arrowLeft, and
`resize` is fired when the user resizes their terminal. The listener receives
an object with 'w' and 'h' properties set to the new width and height of the
`keypress` is fired when a key is pressed. This works just like the `keypress`
event on `process.stdin`
`mousedown, mouseup, drag, wheel` are all the mouse events that are fired. The
receiver is sent an object that contains which button was pressed, which direction
the wheel scrolled, the x/y location, and whether or not shift was pressed.
Buttons are simply clickable rectangular areas that can have a label on them.
Here's how to use one...
TermUI = require 'TermUI'
button = new TermUI.Button
label: 'I am a banana!'
button.on 'mousedown', ->
button.bg = TermUI.C.y
button.on 'mouseup', ->
button.bg = TermUI.C.b