@pilotlab/lux-debug
Version:
A luxurious user experience framework, developed by your friends at Pilot.
53 lines • 2.08 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var readline = require('readline');
var LogCursor = (function () {
function LogCursor(console) {
this._console = console;
}
LogCursor.prototype.setLine = function (value) { return this.setPosition(undefined, value); };
LogCursor.prototype.setColumn = function (value) { return this.setPosition(value, undefined); };
LogCursor.prototype.setPosition = function (x, y) { readline.cursorTo(this._console.stream, x, y); return this; };
LogCursor.prototype.move = function (x, y) { readline.moveCursor(this._console.stream, x, y); return this; };
LogCursor.prototype.up = function (value) {
if (value === void 0) { value = 1; }
return this.move(0, -Math.abs(value));
};
LogCursor.prototype.down = function (value) {
if (value === void 0) { value = 1; }
return this.move(0, Math.abs(value));
};
LogCursor.prototype.left = function (value) {
if (value === void 0) { value = 1; }
return this.move(-Math.abs(value), 0);
};
LogCursor.prototype.right = function (value) {
if (value === void 0) { value = 1; }
return this.move(Math.abs(value), 0);
};
LogCursor.prototype.hide = function () {
this._readline = readline.createInterface({
input: process.stdin,
output: process.stdout
});
if (this._readline)
this._readline.pause();
this._console.stream.write(this._encode('[?25l'));
return this;
};
LogCursor.prototype.show = function () {
if (this._readline) {
this._readline.close();
}
this._console.stream.write(this._encode('[?25h'));
return this;
};
LogCursor.prototype._encode = function (value) {
return new Buffer([0x1b].concat(value.split('').map(function (value) { return value.charCodeAt(0); })));
};
;
return LogCursor;
}());
exports.LogCursor = LogCursor;
exports.default = LogCursor;
//# sourceMappingURL=logCursor.js.map