Skip to content

Instantly share code, notes, and snippets.

@DrMabuse23
Created July 8, 2015 19:31
Show Gist options
  • Save DrMabuse23/b83cf26b9e5a169e576e to your computer and use it in GitHub Desktop.
Save DrMabuse23/b83cf26b9e5a169e576e to your computer and use it in GitHub Desktop.
var blessed = require('blessed')
, contrib = require('blessed-contrib')
, screen = blessed.screen();
var grid = new contrib.grid({rows: 12, cols: 12, screen: screen});
var tree = grid.set(0, 0, 4, 4, contrib.tree, {label: 'Commands'});
//allow control the table with the keyboard
tree.focus();
var log = grid.set(4, 2, 2, 2, contrib.log,
{
label: 'Server Log'
});
log.log("new log line")
tree.on('select', function (node) {
log.log(node.name);
if (node.myCustomProperty){
log.log(node.myCustomProperty);
}
//log.log(JSON.stringify(node));
});
// you can specify a name property at root level to display root
tree.setData(
{
extended: true,
children: {
'Server': {
children: {
'add': {},
'remove': {}
}
}
}
})
screen.key(['escape', 'q', 'C-c'], function (ch, key) {
return process.exit(0);
});
screen.render();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment