blessed-contrib
Advanced tools
Comparing version 2.0.0 to 2.0.1
13
index.js
@@ -8,7 +8,8 @@ | ||
exports.gauge = require('./lib/widget/gauge') | ||
exports.log = require('./lib/widget/log') | ||
exports.picture = require('./lib/widget/picture') | ||
exports.sparkline = require('./lib/widget/sparkline') | ||
exports.table = require('./lib/widget/table') | ||
exports.gauge = require('./lib/widget/gauge.js') | ||
exports.log = require('./lib/widget/log.js') | ||
exports.picture = require('./lib/widget/picture.js') | ||
exports.sparkline = require('./lib/widget/sparkline.js') | ||
exports.table = require('./lib/widget/table.js') | ||
exports.tree = require('./lib/widget/tree.js') | ||
@@ -20,2 +21,2 @@ exports.bar = require('./lib/widget/charts/bar') | ||
exports.InputBuffer = require('./lib/server-utils').InputBuffer | ||
exports.createScreen = require('./lib/server-utils').createScreen | ||
exports.createScreen = require('./lib/server-utils').createScreen |
@@ -32,4 +32,10 @@ var blessed = require('blessed') | ||
Table.prototype.focus = function(){ | ||
this.rows.focus(); | ||
} | ||
Table.prototype.render = function() { | ||
this.rows.focus() | ||
if(this.screen.focused == this.rows) | ||
this.rows.focus() | ||
this.rows.width = this.width-3 | ||
@@ -36,0 +42,0 @@ this.rows.height = this.height-4 |
{ | ||
"name": "blessed-contrib", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -82,2 +82,4 @@ ## blessed-contrib | ||
[Tree](#tree) | ||
### Line Chart | ||
@@ -214,2 +216,84 @@ | ||
### Tree | ||
<img src="./docs/images/tree.gif" alt="table" width="250"> | ||
`````javascript | ||
var tree = contrib.tree({fg: 'green'}) | ||
//allow control the table with the keyboard | ||
tree.focus() | ||
tree.on('select',function(node){ | ||
if (node.myCustomProperty){ | ||
console.log(node.myCustomProperty); | ||
} | ||
console.log(node.name); | ||
} | ||
// you can specify a name property at root level to display root | ||
tree.setData( | ||
{ extended: true | ||
, children: | ||
{ | ||
'Fruit': | ||
{ children: | ||
{ 'Banana': {} | ||
, 'Apple': {} | ||
, 'Cherry': {} | ||
, 'Exotics': { | ||
children: | ||
{ 'Mango': {} | ||
, 'Papaya': {} | ||
, 'Kiwi': { name: 'Kiwi (not the bird!)', myCustomProperty: "hairy fruit" } | ||
}} | ||
, 'Pear': {}}} | ||
, 'Vegetables': | ||
{ children: | ||
{ 'Peas': {} | ||
, 'Lettuce': {} | ||
, 'Pepper': {}}}}}) | ||
````` | ||
#### Options | ||
* keys : Key to expand nodes. Default : ['enter','default'] | ||
* extended : Should nodes be extended/generated by default? Be careful with this setting when using a callback function. Default : false | ||
* template : | ||
* extend : Suffix "icon" for closed node. Default : '[+]' | ||
* retract : Suffix "icon" for opened node. Default : '[-]' | ||
* lines : Show lines in tree. Default : true | ||
#### Nodes | ||
Every node is a hash and it can have custom properties that can be used in "select" event callback. However, there is sevral special keys : | ||
* name | ||
* *Type* : `string` | ||
* *Desc* : Node name | ||
* If the node isn't the root and you don't specify the name, will be set to hash key | ||
* *Example* : <code>{ name: 'Fruit'}</code> | ||
* children | ||
* *Type* : `hash` or `function(node){ return children }` | ||
* *Desc* : Node children. | ||
* The function must return a hash that could have been used as children property | ||
* If you use a function, the result will be stored in `node.childrenContent` and `children` | ||
* *Example* : | ||
* Hash : <code>{'Fruit':{ name: 'Fruit', children:{ 'Banana': {}, 'Cherry': {}}}}</code> | ||
* Function : see `examples/explorer.js` | ||
* childrenContent | ||
* *Type* : `hash` | ||
* *Desc* : Children content for internal usage *DO NOT MODIFY* | ||
* If `node.children` is a hash, `node.children===node.childrenContent` | ||
* If `node.children` is a function, it's used to store the `node.children()` result | ||
* You can read this property, but you should never write it. | ||
* Usually this will be used to check `if(node.childrenContent)` in your `node.children` function to generate children only once | ||
* extended | ||
* *Type* : `boolean` | ||
* *Desc* : Determine if this node is extended | ||
* No effect when the node have no child | ||
* Default value for each node will be `treeInstance.options.extended` if the node `extended` option is not set | ||
* *Example* : <code>{'Fruit':{ name: 'Fruit', extended: true, children:{ 'Banana': {}, 'Cherry': {}}}}</code> | ||
### Layouts | ||
@@ -216,0 +300,0 @@ |
37961
18
744
432