From 0547509481b2825f6f48847072eef5bc2609d0ab Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Thu, 6 Aug 2015 00:13:03 -0700 Subject: [PATCH] add a small Tput.print helper function. --- lib/tput.js | 10 ++++++++++ test/tput.js | 19 ++++++++----------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/lib/tput.js b/lib/tput.js index cb9fedc..2851f7c 100644 --- a/lib/tput.js +++ b/lib/tput.js @@ -1227,6 +1227,16 @@ Tput.prototype._print = function(code, print, done) { })(); }; +// A small helper function if we want +// to easily output text with setTimeouts. +Tput.print = function() { + var fake = { + padding: true, + bools: { needs_xon_xoff: true, xon_xoff: false } + }; + return Tput.prototype._print.apply(fake, arguments); +}; + /** * Termcap */ diff --git a/test/tput.js b/test/tput.js index d42bde7..b199dc2 100644 --- a/test/tput.js +++ b/test/tput.js @@ -107,17 +107,14 @@ if (argv[0] === 'all') { result = result.trim().toLowerCase(); if (result !== 'y') return process.exit(0); console.log('\x1b[32m(You bet your ass I wish to proceed.)\x1b[m'); - // tput._write('$<1000/>.$<1000/>.$<1000/>.$<100/>Let\'s go...', - // process.stdout.write.bind(process.stdout), - // function() {}); - setTimeout(function() { process.stdout.write('.'); }, 1000); - setTimeout(function() { process.stdout.write('.'); }, 2000); - setTimeout(function() { process.stdout.write('.'); }, 3000); - setTimeout(function() { console.log('Let\'s go...'); }, 3100); - setTimeout(function() { - tput.compileAll(argv[1]); - process.exit(0); - }, 4000); + blessed.tput.print( + '$<1000/>.$<1000/>.$<1000/>.$<100/>Let\'s go...', + process.stdout.write.bind(process.stdout), + function() { + tput.compileAll(argv[1]); + process.exit(0); + } + ); }); return;