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.15 kB
JavaScript
const u=require("./node"),a=require("./box"),c=require("./button"),d=require("./textbox");function e(t){if(!(this instanceof u))return new e(t);t=t||{},t.hidden=!0,a.call(this,t),this._.input=new d({parent:this,top:3,height:1,left:2,right:2,bg:"black"}),this._.okay=new c({parent:this,top:5,height:1,left:2,width:6,content:"Okay",align:"center",bg:"black",hoverBg:"blue",autoFocus:!1,mouse:!0}),this._.cancel=new c({parent:this,top:5,height:1,shrink:!0,left:10,width:8,content:"Cancel",align:"center",bg:"black",hoverBg:"blue",autoFocus:!1,mouse:!0})}e.prototype.__proto__=a.prototype,e.prototype.type="prompt",e.prototype.input=e.prototype.setInput=e.prototype.readInput=function(t,n,o){const r=this;let i,s;o||(o=n,n=""),this.show(),this.setContent(" "+t),this._.input.value=n,this.screen.saveFocus(),this._.okay.on("press",i=function(){r._.input.submit()}),this._.cancel.on("press",s=function(){r._.input.cancel()}),this._.input.readInput(function(l,p){return r.hide(),r.screen.restoreFocus(),r._.okay.removeListener("press",i),r._.cancel.removeListener("press",s),o(l,p)}),this.screen.render()},module.exports=e;
//# sourceMappingURL=prompt.js.map