clite.libs.data = function() { clite.libs.load('libcurses','curses',function(io,env) { return Object.create({ isinit:false, types:{ A_NULL:0, A_BOLD:1, }, attmap:function(t) { switch (t) { case this.types.A_BOLD: return 'bold'; break; } return null; }, initscr:function() { // curses only works on a tty if (!clite.io.isatty(io.pid,io.stdin)) return false; this.isinit = clite.term.ttyctrl('alt',true); }, endwin:function() { if (!this.isinit) return; clite.term.ttyctrl('rawin',false); clite.term.ttyctrl('rawout',false); clite.term.ttyctrl('echo',true); clite.term.ttyctrl('iset',''); this.isinit = clite.term.ttyctrl('alt',false); }, cbreak:function() { if (!this.isinit) return; clite.term.ttyctrl('rawin',true); }, nocbreak:function() { if (!this.isinit) return; clite.term.ttyctrl('rawin',false); }, raw:function() { if (!this.isinit) return; clite.term.ttyctrl('rawin',true); }, noraw:function() { if (!this.isinit) return; clite.term.ttyctrl('rawin',false); }, clear:function() { if (!this.isinit) return; clite.term.clear(); }, echo:function() { if (!this.isinit) return; clite.term.ttyctrl('echo',true); }, noecho:function() { if (!this.isinit) return; clite.term.ttyctrl('echo',false); }, printw:function(fmt) { if (!this.isinit) return; var args = Array.from(arguments); args.shift(); clite.io.vfprintf(io.pid,io.stdout,fmt,args); }, getch:function(cb) { if (!this.isinit) return false; return clite.io.read(io.pid,io.stdin,cb); }, refresh:function() { // no op, drawing isn't queued }, attron:function(a) { if (!this.isinit) return; a = this.attmap(a); clite.term.ttyctrl('atton',a); }, attroff:function(a) { if (!this.isinit) return; a = this.attmap(a); clite.term.ttyctrl('attoff',a); }, getmaxx:function() { if (!this.isinit) return 0; return clite.term.data.alt.cols; }, getmaxy:function() { if (!this.isinit) return 0; return clite.term.data.alt.lines; }, getmaxyx:function(ptry,ptrx) { if (!this.isinit) return false; ptrx.value = clite.term.data.alt.cols; ptry.value = clite.term.data.alt.lines; return true; } }); }); };