Skip to content

Instantly share code, notes, and snippets.

@johnspackman
Created August 9, 2013 10:55
Show Gist options
  • Save johnspackman/6192788 to your computer and use it in GitHub Desktop.
Save johnspackman/6192788 to your computer and use it in GitHub Desktop.
var blessed = require('blessed');
// Create a screen object.
var screen = blessed.screen();
var list = blessed.list({
width: 50,
height: 10,
top: 1,
left: 1,
fg: 'blue',
border: {
type: 'line'
},
selectedBg: 'green',
// Allow mouse support
mouse: true,
// Allow key support (arrow keys + enter)
keys: true,
// Use vi built-in keys
vi: true
});
list.setItems([
'one',
'two',
'three',
'four',
'five',
'six',
'seven',
'eight',
'nine',
'ten'
]);
list.prepend(new blessed.Text({
left: 2,
content: ' My list '
}));
// Allow scrolling with the mousewheel (manually).
// list.on('wheeldown', function() {
// list.down();
// });
//
// list.on('wheelup', function() {
// list.up();
// });
// Select the first item.
list.select(0);
screen.key('q', function(ch, key) {
return process.exit(0);
});
screen.append(list);
screen.render();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment