clivas
v0.2.0
Published
use your terminal as a canvas. features easy redrawing, colors and more
Downloads
1,323
Readme
clivas
Turn your terminal into a canvas.
It is available through npm:
npm install clivas
Usage
It is easy to use
var clivas = require('clivas');
var frame = 0;
setInterval(function() {
clivas.clear(); // clears the canvas
clivas.line('hello world (#frame '+frame+')');
clivas.line('{red:also} {green:colors}!');
frame++;
}, 200);
When you draw something with clivas you can use the format patten to help you
clivas.line('{red:i am red} and {blue: i am blue}');
If you wanted to inverse a color you would provide the inverse tag
clivas.line('{red+inverse:i am inversed}');
The format pattern can also help you add whitespace
clivas.line('[{10:===>}]'); // prints [===> ]
API
clivas.clear()
- Clears the screen. If you calledclivas.pin()
it would only clear up until the pin.clivas.flush()
- Clears everything below the cursor.clivas.pin([lineNumber])
- Only clear to here whenclivas.clear()
is calledclivas.line(str)
- Write a line (accepts a format string as described above)clivas.write(str)
- Same asclivas.line(str)
except it does not add a newlineclivas.cursor(enable)
- Enable or disable the terminal cursorclivas.alias(name, value)
- Add an alias to the format pattern i.e.clivas.alias('link', 'red+underline')
enables you to use{link:http://google.com}
License
MIT