Skip to content

Instantly share code, notes, and snippets.

@alfonsodev
Last active December 26, 2015 19:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alfonsodev/7199536 to your computer and use it in GitHub Desktop.
Save alfonsodev/7199536 to your computer and use it in GitHub Desktop.
ncurses snippet for nodejs
//first do a 'npm install ncurses'
var nc = require('ncurses'),
widgets = require('./node_modules/ncurses/lib/widgets');
var win = new nc.Window();
nc.showCursor = false;
widgets.MessageBox('Do you want to continue', { buttons: ['OK', 'Cancel'], pos: 'center'}, function(choice) {
win.refresh();
if(choice == 'OK') {
win.centertext(0, 'Press a key to know the code, [q] or [scape] to quit.');
win.refresh();
} else {
win.centertext(0, 'Bye! ');
setTimeout(function() { win.close(); }, 1000);
}
});
win.on('inputChar', function(char, charCode, isKey) {
win.refresh();
win.centertext(1, 'charCode: ' + charCode);
if(charCode == 27 || charCode == 113) {
win.centertext(5, 'Bye!' );
setTimeout(function() { win.close(); }, 500);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment