From 5be66f7728450c673ca46dbe4a58192c6f6e0831 Mon Sep 17 00:00:00 2001 From: Florian Mounier Date: Fri, 17 Apr 2015 11:30:53 +0200 Subject: [PATCH 1/2] Fix style --- butterfly/sass/_layout.sass | 8 ++++++-- butterfly/static/ext.min.js | 2 +- butterfly/static/main.css | 14 +++++++++----- butterfly/static/main.js | 1 + butterfly/static/main.min.js | 4 ++-- coffees/term.coffee | 1 + 6 files changed, 20 insertions(+), 10 deletions(-) diff --git a/butterfly/sass/_layout.sass b/butterfly/sass/_layout.sass index edca4ea..be49363 100644 --- a/butterfly/sass/_layout.sass +++ b/butterfly/sass/_layout.sass @@ -19,17 +19,21 @@ html, body margin: 0 padding: 0 line-height: 1.2 + +body + white-space: nowrap overflow-x: hidden overflow-y: scroll - white-space: nowrap ::-webkit-scrollbar background: $bg width: .75em - height: .75em ::-webkit-scrollbar-thumb background: rgba($fg, .1) +::-webkit-scrollbar-thumb:hover + background: rgba($fg, .15) + .terminal outline: none diff --git a/butterfly/static/ext.min.js b/butterfly/static/ext.min.js index 62df7ca..a736fac 100644 --- a/butterfly/static/ext.min.js +++ b/butterfly/static/ext.min.js @@ -1,4 +1,4 @@ -/*! butterfly 2015-04-14 */ +/*! butterfly 2015-04-16 */ (function(){var a,b,c,d,e,f,g,h,i,j,k,l=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};j=function(a){var b;return b=function(c){var d;return butterfly.element.classList.remove("alarm"),d="New activity on butterfly terminal ["+butterfly.title+"]",a?new Notification(d,{body:c.data,icon:"/static/images/favicon.png"}):alert(d+"\n"+c.data),butterfly.ws.removeEventListener("message",b)},butterfly.ws.addEventListener("message",b),butterfly.element.classList.add("alarm")},c=function(a){return a.preventDefault&&a.preventDefault(),a.stopPropagation&&a.stopPropagation(),a.cancelBubble=!0,!1},addEventListener("keydown",function(a){return a.altKey&&65===a.keyCode?(Notification&&"default"===Notification.permission?Notification.requestPermission(function(){return j("granted"===Notification.permission)}):j("granted"===Notification.permission),c(a)):!0}),addEventListener("copy",d=function(a){var b,c,d,e,f,g,h;for(butterfly.bell("copied"),a.clipboardData.clearData(),h=getSelection().toString().replace(/\u00A0/g," ").replace(/\u2007/g," "),b="",g=h.split("\n"),d=0,e=g.length;e>d;d++)f=g[d],"⏎"===f.slice(-1)?(c="",f=f.slice(0,-1)):c="\n",b+=f.replace(/\s*$/,"")+c;return a.clipboardData.setData("text/plain",b.slice(0,-1)),a.preventDefault()}),addEventListener("paste",function(a){var b;return butterfly.bell("pasted"),b=a.clipboardData.getData("text/plain"),b=b.replace(/\r\n/g,"\n").replace(/\n/g,"\r"),butterfly.send(b),a.preventDefault()}),i=null,c=function(a){return a.preventDefault&&a.preventDefault(),a.stopPropagation&&a.stopPropagation(),a.cancelBubble=!0,!1},h=function(a){var b;for(b=a.previousSibling,b||(b=a.parentNode.previousSibling),b||(b=a.parentNode.parentNode.previousSibling);b.lastChild;)b=b.lastChild;return b},g=function(a){var b;for(b=a.nextSibling,b||(b=a.parentNode.nextSibling),b||(b=a.parentNode.parentNode.nextSibling);null!=b?b.firstChild:void 0;)b=b.firstChild;return b},a=function(){function a(){butterfly.element.classList.add("selection"),this.selection=getSelection()}return a.prototype.reset=function(){var a,b,c;for(this.selection=getSelection(),a=document.createRange(),a.setStart(this.selection.anchorNode,this.selection.anchorOffset),a.setEnd(this.selection.focusNode,this.selection.focusOffset),this.start={node:this.selection.anchorNode,offset:this.selection.anchorOffset},this.end={node:this.selection.focusNode,offset:this.selection.focusOffset},a.collapsed&&(b=[this.end,this.start],this.start=b[0],this.end=b[1]),this.start_line=this.start.node;!this.start_line.classList||l.call(this.start_line.classList,"line")<0;)this.start_line=this.start_line.parentNode;for(this.end_line=this.end.node,c=[];!this.end_line.classList||l.call(this.end_line.classList,"line")<0;)c.push(this.end_line=this.end_line.parentNode);return c},a.prototype.clear=function(){return this.selection.removeAllRanges()},a.prototype.destroy=function(){return butterfly.element.classList.remove("selection"),this.clear()},a.prototype.text=function(){return this.selection.toString().replace(/\u00A0/g," ").replace(/\u2007/g," ")},a.prototype.up=function(){return this.go(-1)},a.prototype.down=function(){return this.go(1)},a.prototype.go=function(a){var b;if(b=butterfly.children.indexOf(this.start_line)+a,b>=0&&b=0&&b0;)if(f[--d].match(b))return{node:e,offset:d+1};e=h(e),f=e.textContent,d=f.length}else for(;e;){for(;d=0)return!0;if(b.shiftKey&&13===b.keyCode&&!i&&!getSelection().isCollapsed)return butterfly.send(getSelection().toString()),getSelection().removeAllRanges(),c(b);if(i){if(i.reset(),!b.ctrlKey&&b.shiftKey&&37<=(e=b.keyCode)&&40>=e)return!0;if(b.shiftKey&&b.ctrlKey)38===b.keyCode?i.up():40===b.keyCode&&i.down();else if(39===b.keyCode)i.shrink_left();else if(38===b.keyCode)i.expand_left();else if(37===b.keyCode)i.shrink_right();else{if(40!==b.keyCode)return c(b);i.expand_right()}return null!=i&&i.apply(),c(b)}return!i&&b.ctrlKey&&b.shiftKey&&38===b.keyCode?(i=new a,i.select_line(butterfly.y-1),i.apply(),c(b)):!0}),document.addEventListener("keyup",function(a){var b,d;if(b=a.keyCode,l.call([16,17,18,19],b)>=0)return!0;if(i){if(13===a.keyCode)return butterfly.send(i.text()),i.destroy(),i=null,c(a);if(d=a.keyCode,l.call([37,38,39,40],d)<0)return i.destroy(),i=null,!0}return!0}),document.addEventListener("dblclick",function(a){var b,c,d,e,f;if(!(a.ctrlKey||a.altkey||(f=getSelection(),f.isCollapsed||f.toString().match(/\s/)))){for(e=document.createRange(),e.setStart(f.anchorNode,f.anchorOffset),e.setEnd(f.focusNode,f.focusOffset),e.collapsed&&(f.removeAllRanges(),d=document.createRange(),d.setStart(f.focusNode,f.focusOffset),d.setEnd(f.anchorNode,f.anchorOffset),f.addRange(d));!f.toString().match(/\s/)&&f.toString();)f.modify("extend","forward","character");for(f.modify("extend","backward","character"),b=f.anchorNode,c=f.anchorOffset,f.collapseToEnd(),f.extend(b,c);!f.toString().match(/\s/)&&f.toString();)f.modify("extend","backward","character");return f.modify("extend","forward","character")}}),document.addEventListener("DOMContentLoaded",function(){}),/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)&&(e=!1,b=!1,f=!0,k=document.createElement("input"),k.type="password",k.style.position="fixed",k.style.top=0,k.style.left=0,k.style.border="none",k.style.outline="none",k.style.opacity=0,k.value="0",document.body.appendChild(k),k.addEventListener("blur",function(){return setTimeout(function(a){return function(){return a.focus()}}(this),10)}),addEventListener("click",function(){return k.focus()}),addEventListener("touchstart",function(a){return 2===a.touches.length?e=!0:3===a.touches.length?(e=!1,b=!0):4===a.touches.length?(e=!0,b=!0):void 0}),k.addEventListener("keydown",function(a){return butterfly.keyDown(a),!0}),k.addEventListener("input",function(a){var c;return c=this.value.length,0===c?(a.keyCode=8,butterfly.keyDown(a),this.value="0",!0):(a.keyCode=this.value.charAt(1).charCodeAt(0),!e&&!b||f?(butterfly.keyPress(a),f=!1,this.value="0",!0):(a.keyCode=this.value.charAt(1).charCodeAt(0),a.ctrlKey=e,a.altKey=b,a.keyCode>=97&&a.keyCode<=122&&(a.keyCode-=32),butterfly.keyDown(a),this.value="0",e=b=!1,!0))}))}).call(this); //# sourceMappingURL=ext.min.js.map \ No newline at end of file diff --git a/butterfly/static/main.css b/butterfly/static/main.css index 83c2c98..0a9b7b1 100644 --- a/butterfly/static/main.css +++ b/butterfly/static/main.css @@ -3020,19 +3020,23 @@ html, body { html, body { margin: 0; padding: 0; - line-height: 1.2; + line-height: 1.2; } + +body { + white-space: nowrap; overflow-x: hidden; - overflow-y: scroll; - white-space: nowrap; } + overflow-y: scroll; } ::-webkit-scrollbar { background: #110f13; - width: .75em; - height: .75em; } + width: .75em; } ::-webkit-scrollbar-thumb { background: rgba(244, 234, 213, 0.1); } +::-webkit-scrollbar-thumb:hover { + background: rgba(244, 234, 213, 0.15); } + .terminal { outline: none; } diff --git a/butterfly/static/main.js b/butterfly/static/main.js index 9f2a7cf..d1dec81 100644 --- a/butterfly/static/main.js +++ b/butterfly/static/main.js @@ -166,6 +166,7 @@ while (i--) { div = this.document.createElement('div'); div.className = 'line'; + div.textContent = ' '; this.element.appendChild(div); this.children.push(div); } diff --git a/butterfly/static/main.min.js b/butterfly/static/main.min.js index fb6c14b..ee7f37a 100644 --- a/butterfly/static/main.min.js +++ b/butterfly/static/main.min.js @@ -1,5 +1,5 @@ -/*! butterfly 2015-04-14 */ +/*! butterfly 2015-04-16 */ -(function(){var a,b,c,d,e,f,g,h,i,j=[].slice,k=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};e=h=null,g=!1,f=(new Date).getTime(),a=document.querySelectorAll.bind(document),document.addEventListener("DOMContentLoaded",function(){var a,b,d,e,h,i,k;return d=function(a){return i.send("S"+a)},a=function(){var a,b,c;return c=arguments[0],a=2<=arguments.length?j.call(arguments,1):[],b=a.join(","),"Resize"===c?i.send("R"+b):void 0},k="https:"===location.protocol?"wss://":"ws://",k+=document.location.host+"/ws"+location.pathname,i=new WebSocket(k),i.addEventListener("open",function(){return console.log("WebSocket open",arguments),i.send("R"+h.cols+","+h.rows),f=(new Date).getTime()}),i.addEventListener("error",function(){return console.log("WebSocket error",arguments)}),e=null,b="",i.addEventListener("message",function(a){return h.stop?(b+=a.data,b=b.slice(-10240),e&&e&&clearTimeout(e),void(e=setTimeout(function(){return h.stop=!1,h.element.classList.remove("stopped"),h.write(b),b="",e=null},100))):h.write(a.data)}),i.addEventListener("close",function(){return console.log("WebSocket closed",arguments),setTimeout(function(){return h.write("Closed"),h.skipNextKey=!0,h.element.classList.add("dead")},1),g=!0,(new Date).getTime()-f>6e4?open("","_self").close():void 0}),h=new c(document.body,d,a),addEventListener("beforeunload",function(){return g?void 0:"This will exit the terminal session"}),h.ws=i,window.butterfly=h,window.bench=function(a){var b;for(null==a&&(a=1e8),b="";b.lengthc?b.push(c):(c>2047&&(c=2047),b.push(192|c>>6),b.push(128|63&c)):255===c?b.push(0):(c>127&&(c=127),b.push(c))}}(this),g=function(b){return function(c,d){var e;return b.urxvtMouse?(d.x-=32,d.y-=32,d.x++,d.y++,void b.send("["+c+";"+d.x+";"+d.y+"M")):b.sgrMouse?(d.x-=32,d.y-=32,void b.send("[<"+(3===(3&c)?-4&c:c)+";"+d.x+";"+d.y+(3===(3&c)?"m":"M"))):(e=[],a(e,c),a(e,d.x),a(e,d.y),b.send(""+String.fromCharCode.apply(String,e)))}}(this),b=function(a){return function(b){var c,d,e,f,g;switch(b.type){case"mousedown":c=null!=b.button?+b.button:null!=b.which?b.which-1:null;break;case"mouseup":c=3;break;case"wheel":c=b.deltaY<0?64:65}return g=b.shiftKey?4:0,e=b.metaKey?8:0,d=b.ctrlKey?16:0,f=g|e|d,a.vt200Mouse?f&=d:a.normalMouse||(f=0),32+(f<<2)+c}}(this),c=function(a){return function(b){var c,d,e,f,g;for(f=b.pageX,g=b.pageY,c=a.element;c&&c!==a.document.documentElement;)f-=c.offsetLeft,g-=c.offsetTop,c="offsetParent"in c?c.offsetParent:c.parentNode;return e=a.element.clientWidth,d=window.innerHeight,f=Math.ceil(f/e*a.cols),g=Math.ceil(g/d*a.rows),0>f&&(f=0),f>a.cols&&(f=a.cols),0>g&&(g=0),g>a.rows&&(g=a.rows),f+=32,g+=32,{x:f,y:g,type:b.type}}}(this),addEventListener("mousedown",function(a){return function(b){var c,e;if(a.mouseEvents)return f(b),c=h.bind(a),a.normalMouse&&addEventListener("mousemove",c),a.x10Mouse||addEventListener("mouseup",e=function(b){return f(b),a.normalMouse&&removeEventListener("mousemove",c),removeEventListener("mouseup",e),d(b)}),d(b)}}(this)),addEventListener("wheel",function(a){return function(b){if(a.mouseEvents){if(a.x10Mouse)return;return f(b),d(b)}}}(this))},a.prototype.refresh=function(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v;for(b=Math.min(b,this.screen.length-1),j=k=p=a,q=b;q>=p?q>=k:k>=q;j=q>=p?++k:--k){for(t=j,m=this.screen[t],o="",v=j!==this.y||this.cursorHidden?-(1/0):this.x,c=this.cloneAttr(this.defAttr),i=n=0,r=this.cols-1;r>=0?r>=n:n>=r;i=r>=0?++n:--n){if(f=m[i],d=f.ch,this.equalAttr(f,c)||(this.equalAttr(c,this.defAttr)||(o+=""),this.equalAttr(f,this.defAttr)||(e=[],u=[],o+="g&&(g+=8),e.push("fg-color-"+g)),"string"==typeof f.fg&&u.push("color: "+f.fg),"number"==typeof f.bg&&e.push("bg-color-"+f.bg),"string"==typeof f.bg&&u.push("background-color: "+f.bg),o+='class="',o+=e.join(" "),o+='"',u.length&&(o+=' style="'+u.join("; ")+'"'),o+=">")),i===v&&(o+=''),d.length>1)o+=d;else switch(d){case"&":o+="&";break;case"<":o+="<";break;case">":o+=">";break;default:" "===d?o+='':" ">=d?o+=" ":(d>"＀"&&"￯">d&&i++,o+=d)}i===v&&(o+=""),c=f}this.equalAttr(c,this.defAttr)||(o+=""),this.children[j].innerHTML=o}s=this.html;for(l in s)h=s[l],this.children[l].innerHTML="",this.children[l].appendChild(h);return this.html={},this.native_scroll_to()},a.prototype._cursorBlink=function(){var a;return this.cursorState^=1,(a=this.element.querySelector(".cursor"))?a.classList.contains("reverse-video")?a.classList.remove("reverse-video"):a.classList.add("reverse-video"):void 0},a.prototype.showCursor=function(){return this.cursorState?void 0:(this.cursorState=1,this.refresh(this.y,this.y))},a.prototype.startBlink=function(){return this.cursorBlink?(this._blinker=function(a){return function(){return a._cursorBlink()}}(this),this.t_blink=setInterval(this._blinker,500)):void 0},a.prototype.refreshBlink=function(){return this.cursorBlink?(clearInterval(this.t_blink),this.t_blink=setInterval(this._blinker,500)):void 0},a.prototype.scroll=function(){return 0!==this.scrollTop||this.scrollBottom!==this.rows-1?(this.screen.splice(this.scrollBottom,0,this.blank_line()),this.screen.splice(this.scrollTop,1),this.y++,this.updateRange(this.scrollTop),this.updateRange(this.scrollBottom)):(this.screen.shift(),this.screen.push(this.blank_line()),this.refreshStart=Math.max(this.refreshStart-1,0),this.new_line())},a.prototype.native_scroll_to=function(a){return null==a&&(a=-1),-1===a?this.children.slice(-1)[0].scrollIntoView():window.scrollTo(0,a)},a.prototype.scroll_display=function(a){return this.native_scroll_to(window.scrollY+a*this.char_size.height)},a.prototype.new_line=function(){var a;return a=this.document.createElement("div"),a.className="line",this.element.appendChild(a),this.element.childElementCount>this.scrollback&&this.element.children[0].remove(),this.children.shift(),this.children.push(a)},a.prototype.next_line=function(){return this.y++,this.y>=this.scrollBottom?(this.y--,this.scroll()):void 0},a.prototype.write=function(c){var d,e,f,g,h,i,j,k,l,m,n;for(this.refreshStart=this.y,this.refreshEnd=this.y,h=0,i=c.length;i>h;){switch(d=c.charAt(h),this.state){case b.normal:switch(d){case"":this.bell();break;case"\n":case" ":case"\f":this.convertEol&&(this.x=0),this.next_line();break;case"\r":this.x=0;break;case"\b":this.x>0&&this.x--;break;case" ":this.x=this.nextStop();break;case"":this.setgLevel(1);break;case"":this.setgLevel(0);break;case"":this.state=b.escaped;break;default:if(d>=" "&&((null!=(k=this.charset)?k[d]:void 0)&&(d=this.charset[d]),this.x>=this.cols&&(this.screen[this.y][this.x]=this.cloneAttr(this.curAttr,"⏎"),this.x=0,this.next_line()),this.updateRange(this.y),this.screen[this.y][this.x]=this.cloneAttr(this.curAttr,d),this.x++,d>"＀"&&"￯">d)){if(this.cols<2||this.x>=this.cols){this.screen[this.y][this.x-1]=this.cloneAttr(this.curAttr," ");break}this.screen[this.y][this.x]=this.cloneAttr(this.curAttr," "),this.x++}}break;case b.escaped:switch(d){case"[":this.params=[],this.currentParam=0,this.state=b.csi;break;case"]":this.params=[],this.currentParam=0,this.state=b.osc;break;case"P":this.params=[],this.currentParam=0,this.state=b.dcs;break;case"_":this.state=b.ignore;break;case"^":this.state=b.ignore;break;case"c":this.reset();break;case"E":this.x=0,this.index();break;case"D":this.index();break;case"M":this.reverseIndex();break;case"%":this.setgLevel(0),this.setgCharset(0,a.prototype.charsets.US),this.state=b.normal,h++;break;case"(":case")":case"*":case"+":case"-":case".":switch(d){case"(":this.gcharset=0;break;case")":case"-":this.gcharset=1;break;case"*":case".":this.gcharset=2;break;case"+":this.gcharset=3}this.state=b.charset;break;case"/":this.gcharset=3,this.state=b.charset,h--;break;case"n":this.setgLevel(2);break;case"o":this.setgLevel(3);break;case"|":this.setgLevel(3);break;case"}":this.setgLevel(2);break;case"~":this.setgLevel(1);break;case"7":this.saveCursor(),this.state=b.normal;break;case"8":this.restoreCursor(),this.state=b.normal;break;case"#":this.state=b.normal,h++;break;case"H":this.tabSet();break;case"=":this.applicationKeypad=!0,this.state=b.normal;break;case">":this.applicationKeypad=!1,this.state=b.normal;break;default:this.state=b.normal,console.log("Unknown ESC control:",d)}break;case b.charset:switch(d){case"0":f=a.prototype.charsets.SCLD;break;case"A":f=a.prototype.charsets.UK;break;case"B":f=a.prototype.charsets.US;break;case"4":f=a.prototype.charsets.Dutch;break;case"C":case"5":f=a.prototype.charsets.Finnish;break;case"R":f=a.prototype.charsets.French;break;case"Q":f=a.prototype.charsets.FrenchCanadian;break;case"K":f=a.prototype.charsets.German;break;case"Y":f=a.prototype.charsets.Italian;break;case"E":case"6":f=a.prototype.charsets.NorwegianDanish;break;case"Z":f=a.prototype.charsets.Spanish;break;case"H":case"7":f=a.prototype.charsets.Swedish;break;case"=":f=a.prototype.charsets.Swiss;break;case"/":f=a.prototype.charsets.ISOLatin,h++;break;default:f=a.prototype.charsets.US}this.setgCharset(this.gcharset,f),this.gcharset=null,this.state=b.normal;break;case b.osc:if(""===d||""===d){switch(""===d&&h++,this.params.push(this.currentParam),this.params[0]){case 0:case 1:case 2:this.params[1]&&(this.title=this.params[1]+" - ƸӜƷ butterfly",this.handleTitle(this.title))}this.params=[],this.currentParam=0,this.state=b.normal}else this.params.length?this.currentParam+=d:d>="0"&&"9">=d?this.currentParam=10*this.currentParam+d.charCodeAt(0)-48:";"===d&&(this.params.push(this.currentParam),this.currentParam="");break;case b.csi:if("?"===d||">"===d||"!"===d){this.prefix=d;break}if(d>="0"&&"9">=d){this.currentParam=10*this.currentParam+d.charCodeAt(0)-48;break}if("$"===d||'"'===d||" "===d||"'"===d)break;if(this.params.push(this.currentParam),this.currentParam=0,";"===d)break;switch(this.state=b.normal,d){case"A":this.cursorUp(this.params);break;case"B":this.cursorDown(this.params);break;case"C":this.cursorForward(this.params);break;case"D":this.cursorBackward(this.params);break;case"H":this.cursorPos(this.params);break;case"J":this.eraseInDisplay(this.params);break;case"K":this.eraseInLine(this.params);break;case"m":this.prefix||this.charAttributes(this.params);break;case"n":this.prefix||this.deviceStatus(this.params);break;case"@":this.insertChars(this.params);break;case"E":this.cursorNextLine(this.params);break;case"F":this.cursorPrecedingLine(this.params);break;case"G":this.cursorCharAbsolute(this.params);break;case"L":this.insertLines(this.params);break;case"M":this.deleteLines(this.params);break;case"P":this.deleteChars(this.params);break;case"X":this.eraseChars(this.params);break;case"`":this.charPosAbsolute(this.params);break;case"a":this.HPositionRelative(this.params);break;case"c":this.sendDeviceAttributes(this.params);break;case"d":this.linePosAbsolute(this.params);break;case"e":this.VPositionRelative(this.params);break;case"f":this.HVPosition(this.params);break;case"h":this.setMode(this.params);break;case"l":this.resetMode(this.params);break;case"r":this.setScrollRegion(this.params);break;case"s":this.saveCursor(this.params);break;case"u":this.restoreCursor(this.params);break;case"I":this.cursorForwardTab(this.params);break;case"S":this.scrollUp(this.params);break;case"T":this.params.length<2&&!this.prefix&&this.scrollDown(this.params);break;case"Z":this.cursorBackwardTab(this.params);break;case"b":this.repeatPrecedingCharacter(this.params);break;case"g":this.tabClear(this.params);break;case"p":"!"===this.prefix&&this.softReset(this.params);break;default:console.error("Unknown CSI code: %s.",d)}this.prefix="";break;case b.dcs:if(""===d||""===d){switch(""===d&&h++,this.prefix){case"":if(j=this.currentParam,";"!==j[0]){console.error("Unknown DECUDK: "+j);break}if(j=j.slice(1),l=j.split("|",2),m=l[0],e=l[1],!e){console.error("No type for inline DECUDK: "+j);break}switch(m){case"HTML":if(!this.html_escapes_enabled){console.log("HTML escapes are disabled");break}g=document.createElement("div"),g.classList.add("inline-html"),g.innerHTML=e,this.html[this.y]=g,this.updateRange(this.y);break;case"IMAGE":g=document.createElement("img"),g.classList.add("inline-image"),g.src="data:image;base64,"+e,this.html[this.y]=g,this.updateRange(this.y);break;case"PROMPT":this.send(e);break;case"TEXT":i+=e.length,c=c.slice(0,h+1)+e+c.slice(h+1);break;default:console.error("Unknown type "+m+" for DECUDK")}break;case"$q":switch(j=this.currentParam,n=!1,j){case'"q':j='0"q';break;case'"p':j='61"p';break;case"r":j=""+(this.scrollTop+1)+";"+(this.scrollBottom+1)+"r";break;case"m":j="0m";break;default:console.error("Unknown DCS Pt: %s.",j),j=""}this.send("P"+ +n+"$r"+j+"\\");break;case"+q":j=this.currentParam,n=!1,this.send("P"+ +n+"+r"+j+"\\");break;default:console.error("Unknown DCS prefix: %s.",this.prefix)}this.currentParam=0,this.prefix="",this.state=b.normal}else this.currentParam?this.currentParam+=d:this.prefix||"$"===d||"+"===d?2===this.prefix.length?this.currentParam=d:this.prefix+=d:this.currentParam=d;break;case b.ignore:(""===d||""===d)&&(""===d&&h++,this.state=b.normal)}h++}return this.updateRange(this.y),this.refresh(this.refreshStart,this.refreshEnd)},a.prototype.writeln=function(a){return this.write(a+"\r\n")},a.prototype.keyDown=function(a){var b,c,e,f;if(a.keyCode>15&&a.keyCode<19)return!0;if((a.shiftKey||a.ctrlKey)&&45===a.keyCode)return!0;if(a.shiftKey&&a.ctrlKey&&(67===(e=a.keyCode)||86===e))return!0;if(a.altKey&&90===a.keyCode&&!this.skipNextKey)return this.skipNextKey=!0,this.element.classList.add("skip"),d(a);if(this.skipNextKey)return this.skipNextKey=!1,this.element.classList.remove("skip"),!0;switch(a.keyCode){case 8:if(c=a.altKey?"":"",a.shiftKey){c+="\b";break}c+="";break;case 9:if(a.shiftKey){c="";break}c=" ";break;case 13:c="\r";break;case 27:c="";break;case 37:if(this.applicationCursor){c="OD";break}c="";break;case 39:if(this.applicationCursor){c="OC";break}c="";break;case 38:if(this.applicationCursor){c="OA";break}if(a.ctrlKey)return this.scroll_display(-1),d(a);c="";break;case 40:if(this.applicationCursor){c="OB";break}if(a.ctrlKey)return this.scroll_display(1),d(a);c="";break;case 46:c="[3~";break;case 45:c="[2~";break;case 36:if(this.applicationKeypad){c="OH";break}c="OH";break;case 35:if(this.applicationKeypad){c="OF";break}c="OF";break;case 33:if(a.shiftKey)return this.scroll_display(-(this.rows-1)),d(a);c="[5~";break;case 34:if(a.shiftKey)return this.scroll_display(this.rows-1),d(a);c="[6~";break;case 112:c="OP";break;case 113:c="OQ";break;case 114:c="OR";break;case 115:c="OS";break;case 116:c="[15~";break;case 117:c="[17~";break;case 118:c="[18~";break;case 119:c="[19~";break;case 120:c="[20~";break;case 121:c="[21~";break;case 122:c="[23~";break;case 123:c="[24~";break;default:if(a.ctrlKey)if(a.keyCode>=65&&a.keyCode<=90){if(67===a.keyCode){if(f=(new Date).getTime(),f-this.last_cc<500&&!this.stop){for(b=setTimeout(function(){});b--;)b!==this.t_bell&&b!==this.t_queue&&b!==this.t_blink&&clearTimeout(b);this.element.classList.add("stopped"),this.stop=!0}else if(this.stop)return!0;this.last_cc=f}c=String.fromCharCode(a.keyCode-64)}else 32===a.keyCode?c=String.fromCharCode(0):a.keyCode>=51&&a.keyCode<=55?c=String.fromCharCode(a.keyCode-51+27):56===a.keyCode?c=String.fromCharCode(127):219===a.keyCode?c=String.fromCharCode(27):221===a.keyCode&&(c=String.fromCharCode(29));else(a.altKey&&k.call(navigator.platform,"Mac")<0||a.metaKey&&k.call(navigator.platform,"Mac")>=0)&&(a.keyCode>=65&&a.keyCode<=90?c=""+String.fromCharCode(a.keyCode+32):192===a.keyCode?c="`":a.keyCode>=48&&a.keyCode<=57&&(c=""+(a.keyCode-48)))}return a.keyCode>=37&&a.keyCode<=40&&(a.ctrlKey?c=c.slice(0,-1)+"1;5"+c.slice(-1):a.altKey?c=c.slice(0,-1)+"1;3"+c.slice(-1):a.shiftKey&&(c=c.slice(0,-1)+"1;4"+c.slice(-1))),c?(this.showCursor(),this.handler(c),d(a)):!0},a.prototype.setgLevel=function(a){return this.glevel=a,this.charset=this.charsets[a]},a.prototype.setgCharset=function(a,b){return this.charsets[a]=b,this.glevel===a?this.charset=b:void 0},a.prototype.keyPress=function(a){var b,c;if(this.skipNextKey===!1)return this.skipNextKey=null,!0;if(a.keyCode>15&&a.keyCode<19)return!0;if((a.shiftKey||a.ctrlKey)&&45===a.keyCode)return!0;if(a.shiftKey&&a.ctrlKey&&(67===(c=a.keyCode)||86===c))return!0;if(d(a),a.charCode)b=a.charCode;else if(null==a.which)b=a.keyCode;else{if(0===a.which||0===a.charCode)return!1;b=a.which}return!b||a.ctrlKey||a.altKey||a.metaKey?!1:(b=String.fromCharCode(b),this.showCursor(),this.handler(b),!1)},a.prototype.send=function(a){return this.queue||(this.t_queue=setTimeout(function(a){return function(){return a.handler(a.queue),a.queue=""}}(this),1)),this.queue+=a},a.prototype.bell=function(a){return null==a&&(a="bell"),this.visualBell?(this.element.classList.add(a),this.t_bell=setTimeout(function(b){return function(){return b.element.classList.remove(a)}}(this),this.visualBell)):void 0},a.prototype.resize=function(){var a,b,c,d,e,f,g;if(e=this.cols,f=this.rows,this.compute_char_size(),this.cols=Math.floor(this.element.clientWidth/this.char_size.width),this.rows=Math.floor(window.innerHeight/this.char_size.height),g=window.innerHeight%this.char_size.height,this.element.style["padding-bottom"]=g+"px",e!==this.cols||f!==this.rows){if(this.ctl("Resize",this.cols,this.rows),ethis.cols)for(b=this.screen.length;b--;)for(;this.screen[b].length>this.cols;)this.screen[b].pop();if(this.setupStops(e),c=f,cthis.rows)for(;c-->this.rows;)this.screen.length>this.rows&&this.screen.pop(),this.children.length>this.rows&&(a=this.children.pop(),null!=a&&a.parentNode.removeChild(a));return this.y>=this.rows&&(this.y=this.rows-1),this.x>=this.cols&&(this.x=this.cols-1),this.scrollTop=0,this.scrollBottom=this.rows-1,this.refresh(0,this.rows-1),this.normal=null}},a.prototype.updateRange=function(a){return athis.refreshEnd?this.refreshEnd=a:void 0},a.prototype.maxRange=function(){return this.refreshStart=0,this.refreshEnd=this.rows-1},a.prototype.setupStops=function(a){var b;for(null!=a?this.tabs[a]||(a=this.prevStop(a)):(this.tabs={},a=0),b=[];a0;);return a>=this.cols?this.cols-1:0>a?0:a},a.prototype.nextStop=function(a){for(null==a&&(a=this.x);!this.tabs[++a]&&a=this.cols?this.cols-1:0>a?0:a},a.prototype.eraseRight=function(a,b){var c;for(c=this.screen[b];ab&&(b=1),this.y-=b,this.y<0?this.y=0:void 0},a.prototype.cursorDown=function(a){var b;return b=a[0],1>b&&(b=1),this.y+=b,this.y>=this.rows?this.y=this.rows-1:void 0},a.prototype.cursorForward=function(a){var b;return b=a[0],1>b&&(b=1),this.x+=b,this.x>=this.cols?this.x=this.cols-1:void 0},a.prototype.cursorBackward=function(a){var b;return b=a[0],1>b&&(b=1),this.x-=b,this.x<0?this.x=0:void 0},a.prototype.cursorPos=function(a){var b,c;return c=a[0]-1,b=a.length>=2?a[1]-1:0,0>c?c=0:c>=this.rows&&(c=this.rows-1),0>b?b=0:b>=this.cols&&(b=this.cols-1),this.x=b,this.y=c},a.prototype.eraseInDisplay=function(a){var b,c,d,e;switch(a[0]){case 0:for(this.eraseRight(this.x,this.y),b=this.y+1,c=[];bb;)d=a[b],d>=30&&37>=d?this.curAttr.fg=d-30:d>=40&&47>=d?this.curAttr.bg=d-40:d>=90&&97>=d?(d+=8,this.curAttr.fg=d-90):d>=100&&107>=d?(d+=8,this.curAttr.bg=d-100):0===d?this.curAttr=this.cloneAttr(this.defAttr):1===d?this.curAttr.bold=!0:4===d?this.curAttr.underline=!0:5===d?this.curAttr.blink=!0:7===d?this.curAttr.inverse=!0:8===d?this.curAttr.invisible=!0:10===d||(22===d?this.curAttr.bold=!1:24===d?this.curAttr.underline=!1:25===d?this.curAttr.blink=!1:27===d?this.curAttr.inverse=!1:28===d?this.curAttr.invisible=!1:39===d?this.curAttr.fg=257:49===d?this.curAttr.bg=256:38===d?2===a[b+1]?(b+=2,this.curAttr.fg="rgb("+a[b]+", "+a[b+1]+", "+a[b+2]+")",b+=2):5===a[b+1]&&(b+=2,this.curAttr.fg=255&a[b]):48===d?2===a[b+1]?(b+=2,this.curAttr.bg="rgb("+a[b]+", "+a[b+1]+", "+a[b+2]+")",b+=2):5===a[b+1]&&(b+=2,this.curAttr.bg=255&a[b]):100===d?(this.curAttr.fg=257,this.curAttr.bg=256):console.error("Unknown SGR attribute: %d.",d)),e.push(b++);return e},a.prototype.deviceStatus=function(a){if(this.prefix){if("?"===this.prefix&&6===a[0])return this.send("[?"+(this.y+1)+";"+(this.x+1)+"R")}else switch(a[0]){case 5:return this.send("");case 6:return this.send("["+(this.y+1)+";"+(this.x+1)+"R")}},a.prototype.insertChars=function(a){var b,c,d,e;for(c=a[0],1>c&&(c=1),e=this.y,b=this.x,d=[];c--&&bb&&(b=1),this.y+=b,this.y>=this.rows&&(this.y=this.rows-1),this.x=0},a.prototype.cursorPrecedingLine=function(a){var b;return b=a[0],1>b&&(b=1),this.y-=b,this.y<0&&(this.y=0),this.x=0},a.prototype.cursorCharAbsolute=function(a){var b;return b=a[0],1>b&&(b=1),this.x=b-1},a.prototype.insertLines=function(a){var b;for(b=a[0],1>b&&(b=1);b--;)this.screen.splice(this.y,0,this.blank_line(!0)),this.screen.splice(this.scrollBottom+1,1);return this.updateRange(this.y),this.updateRange(this.scrollBottom)},a.prototype.deleteLines=function(a){var b,c;for(b=a[0],1>b&&(b=1),c=this.y;b--;)this.screen.push(this.blank_line(!0)),this.screen.splice(this.y,1);return this.updateRange(this.y),this.updateRange(this.scrollBottom)},a.prototype.deleteChars=function(a){var b,c,d;for(b=a[0],1>b&&(b=1),d=this.y,c=[];b--;)this.screen[d].splice(this.x,1),c.push(this.screen[d].push(this.eraseAttr()));return c},a.prototype.eraseChars=function(a){var b,c,d,e;for(c=a[0],1>c&&(c=1),e=this.y,b=this.x,d=[];c--&&bb&&(b=1),this.x=b-1,this.x>=this.cols?this.x=this.cols-1:void 0},a.prototype.HPositionRelative=function(a){var b;return b=a[0],1>b&&(b=1),this.x+=b,this.x>=this.cols?this.x=this.cols-1:void 0},a.prototype.sendDeviceAttributes=function(a){if(!(a[0]>0))if(this.prefix){if(">"===this.prefix){if(this.isterm("xterm"))return this.send("[>0;276;0c");if(this.isterm("rxvt-unicode"))return this.send("[>85;95;0c");if(this.isterm("linux"))return this.send(a[0]+"c");if(this.isterm("screen"))return this.send("[>83;40003;0c")}}else{if(this.isterm("xterm")||this.isterm("rxvt-unicode")||this.isterm("screen"))return this.send("[?1;2c");if(this.isterm("linux"))return this.send("[?6c")}},a.prototype.linePosAbsolute=function(a){var b;return b=a[0],1>b&&(b=1),this.y=b-1,this.y>=this.rows?this.y=this.rows-1:void 0},a.prototype.VPositionRelative=function(a){var b;return b=a[0],1>b&&(b=1),this.y+=b,this.y>=this.rows?this.y=this.rows-1:void 0},a.prototype.HVPosition=function(a){return a[0]<1&&(a[0]=1),a[1]<1&&(a[1]=1),this.y=a[0]-1,this.y>=this.rows&&(this.y=this.rows-1),this.x=a[1]-1,this.x>=this.cols?this.x=this.cols-1:void 0},a.prototype.setMode=function(b){var c,d,e;if("object"!=typeof b){if("?"===this.prefix)switch(b){case 1:return this.applicationCursor=!0;case 2:return this.setgCharset(0,a.prototype.charsets.US),this.setgCharset(1,a.prototype.charsets.US),this.setgCharset(2,a.prototype.charsets.US),this.setgCharset(3,a.prototype.charsets.US);case 3:return this.savedCols=this.cols,this.resize(132,this.rows);case 6:return this.originMode=!0;case 7:return this.wraparoundMode=!0;case 66:return this.applicationKeypad=!0;case 9:case 1e3:case 1002:case 1003:return this.x10Mouse=9===b,this.vt200Mouse=1e3===b,this.normalMouse=b>1e3,this.mouseEvents=!0,this.element.style.cursor="pointer";case 1004:return this.sendFocus=!0;case 1005:return this.utfMouse=!0;case 1006:return this.sgrMouse=!0;case 1015:return this.urxvtMouse=!0;case 25:return this.cursorHidden=!1;case 1049:case 47:case 1047:if(!this.normal)return e={lines:this.screen,x:this.x,y:this.y,scrollTop:this.scrollTop,scrollBottom:this.scrollBottom,tabs:this.tabs},this.reset(),this.normal=e,this.showCursor()}}else for(d=b.length,c=0;d>c;)this.setMode(b[c]),c++},a.prototype.resetMode=function(a){var b,c;if("object"!=typeof a){if("?"===this.prefix)switch(a){case 1:return this.applicationCursor=!1;case 3:return 132===this.cols&&this.savedCols&&this.resize(this.savedCols,this.rows),delete this.savedCols;case 6:return this.originMode=!1;case 7:return this.wraparoundMode=!1;case 66:return this.applicationKeypad=!1;case 9:case 1e3:case 1002:case 1003:return this.x10Mouse=!1,this.vt200Mouse=!1,this.normalMouse=!1,this.mouseEvents=!1,this.element.style.cursor="";case 1004:return this.sendFocus=!1;case 1005:return this.utfMouse=!1;case 1006:return this.sgrMouse=!1;case 1015:return this.urxvtMouse=!1;case 25:return this.cursorHidden=!0;case 1049:case 47:case 1047:if(this.normal)return this.screen=this.normal.lines,this.x=this.normal.x,this.y=this.normal.y,this.scrollTop=this.normal.scrollTop,this.scrollBottom=this.normal.scrollBottom,this.tabs=this.normal.tabs,this.normal=null,this.refresh(0,this.rows-1),this.showCursor()}}else for(c=a.length,b=0;c>b;)this.resetMode(a[b]),b++},a.prototype.setScrollRegion=function(a){return this.prefix?void 0:(this.scrollTop=(a[0]||1)-1, +(function(){var a,b,c,d,e,f,g,h,i,j=[].slice,k=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};e=h=null,g=!1,f=(new Date).getTime(),a=document.querySelectorAll.bind(document),document.addEventListener("DOMContentLoaded",function(){var a,b,d,e,h,i,k;return d=function(a){return i.send("S"+a)},a=function(){var a,b,c;return c=arguments[0],a=2<=arguments.length?j.call(arguments,1):[],b=a.join(","),"Resize"===c?i.send("R"+b):void 0},k="https:"===location.protocol?"wss://":"ws://",k+=document.location.host+"/ws"+location.pathname,i=new WebSocket(k),i.addEventListener("open",function(){return console.log("WebSocket open",arguments),i.send("R"+h.cols+","+h.rows),f=(new Date).getTime()}),i.addEventListener("error",function(){return console.log("WebSocket error",arguments)}),e=null,b="",i.addEventListener("message",function(a){return h.stop?(b+=a.data,b=b.slice(-10240),e&&e&&clearTimeout(e),void(e=setTimeout(function(){return h.stop=!1,h.element.classList.remove("stopped"),h.write(b),b="",e=null},100))):h.write(a.data)}),i.addEventListener("close",function(){return console.log("WebSocket closed",arguments),setTimeout(function(){return h.write("Closed"),h.skipNextKey=!0,h.element.classList.add("dead")},1),g=!0,(new Date).getTime()-f>6e4?open("","_self").close():void 0}),h=new c(document.body,d,a),addEventListener("beforeunload",function(){return g?void 0:"This will exit the terminal session"}),h.ws=i,window.butterfly=h,window.bench=function(a){var b;for(null==a&&(a=1e8),b="";b.lengthc?b.push(c):(c>2047&&(c=2047),b.push(192|c>>6),b.push(128|63&c)):255===c?b.push(0):(c>127&&(c=127),b.push(c))}}(this),g=function(b){return function(c,d){var e;return b.urxvtMouse?(d.x-=32,d.y-=32,d.x++,d.y++,void b.handler("["+c+";"+d.x+";"+d.y+"M")):b.sgrMouse?(d.x-=32,d.y-=32,void b.handler("[<"+(3===(3&c)?-4&c:c)+";"+d.x+";"+d.y+(3===(3&c)?"m":"M"))):(e=[],a(e,c),a(e,d.x),a(e,d.y),b.handler(""+String.fromCharCode.apply(String,e)))}}(this),b=function(a){return function(b){var c,d,e,f,g;switch(b.type){case"mousedown":c=null!=b.button?+b.button:null!=b.which?b.which-1:null;break;case"mouseup":c=3;break;case"wheel":c=b.deltaY<0?64:65}return g=b.shiftKey?4:0,e=b.metaKey?8:0,d=b.ctrlKey?16:0,f=g|e|d,a.vt200Mouse?f&=d:a.normalMouse||(f=0),32+(f<<2)+c}}(this),c=function(a){return function(b){var c,d,e,f,g;for(f=b.pageX,g=b.pageY,c=a.element;c&&c!==a.document.documentElement;)f-=c.offsetLeft,g-=c.offsetTop,c="offsetParent"in c?c.offsetParent:c.parentNode;return e=a.element.clientWidth,d=window.innerHeight,f=Math.ceil(f/e*a.cols),g=Math.ceil(g/d*a.rows),0>f&&(f=0),f>a.cols&&(f=a.cols),0>g&&(g=0),g>a.rows&&(g=a.rows),f+=32,g+=32,{x:f,y:g,type:b.type}}}(this),addEventListener("contextmenu",function(a){return function(b){return a.mouseEvents?d(b):void 0}}(this)),addEventListener("mousedown",function(a){return function(b){var c,e;if(a.mouseEvents)return f(b),c=h.bind(a),a.normalMouse&&addEventListener("mousemove",c),a.x10Mouse||addEventListener("mouseup",e=function(b){return f(b),a.normalMouse&&removeEventListener("mousemove",c),removeEventListener("mouseup",e),d(b)}),d(b)}}(this)),addEventListener("wheel",function(a){return function(b){if(a.mouseEvents){if(a.x10Mouse)return;return f(b),d(b)}}}(this))},a.prototype.refresh=function(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v;for(b=Math.min(b,this.screen.length-1),j=k=p=a,q=b;q>=p?q>=k:k>=q;j=q>=p?++k:--k){for(t=j,m=this.screen[t],o="",v=j!==this.y||this.cursorHidden?-(1/0):this.x,c=this.cloneAttr(this.defAttr),i=n=0,r=this.cols-1;r>=0?r>=n:n>=r;i=r>=0?++n:--n){if(f=m[i],d=f.ch,this.equalAttr(f,c)||(this.equalAttr(c,this.defAttr)||(o+=""),this.equalAttr(f,this.defAttr)||(e=[],u=[],o+="g&&(g+=8),e.push("fg-color-"+g)),"string"==typeof f.fg&&u.push("color: "+f.fg),"number"==typeof f.bg&&e.push("bg-color-"+f.bg),"string"==typeof f.bg&&u.push("background-color: "+f.bg),o+='class="',o+=e.join(" "),o+='"',u.length&&(o+=' style="'+u.join("; ")+'"'),o+=">")),i===v&&(o+=''),d.length>1)o+=d;else switch(d){case"&":o+="&";break;case"<":o+="<";break;case">":o+=">";break;default:" "===d?o+='':" ">=d?o+=" ":(d>"＀"&&"￯">d&&i++,o+=d)}i===v&&(o+=""),c=f}this.equalAttr(c,this.defAttr)||(o+=""),this.children[j].innerHTML=o}s=this.html;for(l in s)h=s[l],this.children[l].innerHTML="",this.children[l].appendChild(h);return this.html={},this.native_scroll_to()},a.prototype._cursorBlink=function(){var a;return this.cursorState^=1,(a=this.element.querySelector(".cursor"))?a.classList.contains("reverse-video")?a.classList.remove("reverse-video"):a.classList.add("reverse-video"):void 0},a.prototype.showCursor=function(){return this.cursorState?void 0:(this.cursorState=1,this.refresh(this.y,this.y))},a.prototype.startBlink=function(){return this.cursorBlink?(this._blinker=function(a){return function(){return a._cursorBlink()}}(this),this.t_blink=setInterval(this._blinker,500)):void 0},a.prototype.refreshBlink=function(){return this.cursorBlink?(clearInterval(this.t_blink),this.t_blink=setInterval(this._blinker,500)):void 0},a.prototype.scroll=function(){return this.normal||0!==this.scrollTop||this.scrollBottom!==this.rows-1?(this.screen.splice(this.scrollBottom+1,0,this.blank_line()),this.screen.splice(this.scrollTop,1),this.y,this.updateRange(this.scrollTop),this.updateRange(this.scrollBottom)):(this.screen.shift(),this.screen.push(this.blank_line()),this.refreshStart=Math.max(this.refreshStart-1,0),this.new_line())},a.prototype.native_scroll_to=function(a){return null==a&&(a=-1),-1===a?this.children.slice(-1)[0].scrollIntoView():window.scrollTo(0,a)},a.prototype.scroll_display=function(a){return this.native_scroll_to(window.scrollY+a*this.char_size.height)},a.prototype.new_line=function(){var a;return a=this.document.createElement("div"),a.className="line",this.element.appendChild(a),this.element.childElementCount>this.scrollback&&this.element.children[0].remove(),this.children.shift(),this.children.push(a)},a.prototype.next_line=function(){return this.y++,this.y>this.scrollBottom?(this.y--,this.scroll()):void 0},a.prototype.write=function(c){var d,e,f,g,h,i,j,k,l,m,n;for(this.refreshStart=this.y,this.refreshEnd=this.y,h=0,i=c.length;i>h;){switch(d=c.charAt(h),this.state){case b.normal:switch(d){case"":this.bell();break;case"\n":case" ":case"\f":this.convertEol&&(this.x=0),this.next_line();break;case"\r":this.x=0;break;case"\b":this.x>0&&this.x--;break;case" ":this.x=this.nextStop();break;case"":this.setgLevel(1);break;case"":this.setgLevel(0);break;case"":this.state=b.escaped;break;default:if(d>=" "&&((null!=(k=this.charset)?k[d]:void 0)&&(d=this.charset[d]),this.x>=this.cols&&(this.screen[this.y][this.x]=this.cloneAttr(this.curAttr,"⏎"),this.x=0,this.next_line()),this.updateRange(this.y),this.screen[this.y][this.x]=this.cloneAttr(this.curAttr,d),this.x++,d>"＀"&&"￯">d)){if(this.cols<2||this.x>=this.cols){this.screen[this.y][this.x-1]=this.cloneAttr(this.curAttr," ");break}this.screen[this.y][this.x]=this.cloneAttr(this.curAttr," "),this.x++}}break;case b.escaped:switch(d){case"[":this.params=[],this.currentParam=0,this.state=b.csi;break;case"]":this.params=[],this.currentParam=0,this.state=b.osc;break;case"P":this.params=[],this.currentParam=0,this.state=b.dcs;break;case"_":this.state=b.ignore;break;case"^":this.state=b.ignore;break;case"c":this.reset();break;case"E":this.x=0,this.index();break;case"D":this.index();break;case"M":this.reverseIndex();break;case"%":this.setgLevel(0),this.setgCharset(0,a.prototype.charsets.US),this.state=b.normal,h++;break;case"(":case")":case"*":case"+":case"-":case".":switch(d){case"(":this.gcharset=0;break;case")":case"-":this.gcharset=1;break;case"*":case".":this.gcharset=2;break;case"+":this.gcharset=3}this.state=b.charset;break;case"/":this.gcharset=3,this.state=b.charset,h--;break;case"n":this.setgLevel(2);break;case"o":this.setgLevel(3);break;case"|":this.setgLevel(3);break;case"}":this.setgLevel(2);break;case"~":this.setgLevel(1);break;case"7":this.saveCursor(),this.state=b.normal;break;case"8":this.restoreCursor(),this.state=b.normal;break;case"#":this.state=b.normal,h++;break;case"H":this.tabSet();break;case"=":this.applicationKeypad=!0,this.state=b.normal;break;case">":this.applicationKeypad=!1,this.state=b.normal;break;default:this.state=b.normal,console.log("Unknown ESC control:",d)}break;case b.charset:switch(d){case"0":f=a.prototype.charsets.SCLD;break;case"A":f=a.prototype.charsets.UK;break;case"B":f=a.prototype.charsets.US;break;case"4":f=a.prototype.charsets.Dutch;break;case"C":case"5":f=a.prototype.charsets.Finnish;break;case"R":f=a.prototype.charsets.French;break;case"Q":f=a.prototype.charsets.FrenchCanadian;break;case"K":f=a.prototype.charsets.German;break;case"Y":f=a.prototype.charsets.Italian;break;case"E":case"6":f=a.prototype.charsets.NorwegianDanish;break;case"Z":f=a.prototype.charsets.Spanish;break;case"H":case"7":f=a.prototype.charsets.Swedish;break;case"=":f=a.prototype.charsets.Swiss;break;case"/":f=a.prototype.charsets.ISOLatin,h++;break;default:f=a.prototype.charsets.US}this.setgCharset(this.gcharset,f),this.gcharset=null,this.state=b.normal;break;case b.osc:if(""===d||""===d){switch(""===d&&h++,this.params.push(this.currentParam),this.params[0]){case 0:case 1:case 2:this.params[1]&&(this.title=this.params[1]+" - ƸӜƷ butterfly",this.handleTitle(this.title))}this.params=[],this.currentParam=0,this.state=b.normal}else this.params.length?this.currentParam+=d:d>="0"&&"9">=d?this.currentParam=10*this.currentParam+d.charCodeAt(0)-48:";"===d&&(this.params.push(this.currentParam),this.currentParam="");break;case b.csi:if("?"===d||">"===d||"!"===d){this.prefix=d;break}if(d>="0"&&"9">=d){this.currentParam=10*this.currentParam+d.charCodeAt(0)-48;break}if("$"===d||'"'===d||" "===d||"'"===d)break;if(this.params.push(this.currentParam),this.currentParam=0,";"===d)break;switch(this.state=b.normal,d){case"A":this.cursorUp(this.params);break;case"B":this.cursorDown(this.params);break;case"C":this.cursorForward(this.params);break;case"D":this.cursorBackward(this.params);break;case"H":this.cursorPos(this.params);break;case"J":this.eraseInDisplay(this.params);break;case"K":this.eraseInLine(this.params);break;case"m":this.prefix||this.charAttributes(this.params);break;case"n":this.prefix||this.deviceStatus(this.params);break;case"@":this.insertChars(this.params);break;case"E":this.cursorNextLine(this.params);break;case"F":this.cursorPrecedingLine(this.params);break;case"G":this.cursorCharAbsolute(this.params);break;case"L":this.insertLines(this.params);break;case"M":this.deleteLines(this.params);break;case"P":this.deleteChars(this.params);break;case"X":this.eraseChars(this.params);break;case"`":this.charPosAbsolute(this.params);break;case"a":this.HPositionRelative(this.params);break;case"c":this.sendDeviceAttributes(this.params);break;case"d":this.linePosAbsolute(this.params);break;case"e":this.VPositionRelative(this.params);break;case"f":this.HVPosition(this.params);break;case"h":this.setMode(this.params);break;case"l":this.resetMode(this.params);break;case"r":this.setScrollRegion(this.params);break;case"s":this.saveCursor(this.params);break;case"u":this.restoreCursor(this.params);break;case"I":this.cursorForwardTab(this.params);break;case"S":this.scrollUp(this.params);break;case"T":this.params.length<2&&!this.prefix&&this.scrollDown(this.params);break;case"Z":this.cursorBackwardTab(this.params);break;case"b":this.repeatPrecedingCharacter(this.params);break;case"g":this.tabClear(this.params);break;case"p":"!"===this.prefix&&this.softReset(this.params);break;default:console.error("Unknown CSI code: %s.",d)}this.prefix="";break;case b.dcs:if(""===d||""===d){switch(""===d&&h++,this.prefix){case"":if(j=this.currentParam,";"!==j[0]){console.error("Unknown DECUDK: "+j);break}if(j=j.slice(1),l=j.split("|",2),m=l[0],e=l[1],!e){console.error("No type for inline DECUDK: "+j);break}switch(m){case"HTML":if(!this.html_escapes_enabled){console.log("HTML escapes are disabled");break}g=document.createElement("div"),g.classList.add("inline-html"),g.innerHTML=e,this.html[this.y]=g,this.updateRange(this.y);break;case"IMAGE":g=document.createElement("img"),g.classList.add("inline-image"),g.src="data:image;base64,"+e,this.html[this.y]=g,this.updateRange(this.y);break;case"PROMPT":this.handler(e);break;case"TEXT":i+=e.length,c=c.slice(0,h+1)+e+c.slice(h+1);break;default:console.error("Unknown type "+m+" for DECUDK")}break;case"$q":switch(j=this.currentParam,n=!1,j){case'"q':j='0"q';break;case'"p':j='61"p';break;case"r":j=""+(this.scrollTop+1)+";"+(this.scrollBottom+1)+"r";break;case"m":j="0m";break;default:console.error("Unknown DCS Pt: %s.",j),j=""}this.handler("P"+ +n+"$r"+j+"\\");break;case"+q":j=this.currentParam,n=!1,this.handler("P"+ +n+"+r"+j+"\\");break;default:console.error("Unknown DCS prefix: %s.",this.prefix)}this.currentParam=0,this.prefix="",this.state=b.normal}else this.currentParam?this.currentParam+=d:this.prefix||"$"===d||"+"===d?2===this.prefix.length?this.currentParam=d:this.prefix+=d:this.currentParam=d;break;case b.ignore:(""===d||""===d)&&(""===d&&h++,this.state=b.normal)}h++}return this.updateRange(this.y),this.refresh(this.refreshStart,this.refreshEnd)},a.prototype.writeln=function(a){return this.write(a+"\r\n")},a.prototype.keyDown=function(a){var b,c,e,f;if(a.keyCode>15&&a.keyCode<19)return!0;if((a.shiftKey||a.ctrlKey)&&45===a.keyCode)return!0;if(a.shiftKey&&a.ctrlKey&&(67===(e=a.keyCode)||86===e))return!0;if(a.altKey&&90===a.keyCode&&!this.skipNextKey)return this.skipNextKey=!0,this.element.classList.add("skip"),d(a);if(this.skipNextKey)return this.skipNextKey=!1,this.element.classList.remove("skip"),!0;switch(a.keyCode){case 8:if(c=a.altKey?"":"",a.shiftKey){c+="\b";break}c+="";break;case 9:if(a.shiftKey){c="";break}c=" ";break;case 13:c="\r";break;case 27:c="";break;case 37:if(this.applicationCursor){c="OD";break}c="";break;case 39:if(this.applicationCursor){c="OC";break}c="";break;case 38:if(this.applicationCursor){c="OA";break}if(a.ctrlKey)return this.scroll_display(-1),d(a);c="";break;case 40:if(this.applicationCursor){c="OB";break}if(a.ctrlKey)return this.scroll_display(1),d(a);c="";break;case 46:c="[3~";break;case 45:c="[2~";break;case 36:if(this.applicationKeypad){c="OH";break}c="OH";break;case 35:if(this.applicationKeypad){c="OF";break}c="OF";break;case 33:if(a.shiftKey)return this.scroll_display(-(this.rows-1)),d(a);c="[5~";break;case 34:if(a.shiftKey)return this.scroll_display(this.rows-1),d(a);c="[6~";break;case 112:c="OP";break;case 113:c="OQ";break;case 114:c="OR";break;case 115:c="OS";break;case 116:c="[15~";break;case 117:c="[17~";break;case 118:c="[18~";break;case 119:c="[19~";break;case 120:c="[20~";break;case 121:c="[21~";break;case 122:c="[23~";break;case 123:c="[24~";break;default:if(a.ctrlKey)if(a.keyCode>=65&&a.keyCode<=90){if(67===a.keyCode){if(f=(new Date).getTime(),f-this.last_cc<500&&!this.stop){for(b=setTimeout(function(){});b--;)b!==this.t_bell&&b!==this.t_queue&&b!==this.t_blink&&clearTimeout(b);this.element.classList.add("stopped"),this.stop=!0}else if(this.stop)return!0;this.last_cc=f}c=String.fromCharCode(a.keyCode-64)}else 32===a.keyCode?c=String.fromCharCode(0):a.keyCode>=51&&a.keyCode<=55?c=String.fromCharCode(a.keyCode-51+27):56===a.keyCode?c=String.fromCharCode(127):219===a.keyCode?c=String.fromCharCode(27):221===a.keyCode&&(c=String.fromCharCode(29));else(a.altKey&&k.call(navigator.platform,"Mac")<0||a.metaKey&&k.call(navigator.platform,"Mac")>=0)&&(a.keyCode>=65&&a.keyCode<=90?c=""+String.fromCharCode(a.keyCode+32):192===a.keyCode?c="`":a.keyCode>=48&&a.keyCode<=57&&(c=""+(a.keyCode-48)))}return a.keyCode>=37&&a.keyCode<=40&&(a.ctrlKey?c=c.slice(0,-1)+"1;5"+c.slice(-1):a.altKey?c=c.slice(0,-1)+"1;3"+c.slice(-1):a.shiftKey&&(c=c.slice(0,-1)+"1;4"+c.slice(-1))),c?(this.showCursor(),this.handler(c),d(a)):!0},a.prototype.setgLevel=function(a){return this.glevel=a,this.charset=this.charsets[a]},a.prototype.setgCharset=function(a,b){return this.charsets[a]=b,this.glevel===a?this.charset=b:void 0},a.prototype.keyPress=function(a){var b,c;if(this.skipNextKey===!1)return this.skipNextKey=null,!0;if(a.keyCode>15&&a.keyCode<19)return!0;if((a.shiftKey||a.ctrlKey)&&45===a.keyCode)return!0;if(a.shiftKey&&a.ctrlKey&&(67===(c=a.keyCode)||86===c))return!0;if(d(a),a.charCode)b=a.charCode;else if(null==a.which)b=a.keyCode;else{if(0===a.which||0===a.charCode)return!1;b=a.which}return!b||a.ctrlKey||a.altKey||a.metaKey?!1:(b=String.fromCharCode(b),this.showCursor(),this.handler(b),!1)},a.prototype.bell=function(a){return null==a&&(a="bell"),this.visualBell?(this.element.classList.add(a),this.t_bell=setTimeout(function(b){return function(){return b.element.classList.remove(a)}}(this),this.visualBell)):void 0},a.prototype.resize=function(){var a,b,c,d,e,f,g;if(e=this.cols,f=this.rows,this.compute_char_size(),this.cols=Math.floor(this.element.clientWidth/this.char_size.width),this.rows=Math.floor(window.innerHeight/this.char_size.height),g=window.innerHeight%this.char_size.height,this.element.style["padding-bottom"]=g+"px",e!==this.cols||f!==this.rows){if(this.ctl("Resize",this.cols,this.rows),ethis.cols)for(b=this.screen.length;b--;)for(;this.screen[b].length>this.cols;)this.screen[b].pop();if(this.setupStops(e),c=f,cthis.rows)for(;c-->this.rows;)this.screen.length>this.rows&&this.screen.pop(),this.children.length>this.rows&&(a=this.children.pop(),null!=a&&a.parentNode.removeChild(a));return this.y>=this.rows&&(this.y=this.rows-1),this.x>=this.cols&&(this.x=this.cols-1),this.scrollTop=0,this.scrollBottom=this.rows-1,this.refresh(0,this.rows-1),this.normal=null}},a.prototype.updateRange=function(a){return athis.refreshEnd?this.refreshEnd=a:void 0},a.prototype.maxRange=function(){return this.refreshStart=0,this.refreshEnd=this.rows-1},a.prototype.setupStops=function(a){var b;for(null!=a?this.tabs[a]||(a=this.prevStop(a)):(this.tabs={},a=0),b=[];a0;);return a>=this.cols?this.cols-1:0>a?0:a},a.prototype.nextStop=function(a){for(null==a&&(a=this.x);!this.tabs[++a]&&a=this.cols?this.cols-1:0>a?0:a},a.prototype.eraseRight=function(a,b){var c;for(c=this.screen[b];ab&&(b=1),this.y-=b,this.y<0?this.y=0:void 0},a.prototype.cursorDown=function(a){var b;return b=a[0],1>b&&(b=1),this.y+=b,this.y>=this.rows?this.y=this.rows-1:void 0},a.prototype.cursorForward=function(a){var b;return b=a[0],1>b&&(b=1),this.x+=b,this.x>=this.cols?this.x=this.cols-1:void 0},a.prototype.cursorBackward=function(a){var b;return b=a[0],1>b&&(b=1),this.x-=b,this.x<0?this.x=0:void 0},a.prototype.cursorPos=function(a){var b,c;return c=a[0]-1,b=a.length>=2?a[1]-1:0,0>c?c=0:c>=this.rows&&(c=this.rows-1),0>b?b=0:b>=this.cols&&(b=this.cols-1),this.x=b,this.y=c},a.prototype.eraseInDisplay=function(a){var b,c,d,e;switch(a[0]){case 0:for(this.eraseRight(this.x,this.y),b=this.y+1,c=[];bb;)d=a[b],d>=30&&37>=d?this.curAttr.fg=d-30:d>=40&&47>=d?this.curAttr.bg=d-40:d>=90&&97>=d?(d+=8,this.curAttr.fg=d-90):d>=100&&107>=d?(d+=8,this.curAttr.bg=d-100):0===d?this.curAttr=this.cloneAttr(this.defAttr):1===d?this.curAttr.bold=!0:4===d?this.curAttr.underline=!0:5===d?this.curAttr.blink=!0:7===d?this.curAttr.inverse=!0:8===d?this.curAttr.invisible=!0:10===d||(22===d?this.curAttr.bold=!1:24===d?this.curAttr.underline=!1:25===d?this.curAttr.blink=!1:27===d?this.curAttr.inverse=!1:28===d?this.curAttr.invisible=!1:39===d?this.curAttr.fg=257:49===d?this.curAttr.bg=256:38===d?2===a[b+1]?(b+=2,this.curAttr.fg="rgb("+a[b]+", "+a[b+1]+", "+a[b+2]+")",b+=2):5===a[b+1]&&(b+=2,this.curAttr.fg=255&a[b]):48===d?2===a[b+1]?(b+=2,this.curAttr.bg="rgb("+a[b]+", "+a[b+1]+", "+a[b+2]+")",b+=2):5===a[b+1]&&(b+=2,this.curAttr.bg=255&a[b]):100===d?(this.curAttr.fg=257,this.curAttr.bg=256):console.error("Unknown SGR attribute: %d.",d)),e.push(b++);return e},a.prototype.deviceStatus=function(a){if(this.prefix){if("?"===this.prefix&&6===a[0])return this.handler("[?"+(this.y+1)+";"+(this.x+1)+"R")}else switch(a[0]){case 5:return this.handler("");case 6:return this.handler("["+(this.y+1)+";"+(this.x+1)+"R")}},a.prototype.insertChars=function(a){var b,c,d,e;for(c=a[0],1>c&&(c=1),e=this.y,b=this.x,d=[];c--&&bb&&(b=1),this.y+=b,this.y>=this.rows&&(this.y=this.rows-1),this.x=0},a.prototype.cursorPrecedingLine=function(a){var b;return b=a[0],1>b&&(b=1),this.y-=b,this.y<0&&(this.y=0),this.x=0},a.prototype.cursorCharAbsolute=function(a){var b;return b=a[0],1>b&&(b=1),this.x=b-1},a.prototype.insertLines=function(a){var b;for(b=a[0],1>b&&(b=1);b--;)this.screen.splice(this.y,0,this.blank_line(!0)),this.screen.splice(this.scrollBottom+1,1);return this.updateRange(this.y),this.updateRange(this.scrollBottom)},a.prototype.deleteLines=function(a){var b,c;for(b=a[0],1>b&&(b=1),c=this.y;b--;)this.screen.push(this.blank_line(!0)),this.screen.splice(this.y,1);return this.updateRange(this.y),this.updateRange(this.scrollBottom)},a.prototype.deleteChars=function(a){var b,c,d;for(b=a[0],1>b&&(b=1),d=this.y,c=[];b--;)this.screen[d].splice(this.x,1),c.push(this.screen[d].push(this.eraseAttr()));return c},a.prototype.eraseChars=function(a){var b,c,d,e;for(c=a[0],1>c&&(c=1),e=this.y,b=this.x,d=[];c--&&bb&&(b=1),this.x=b-1,this.x>=this.cols?this.x=this.cols-1:void 0},a.prototype.HPositionRelative=function(a){var b;return b=a[0],1>b&&(b=1),this.x+=b,this.x>=this.cols?this.x=this.cols-1:void 0},a.prototype.sendDeviceAttributes=function(a){if(!(a[0]>0))if(this.prefix){if(">"===this.prefix){if(this.isterm("xterm"))return this.handler("[>0;276;0c");if(this.isterm("rxvt-unicode"))return this.handler("[>85;95;0c");if(this.isterm("linux"))return this.handler(a[0]+"c");if(this.isterm("screen"))return this.handler("[>83;40003;0c")}}else{if(this.isterm("xterm")||this.isterm("rxvt-unicode")||this.isterm("screen"))return this.handler("[?1;2c");if(this.isterm("linux"))return this.handler("[?6c")}},a.prototype.linePosAbsolute=function(a){var b;return b=a[0],1>b&&(b=1),this.y=b-1,this.y>=this.rows?this.y=this.rows-1:void 0},a.prototype.VPositionRelative=function(a){var b;return b=a[0],1>b&&(b=1),this.y+=b,this.y>=this.rows?this.y=this.rows-1:void 0},a.prototype.HVPosition=function(a){return a[0]<1&&(a[0]=1),a[1]<1&&(a[1]=1),this.y=a[0]-1,this.y>=this.rows&&(this.y=this.rows-1),this.x=a[1]-1,this.x>=this.cols?this.x=this.cols-1:void 0},a.prototype.setMode=function(b){var c,d,e;if("object"!=typeof b){if("?"===this.prefix)switch(b){case 1:return this.applicationCursor=!0;case 2:return this.setgCharset(0,a.prototype.charsets.US),this.setgCharset(1,a.prototype.charsets.US),this.setgCharset(2,a.prototype.charsets.US),this.setgCharset(3,a.prototype.charsets.US);case 3:return this.savedCols=this.cols,this.resize(132,this.rows);case 6:return this.originMode=!0;case 7:return this.wraparoundMode=!0;case 66:return this.applicationKeypad=!0;case 9:case 1e3:case 1002:case 1003:return this.x10Mouse=9===b,this.vt200Mouse=1e3===b,this.normalMouse=b>1e3,this.mouseEvents=!0,this.element.style.cursor="pointer";case 1004:return this.sendFocus=!0;case 1005:return this.utfMouse=!0;case 1006:return this.sgrMouse=!0;case 1015:return this.urxvtMouse=!0;case 25:return this.cursorHidden=!1;case 1049:case 47:case 1047:if(!this.normal)return e={lines:this.screen,x:this.x,y:this.y,scrollTop:this.scrollTop,scrollBottom:this.scrollBottom,tabs:this.tabs},this.reset(),this.normal=e,this.showCursor()}}else for(d=b.length,c=0;d>c;)this.setMode(b[c]),c++},a.prototype.resetMode=function(a){var b,c;if("object"!=typeof a){if("?"===this.prefix)switch(a){case 1:return this.applicationCursor=!1;case 3:return 132===this.cols&&this.savedCols&&this.resize(this.savedCols,this.rows),delete this.savedCols;case 6:return this.originMode=!1;case 7:return this.wraparoundMode=!1;case 66:return this.applicationKeypad=!1;case 9:case 1e3:case 1002:case 1003:return this.x10Mouse=!1,this.vt200Mouse=!1,this.normalMouse=!1,this.mouseEvents=!1,this.element.style.cursor="";case 1004:return this.sendFocus=!1;case 1005:return this.utfMouse=!1;case 1006:return this.sgrMouse=!1;case 1015:return this.urxvtMouse=!1;case 25:return this.cursorHidden=!0;case 1049:case 47:case 1047:if(this.normal)return this.screen=this.normal.lines,this.x=this.normal.x,this.y=this.normal.y,this.scrollTop=this.normal.scrollTop,this.scrollBottom=this.normal.scrollBottom,this.tabs=this.normal.tabs,this.normal=null,this.refresh(0,this.rows-1),this.showCursor()}}else for(c=a.length,b=0;c>b;)this.resetMode(a[b]),b++},a.prototype.setScrollRegion=function(a){return this.prefix?void 0:(this.scrollTop=(a[0]||1)-1, this.scrollBottom=(a[1]||this.rows)-1,this.x=0,this.y=0)},a.prototype.saveCursor=function(a){return this.savedX=this.x,this.savedY=this.y},a.prototype.restoreCursor=function(a){return this.x=this.savedX||0,this.y=this.savedY||0},a.prototype.cursorForwardTab=function(a){var b,c;for(b=a[0]||1,c=[];b--;)c.push(this.x=this.nextStop());return c},a.prototype.scrollUp=function(a){var b;for(b=a[0]||1;b--;)this.screen.splice(this.scrollTop,1),this.screen.splice(this.scrollBottom,0,this.blank_line());return this.updateRange(this.scrollTop),this.updateRange(this.scrollBottom)},a.prototype.scrollDown=function(a){var b;for(b=a[0]||1;b--;)this.screen.splice(this.scrollBottom,1),this.screen.splice(this.scrollTop,0,this.blank_line());return this.updateRange(this.scrollTop),this.updateRange(this.scrollBottom)},a.prototype.initMouseTracking=function(a){},a.prototype.resetTitleModes=function(a){},a.prototype.cursorBackwardTab=function(a){var b,c;for(b=a[0]||1,c=[];b--;)c.push(this.x=this.prevStop());return c},a.prototype.repeatPrecedingCharacter=function(a){var b,c,d,e;for(d=a[0]||1,c=this.screen[this.y],b=c[this.x-1]||this.defAttr,e=[];d--;)e.push(c[this.x++]=b);return e},a.prototype.tabClear=function(a){var b;return b=a[0],0>=b?delete this.tabs[this.x]:3===b?this.tabs={}:void 0},a.prototype.mediaCopy=function(a){},a.prototype.setResources=function(a){},a.prototype.disableModifiers=function(a){},a.prototype.setPointerMode=function(a){},a.prototype.softReset=function(a){return this.cursorHidden=!1,this.insertMode=!1,this.originMode=!1,this.wraparoundMode=!1,this.applicationKeypad=!1,this.applicationCursor=!1,this.scrollTop=0,this.scrollBottom=this.rows-1,this.curAttr=this.defAttr,this.x=this.y=0,this.charset=null,this.glevel=0,this.charsets=[null]},a.prototype.requestAnsiMode=function(a){},a.prototype.requestPrivateMode=function(a){},a.prototype.setConformanceLevel=function(a){},a.prototype.loadLEDs=function(a){},a.prototype.setCursorStyle=function(a){},a.prototype.setCharProtectionAttr=function(a){},a.prototype.restorePrivateValues=function(a){},a.prototype.setAttrInRectangle=function(a){var b,c,d,e,f,g,h;for(h=a[0],e=a[1],c=a[2],g=a[3],b=a[4];c+1>h;){for(f=this.screen[h],d=e;g>d;)f[d]=this.cloneAttr(b,f[d].ch),d++;h++}return this.updateRange(a[0]),this.updateRange(a[2])},a.prototype.savePrivateValues=function(a){},a.prototype.manipulateWindow=function(a){},a.prototype.reverseAttrInRectangle=function(a){},a.prototype.setTitleModeFeature=function(a){},a.prototype.setWarningBellVolume=function(a){},a.prototype.setMarginBellVolume=function(a){},a.prototype.copyRectangle=function(a){},a.prototype.enableFilterRectangle=function(a){},a.prototype.requestParameters=function(a){},a.prototype.selectChangeExtent=function(a){},a.prototype.fillRectangle=function(a){var b,c,d,e,f,g,h;for(c=a[0],h=a[1],e=a[2],b=a[3],g=a[4];b+1>h;){for(f=this.screen[h],d=e;g>d;)f[d]=this.cloneAttr(f[d][0],String.fromCharCode(c)),d++;h++}return this.updateRange(a[1]),this.updateRange(a[3])},a.prototype.enableLocatorReporting=function(a){var b;return b=a[0]>0},a.prototype.eraseRectangle=function(a){var b,c,d,e,f,g;for(g=a[0],d=a[1],b=a[2],f=a[3];b+1>g;){for(e=this.screen[g],c=d;f>c;)e[c]=this.eraseAttr(),c++;g++}return this.updateRange(a[0]),this.updateRange(a[2])},a.prototype.setLocatorEvents=function(a){},a.prototype.selectiveEraseRectangle=function(a){},a.prototype.requestLocatorPosition=function(a){},a.prototype.insertColumns=function(){var a,b,c;for(c=params[0],b=this.rows;c--;)for(a=0;b>a;)this.screen[a].splice(this.x+1,0,this.eraseAttr()),this.screen[a].pop(),a++;return this.maxRange()},a.prototype.deleteColumns=function(){var a,b,c;for(c=params[0],b=this.rows;c--;)for(a=0;b>a;)this.screen[a].splice(this.x,1),this.screen[a].push(this.eraseAttr()),a++;return this.maxRange()},a.prototype.charsets={SCLD:{"`":"◆",a:"▒",b:" ",c:"\f",d:"\r",e:"\n",f:"°",g:"±",h:"␤",i:" ",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"},UK:null,US:null,Dutch:null,Finnish:null,French:null,FrenchCanadian:null,German:null,Italian:null,NorwegianDanish:null,Spanish:null,Swedish:null,Swiss:null,ISOLatin:null},a}(),window.Terminal=c}).call(this); //# sourceMappingURL=main.min.js.map \ No newline at end of file diff --git a/coffees/term.coffee b/coffees/term.coffee index 0dc97b5..84227b8 100644 --- a/coffees/term.coffee +++ b/coffees/term.coffee @@ -79,6 +79,7 @@ class Terminal while i-- div = @document.createElement('div') div.className = 'line' + div.textContent = ' ' @element.appendChild(div) @children.push(div) From 562e345c80793ed2a50d63fac2c8c08f4a990aa4 Mon Sep 17 00:00:00 2001 From: Florian Mounier Date: Fri, 17 Apr 2015 11:37:47 +0200 Subject: [PATCH 2/2] Fix send --- butterfly/static/ext.min.js | 2 +- butterfly/static/main.js | 40 ++++++++++++++++++------------------ butterfly/static/main.min.js | 6 +++--- coffees/term.coffee | 40 ++++++++++++++++++------------------ 4 files changed, 44 insertions(+), 44 deletions(-) diff --git a/butterfly/static/ext.min.js b/butterfly/static/ext.min.js index a736fac..7d0ec85 100644 --- a/butterfly/static/ext.min.js +++ b/butterfly/static/ext.min.js @@ -1,4 +1,4 @@ -/*! butterfly 2015-04-16 */ +/*! butterfly 2015-04-17 */ (function(){var a,b,c,d,e,f,g,h,i,j,k,l=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};j=function(a){var b;return b=function(c){var d;return butterfly.element.classList.remove("alarm"),d="New activity on butterfly terminal ["+butterfly.title+"]",a?new Notification(d,{body:c.data,icon:"/static/images/favicon.png"}):alert(d+"\n"+c.data),butterfly.ws.removeEventListener("message",b)},butterfly.ws.addEventListener("message",b),butterfly.element.classList.add("alarm")},c=function(a){return a.preventDefault&&a.preventDefault(),a.stopPropagation&&a.stopPropagation(),a.cancelBubble=!0,!1},addEventListener("keydown",function(a){return a.altKey&&65===a.keyCode?(Notification&&"default"===Notification.permission?Notification.requestPermission(function(){return j("granted"===Notification.permission)}):j("granted"===Notification.permission),c(a)):!0}),addEventListener("copy",d=function(a){var b,c,d,e,f,g,h;for(butterfly.bell("copied"),a.clipboardData.clearData(),h=getSelection().toString().replace(/\u00A0/g," ").replace(/\u2007/g," "),b="",g=h.split("\n"),d=0,e=g.length;e>d;d++)f=g[d],"⏎"===f.slice(-1)?(c="",f=f.slice(0,-1)):c="\n",b+=f.replace(/\s*$/,"")+c;return a.clipboardData.setData("text/plain",b.slice(0,-1)),a.preventDefault()}),addEventListener("paste",function(a){var b;return butterfly.bell("pasted"),b=a.clipboardData.getData("text/plain"),b=b.replace(/\r\n/g,"\n").replace(/\n/g,"\r"),butterfly.send(b),a.preventDefault()}),i=null,c=function(a){return a.preventDefault&&a.preventDefault(),a.stopPropagation&&a.stopPropagation(),a.cancelBubble=!0,!1},h=function(a){var b;for(b=a.previousSibling,b||(b=a.parentNode.previousSibling),b||(b=a.parentNode.parentNode.previousSibling);b.lastChild;)b=b.lastChild;return b},g=function(a){var b;for(b=a.nextSibling,b||(b=a.parentNode.nextSibling),b||(b=a.parentNode.parentNode.nextSibling);null!=b?b.firstChild:void 0;)b=b.firstChild;return b},a=function(){function a(){butterfly.element.classList.add("selection"),this.selection=getSelection()}return a.prototype.reset=function(){var a,b,c;for(this.selection=getSelection(),a=document.createRange(),a.setStart(this.selection.anchorNode,this.selection.anchorOffset),a.setEnd(this.selection.focusNode,this.selection.focusOffset),this.start={node:this.selection.anchorNode,offset:this.selection.anchorOffset},this.end={node:this.selection.focusNode,offset:this.selection.focusOffset},a.collapsed&&(b=[this.end,this.start],this.start=b[0],this.end=b[1]),this.start_line=this.start.node;!this.start_line.classList||l.call(this.start_line.classList,"line")<0;)this.start_line=this.start_line.parentNode;for(this.end_line=this.end.node,c=[];!this.end_line.classList||l.call(this.end_line.classList,"line")<0;)c.push(this.end_line=this.end_line.parentNode);return c},a.prototype.clear=function(){return this.selection.removeAllRanges()},a.prototype.destroy=function(){return butterfly.element.classList.remove("selection"),this.clear()},a.prototype.text=function(){return this.selection.toString().replace(/\u00A0/g," ").replace(/\u2007/g," ")},a.prototype.up=function(){return this.go(-1)},a.prototype.down=function(){return this.go(1)},a.prototype.go=function(a){var b;if(b=butterfly.children.indexOf(this.start_line)+a,b>=0&&b=0&&b0;)if(f[--d].match(b))return{node:e,offset:d+1};e=h(e),f=e.textContent,d=f.length}else for(;e;){for(;d=0)return!0;if(b.shiftKey&&13===b.keyCode&&!i&&!getSelection().isCollapsed)return butterfly.send(getSelection().toString()),getSelection().removeAllRanges(),c(b);if(i){if(i.reset(),!b.ctrlKey&&b.shiftKey&&37<=(e=b.keyCode)&&40>=e)return!0;if(b.shiftKey&&b.ctrlKey)38===b.keyCode?i.up():40===b.keyCode&&i.down();else if(39===b.keyCode)i.shrink_left();else if(38===b.keyCode)i.expand_left();else if(37===b.keyCode)i.shrink_right();else{if(40!==b.keyCode)return c(b);i.expand_right()}return null!=i&&i.apply(),c(b)}return!i&&b.ctrlKey&&b.shiftKey&&38===b.keyCode?(i=new a,i.select_line(butterfly.y-1),i.apply(),c(b)):!0}),document.addEventListener("keyup",function(a){var b,d;if(b=a.keyCode,l.call([16,17,18,19],b)>=0)return!0;if(i){if(13===a.keyCode)return butterfly.send(i.text()),i.destroy(),i=null,c(a);if(d=a.keyCode,l.call([37,38,39,40],d)<0)return i.destroy(),i=null,!0}return!0}),document.addEventListener("dblclick",function(a){var b,c,d,e,f;if(!(a.ctrlKey||a.altkey||(f=getSelection(),f.isCollapsed||f.toString().match(/\s/)))){for(e=document.createRange(),e.setStart(f.anchorNode,f.anchorOffset),e.setEnd(f.focusNode,f.focusOffset),e.collapsed&&(f.removeAllRanges(),d=document.createRange(),d.setStart(f.focusNode,f.focusOffset),d.setEnd(f.anchorNode,f.anchorOffset),f.addRange(d));!f.toString().match(/\s/)&&f.toString();)f.modify("extend","forward","character");for(f.modify("extend","backward","character"),b=f.anchorNode,c=f.anchorOffset,f.collapseToEnd(),f.extend(b,c);!f.toString().match(/\s/)&&f.toString();)f.modify("extend","backward","character");return f.modify("extend","forward","character")}}),document.addEventListener("DOMContentLoaded",function(){}),/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)&&(e=!1,b=!1,f=!0,k=document.createElement("input"),k.type="password",k.style.position="fixed",k.style.top=0,k.style.left=0,k.style.border="none",k.style.outline="none",k.style.opacity=0,k.value="0",document.body.appendChild(k),k.addEventListener("blur",function(){return setTimeout(function(a){return function(){return a.focus()}}(this),10)}),addEventListener("click",function(){return k.focus()}),addEventListener("touchstart",function(a){return 2===a.touches.length?e=!0:3===a.touches.length?(e=!1,b=!0):4===a.touches.length?(e=!0,b=!0):void 0}),k.addEventListener("keydown",function(a){return butterfly.keyDown(a),!0}),k.addEventListener("input",function(a){var c;return c=this.value.length,0===c?(a.keyCode=8,butterfly.keyDown(a),this.value="0",!0):(a.keyCode=this.value.charAt(1).charCodeAt(0),!e&&!b||f?(butterfly.keyPress(a),f=!1,this.value="0",!0):(a.keyCode=this.value.charAt(1).charCodeAt(0),a.ctrlKey=e,a.altKey=b,a.keyCode>=97&&a.keyCode<=122&&(a.keyCode-=32),butterfly.keyDown(a),this.value="0",e=b=!1,!0))}))}).call(this); //# sourceMappingURL=ext.min.js.map \ No newline at end of file diff --git a/butterfly/static/main.js b/butterfly/static/main.js index d1dec81..1afa0bd 100644 --- a/butterfly/static/main.js +++ b/butterfly/static/main.js @@ -275,7 +275,7 @@ Terminal.prototype.focus = function() { if (this.sendFocus) { - this.handler('\x1b[I'); + this.send('\x1b[I'); } this.showCursor(); this.element.classList.add('focus'); @@ -286,7 +286,7 @@ this.cursorState = 1; this.refresh(this.y, this.y); if (this.sendFocus) { - this.handler('\x1b[O'); + this.send('\x1b[O'); } this.element.classList.add('blur'); return this.element.classList.remove('focus'); @@ -354,20 +354,20 @@ pos.y -= 32; pos.x++; pos.y++; - _this.handler("\x1b[" + button + ";" + pos.x + ";" + pos.y + "M"); + _this.send("\x1b[" + button + ";" + pos.x + ";" + pos.y + "M"); return; } if (_this.sgrMouse) { pos.x -= 32; pos.y -= 32; - _this.handler("\x1b[<" + ((button & 3) === 3 ? button & ~3 : button) + ";" + pos.x + ";" + pos.y + ((button & 3) === 3 ? "m" : "M")); + _this.send("\x1b[<" + ((button & 3) === 3 ? button & ~3 : button) + ";" + pos.x + ";" + pos.y + ((button & 3) === 3 ? "m" : "M")); return; } data = []; encode(data, button); encode(data, pos.x); encode(data, pos.y); - return _this.handler("\x1b[M" + String.fromCharCode.apply(String, data)); + return _this.send("\x1b[M" + String.fromCharCode.apply(String, data)); }; })(this); getButton = (function(_this) { @@ -1122,7 +1122,7 @@ this.updateRange(this.y); break; case "PROMPT": - this.handler(content); + this.send(content); break; case "TEXT": l += content.length; @@ -1152,12 +1152,12 @@ console.error("Unknown DCS Pt: %s.", pt); pt = ""; } - this.handler("\x1bP" + +valid + "$r" + pt + "\x1b\\"); + this.send("\x1bP" + +valid + "$r" + pt + "\x1b\\"); break; case "+q": pt = this.currentParam; valid = false; - this.handler("\x1bP" + +valid + "+r" + pt + "\x1b\\"); + this.send("\x1bP" + +valid + "+r" + pt + "\x1b\\"); break; default: console.error("Unknown DCS prefix: %s.", this.prefix); @@ -1406,7 +1406,7 @@ return true; } this.showCursor(); - this.handler(key); + this.send(key); return cancel(ev); }; @@ -1452,7 +1452,7 @@ } key = String.fromCharCode(key); this.showCursor(); - this.handler(key); + this.send(key); return false; }; @@ -1655,7 +1655,7 @@ return ("" + this.termName).indexOf(term) === 0; }; - Terminal.prototype.handler = function(data) { + Terminal.prototype.send = function(data) { return this.out(data); }; @@ -1899,13 +1899,13 @@ if (!this.prefix) { switch (params[0]) { case 5: - return this.handler("\x1b[0n"); + return this.send("\x1b[0n"); case 6: - return this.handler("\x1b[" + (this.y + 1) + ";" + (this.x + 1) + "R"); + return this.send("\x1b[" + (this.y + 1) + ";" + (this.x + 1) + "R"); } } else if (this.prefix === "?") { if (params[0] === 6) { - return this.handler("\x1b[?" + (this.y + 1) + ";" + (this.x + 1) + "R"); + return this.send("\x1b[?" + (this.y + 1) + ";" + (this.x + 1) + "R"); } } }; @@ -2050,22 +2050,22 @@ } if (!this.prefix) { if (this.isterm("xterm") || this.isterm("rxvt-unicode") || this.isterm("screen")) { - return this.handler("\x1b[?1;2c"); + return this.send("\x1b[?1;2c"); } else { if (this.isterm("linux")) { - return this.handler("\x1b[?6c"); + return this.send("\x1b[?6c"); } } } else if (this.prefix === ">") { if (this.isterm("xterm")) { - return this.handler("\x1b[>0;276;0c"); + return this.send("\x1b[>0;276;0c"); } else if (this.isterm("rxvt-unicode")) { - return this.handler("\x1b[>85;95;0c"); + return this.send("\x1b[>85;95;0c"); } else if (this.isterm("linux")) { - return this.handler(params[0] + "c"); + return this.send(params[0] + "c"); } else { if (this.isterm("screen")) { - return this.handler("\x1b[>83;40003;0c"); + return this.send("\x1b[>83;40003;0c"); } } } diff --git a/butterfly/static/main.min.js b/butterfly/static/main.min.js index ee7f37a..eb2874c 100644 --- a/butterfly/static/main.min.js +++ b/butterfly/static/main.min.js @@ -1,5 +1,5 @@ -/*! butterfly 2015-04-16 */ +/*! butterfly 2015-04-17 */ -(function(){var a,b,c,d,e,f,g,h,i,j=[].slice,k=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};e=h=null,g=!1,f=(new Date).getTime(),a=document.querySelectorAll.bind(document),document.addEventListener("DOMContentLoaded",function(){var a,b,d,e,h,i,k;return d=function(a){return i.send("S"+a)},a=function(){var a,b,c;return c=arguments[0],a=2<=arguments.length?j.call(arguments,1):[],b=a.join(","),"Resize"===c?i.send("R"+b):void 0},k="https:"===location.protocol?"wss://":"ws://",k+=document.location.host+"/ws"+location.pathname,i=new WebSocket(k),i.addEventListener("open",function(){return console.log("WebSocket open",arguments),i.send("R"+h.cols+","+h.rows),f=(new Date).getTime()}),i.addEventListener("error",function(){return console.log("WebSocket error",arguments)}),e=null,b="",i.addEventListener("message",function(a){return h.stop?(b+=a.data,b=b.slice(-10240),e&&e&&clearTimeout(e),void(e=setTimeout(function(){return h.stop=!1,h.element.classList.remove("stopped"),h.write(b),b="",e=null},100))):h.write(a.data)}),i.addEventListener("close",function(){return console.log("WebSocket closed",arguments),setTimeout(function(){return h.write("Closed"),h.skipNextKey=!0,h.element.classList.add("dead")},1),g=!0,(new Date).getTime()-f>6e4?open("","_self").close():void 0}),h=new c(document.body,d,a),addEventListener("beforeunload",function(){return g?void 0:"This will exit the terminal session"}),h.ws=i,window.butterfly=h,window.bench=function(a){var b;for(null==a&&(a=1e8),b="";b.lengthc?b.push(c):(c>2047&&(c=2047),b.push(192|c>>6),b.push(128|63&c)):255===c?b.push(0):(c>127&&(c=127),b.push(c))}}(this),g=function(b){return function(c,d){var e;return b.urxvtMouse?(d.x-=32,d.y-=32,d.x++,d.y++,void b.handler("["+c+";"+d.x+";"+d.y+"M")):b.sgrMouse?(d.x-=32,d.y-=32,void b.handler("[<"+(3===(3&c)?-4&c:c)+";"+d.x+";"+d.y+(3===(3&c)?"m":"M"))):(e=[],a(e,c),a(e,d.x),a(e,d.y),b.handler(""+String.fromCharCode.apply(String,e)))}}(this),b=function(a){return function(b){var c,d,e,f,g;switch(b.type){case"mousedown":c=null!=b.button?+b.button:null!=b.which?b.which-1:null;break;case"mouseup":c=3;break;case"wheel":c=b.deltaY<0?64:65}return g=b.shiftKey?4:0,e=b.metaKey?8:0,d=b.ctrlKey?16:0,f=g|e|d,a.vt200Mouse?f&=d:a.normalMouse||(f=0),32+(f<<2)+c}}(this),c=function(a){return function(b){var c,d,e,f,g;for(f=b.pageX,g=b.pageY,c=a.element;c&&c!==a.document.documentElement;)f-=c.offsetLeft,g-=c.offsetTop,c="offsetParent"in c?c.offsetParent:c.parentNode;return e=a.element.clientWidth,d=window.innerHeight,f=Math.ceil(f/e*a.cols),g=Math.ceil(g/d*a.rows),0>f&&(f=0),f>a.cols&&(f=a.cols),0>g&&(g=0),g>a.rows&&(g=a.rows),f+=32,g+=32,{x:f,y:g,type:b.type}}}(this),addEventListener("contextmenu",function(a){return function(b){return a.mouseEvents?d(b):void 0}}(this)),addEventListener("mousedown",function(a){return function(b){var c,e;if(a.mouseEvents)return f(b),c=h.bind(a),a.normalMouse&&addEventListener("mousemove",c),a.x10Mouse||addEventListener("mouseup",e=function(b){return f(b),a.normalMouse&&removeEventListener("mousemove",c),removeEventListener("mouseup",e),d(b)}),d(b)}}(this)),addEventListener("wheel",function(a){return function(b){if(a.mouseEvents){if(a.x10Mouse)return;return f(b),d(b)}}}(this))},a.prototype.refresh=function(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v;for(b=Math.min(b,this.screen.length-1),j=k=p=a,q=b;q>=p?q>=k:k>=q;j=q>=p?++k:--k){for(t=j,m=this.screen[t],o="",v=j!==this.y||this.cursorHidden?-(1/0):this.x,c=this.cloneAttr(this.defAttr),i=n=0,r=this.cols-1;r>=0?r>=n:n>=r;i=r>=0?++n:--n){if(f=m[i],d=f.ch,this.equalAttr(f,c)||(this.equalAttr(c,this.defAttr)||(o+=""),this.equalAttr(f,this.defAttr)||(e=[],u=[],o+="g&&(g+=8),e.push("fg-color-"+g)),"string"==typeof f.fg&&u.push("color: "+f.fg),"number"==typeof f.bg&&e.push("bg-color-"+f.bg),"string"==typeof f.bg&&u.push("background-color: "+f.bg),o+='class="',o+=e.join(" "),o+='"',u.length&&(o+=' style="'+u.join("; ")+'"'),o+=">")),i===v&&(o+=''),d.length>1)o+=d;else switch(d){case"&":o+="&";break;case"<":o+="<";break;case">":o+=">";break;default:" "===d?o+='':" ">=d?o+=" ":(d>"＀"&&"￯">d&&i++,o+=d)}i===v&&(o+=""),c=f}this.equalAttr(c,this.defAttr)||(o+=""),this.children[j].innerHTML=o}s=this.html;for(l in s)h=s[l],this.children[l].innerHTML="",this.children[l].appendChild(h);return this.html={},this.native_scroll_to()},a.prototype._cursorBlink=function(){var a;return this.cursorState^=1,(a=this.element.querySelector(".cursor"))?a.classList.contains("reverse-video")?a.classList.remove("reverse-video"):a.classList.add("reverse-video"):void 0},a.prototype.showCursor=function(){return this.cursorState?void 0:(this.cursorState=1,this.refresh(this.y,this.y))},a.prototype.startBlink=function(){return this.cursorBlink?(this._blinker=function(a){return function(){return a._cursorBlink()}}(this),this.t_blink=setInterval(this._blinker,500)):void 0},a.prototype.refreshBlink=function(){return this.cursorBlink?(clearInterval(this.t_blink),this.t_blink=setInterval(this._blinker,500)):void 0},a.prototype.scroll=function(){return this.normal||0!==this.scrollTop||this.scrollBottom!==this.rows-1?(this.screen.splice(this.scrollBottom+1,0,this.blank_line()),this.screen.splice(this.scrollTop,1),this.y,this.updateRange(this.scrollTop),this.updateRange(this.scrollBottom)):(this.screen.shift(),this.screen.push(this.blank_line()),this.refreshStart=Math.max(this.refreshStart-1,0),this.new_line())},a.prototype.native_scroll_to=function(a){return null==a&&(a=-1),-1===a?this.children.slice(-1)[0].scrollIntoView():window.scrollTo(0,a)},a.prototype.scroll_display=function(a){return this.native_scroll_to(window.scrollY+a*this.char_size.height)},a.prototype.new_line=function(){var a;return a=this.document.createElement("div"),a.className="line",this.element.appendChild(a),this.element.childElementCount>this.scrollback&&this.element.children[0].remove(),this.children.shift(),this.children.push(a)},a.prototype.next_line=function(){return this.y++,this.y>this.scrollBottom?(this.y--,this.scroll()):void 0},a.prototype.write=function(c){var d,e,f,g,h,i,j,k,l,m,n;for(this.refreshStart=this.y,this.refreshEnd=this.y,h=0,i=c.length;i>h;){switch(d=c.charAt(h),this.state){case b.normal:switch(d){case"":this.bell();break;case"\n":case" ":case"\f":this.convertEol&&(this.x=0),this.next_line();break;case"\r":this.x=0;break;case"\b":this.x>0&&this.x--;break;case" ":this.x=this.nextStop();break;case"":this.setgLevel(1);break;case"":this.setgLevel(0);break;case"":this.state=b.escaped;break;default:if(d>=" "&&((null!=(k=this.charset)?k[d]:void 0)&&(d=this.charset[d]),this.x>=this.cols&&(this.screen[this.y][this.x]=this.cloneAttr(this.curAttr,"⏎"),this.x=0,this.next_line()),this.updateRange(this.y),this.screen[this.y][this.x]=this.cloneAttr(this.curAttr,d),this.x++,d>"＀"&&"￯">d)){if(this.cols<2||this.x>=this.cols){this.screen[this.y][this.x-1]=this.cloneAttr(this.curAttr," ");break}this.screen[this.y][this.x]=this.cloneAttr(this.curAttr," "),this.x++}}break;case b.escaped:switch(d){case"[":this.params=[],this.currentParam=0,this.state=b.csi;break;case"]":this.params=[],this.currentParam=0,this.state=b.osc;break;case"P":this.params=[],this.currentParam=0,this.state=b.dcs;break;case"_":this.state=b.ignore;break;case"^":this.state=b.ignore;break;case"c":this.reset();break;case"E":this.x=0,this.index();break;case"D":this.index();break;case"M":this.reverseIndex();break;case"%":this.setgLevel(0),this.setgCharset(0,a.prototype.charsets.US),this.state=b.normal,h++;break;case"(":case")":case"*":case"+":case"-":case".":switch(d){case"(":this.gcharset=0;break;case")":case"-":this.gcharset=1;break;case"*":case".":this.gcharset=2;break;case"+":this.gcharset=3}this.state=b.charset;break;case"/":this.gcharset=3,this.state=b.charset,h--;break;case"n":this.setgLevel(2);break;case"o":this.setgLevel(3);break;case"|":this.setgLevel(3);break;case"}":this.setgLevel(2);break;case"~":this.setgLevel(1);break;case"7":this.saveCursor(),this.state=b.normal;break;case"8":this.restoreCursor(),this.state=b.normal;break;case"#":this.state=b.normal,h++;break;case"H":this.tabSet();break;case"=":this.applicationKeypad=!0,this.state=b.normal;break;case">":this.applicationKeypad=!1,this.state=b.normal;break;default:this.state=b.normal,console.log("Unknown ESC control:",d)}break;case b.charset:switch(d){case"0":f=a.prototype.charsets.SCLD;break;case"A":f=a.prototype.charsets.UK;break;case"B":f=a.prototype.charsets.US;break;case"4":f=a.prototype.charsets.Dutch;break;case"C":case"5":f=a.prototype.charsets.Finnish;break;case"R":f=a.prototype.charsets.French;break;case"Q":f=a.prototype.charsets.FrenchCanadian;break;case"K":f=a.prototype.charsets.German;break;case"Y":f=a.prototype.charsets.Italian;break;case"E":case"6":f=a.prototype.charsets.NorwegianDanish;break;case"Z":f=a.prototype.charsets.Spanish;break;case"H":case"7":f=a.prototype.charsets.Swedish;break;case"=":f=a.prototype.charsets.Swiss;break;case"/":f=a.prototype.charsets.ISOLatin,h++;break;default:f=a.prototype.charsets.US}this.setgCharset(this.gcharset,f),this.gcharset=null,this.state=b.normal;break;case b.osc:if(""===d||""===d){switch(""===d&&h++,this.params.push(this.currentParam),this.params[0]){case 0:case 1:case 2:this.params[1]&&(this.title=this.params[1]+" - ƸӜƷ butterfly",this.handleTitle(this.title))}this.params=[],this.currentParam=0,this.state=b.normal}else this.params.length?this.currentParam+=d:d>="0"&&"9">=d?this.currentParam=10*this.currentParam+d.charCodeAt(0)-48:";"===d&&(this.params.push(this.currentParam),this.currentParam="");break;case b.csi:if("?"===d||">"===d||"!"===d){this.prefix=d;break}if(d>="0"&&"9">=d){this.currentParam=10*this.currentParam+d.charCodeAt(0)-48;break}if("$"===d||'"'===d||" "===d||"'"===d)break;if(this.params.push(this.currentParam),this.currentParam=0,";"===d)break;switch(this.state=b.normal,d){case"A":this.cursorUp(this.params);break;case"B":this.cursorDown(this.params);break;case"C":this.cursorForward(this.params);break;case"D":this.cursorBackward(this.params);break;case"H":this.cursorPos(this.params);break;case"J":this.eraseInDisplay(this.params);break;case"K":this.eraseInLine(this.params);break;case"m":this.prefix||this.charAttributes(this.params);break;case"n":this.prefix||this.deviceStatus(this.params);break;case"@":this.insertChars(this.params);break;case"E":this.cursorNextLine(this.params);break;case"F":this.cursorPrecedingLine(this.params);break;case"G":this.cursorCharAbsolute(this.params);break;case"L":this.insertLines(this.params);break;case"M":this.deleteLines(this.params);break;case"P":this.deleteChars(this.params);break;case"X":this.eraseChars(this.params);break;case"`":this.charPosAbsolute(this.params);break;case"a":this.HPositionRelative(this.params);break;case"c":this.sendDeviceAttributes(this.params);break;case"d":this.linePosAbsolute(this.params);break;case"e":this.VPositionRelative(this.params);break;case"f":this.HVPosition(this.params);break;case"h":this.setMode(this.params);break;case"l":this.resetMode(this.params);break;case"r":this.setScrollRegion(this.params);break;case"s":this.saveCursor(this.params);break;case"u":this.restoreCursor(this.params);break;case"I":this.cursorForwardTab(this.params);break;case"S":this.scrollUp(this.params);break;case"T":this.params.length<2&&!this.prefix&&this.scrollDown(this.params);break;case"Z":this.cursorBackwardTab(this.params);break;case"b":this.repeatPrecedingCharacter(this.params);break;case"g":this.tabClear(this.params);break;case"p":"!"===this.prefix&&this.softReset(this.params);break;default:console.error("Unknown CSI code: %s.",d)}this.prefix="";break;case b.dcs:if(""===d||""===d){switch(""===d&&h++,this.prefix){case"":if(j=this.currentParam,";"!==j[0]){console.error("Unknown DECUDK: "+j);break}if(j=j.slice(1),l=j.split("|",2),m=l[0],e=l[1],!e){console.error("No type for inline DECUDK: "+j);break}switch(m){case"HTML":if(!this.html_escapes_enabled){console.log("HTML escapes are disabled");break}g=document.createElement("div"),g.classList.add("inline-html"),g.innerHTML=e,this.html[this.y]=g,this.updateRange(this.y);break;case"IMAGE":g=document.createElement("img"),g.classList.add("inline-image"),g.src="data:image;base64,"+e,this.html[this.y]=g,this.updateRange(this.y);break;case"PROMPT":this.handler(e);break;case"TEXT":i+=e.length,c=c.slice(0,h+1)+e+c.slice(h+1);break;default:console.error("Unknown type "+m+" for DECUDK")}break;case"$q":switch(j=this.currentParam,n=!1,j){case'"q':j='0"q';break;case'"p':j='61"p';break;case"r":j=""+(this.scrollTop+1)+";"+(this.scrollBottom+1)+"r";break;case"m":j="0m";break;default:console.error("Unknown DCS Pt: %s.",j),j=""}this.handler("P"+ +n+"$r"+j+"\\");break;case"+q":j=this.currentParam,n=!1,this.handler("P"+ +n+"+r"+j+"\\");break;default:console.error("Unknown DCS prefix: %s.",this.prefix)}this.currentParam=0,this.prefix="",this.state=b.normal}else this.currentParam?this.currentParam+=d:this.prefix||"$"===d||"+"===d?2===this.prefix.length?this.currentParam=d:this.prefix+=d:this.currentParam=d;break;case b.ignore:(""===d||""===d)&&(""===d&&h++,this.state=b.normal)}h++}return this.updateRange(this.y),this.refresh(this.refreshStart,this.refreshEnd)},a.prototype.writeln=function(a){return this.write(a+"\r\n")},a.prototype.keyDown=function(a){var b,c,e,f;if(a.keyCode>15&&a.keyCode<19)return!0;if((a.shiftKey||a.ctrlKey)&&45===a.keyCode)return!0;if(a.shiftKey&&a.ctrlKey&&(67===(e=a.keyCode)||86===e))return!0;if(a.altKey&&90===a.keyCode&&!this.skipNextKey)return this.skipNextKey=!0,this.element.classList.add("skip"),d(a);if(this.skipNextKey)return this.skipNextKey=!1,this.element.classList.remove("skip"),!0;switch(a.keyCode){case 8:if(c=a.altKey?"":"",a.shiftKey){c+="\b";break}c+="";break;case 9:if(a.shiftKey){c="";break}c=" ";break;case 13:c="\r";break;case 27:c="";break;case 37:if(this.applicationCursor){c="OD";break}c="";break;case 39:if(this.applicationCursor){c="OC";break}c="";break;case 38:if(this.applicationCursor){c="OA";break}if(a.ctrlKey)return this.scroll_display(-1),d(a);c="";break;case 40:if(this.applicationCursor){c="OB";break}if(a.ctrlKey)return this.scroll_display(1),d(a);c="";break;case 46:c="[3~";break;case 45:c="[2~";break;case 36:if(this.applicationKeypad){c="OH";break}c="OH";break;case 35:if(this.applicationKeypad){c="OF";break}c="OF";break;case 33:if(a.shiftKey)return this.scroll_display(-(this.rows-1)),d(a);c="[5~";break;case 34:if(a.shiftKey)return this.scroll_display(this.rows-1),d(a);c="[6~";break;case 112:c="OP";break;case 113:c="OQ";break;case 114:c="OR";break;case 115:c="OS";break;case 116:c="[15~";break;case 117:c="[17~";break;case 118:c="[18~";break;case 119:c="[19~";break;case 120:c="[20~";break;case 121:c="[21~";break;case 122:c="[23~";break;case 123:c="[24~";break;default:if(a.ctrlKey)if(a.keyCode>=65&&a.keyCode<=90){if(67===a.keyCode){if(f=(new Date).getTime(),f-this.last_cc<500&&!this.stop){for(b=setTimeout(function(){});b--;)b!==this.t_bell&&b!==this.t_queue&&b!==this.t_blink&&clearTimeout(b);this.element.classList.add("stopped"),this.stop=!0}else if(this.stop)return!0;this.last_cc=f}c=String.fromCharCode(a.keyCode-64)}else 32===a.keyCode?c=String.fromCharCode(0):a.keyCode>=51&&a.keyCode<=55?c=String.fromCharCode(a.keyCode-51+27):56===a.keyCode?c=String.fromCharCode(127):219===a.keyCode?c=String.fromCharCode(27):221===a.keyCode&&(c=String.fromCharCode(29));else(a.altKey&&k.call(navigator.platform,"Mac")<0||a.metaKey&&k.call(navigator.platform,"Mac")>=0)&&(a.keyCode>=65&&a.keyCode<=90?c=""+String.fromCharCode(a.keyCode+32):192===a.keyCode?c="`":a.keyCode>=48&&a.keyCode<=57&&(c=""+(a.keyCode-48)))}return a.keyCode>=37&&a.keyCode<=40&&(a.ctrlKey?c=c.slice(0,-1)+"1;5"+c.slice(-1):a.altKey?c=c.slice(0,-1)+"1;3"+c.slice(-1):a.shiftKey&&(c=c.slice(0,-1)+"1;4"+c.slice(-1))),c?(this.showCursor(),this.handler(c),d(a)):!0},a.prototype.setgLevel=function(a){return this.glevel=a,this.charset=this.charsets[a]},a.prototype.setgCharset=function(a,b){return this.charsets[a]=b,this.glevel===a?this.charset=b:void 0},a.prototype.keyPress=function(a){var b,c;if(this.skipNextKey===!1)return this.skipNextKey=null,!0;if(a.keyCode>15&&a.keyCode<19)return!0;if((a.shiftKey||a.ctrlKey)&&45===a.keyCode)return!0;if(a.shiftKey&&a.ctrlKey&&(67===(c=a.keyCode)||86===c))return!0;if(d(a),a.charCode)b=a.charCode;else if(null==a.which)b=a.keyCode;else{if(0===a.which||0===a.charCode)return!1;b=a.which}return!b||a.ctrlKey||a.altKey||a.metaKey?!1:(b=String.fromCharCode(b),this.showCursor(),this.handler(b),!1)},a.prototype.bell=function(a){return null==a&&(a="bell"),this.visualBell?(this.element.classList.add(a),this.t_bell=setTimeout(function(b){return function(){return b.element.classList.remove(a)}}(this),this.visualBell)):void 0},a.prototype.resize=function(){var a,b,c,d,e,f,g;if(e=this.cols,f=this.rows,this.compute_char_size(),this.cols=Math.floor(this.element.clientWidth/this.char_size.width),this.rows=Math.floor(window.innerHeight/this.char_size.height),g=window.innerHeight%this.char_size.height,this.element.style["padding-bottom"]=g+"px",e!==this.cols||f!==this.rows){if(this.ctl("Resize",this.cols,this.rows),ethis.cols)for(b=this.screen.length;b--;)for(;this.screen[b].length>this.cols;)this.screen[b].pop();if(this.setupStops(e),c=f,cthis.rows)for(;c-->this.rows;)this.screen.length>this.rows&&this.screen.pop(),this.children.length>this.rows&&(a=this.children.pop(),null!=a&&a.parentNode.removeChild(a));return this.y>=this.rows&&(this.y=this.rows-1),this.x>=this.cols&&(this.x=this.cols-1),this.scrollTop=0,this.scrollBottom=this.rows-1,this.refresh(0,this.rows-1),this.normal=null}},a.prototype.updateRange=function(a){return athis.refreshEnd?this.refreshEnd=a:void 0},a.prototype.maxRange=function(){return this.refreshStart=0,this.refreshEnd=this.rows-1},a.prototype.setupStops=function(a){var b;for(null!=a?this.tabs[a]||(a=this.prevStop(a)):(this.tabs={},a=0),b=[];a0;);return a>=this.cols?this.cols-1:0>a?0:a},a.prototype.nextStop=function(a){for(null==a&&(a=this.x);!this.tabs[++a]&&a=this.cols?this.cols-1:0>a?0:a},a.prototype.eraseRight=function(a,b){var c;for(c=this.screen[b];ab&&(b=1),this.y-=b,this.y<0?this.y=0:void 0},a.prototype.cursorDown=function(a){var b;return b=a[0],1>b&&(b=1),this.y+=b,this.y>=this.rows?this.y=this.rows-1:void 0},a.prototype.cursorForward=function(a){var b;return b=a[0],1>b&&(b=1),this.x+=b,this.x>=this.cols?this.x=this.cols-1:void 0},a.prototype.cursorBackward=function(a){var b;return b=a[0],1>b&&(b=1),this.x-=b,this.x<0?this.x=0:void 0},a.prototype.cursorPos=function(a){var b,c;return c=a[0]-1,b=a.length>=2?a[1]-1:0,0>c?c=0:c>=this.rows&&(c=this.rows-1),0>b?b=0:b>=this.cols&&(b=this.cols-1),this.x=b,this.y=c},a.prototype.eraseInDisplay=function(a){var b,c,d,e;switch(a[0]){case 0:for(this.eraseRight(this.x,this.y),b=this.y+1,c=[];bb;)d=a[b],d>=30&&37>=d?this.curAttr.fg=d-30:d>=40&&47>=d?this.curAttr.bg=d-40:d>=90&&97>=d?(d+=8,this.curAttr.fg=d-90):d>=100&&107>=d?(d+=8,this.curAttr.bg=d-100):0===d?this.curAttr=this.cloneAttr(this.defAttr):1===d?this.curAttr.bold=!0:4===d?this.curAttr.underline=!0:5===d?this.curAttr.blink=!0:7===d?this.curAttr.inverse=!0:8===d?this.curAttr.invisible=!0:10===d||(22===d?this.curAttr.bold=!1:24===d?this.curAttr.underline=!1:25===d?this.curAttr.blink=!1:27===d?this.curAttr.inverse=!1:28===d?this.curAttr.invisible=!1:39===d?this.curAttr.fg=257:49===d?this.curAttr.bg=256:38===d?2===a[b+1]?(b+=2,this.curAttr.fg="rgb("+a[b]+", "+a[b+1]+", "+a[b+2]+")",b+=2):5===a[b+1]&&(b+=2,this.curAttr.fg=255&a[b]):48===d?2===a[b+1]?(b+=2,this.curAttr.bg="rgb("+a[b]+", "+a[b+1]+", "+a[b+2]+")",b+=2):5===a[b+1]&&(b+=2,this.curAttr.bg=255&a[b]):100===d?(this.curAttr.fg=257,this.curAttr.bg=256):console.error("Unknown SGR attribute: %d.",d)),e.push(b++);return e},a.prototype.deviceStatus=function(a){if(this.prefix){if("?"===this.prefix&&6===a[0])return this.handler("[?"+(this.y+1)+";"+(this.x+1)+"R")}else switch(a[0]){case 5:return this.handler("");case 6:return this.handler("["+(this.y+1)+";"+(this.x+1)+"R")}},a.prototype.insertChars=function(a){var b,c,d,e;for(c=a[0],1>c&&(c=1),e=this.y,b=this.x,d=[];c--&&bb&&(b=1),this.y+=b,this.y>=this.rows&&(this.y=this.rows-1),this.x=0},a.prototype.cursorPrecedingLine=function(a){var b;return b=a[0],1>b&&(b=1),this.y-=b,this.y<0&&(this.y=0),this.x=0},a.prototype.cursorCharAbsolute=function(a){var b;return b=a[0],1>b&&(b=1),this.x=b-1},a.prototype.insertLines=function(a){var b;for(b=a[0],1>b&&(b=1);b--;)this.screen.splice(this.y,0,this.blank_line(!0)),this.screen.splice(this.scrollBottom+1,1);return this.updateRange(this.y),this.updateRange(this.scrollBottom)},a.prototype.deleteLines=function(a){var b,c;for(b=a[0],1>b&&(b=1),c=this.y;b--;)this.screen.push(this.blank_line(!0)),this.screen.splice(this.y,1);return this.updateRange(this.y),this.updateRange(this.scrollBottom)},a.prototype.deleteChars=function(a){var b,c,d;for(b=a[0],1>b&&(b=1),d=this.y,c=[];b--;)this.screen[d].splice(this.x,1),c.push(this.screen[d].push(this.eraseAttr()));return c},a.prototype.eraseChars=function(a){var b,c,d,e;for(c=a[0],1>c&&(c=1),e=this.y,b=this.x,d=[];c--&&bb&&(b=1),this.x=b-1,this.x>=this.cols?this.x=this.cols-1:void 0},a.prototype.HPositionRelative=function(a){var b;return b=a[0],1>b&&(b=1),this.x+=b,this.x>=this.cols?this.x=this.cols-1:void 0},a.prototype.sendDeviceAttributes=function(a){if(!(a[0]>0))if(this.prefix){if(">"===this.prefix){if(this.isterm("xterm"))return this.handler("[>0;276;0c");if(this.isterm("rxvt-unicode"))return this.handler("[>85;95;0c");if(this.isterm("linux"))return this.handler(a[0]+"c");if(this.isterm("screen"))return this.handler("[>83;40003;0c")}}else{if(this.isterm("xterm")||this.isterm("rxvt-unicode")||this.isterm("screen"))return this.handler("[?1;2c");if(this.isterm("linux"))return this.handler("[?6c")}},a.prototype.linePosAbsolute=function(a){var b;return b=a[0],1>b&&(b=1),this.y=b-1,this.y>=this.rows?this.y=this.rows-1:void 0},a.prototype.VPositionRelative=function(a){var b;return b=a[0],1>b&&(b=1),this.y+=b,this.y>=this.rows?this.y=this.rows-1:void 0},a.prototype.HVPosition=function(a){return a[0]<1&&(a[0]=1),a[1]<1&&(a[1]=1),this.y=a[0]-1,this.y>=this.rows&&(this.y=this.rows-1),this.x=a[1]-1,this.x>=this.cols?this.x=this.cols-1:void 0},a.prototype.setMode=function(b){var c,d,e;if("object"!=typeof b){if("?"===this.prefix)switch(b){case 1:return this.applicationCursor=!0;case 2:return this.setgCharset(0,a.prototype.charsets.US),this.setgCharset(1,a.prototype.charsets.US),this.setgCharset(2,a.prototype.charsets.US),this.setgCharset(3,a.prototype.charsets.US);case 3:return this.savedCols=this.cols,this.resize(132,this.rows);case 6:return this.originMode=!0;case 7:return this.wraparoundMode=!0;case 66:return this.applicationKeypad=!0;case 9:case 1e3:case 1002:case 1003:return this.x10Mouse=9===b,this.vt200Mouse=1e3===b,this.normalMouse=b>1e3,this.mouseEvents=!0,this.element.style.cursor="pointer";case 1004:return this.sendFocus=!0;case 1005:return this.utfMouse=!0;case 1006:return this.sgrMouse=!0;case 1015:return this.urxvtMouse=!0;case 25:return this.cursorHidden=!1;case 1049:case 47:case 1047:if(!this.normal)return e={lines:this.screen,x:this.x,y:this.y,scrollTop:this.scrollTop,scrollBottom:this.scrollBottom,tabs:this.tabs},this.reset(),this.normal=e,this.showCursor()}}else for(d=b.length,c=0;d>c;)this.setMode(b[c]),c++},a.prototype.resetMode=function(a){var b,c;if("object"!=typeof a){if("?"===this.prefix)switch(a){case 1:return this.applicationCursor=!1;case 3:return 132===this.cols&&this.savedCols&&this.resize(this.savedCols,this.rows),delete this.savedCols;case 6:return this.originMode=!1;case 7:return this.wraparoundMode=!1;case 66:return this.applicationKeypad=!1;case 9:case 1e3:case 1002:case 1003:return this.x10Mouse=!1,this.vt200Mouse=!1,this.normalMouse=!1,this.mouseEvents=!1,this.element.style.cursor="";case 1004:return this.sendFocus=!1;case 1005:return this.utfMouse=!1;case 1006:return this.sgrMouse=!1;case 1015:return this.urxvtMouse=!1;case 25:return this.cursorHidden=!0;case 1049:case 47:case 1047:if(this.normal)return this.screen=this.normal.lines,this.x=this.normal.x,this.y=this.normal.y,this.scrollTop=this.normal.scrollTop,this.scrollBottom=this.normal.scrollBottom,this.tabs=this.normal.tabs,this.normal=null,this.refresh(0,this.rows-1),this.showCursor()}}else for(c=a.length,b=0;c>b;)this.resetMode(a[b]),b++},a.prototype.setScrollRegion=function(a){return this.prefix?void 0:(this.scrollTop=(a[0]||1)-1, -this.scrollBottom=(a[1]||this.rows)-1,this.x=0,this.y=0)},a.prototype.saveCursor=function(a){return this.savedX=this.x,this.savedY=this.y},a.prototype.restoreCursor=function(a){return this.x=this.savedX||0,this.y=this.savedY||0},a.prototype.cursorForwardTab=function(a){var b,c;for(b=a[0]||1,c=[];b--;)c.push(this.x=this.nextStop());return c},a.prototype.scrollUp=function(a){var b;for(b=a[0]||1;b--;)this.screen.splice(this.scrollTop,1),this.screen.splice(this.scrollBottom,0,this.blank_line());return this.updateRange(this.scrollTop),this.updateRange(this.scrollBottom)},a.prototype.scrollDown=function(a){var b;for(b=a[0]||1;b--;)this.screen.splice(this.scrollBottom,1),this.screen.splice(this.scrollTop,0,this.blank_line());return this.updateRange(this.scrollTop),this.updateRange(this.scrollBottom)},a.prototype.initMouseTracking=function(a){},a.prototype.resetTitleModes=function(a){},a.prototype.cursorBackwardTab=function(a){var b,c;for(b=a[0]||1,c=[];b--;)c.push(this.x=this.prevStop());return c},a.prototype.repeatPrecedingCharacter=function(a){var b,c,d,e;for(d=a[0]||1,c=this.screen[this.y],b=c[this.x-1]||this.defAttr,e=[];d--;)e.push(c[this.x++]=b);return e},a.prototype.tabClear=function(a){var b;return b=a[0],0>=b?delete this.tabs[this.x]:3===b?this.tabs={}:void 0},a.prototype.mediaCopy=function(a){},a.prototype.setResources=function(a){},a.prototype.disableModifiers=function(a){},a.prototype.setPointerMode=function(a){},a.prototype.softReset=function(a){return this.cursorHidden=!1,this.insertMode=!1,this.originMode=!1,this.wraparoundMode=!1,this.applicationKeypad=!1,this.applicationCursor=!1,this.scrollTop=0,this.scrollBottom=this.rows-1,this.curAttr=this.defAttr,this.x=this.y=0,this.charset=null,this.glevel=0,this.charsets=[null]},a.prototype.requestAnsiMode=function(a){},a.prototype.requestPrivateMode=function(a){},a.prototype.setConformanceLevel=function(a){},a.prototype.loadLEDs=function(a){},a.prototype.setCursorStyle=function(a){},a.prototype.setCharProtectionAttr=function(a){},a.prototype.restorePrivateValues=function(a){},a.prototype.setAttrInRectangle=function(a){var b,c,d,e,f,g,h;for(h=a[0],e=a[1],c=a[2],g=a[3],b=a[4];c+1>h;){for(f=this.screen[h],d=e;g>d;)f[d]=this.cloneAttr(b,f[d].ch),d++;h++}return this.updateRange(a[0]),this.updateRange(a[2])},a.prototype.savePrivateValues=function(a){},a.prototype.manipulateWindow=function(a){},a.prototype.reverseAttrInRectangle=function(a){},a.prototype.setTitleModeFeature=function(a){},a.prototype.setWarningBellVolume=function(a){},a.prototype.setMarginBellVolume=function(a){},a.prototype.copyRectangle=function(a){},a.prototype.enableFilterRectangle=function(a){},a.prototype.requestParameters=function(a){},a.prototype.selectChangeExtent=function(a){},a.prototype.fillRectangle=function(a){var b,c,d,e,f,g,h;for(c=a[0],h=a[1],e=a[2],b=a[3],g=a[4];b+1>h;){for(f=this.screen[h],d=e;g>d;)f[d]=this.cloneAttr(f[d][0],String.fromCharCode(c)),d++;h++}return this.updateRange(a[1]),this.updateRange(a[3])},a.prototype.enableLocatorReporting=function(a){var b;return b=a[0]>0},a.prototype.eraseRectangle=function(a){var b,c,d,e,f,g;for(g=a[0],d=a[1],b=a[2],f=a[3];b+1>g;){for(e=this.screen[g],c=d;f>c;)e[c]=this.eraseAttr(),c++;g++}return this.updateRange(a[0]),this.updateRange(a[2])},a.prototype.setLocatorEvents=function(a){},a.prototype.selectiveEraseRectangle=function(a){},a.prototype.requestLocatorPosition=function(a){},a.prototype.insertColumns=function(){var a,b,c;for(c=params[0],b=this.rows;c--;)for(a=0;b>a;)this.screen[a].splice(this.x+1,0,this.eraseAttr()),this.screen[a].pop(),a++;return this.maxRange()},a.prototype.deleteColumns=function(){var a,b,c;for(c=params[0],b=this.rows;c--;)for(a=0;b>a;)this.screen[a].splice(this.x,1),this.screen[a].push(this.eraseAttr()),a++;return this.maxRange()},a.prototype.charsets={SCLD:{"`":"◆",a:"▒",b:" ",c:"\f",d:"\r",e:"\n",f:"°",g:"±",h:"␤",i:" ",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"},UK:null,US:null,Dutch:null,Finnish:null,French:null,FrenchCanadian:null,German:null,Italian:null,NorwegianDanish:null,Spanish:null,Swedish:null,Swiss:null,ISOLatin:null},a}(),window.Terminal=c}).call(this); +(function(){var a,b,c,d,e,f,g,h,i,j=[].slice,k=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};e=h=null,g=!1,f=(new Date).getTime(),a=document.querySelectorAll.bind(document),document.addEventListener("DOMContentLoaded",function(){var a,b,d,e,h,i,k;return d=function(a){return i.send("S"+a)},a=function(){var a,b,c;return c=arguments[0],a=2<=arguments.length?j.call(arguments,1):[],b=a.join(","),"Resize"===c?i.send("R"+b):void 0},k="https:"===location.protocol?"wss://":"ws://",k+=document.location.host+"/ws"+location.pathname,i=new WebSocket(k),i.addEventListener("open",function(){return console.log("WebSocket open",arguments),i.send("R"+h.cols+","+h.rows),f=(new Date).getTime()}),i.addEventListener("error",function(){return console.log("WebSocket error",arguments)}),e=null,b="",i.addEventListener("message",function(a){return h.stop?(b+=a.data,b=b.slice(-10240),e&&e&&clearTimeout(e),void(e=setTimeout(function(){return h.stop=!1,h.element.classList.remove("stopped"),h.write(b),b="",e=null},100))):h.write(a.data)}),i.addEventListener("close",function(){return console.log("WebSocket closed",arguments),setTimeout(function(){return h.write("Closed"),h.skipNextKey=!0,h.element.classList.add("dead")},1),g=!0,(new Date).getTime()-f>6e4?open("","_self").close():void 0}),h=new c(document.body,d,a),addEventListener("beforeunload",function(){return g?void 0:"This will exit the terminal session"}),h.ws=i,window.butterfly=h,window.bench=function(a){var b;for(null==a&&(a=1e8),b="";b.lengthc?b.push(c):(c>2047&&(c=2047),b.push(192|c>>6),b.push(128|63&c)):255===c?b.push(0):(c>127&&(c=127),b.push(c))}}(this),g=function(b){return function(c,d){var e;return b.urxvtMouse?(d.x-=32,d.y-=32,d.x++,d.y++,void b.send("["+c+";"+d.x+";"+d.y+"M")):b.sgrMouse?(d.x-=32,d.y-=32,void b.send("[<"+(3===(3&c)?-4&c:c)+";"+d.x+";"+d.y+(3===(3&c)?"m":"M"))):(e=[],a(e,c),a(e,d.x),a(e,d.y),b.send(""+String.fromCharCode.apply(String,e)))}}(this),b=function(a){return function(b){var c,d,e,f,g;switch(b.type){case"mousedown":c=null!=b.button?+b.button:null!=b.which?b.which-1:null;break;case"mouseup":c=3;break;case"wheel":c=b.deltaY<0?64:65}return g=b.shiftKey?4:0,e=b.metaKey?8:0,d=b.ctrlKey?16:0,f=g|e|d,a.vt200Mouse?f&=d:a.normalMouse||(f=0),32+(f<<2)+c}}(this),c=function(a){return function(b){var c,d,e,f,g;for(f=b.pageX,g=b.pageY,c=a.element;c&&c!==a.document.documentElement;)f-=c.offsetLeft,g-=c.offsetTop,c="offsetParent"in c?c.offsetParent:c.parentNode;return e=a.element.clientWidth,d=window.innerHeight,f=Math.ceil(f/e*a.cols),g=Math.ceil(g/d*a.rows),0>f&&(f=0),f>a.cols&&(f=a.cols),0>g&&(g=0),g>a.rows&&(g=a.rows),f+=32,g+=32,{x:f,y:g,type:b.type}}}(this),addEventListener("contextmenu",function(a){return function(b){return a.mouseEvents?d(b):void 0}}(this)),addEventListener("mousedown",function(a){return function(b){var c,e;if(a.mouseEvents)return f(b),c=h.bind(a),a.normalMouse&&addEventListener("mousemove",c),a.x10Mouse||addEventListener("mouseup",e=function(b){return f(b),a.normalMouse&&removeEventListener("mousemove",c),removeEventListener("mouseup",e),d(b)}),d(b)}}(this)),addEventListener("wheel",function(a){return function(b){if(a.mouseEvents){if(a.x10Mouse)return;return f(b),d(b)}}}(this))},a.prototype.refresh=function(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v;for(b=Math.min(b,this.screen.length-1),j=k=p=a,q=b;q>=p?q>=k:k>=q;j=q>=p?++k:--k){for(t=j,m=this.screen[t],o="",v=j!==this.y||this.cursorHidden?-(1/0):this.x,c=this.cloneAttr(this.defAttr),i=n=0,r=this.cols-1;r>=0?r>=n:n>=r;i=r>=0?++n:--n){if(f=m[i],d=f.ch,this.equalAttr(f,c)||(this.equalAttr(c,this.defAttr)||(o+=""),this.equalAttr(f,this.defAttr)||(e=[],u=[],o+="g&&(g+=8),e.push("fg-color-"+g)),"string"==typeof f.fg&&u.push("color: "+f.fg),"number"==typeof f.bg&&e.push("bg-color-"+f.bg),"string"==typeof f.bg&&u.push("background-color: "+f.bg),o+='class="',o+=e.join(" "),o+='"',u.length&&(o+=' style="'+u.join("; ")+'"'),o+=">")),i===v&&(o+=''),d.length>1)o+=d;else switch(d){case"&":o+="&";break;case"<":o+="<";break;case">":o+=">";break;default:" "===d?o+='':" ">=d?o+=" ":(d>"＀"&&"￯">d&&i++,o+=d)}i===v&&(o+=""),c=f}this.equalAttr(c,this.defAttr)||(o+=""),this.children[j].innerHTML=o}s=this.html;for(l in s)h=s[l],this.children[l].innerHTML="",this.children[l].appendChild(h);return this.html={},this.native_scroll_to()},a.prototype._cursorBlink=function(){var a;return this.cursorState^=1,(a=this.element.querySelector(".cursor"))?a.classList.contains("reverse-video")?a.classList.remove("reverse-video"):a.classList.add("reverse-video"):void 0},a.prototype.showCursor=function(){return this.cursorState?void 0:(this.cursorState=1,this.refresh(this.y,this.y))},a.prototype.startBlink=function(){return this.cursorBlink?(this._blinker=function(a){return function(){return a._cursorBlink()}}(this),this.t_blink=setInterval(this._blinker,500)):void 0},a.prototype.refreshBlink=function(){return this.cursorBlink?(clearInterval(this.t_blink),this.t_blink=setInterval(this._blinker,500)):void 0},a.prototype.scroll=function(){return this.normal||0!==this.scrollTop||this.scrollBottom!==this.rows-1?(this.screen.splice(this.scrollBottom+1,0,this.blank_line()),this.screen.splice(this.scrollTop,1),this.y,this.updateRange(this.scrollTop),this.updateRange(this.scrollBottom)):(this.screen.shift(),this.screen.push(this.blank_line()),this.refreshStart=Math.max(this.refreshStart-1,0),this.new_line())},a.prototype.native_scroll_to=function(a){return null==a&&(a=-1),-1===a?this.children.slice(-1)[0].scrollIntoView():window.scrollTo(0,a)},a.prototype.scroll_display=function(a){return this.native_scroll_to(window.scrollY+a*this.char_size.height)},a.prototype.new_line=function(){var a;return a=this.document.createElement("div"),a.className="line",this.element.appendChild(a),this.element.childElementCount>this.scrollback&&this.element.children[0].remove(),this.children.shift(),this.children.push(a)},a.prototype.next_line=function(){return this.y++,this.y>this.scrollBottom?(this.y--,this.scroll()):void 0},a.prototype.write=function(c){var d,e,f,g,h,i,j,k,l,m,n;for(this.refreshStart=this.y,this.refreshEnd=this.y,h=0,i=c.length;i>h;){switch(d=c.charAt(h),this.state){case b.normal:switch(d){case"":this.bell();break;case"\n":case" ":case"\f":this.convertEol&&(this.x=0),this.next_line();break;case"\r":this.x=0;break;case"\b":this.x>0&&this.x--;break;case" ":this.x=this.nextStop();break;case"":this.setgLevel(1);break;case"":this.setgLevel(0);break;case"":this.state=b.escaped;break;default:if(d>=" "&&((null!=(k=this.charset)?k[d]:void 0)&&(d=this.charset[d]),this.x>=this.cols&&(this.screen[this.y][this.x]=this.cloneAttr(this.curAttr,"⏎"),this.x=0,this.next_line()),this.updateRange(this.y),this.screen[this.y][this.x]=this.cloneAttr(this.curAttr,d),this.x++,d>"＀"&&"￯">d)){if(this.cols<2||this.x>=this.cols){this.screen[this.y][this.x-1]=this.cloneAttr(this.curAttr," ");break}this.screen[this.y][this.x]=this.cloneAttr(this.curAttr," "),this.x++}}break;case b.escaped:switch(d){case"[":this.params=[],this.currentParam=0,this.state=b.csi;break;case"]":this.params=[],this.currentParam=0,this.state=b.osc;break;case"P":this.params=[],this.currentParam=0,this.state=b.dcs;break;case"_":this.state=b.ignore;break;case"^":this.state=b.ignore;break;case"c":this.reset();break;case"E":this.x=0,this.index();break;case"D":this.index();break;case"M":this.reverseIndex();break;case"%":this.setgLevel(0),this.setgCharset(0,a.prototype.charsets.US),this.state=b.normal,h++;break;case"(":case")":case"*":case"+":case"-":case".":switch(d){case"(":this.gcharset=0;break;case")":case"-":this.gcharset=1;break;case"*":case".":this.gcharset=2;break;case"+":this.gcharset=3}this.state=b.charset;break;case"/":this.gcharset=3,this.state=b.charset,h--;break;case"n":this.setgLevel(2);break;case"o":this.setgLevel(3);break;case"|":this.setgLevel(3);break;case"}":this.setgLevel(2);break;case"~":this.setgLevel(1);break;case"7":this.saveCursor(),this.state=b.normal;break;case"8":this.restoreCursor(),this.state=b.normal;break;case"#":this.state=b.normal,h++;break;case"H":this.tabSet();break;case"=":this.applicationKeypad=!0,this.state=b.normal;break;case">":this.applicationKeypad=!1,this.state=b.normal;break;default:this.state=b.normal,console.log("Unknown ESC control:",d)}break;case b.charset:switch(d){case"0":f=a.prototype.charsets.SCLD;break;case"A":f=a.prototype.charsets.UK;break;case"B":f=a.prototype.charsets.US;break;case"4":f=a.prototype.charsets.Dutch;break;case"C":case"5":f=a.prototype.charsets.Finnish;break;case"R":f=a.prototype.charsets.French;break;case"Q":f=a.prototype.charsets.FrenchCanadian;break;case"K":f=a.prototype.charsets.German;break;case"Y":f=a.prototype.charsets.Italian;break;case"E":case"6":f=a.prototype.charsets.NorwegianDanish;break;case"Z":f=a.prototype.charsets.Spanish;break;case"H":case"7":f=a.prototype.charsets.Swedish;break;case"=":f=a.prototype.charsets.Swiss;break;case"/":f=a.prototype.charsets.ISOLatin,h++;break;default:f=a.prototype.charsets.US}this.setgCharset(this.gcharset,f),this.gcharset=null,this.state=b.normal;break;case b.osc:if(""===d||""===d){switch(""===d&&h++,this.params.push(this.currentParam),this.params[0]){case 0:case 1:case 2:this.params[1]&&(this.title=this.params[1]+" - ƸӜƷ butterfly",this.handleTitle(this.title))}this.params=[],this.currentParam=0,this.state=b.normal}else this.params.length?this.currentParam+=d:d>="0"&&"9">=d?this.currentParam=10*this.currentParam+d.charCodeAt(0)-48:";"===d&&(this.params.push(this.currentParam),this.currentParam="");break;case b.csi:if("?"===d||">"===d||"!"===d){this.prefix=d;break}if(d>="0"&&"9">=d){this.currentParam=10*this.currentParam+d.charCodeAt(0)-48;break}if("$"===d||'"'===d||" "===d||"'"===d)break;if(this.params.push(this.currentParam),this.currentParam=0,";"===d)break;switch(this.state=b.normal,d){case"A":this.cursorUp(this.params);break;case"B":this.cursorDown(this.params);break;case"C":this.cursorForward(this.params);break;case"D":this.cursorBackward(this.params);break;case"H":this.cursorPos(this.params);break;case"J":this.eraseInDisplay(this.params);break;case"K":this.eraseInLine(this.params);break;case"m":this.prefix||this.charAttributes(this.params);break;case"n":this.prefix||this.deviceStatus(this.params);break;case"@":this.insertChars(this.params);break;case"E":this.cursorNextLine(this.params);break;case"F":this.cursorPrecedingLine(this.params);break;case"G":this.cursorCharAbsolute(this.params);break;case"L":this.insertLines(this.params);break;case"M":this.deleteLines(this.params);break;case"P":this.deleteChars(this.params);break;case"X":this.eraseChars(this.params);break;case"`":this.charPosAbsolute(this.params);break;case"a":this.HPositionRelative(this.params);break;case"c":this.sendDeviceAttributes(this.params);break;case"d":this.linePosAbsolute(this.params);break;case"e":this.VPositionRelative(this.params);break;case"f":this.HVPosition(this.params);break;case"h":this.setMode(this.params);break;case"l":this.resetMode(this.params);break;case"r":this.setScrollRegion(this.params);break;case"s":this.saveCursor(this.params);break;case"u":this.restoreCursor(this.params);break;case"I":this.cursorForwardTab(this.params);break;case"S":this.scrollUp(this.params);break;case"T":this.params.length<2&&!this.prefix&&this.scrollDown(this.params);break;case"Z":this.cursorBackwardTab(this.params);break;case"b":this.repeatPrecedingCharacter(this.params);break;case"g":this.tabClear(this.params);break;case"p":"!"===this.prefix&&this.softReset(this.params);break;default:console.error("Unknown CSI code: %s.",d)}this.prefix="";break;case b.dcs:if(""===d||""===d){switch(""===d&&h++,this.prefix){case"":if(j=this.currentParam,";"!==j[0]){console.error("Unknown DECUDK: "+j);break}if(j=j.slice(1),l=j.split("|",2),m=l[0],e=l[1],!e){console.error("No type for inline DECUDK: "+j);break}switch(m){case"HTML":if(!this.html_escapes_enabled){console.log("HTML escapes are disabled");break}g=document.createElement("div"),g.classList.add("inline-html"),g.innerHTML=e,this.html[this.y]=g,this.updateRange(this.y);break;case"IMAGE":g=document.createElement("img"),g.classList.add("inline-image"),g.src="data:image;base64,"+e,this.html[this.y]=g,this.updateRange(this.y);break;case"PROMPT":this.send(e);break;case"TEXT":i+=e.length,c=c.slice(0,h+1)+e+c.slice(h+1);break;default:console.error("Unknown type "+m+" for DECUDK")}break;case"$q":switch(j=this.currentParam,n=!1,j){case'"q':j='0"q';break;case'"p':j='61"p';break;case"r":j=""+(this.scrollTop+1)+";"+(this.scrollBottom+1)+"r";break;case"m":j="0m";break;default:console.error("Unknown DCS Pt: %s.",j),j=""}this.send("P"+ +n+"$r"+j+"\\");break;case"+q":j=this.currentParam,n=!1,this.send("P"+ +n+"+r"+j+"\\");break;default:console.error("Unknown DCS prefix: %s.",this.prefix)}this.currentParam=0,this.prefix="",this.state=b.normal}else this.currentParam?this.currentParam+=d:this.prefix||"$"===d||"+"===d?2===this.prefix.length?this.currentParam=d:this.prefix+=d:this.currentParam=d;break;case b.ignore:(""===d||""===d)&&(""===d&&h++,this.state=b.normal)}h++}return this.updateRange(this.y),this.refresh(this.refreshStart,this.refreshEnd)},a.prototype.writeln=function(a){return this.write(a+"\r\n")},a.prototype.keyDown=function(a){var b,c,e,f;if(a.keyCode>15&&a.keyCode<19)return!0;if((a.shiftKey||a.ctrlKey)&&45===a.keyCode)return!0;if(a.shiftKey&&a.ctrlKey&&(67===(e=a.keyCode)||86===e))return!0;if(a.altKey&&90===a.keyCode&&!this.skipNextKey)return this.skipNextKey=!0,this.element.classList.add("skip"),d(a);if(this.skipNextKey)return this.skipNextKey=!1,this.element.classList.remove("skip"),!0;switch(a.keyCode){case 8:if(c=a.altKey?"":"",a.shiftKey){c+="\b";break}c+="";break;case 9:if(a.shiftKey){c="";break}c=" ";break;case 13:c="\r";break;case 27:c="";break;case 37:if(this.applicationCursor){c="OD";break}c="";break;case 39:if(this.applicationCursor){c="OC";break}c="";break;case 38:if(this.applicationCursor){c="OA";break}if(a.ctrlKey)return this.scroll_display(-1),d(a);c="";break;case 40:if(this.applicationCursor){c="OB";break}if(a.ctrlKey)return this.scroll_display(1),d(a);c="";break;case 46:c="[3~";break;case 45:c="[2~";break;case 36:if(this.applicationKeypad){c="OH";break}c="OH";break;case 35:if(this.applicationKeypad){c="OF";break}c="OF";break;case 33:if(a.shiftKey)return this.scroll_display(-(this.rows-1)),d(a);c="[5~";break;case 34:if(a.shiftKey)return this.scroll_display(this.rows-1),d(a);c="[6~";break;case 112:c="OP";break;case 113:c="OQ";break;case 114:c="OR";break;case 115:c="OS";break;case 116:c="[15~";break;case 117:c="[17~";break;case 118:c="[18~";break;case 119:c="[19~";break;case 120:c="[20~";break;case 121:c="[21~";break;case 122:c="[23~";break;case 123:c="[24~";break;default:if(a.ctrlKey)if(a.keyCode>=65&&a.keyCode<=90){if(67===a.keyCode){if(f=(new Date).getTime(),f-this.last_cc<500&&!this.stop){for(b=setTimeout(function(){});b--;)b!==this.t_bell&&b!==this.t_queue&&b!==this.t_blink&&clearTimeout(b);this.element.classList.add("stopped"),this.stop=!0}else if(this.stop)return!0;this.last_cc=f}c=String.fromCharCode(a.keyCode-64)}else 32===a.keyCode?c=String.fromCharCode(0):a.keyCode>=51&&a.keyCode<=55?c=String.fromCharCode(a.keyCode-51+27):56===a.keyCode?c=String.fromCharCode(127):219===a.keyCode?c=String.fromCharCode(27):221===a.keyCode&&(c=String.fromCharCode(29));else(a.altKey&&k.call(navigator.platform,"Mac")<0||a.metaKey&&k.call(navigator.platform,"Mac")>=0)&&(a.keyCode>=65&&a.keyCode<=90?c=""+String.fromCharCode(a.keyCode+32):192===a.keyCode?c="`":a.keyCode>=48&&a.keyCode<=57&&(c=""+(a.keyCode-48)))}return a.keyCode>=37&&a.keyCode<=40&&(a.ctrlKey?c=c.slice(0,-1)+"1;5"+c.slice(-1):a.altKey?c=c.slice(0,-1)+"1;3"+c.slice(-1):a.shiftKey&&(c=c.slice(0,-1)+"1;4"+c.slice(-1))),c?(this.showCursor(),this.send(c),d(a)):!0},a.prototype.setgLevel=function(a){return this.glevel=a,this.charset=this.charsets[a]},a.prototype.setgCharset=function(a,b){return this.charsets[a]=b,this.glevel===a?this.charset=b:void 0},a.prototype.keyPress=function(a){var b,c;if(this.skipNextKey===!1)return this.skipNextKey=null,!0;if(a.keyCode>15&&a.keyCode<19)return!0;if((a.shiftKey||a.ctrlKey)&&45===a.keyCode)return!0;if(a.shiftKey&&a.ctrlKey&&(67===(c=a.keyCode)||86===c))return!0;if(d(a),a.charCode)b=a.charCode;else if(null==a.which)b=a.keyCode;else{if(0===a.which||0===a.charCode)return!1;b=a.which}return!b||a.ctrlKey||a.altKey||a.metaKey?!1:(b=String.fromCharCode(b),this.showCursor(),this.send(b),!1)},a.prototype.bell=function(a){return null==a&&(a="bell"),this.visualBell?(this.element.classList.add(a),this.t_bell=setTimeout(function(b){return function(){return b.element.classList.remove(a)}}(this),this.visualBell)):void 0},a.prototype.resize=function(){var a,b,c,d,e,f,g;if(e=this.cols,f=this.rows,this.compute_char_size(),this.cols=Math.floor(this.element.clientWidth/this.char_size.width),this.rows=Math.floor(window.innerHeight/this.char_size.height),g=window.innerHeight%this.char_size.height,this.element.style["padding-bottom"]=g+"px",e!==this.cols||f!==this.rows){if(this.ctl("Resize",this.cols,this.rows),ethis.cols)for(b=this.screen.length;b--;)for(;this.screen[b].length>this.cols;)this.screen[b].pop();if(this.setupStops(e),c=f,cthis.rows)for(;c-->this.rows;)this.screen.length>this.rows&&this.screen.pop(),this.children.length>this.rows&&(a=this.children.pop(),null!=a&&a.parentNode.removeChild(a));return this.y>=this.rows&&(this.y=this.rows-1),this.x>=this.cols&&(this.x=this.cols-1),this.scrollTop=0,this.scrollBottom=this.rows-1,this.refresh(0,this.rows-1),this.normal=null}},a.prototype.updateRange=function(a){return athis.refreshEnd?this.refreshEnd=a:void 0},a.prototype.maxRange=function(){return this.refreshStart=0,this.refreshEnd=this.rows-1},a.prototype.setupStops=function(a){var b;for(null!=a?this.tabs[a]||(a=this.prevStop(a)):(this.tabs={},a=0),b=[];a0;);return a>=this.cols?this.cols-1:0>a?0:a},a.prototype.nextStop=function(a){for(null==a&&(a=this.x);!this.tabs[++a]&&a=this.cols?this.cols-1:0>a?0:a},a.prototype.eraseRight=function(a,b){var c;for(c=this.screen[b];ab&&(b=1),this.y-=b,this.y<0?this.y=0:void 0},a.prototype.cursorDown=function(a){var b;return b=a[0],1>b&&(b=1),this.y+=b,this.y>=this.rows?this.y=this.rows-1:void 0},a.prototype.cursorForward=function(a){var b;return b=a[0],1>b&&(b=1),this.x+=b,this.x>=this.cols?this.x=this.cols-1:void 0},a.prototype.cursorBackward=function(a){var b;return b=a[0],1>b&&(b=1),this.x-=b,this.x<0?this.x=0:void 0},a.prototype.cursorPos=function(a){var b,c;return c=a[0]-1,b=a.length>=2?a[1]-1:0,0>c?c=0:c>=this.rows&&(c=this.rows-1),0>b?b=0:b>=this.cols&&(b=this.cols-1),this.x=b,this.y=c},a.prototype.eraseInDisplay=function(a){var b,c,d,e;switch(a[0]){case 0:for(this.eraseRight(this.x,this.y),b=this.y+1,c=[];bb;)d=a[b],d>=30&&37>=d?this.curAttr.fg=d-30:d>=40&&47>=d?this.curAttr.bg=d-40:d>=90&&97>=d?(d+=8,this.curAttr.fg=d-90):d>=100&&107>=d?(d+=8,this.curAttr.bg=d-100):0===d?this.curAttr=this.cloneAttr(this.defAttr):1===d?this.curAttr.bold=!0:4===d?this.curAttr.underline=!0:5===d?this.curAttr.blink=!0:7===d?this.curAttr.inverse=!0:8===d?this.curAttr.invisible=!0:10===d||(22===d?this.curAttr.bold=!1:24===d?this.curAttr.underline=!1:25===d?this.curAttr.blink=!1:27===d?this.curAttr.inverse=!1:28===d?this.curAttr.invisible=!1:39===d?this.curAttr.fg=257:49===d?this.curAttr.bg=256:38===d?2===a[b+1]?(b+=2,this.curAttr.fg="rgb("+a[b]+", "+a[b+1]+", "+a[b+2]+")",b+=2):5===a[b+1]&&(b+=2,this.curAttr.fg=255&a[b]):48===d?2===a[b+1]?(b+=2,this.curAttr.bg="rgb("+a[b]+", "+a[b+1]+", "+a[b+2]+")",b+=2):5===a[b+1]&&(b+=2,this.curAttr.bg=255&a[b]):100===d?(this.curAttr.fg=257,this.curAttr.bg=256):console.error("Unknown SGR attribute: %d.",d)),e.push(b++);return e},a.prototype.deviceStatus=function(a){if(this.prefix){if("?"===this.prefix&&6===a[0])return this.send("[?"+(this.y+1)+";"+(this.x+1)+"R")}else switch(a[0]){case 5:return this.send("");case 6:return this.send("["+(this.y+1)+";"+(this.x+1)+"R")}},a.prototype.insertChars=function(a){var b,c,d,e;for(c=a[0],1>c&&(c=1),e=this.y,b=this.x,d=[];c--&&bb&&(b=1),this.y+=b,this.y>=this.rows&&(this.y=this.rows-1),this.x=0},a.prototype.cursorPrecedingLine=function(a){var b;return b=a[0],1>b&&(b=1),this.y-=b,this.y<0&&(this.y=0),this.x=0},a.prototype.cursorCharAbsolute=function(a){var b;return b=a[0],1>b&&(b=1),this.x=b-1},a.prototype.insertLines=function(a){var b;for(b=a[0],1>b&&(b=1);b--;)this.screen.splice(this.y,0,this.blank_line(!0)),this.screen.splice(this.scrollBottom+1,1);return this.updateRange(this.y),this.updateRange(this.scrollBottom)},a.prototype.deleteLines=function(a){var b,c;for(b=a[0],1>b&&(b=1),c=this.y;b--;)this.screen.push(this.blank_line(!0)),this.screen.splice(this.y,1);return this.updateRange(this.y),this.updateRange(this.scrollBottom)},a.prototype.deleteChars=function(a){var b,c,d;for(b=a[0],1>b&&(b=1),d=this.y,c=[];b--;)this.screen[d].splice(this.x,1),c.push(this.screen[d].push(this.eraseAttr()));return c},a.prototype.eraseChars=function(a){var b,c,d,e;for(c=a[0],1>c&&(c=1),e=this.y,b=this.x,d=[];c--&&bb&&(b=1),this.x=b-1,this.x>=this.cols?this.x=this.cols-1:void 0},a.prototype.HPositionRelative=function(a){var b;return b=a[0],1>b&&(b=1),this.x+=b,this.x>=this.cols?this.x=this.cols-1:void 0},a.prototype.sendDeviceAttributes=function(a){if(!(a[0]>0))if(this.prefix){if(">"===this.prefix){if(this.isterm("xterm"))return this.send("[>0;276;0c");if(this.isterm("rxvt-unicode"))return this.send("[>85;95;0c");if(this.isterm("linux"))return this.send(a[0]+"c");if(this.isterm("screen"))return this.send("[>83;40003;0c")}}else{if(this.isterm("xterm")||this.isterm("rxvt-unicode")||this.isterm("screen"))return this.send("[?1;2c");if(this.isterm("linux"))return this.send("[?6c")}},a.prototype.linePosAbsolute=function(a){var b;return b=a[0],1>b&&(b=1),this.y=b-1,this.y>=this.rows?this.y=this.rows-1:void 0},a.prototype.VPositionRelative=function(a){var b;return b=a[0],1>b&&(b=1),this.y+=b,this.y>=this.rows?this.y=this.rows-1:void 0},a.prototype.HVPosition=function(a){return a[0]<1&&(a[0]=1),a[1]<1&&(a[1]=1),this.y=a[0]-1,this.y>=this.rows&&(this.y=this.rows-1),this.x=a[1]-1,this.x>=this.cols?this.x=this.cols-1:void 0},a.prototype.setMode=function(b){var c,d,e;if("object"!=typeof b){if("?"===this.prefix)switch(b){case 1:return this.applicationCursor=!0;case 2:return this.setgCharset(0,a.prototype.charsets.US),this.setgCharset(1,a.prototype.charsets.US),this.setgCharset(2,a.prototype.charsets.US),this.setgCharset(3,a.prototype.charsets.US);case 3:return this.savedCols=this.cols,this.resize(132,this.rows);case 6:return this.originMode=!0;case 7:return this.wraparoundMode=!0;case 66:return this.applicationKeypad=!0;case 9:case 1e3:case 1002:case 1003:return this.x10Mouse=9===b,this.vt200Mouse=1e3===b,this.normalMouse=b>1e3,this.mouseEvents=!0,this.element.style.cursor="pointer";case 1004:return this.sendFocus=!0;case 1005:return this.utfMouse=!0;case 1006:return this.sgrMouse=!0;case 1015:return this.urxvtMouse=!0;case 25:return this.cursorHidden=!1;case 1049:case 47:case 1047:if(!this.normal)return e={lines:this.screen,x:this.x,y:this.y,scrollTop:this.scrollTop,scrollBottom:this.scrollBottom,tabs:this.tabs},this.reset(),this.normal=e,this.showCursor()}}else for(d=b.length,c=0;d>c;)this.setMode(b[c]),c++},a.prototype.resetMode=function(a){var b,c;if("object"!=typeof a){if("?"===this.prefix)switch(a){case 1:return this.applicationCursor=!1;case 3:return 132===this.cols&&this.savedCols&&this.resize(this.savedCols,this.rows),delete this.savedCols;case 6:return this.originMode=!1;case 7:return this.wraparoundMode=!1;case 66:return this.applicationKeypad=!1;case 9:case 1e3:case 1002:case 1003:return this.x10Mouse=!1,this.vt200Mouse=!1,this.normalMouse=!1,this.mouseEvents=!1,this.element.style.cursor="";case 1004:return this.sendFocus=!1;case 1005:return this.utfMouse=!1;case 1006:return this.sgrMouse=!1;case 1015:return this.urxvtMouse=!1;case 25:return this.cursorHidden=!0;case 1049:case 47:case 1047:if(this.normal)return this.screen=this.normal.lines,this.x=this.normal.x,this.y=this.normal.y,this.scrollTop=this.normal.scrollTop,this.scrollBottom=this.normal.scrollBottom,this.tabs=this.normal.tabs,this.normal=null,this.refresh(0,this.rows-1),this.showCursor()}}else for(c=a.length,b=0;c>b;)this.resetMode(a[b]),b++},a.prototype.setScrollRegion=function(a){return this.prefix?void 0:(this.scrollTop=(a[0]||1)-1,this.scrollBottom=(a[1]||this.rows)-1, +this.x=0,this.y=0)},a.prototype.saveCursor=function(a){return this.savedX=this.x,this.savedY=this.y},a.prototype.restoreCursor=function(a){return this.x=this.savedX||0,this.y=this.savedY||0},a.prototype.cursorForwardTab=function(a){var b,c;for(b=a[0]||1,c=[];b--;)c.push(this.x=this.nextStop());return c},a.prototype.scrollUp=function(a){var b;for(b=a[0]||1;b--;)this.screen.splice(this.scrollTop,1),this.screen.splice(this.scrollBottom,0,this.blank_line());return this.updateRange(this.scrollTop),this.updateRange(this.scrollBottom)},a.prototype.scrollDown=function(a){var b;for(b=a[0]||1;b--;)this.screen.splice(this.scrollBottom,1),this.screen.splice(this.scrollTop,0,this.blank_line());return this.updateRange(this.scrollTop),this.updateRange(this.scrollBottom)},a.prototype.initMouseTracking=function(a){},a.prototype.resetTitleModes=function(a){},a.prototype.cursorBackwardTab=function(a){var b,c;for(b=a[0]||1,c=[];b--;)c.push(this.x=this.prevStop());return c},a.prototype.repeatPrecedingCharacter=function(a){var b,c,d,e;for(d=a[0]||1,c=this.screen[this.y],b=c[this.x-1]||this.defAttr,e=[];d--;)e.push(c[this.x++]=b);return e},a.prototype.tabClear=function(a){var b;return b=a[0],0>=b?delete this.tabs[this.x]:3===b?this.tabs={}:void 0},a.prototype.mediaCopy=function(a){},a.prototype.setResources=function(a){},a.prototype.disableModifiers=function(a){},a.prototype.setPointerMode=function(a){},a.prototype.softReset=function(a){return this.cursorHidden=!1,this.insertMode=!1,this.originMode=!1,this.wraparoundMode=!1,this.applicationKeypad=!1,this.applicationCursor=!1,this.scrollTop=0,this.scrollBottom=this.rows-1,this.curAttr=this.defAttr,this.x=this.y=0,this.charset=null,this.glevel=0,this.charsets=[null]},a.prototype.requestAnsiMode=function(a){},a.prototype.requestPrivateMode=function(a){},a.prototype.setConformanceLevel=function(a){},a.prototype.loadLEDs=function(a){},a.prototype.setCursorStyle=function(a){},a.prototype.setCharProtectionAttr=function(a){},a.prototype.restorePrivateValues=function(a){},a.prototype.setAttrInRectangle=function(a){var b,c,d,e,f,g,h;for(h=a[0],e=a[1],c=a[2],g=a[3],b=a[4];c+1>h;){for(f=this.screen[h],d=e;g>d;)f[d]=this.cloneAttr(b,f[d].ch),d++;h++}return this.updateRange(a[0]),this.updateRange(a[2])},a.prototype.savePrivateValues=function(a){},a.prototype.manipulateWindow=function(a){},a.prototype.reverseAttrInRectangle=function(a){},a.prototype.setTitleModeFeature=function(a){},a.prototype.setWarningBellVolume=function(a){},a.prototype.setMarginBellVolume=function(a){},a.prototype.copyRectangle=function(a){},a.prototype.enableFilterRectangle=function(a){},a.prototype.requestParameters=function(a){},a.prototype.selectChangeExtent=function(a){},a.prototype.fillRectangle=function(a){var b,c,d,e,f,g,h;for(c=a[0],h=a[1],e=a[2],b=a[3],g=a[4];b+1>h;){for(f=this.screen[h],d=e;g>d;)f[d]=this.cloneAttr(f[d][0],String.fromCharCode(c)),d++;h++}return this.updateRange(a[1]),this.updateRange(a[3])},a.prototype.enableLocatorReporting=function(a){var b;return b=a[0]>0},a.prototype.eraseRectangle=function(a){var b,c,d,e,f,g;for(g=a[0],d=a[1],b=a[2],f=a[3];b+1>g;){for(e=this.screen[g],c=d;f>c;)e[c]=this.eraseAttr(),c++;g++}return this.updateRange(a[0]),this.updateRange(a[2])},a.prototype.setLocatorEvents=function(a){},a.prototype.selectiveEraseRectangle=function(a){},a.prototype.requestLocatorPosition=function(a){},a.prototype.insertColumns=function(){var a,b,c;for(c=params[0],b=this.rows;c--;)for(a=0;b>a;)this.screen[a].splice(this.x+1,0,this.eraseAttr()),this.screen[a].pop(),a++;return this.maxRange()},a.prototype.deleteColumns=function(){var a,b,c;for(c=params[0],b=this.rows;c--;)for(a=0;b>a;)this.screen[a].splice(this.x,1),this.screen[a].push(this.eraseAttr()),a++;return this.maxRange()},a.prototype.charsets={SCLD:{"`":"◆",a:"▒",b:" ",c:"\f",d:"\r",e:"\n",f:"°",g:"±",h:"␤",i:" ",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"},UK:null,US:null,Dutch:null,Finnish:null,French:null,FrenchCanadian:null,German:null,Italian:null,NorwegianDanish:null,Spanish:null,Swedish:null,Swiss:null,ISOLatin:null},a}(),window.Terminal=c}).call(this); //# sourceMappingURL=main.min.js.map \ No newline at end of file diff --git a/coffees/term.coffee b/coffees/term.coffee index 84227b8..11a19fc 100644 --- a/coffees/term.coffee +++ b/coffees/term.coffee @@ -186,7 +186,7 @@ class Terminal erased focus: -> - @handler('\x1b[I') if @sendFocus + @send('\x1b[I') if @sendFocus @showCursor() @element.classList.add('focus') @element.classList.remove('blur') @@ -194,7 +194,7 @@ class Terminal blur: -> @cursorState = 1 @refresh(@y, @y) - @handler('\x1b[O') if @sendFocus + @send('\x1b[O') if @sendFocus @element.classList.add('blur') @element.classList.remove('focus') @@ -271,13 +271,13 @@ class Terminal pos.y -= 32 pos.x++ pos.y++ - @handler "\x1b[" + button + ";" + pos.x + ";" + pos.y + "M" + @send "\x1b[" + button + ";" + pos.x + ";" + pos.y + "M" return if @sgrMouse pos.x -= 32 pos.y -= 32 - @handler "\x1b[<" + ( + @send "\x1b[<" + ( if (button & 3) is 3 then button & ~3 else button ) + ";" + pos.x + ";" + pos.y + ( if (button & 3) is 3 then "m" else "M" @@ -288,7 +288,7 @@ class Terminal encode data, button encode data, pos.x encode data, pos.y - @handler "\x1b[M" + String.fromCharCode.apply(String, data) + @send "\x1b[M" + String.fromCharCode.apply(String, data) getButton = (ev) => # two low bits: @@ -1058,7 +1058,7 @@ class Terminal @updateRange @y when "PROMPT" - @handler content + @send content when "TEXT" l += content.length @@ -1093,12 +1093,12 @@ class Terminal console.error "Unknown DCS Pt: %s.", pt pt = "" - @handler "\x1bP" + +valid + "$r" + pt + "\x1b\\" + @send "\x1bP" + +valid + "$r" + pt + "\x1b\\" when "+q" pt = @currentParam valid = false - @handler "\x1bP" + +valid + "+r" + pt + "\x1b\\" + @send "\x1bP" + +valid + "+r" + pt + "\x1b\\" else console.error "Unknown DCS prefix: %s.", @prefix @@ -1362,7 +1362,7 @@ class Terminal return true unless key @showCursor() - @handler(key) + @send(key) cancel ev @@ -1404,7 +1404,7 @@ class Terminal key = String.fromCharCode(key) @showCursor() - @handler key + @send key false bell: (cls="bell")-> @@ -1540,7 +1540,7 @@ class Terminal isterm: (term) -> "#{@termName}".indexOf(term) is 0 - handler: (data) -> + send: (data) -> @out data handleTitle: (title) -> @@ -1869,16 +1869,16 @@ class Terminal switch params[0] when 5 # status report - @handler "\x1b[0n" + @send "\x1b[0n" when 6 # cursor position - @handler "\x1b[" + (@y + 1) + ";" + (@x + 1) + "R" + @send "\x1b[" + (@y + 1) + ";" + (@x + 1) + "R" else if @prefix is "?" # modern xterm doesnt seem to # respond to any of these except ?6, 6, and 5 if params[0] is 6 # cursor position - @handler "\x1b[?" + (@y + 1) + ";" + (@x + 1) + "R" + @send "\x1b[?" + (@y + 1) + ";" + (@x + 1) + "R" ## Additions ## @@ -2037,22 +2037,22 @@ class Terminal return if params[0] > 0 unless @prefix if @isterm("xterm") or @isterm("rxvt-unicode") or @isterm("screen") - @handler "\x1b[?1;2c" - else @handler "\x1b[?6c" if @isterm("linux") + @send "\x1b[?1;2c" + else @send "\x1b[?6c" if @isterm("linux") else if @prefix is ">" # xterm and urxvt # seem to spit this # out around ~370 times (?). if @isterm("xterm") - @handler "\x1b[>0;276;0c" + @send "\x1b[>0;276;0c" else if @isterm("rxvt-unicode") - @handler "\x1b[>85;95;0c" + @send "\x1b[>85;95;0c" else if @isterm("linux") # not supported by linux console. # linux console echoes parameters. - @handler params[0] + "c" - else @handler "\x1b[>83;40003;0c" if @isterm("screen") + @send params[0] + "c" + else @send "\x1b[>83;40003;0c" if @isterm("screen") # CSI Pm d