gauge
Advanced tools
Comparing version 2.3.1 to 2.4.0
@@ -0,1 +1,8 @@ | ||
### v2.4.0 | ||
* Add support for setting themesets on existing gauge objects. | ||
* Add post-IO callback to `gauge.hide()` as it is somtetimes necessary when | ||
your terminal is interleaving output from multiple filehandles (ie, stdout | ||
& stderr). | ||
### v2.3.1 | ||
@@ -2,0 +9,0 @@ |
19
index.js
@@ -9,2 +9,3 @@ 'use strict' | ||
var process = require('./process.js') | ||
var setImmediate = require('./set-immediate') | ||
@@ -50,2 +51,3 @@ module.exports = Gauge | ||
this._themes = options.themes || defaultThemes | ||
this._theme = options.theme | ||
var theme = this._computeTheme(options.theme) | ||
@@ -94,10 +96,16 @@ var template = options.template || [ | ||
Gauge.prototype.setThemeset = function (themes) { | ||
this._themes = themes | ||
this.setTheme(this._theme) | ||
} | ||
Gauge.prototype.setTheme = function (theme) { | ||
this._gauge.setTheme(this._computeTheme(theme)) | ||
if (this._showing) this._requestRedraw() | ||
this._theme = theme | ||
} | ||
Gauge.prototype._requestRedraw = function () { | ||
this._needsRedraw = true | ||
if (!this._fixedFramerate) this._doRedraw() | ||
this._needsRedraw = true | ||
if (!this._fixedFramerate) this._doRedraw() | ||
} | ||
@@ -151,7 +159,8 @@ | ||
Gauge.prototype.hide = function () { | ||
if (this._disabled) return | ||
if (!this._showing) return | ||
Gauge.prototype.hide = function (cb) { | ||
if (this._disabled) return cb && process.nextTick(cb) | ||
if (!this._showing) return cb && process.nextTick(cb) | ||
this._showing = false | ||
this._doRedraw() | ||
cb && setImmediate(cb) | ||
} | ||
@@ -158,0 +167,0 @@ |
{ | ||
"name": "gauge", | ||
"version": "2.3.1", | ||
"version": "2.4.0", | ||
"description": "A terminal based horizontal guage", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -121,6 +121,14 @@ gauge | ||
#### `gauge.hide()` | ||
#### `gauge.hide([cb])` | ||
Removes the gauge from the terminal. | ||
Removes the gauge from the terminal. Optionally, callback `cb` after IO has | ||
had an opportunity to happen (currently this just means after `setImmediate` | ||
has called back.) | ||
It turns out this is important when you're pausing the progress bar on one | ||
filehandle and printing to another– otherwise (with a big enough print) node | ||
can end up printing the "end progress bar" bits to the progress bar filehandle | ||
while other stuff is printing to another filehandle. These getting interleaved | ||
can cause corruption in some terminals. | ||
#### `gauge.pulse([subsection])` | ||
@@ -141,6 +149,21 @@ | ||
#### `gauge.setThemeset(themes)` | ||
Change the themeset to select a theme from. The same as the `themes` option | ||
used in the constructor. The theme will be reselected from this themeset. | ||
#### `gauge.setTheme(theme)` | ||
Change the active theme, will be displayed with the next show or pulse | ||
Change the active theme, will be displayed with the next show or pulse. This can be: | ||
* Theme object, in which case the **themes** is not used. | ||
* The name of a theme, which will be looked up in the current *themes* | ||
object. | ||
* A configuration object with any of `hasUnicode`, `hasColor` or | ||
`platform` keys, which if wlll be used to override our guesses when making | ||
a default theme selection. | ||
If no theme is selected then a default is picked using a combination of our | ||
best guesses at your OS, color support and unicode support. | ||
#### `gauge.setTemplate(template)` | ||
@@ -147,0 +170,0 @@ |
@@ -238,37 +238,39 @@ 'use strict' | ||
constructor | ||
arg2 is writeTo, arg1 is opts | ||
arg2 is writeTo, arg1 is null | ||
no args, all defaults | ||
writeTo: process.stderr & process.stdout IS A TTY (or isn't) | ||
cleanupOnExit: explicitly set to true | ||
setTemplate | ||
setThemeset | ||
setTheme | ||
w/ theme selector | ||
w/ theme name | ||
w/ theme object | ||
setWriteTo | ||
while enabled/disabled | ||
w/ tty | ||
w/o tty & writeTo = process.stderr & process.stdout isTTY | ||
w/o tty & writeTo = process.stderr & process.stdout !isTTY | ||
enable | ||
w/ _showing = true | ||
hide | ||
w/ disabled | ||
w/ !disabled & !showing | ||
w/ !disabled & showing | ||
w/ these & cb | ||
show | ||
w/ disabled | ||
w/ object arg1 | ||
pulse | ||
w/ disabled | ||
w/ !showing | ||
disable while showing then enable | ||
anything to do with _fixedFramerate | ||
enable while fixedFramerate is false | ||
trigger _doRedraw | ||
w/o showing & w/o _onScreen (eg, hide, show, hide, I think) | ||
w/o _needsRedraw | ||
enable while fixedFramerate is true & redrawTracker.unref is false (0.8) | ||
Everything to do with back pressure from _writeTo | ||
disable while fixedFramerate is false | ||
hide() | ||
show() while disabled | ||
show() with object args | ||
show() with neither string nor object (undefined? number?) | ||
show() with fixedFramerate == false | ||
pulse() while disabled | ||
pulse while _showing == false | ||
pulse where fixedFramerate == false | ||
implicit: | ||
_doRedraw will get called with fixedFramerate = false if we test the above | ||
trigger a show + redraw with hideCursor = true | ||
trigger a hide + redraw with hideCursor = true | ||
trigger a _doRedraw when _needsRedraw is false | ||
TEST BACKPRESSURE | ||
*/ |
Sorry, the diff of this file is not supported yet
319417
38
1588
389