Created
August 9, 2013 10:55
-
-
Save johnspackman/6192788 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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