neo-neo-bblessed
Version:
A fork of neo-blessed (which is a fork of blessed) with bug fixes and maintenance.
3 lines (2 loc) • 1.19 kB
JavaScript
const o=require("util"),i=global.setImmediate||process.nextTick.bind(process),a=require("./node"),s=require("./scrollabletext");function r(t){const e=this;if(!(this instanceof a))return new r(t);t=t||{},s.call(this,t),this.scrollback=t.scrollback!=null?t.scrollback:1/0,this.scrollOnInput=t.scrollOnInput,this.on("set content",function(){(!e._userScrolled||e.scrollOnInput)&&i(function(){e.setScrollPerc(100),e._userScrolled=!1,e.screen.render()})})}r.prototype.__proto__=s.prototype,r.prototype.type="log",r.prototype.log=r.prototype.add=function(...t){const e=Array.prototype.slice.call(arguments);if(typeof e[0]=="object"){let l=o.inspect(e[0],{depth:1,colors:!0,maxArrayLength:50});l.length<1e3&&(l=o.inspect(e[0],{depth:2,colors:!0,maxArrayLength:50})),e[0]=l}const n=o.format.apply(o,e);this.emit("log",n);const c=this.pushLine(n);return this._clines.fake.length>this.scrollback&&this.shiftLine(0,this.scrollback/3|0),c},r.prototype._scroll=r.prototype.scroll,r.prototype.scroll=function(t,e){if(t===0)return this._scroll(t,e);this._userScrolled=!0;const n=this._scroll(t,e);return this.getScrollPerc()===100&&(this._userScrolled=!1),n},module.exports=r;
//# sourceMappingURL=log.js.map