From 74193530dff6dd72d8b4fb875cb39a4fc947de3e Mon Sep 17 00:00:00 2001 From: Florian Mounier Date: Wed, 8 Apr 2015 15:25:18 +0200 Subject: [PATCH] Merge both behaviors --- butterfly/sass/_layout.sass | 3 ++- butterfly/static/main.css | 5 +++-- butterfly/static/main.js | 35 ++++++++++++++++++----------------- butterfly/static/main.min.js | 4 ++-- coffees/term.coffee | 33 +++++++++++++++++---------------- 5 files changed, 42 insertions(+), 38 deletions(-) diff --git a/butterfly/sass/_layout.sass b/butterfly/sass/_layout.sass index 5c42eb7..64458a1 100644 --- a/butterfly/sass/_layout.sass +++ b/butterfly/sass/_layout.sass @@ -26,7 +26,8 @@ html, body overflow: hidden white-space: nowrap - [data-native-scroll="yes"] +body[data-native-scroll="yes"] + #wrapper overflow-y: auto .terminal diff --git a/butterfly/static/main.css b/butterfly/static/main.css index 3bda3ea..45c6078 100644 --- a/butterfly/static/main.css +++ b/butterfly/static/main.css @@ -86,8 +86,9 @@ html, body { height: 100%; overflow: hidden; white-space: nowrap; } - #wrapper [data-native-scroll="yes"] { - overflow-y: auto; } + +body[data-native-scroll="yes"] #wrapper { + overflow-y: auto; } .terminal { outline: none; } diff --git a/butterfly/static/main.js b/butterfly/static/main.js index ef58514..69da9ff 100644 --- a/butterfly/static/main.js +++ b/butterfly/static/main.js @@ -454,7 +454,7 @@ }; Terminal.prototype.refresh = function(start, end) { - var attr, bg, ch, classes, data, fg, flags, html, i, j, k, l, line, m, o, out, parent, ref, ref1, ref2, ref3, ref4, x; + var attr, bg, ch, classes, data, fg, flags, html, i, j, k, l, line, m, o, out, parent, ref, ref1, ref2, ref3, ref4, row, x; if (!this.native_scroll && end - start >= this.rows / 3) { parent = this.element.parentNode; if (parent != null) { @@ -471,7 +471,8 @@ } end = Math.min(end, this.screen.length - 1); for (j = m = ref1 = start, ref2 = end; ref1 <= ref2 ? m <= ref2 : m >= ref2; j = ref1 <= ref2 ? ++m : --m) { - line = this.screen[row + this.ydisp]; + row = j + this.ydisp; + line = this.screen[row]; out = ""; if (j === this.y && !this.cursorHidden && (this.native_scroll || this.ydisp === this.ybase || this.selectMode)) { x = this.x; @@ -630,9 +631,9 @@ row = this.ybase + this.rows - 1; row -= this.rows - 1 - this.scrollBottom; if (row === this.screen.length) { - this.screen.push(this.blankLine()); + this.screen.push(this.blank_line()); } else { - this.screen.splice(row, 0, this.blankLine()); + this.screen.splice(row, 0, this.blank_line()); } if (this.scrollTop !== 0) { if (this.ybase !== 0) { @@ -736,7 +737,7 @@ ch = this.charset[ch]; } if (this.x >= this.cols) { - this.lines[this.y + this.ybase][this.x] = [this.curAttr, '\u23CE']; + this.screen[this.y + this.ybase][this.x] = [this.curAttr, '\u23CE']; this.x = 0; this.next_line(); } @@ -1121,7 +1122,7 @@ this.updateRange(this.y); this.next_line(); } else { - this.lines[this.y + this.ybase][this.x] = [this.curAttr, html]; + this.screen[this.y + this.ybase][this.x] = [this.curAttr, html]; line = 0; while (line < this.get_html_height_in_lines(html) - 1) { this.y++; @@ -2021,7 +2022,7 @@ } else { j = this.rows - 1 - this.scrollBottom; j = this.rows - 1 + this.ybase - j; - this.screen.splice(j + 1, 0, this.blankLine(true)); + this.screen.splice(j + 1, 0, this.blank_line(true)); } this.screen.splice(this.y, 1); } @@ -2206,7 +2207,7 @@ case 1047: if (!this.normal) { normal = { - lines: this.lines, + lines: this.screen, ybase: this.ybase, ydisp: this.ydisp, x: this.x, @@ -2272,7 +2273,7 @@ case 47: case 1047: if (this.normal) { - this.lines = this.normal.lines; + this.screen = this.normal.lines; this.ybase = this.normal.ybase; this.ydisp = this.normal.ydisp; this.x = this.normal.x; @@ -2363,7 +2364,7 @@ Terminal.prototype.repeatPrecedingCharacter = function(params) { var ch, line, param, results; param = params[0] || 1; - line = this.lines[this.ybase + this.y]; + line = this.screen[this.ybase + this.y]; ch = line[this.x - 1] || [this.defAttr, " "]; results = []; while (param--) { @@ -2430,7 +2431,7 @@ r = params[3]; attr = params[4]; while (t < b + 1) { - line = this.lines[this.ybase + t]; + line = this.screen[this.ybase + t]; i = l; while (i < r) { line[i] = [attr, line[i][1]]; @@ -2470,7 +2471,7 @@ b = params[3]; r = params[4]; while (t < b + 1) { - line = this.lines[this.ybase + t]; + line = this.screen[this.ybase + t]; i = l; while (i < r) { line[i] = [line[i][0], String.fromCharCode(ch)]; @@ -2495,7 +2496,7 @@ r = params[3]; ch = [this.eraseAttr(), " "]; while (t < b + 1) { - line = this.lines[this.ybase + t]; + line = this.screen[this.ybase + t]; i = l; while (i < r) { line[i] = ch; @@ -2521,8 +2522,8 @@ while (param--) { i = this.ybase; while (i < l) { - this.lines[i].splice(this.x + 1, 0, ch); - this.lines[i].pop(); + this.screen[i].splice(this.x + 1, 0, ch); + this.screen[i].pop(); i++; } } @@ -2537,8 +2538,8 @@ while (param--) { i = this.ybase; while (i < l) { - this.lines[i].splice(this.x, 1); - this.lines[i].push(ch); + this.screen[i].splice(this.x, 1); + this.screen[i].push(ch); i++; } } diff --git a/butterfly/static/main.min.js b/butterfly/static/main.min.js index a782106..d7b72d1 100644 --- a/butterfly/static/main.min.js +++ b/butterfly/static/main.min.js @@ -1,5 +1,5 @@ /*! butterfly 2015-04-08 */ -(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 b,d,e,h,i,k,l;return h=function(a){return k.send("S"+a)},e=function(){var a,b,c;return c=arguments[0],a=2<=arguments.length?j.call(arguments,1):[],b=a.join(","),"Resize"===c?k.send("R"+b):void 0},l="https:"===location.protocol?"wss://":"ws://",l+=document.location.host+"/ws"+location.pathname,k=new WebSocket(l),k.addEventListener("open",function(){return console.log("WebSocket open",arguments),k.send("R"+i.cols+","+i.rows),f=(new Date).getTime()}),k.addEventListener("error",function(){return console.log("WebSocket error",arguments)}),k.addEventListener("message",function(a){return setTimeout(function(){return i.write(a.data)},1)}),k.addEventListener("close",function(){return console.log("WebSocket closed",arguments),setTimeout(function(){return i.write("Closed"),i.skipNextKey=!0,i.element.classList.add("dead")},1),g=!0,(new Date).getTime()-f>6e4?open("","_self").close():void 0}),i=new c(a("#wrapper")[0],h,e),addEventListener("beforeunload",function(){return g?void 0:"This will exit the terminal session"}),b=function(a){var b,c;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=a.element.clientHeight,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),a.vt200Mouse?(f({__proto__:b,type:"mouseup"}),d(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;f(b)}else{if(a.applicationKeypad||a.native_scroll)return!0;a.scroll_display(b.deltaY>0?5:-5)}return 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,w,x,y;if(!this.native_scroll&&b-a>=this.rows/3&&(s=this.element.parentNode,null!=s&&s.removeChild(this.element)),this.native_scroll&&this.missing_lines){for(k=m=1,t=this.missing_lines;t>=1?t>=m:m>=t;k=t>=1?++m:--m)this.new_line();this.missing_lines=0}for(b=Math.min(b,this.screen.length-1),l=p=u=a,v=b;v>=u?v>=p:p>=v;l=v>=u?++p:--p){for(o=this.screen[row+this.ydisp],r="",y=l!==this.y||this.cursorHidden||!this.native_scroll&&this.ydisp!==this.ybase&&!this.selectMode?-(1/0):this.x,c=this.defAttr,k=q=0,w=this.cols-1;w>=0?w>=q:q>=w;k=w>=0?++q:--q){if(g=o[k][0],e=o[k][1],g!==c&&(c!==this.defAttr&&(r+=""),g!==this.defAttr&&(f=[],r+=">9&511,i=g>>18,1&i&&f.push("bold"),2&i&&f.push("underline"),4&i&&f.push("blink"),8&i&&f.push("reverse-video"),16&i&&f.push("invisible"),1&i&&8>h&&(h+=8),f.push("bg-color-"+d),f.push("fg-color-"+h),r+='class="',r+=f.join(" "),r+='">')),k===y&&(r+=''),e.length>1)r+=e;else switch(e){case"&":r+="&";break;case"<":r+="<";break;case">":r+=">";break;default:" "===e?r+='':" ">=e?r+=" ":(e>"＀"&&"￯">e&&k++,r+=e)}k===y&&(r+=""),c=g}c!==this.defAttr&&(r+=""),this.children[l].innerHTML=r}if(null!=s&&s.appendChild(this.element),this.native_scroll){x=this.html;for(n in x)j=x[n],this.element.insertBefore(j,this.children[n]);return this.html={},this.parent.scrollTop=this.parent.scrollHeight}},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(){var a;return this.native_scroll?(this.screen.shift(),this.screen.push(this.blank_line()),this.refreshStart=Math.max(this.refreshStart-1,0),this.missing_lines++,this.missing_lines>=this.rows?this.refresh(0,this.rows-1):void 0):(++this.ybase===this.scrollback&&(this.ybase=this.ybase/2|0,this.screen=this.screen.slice(-(this.ybase+this.rows)+1)),this.ydisp=this.ybase,a=this.ybase+this.rows-1,a-=this.rows-1-this.scrollBottom,a===this.screen.length?this.screen.push(this.blankLine()):this.screen.splice(a,0,this.blankLine()),0!==this.scrollTop&&(0!==this.ybase&&(this.ybase--,this.ydisp=this.ybase),this.screen.splice(this.ybase+this.scrollTop,1)),this.updateRange(this.scrollTop),this.updateRange(this.scrollBottom))},a.prototype.scroll_display=function(a){return this.native_scroll?this.parent.scrollTop+=a*this.char_size.height:(this.ydisp+=a,this.ydisp>this.ybase?this.ydisp=this.ybase:this.ydisp<0&&(this.ydisp=0),this.refresh(0,this.rows-1))},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.native_scroll?this.rows: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,o;for(this.refreshStart=this.y,this.refreshEnd=this.y,this.native_scroll||this.ybase!==this.ydisp&&(this.ydisp=this.ybase,this.maxRange()),h=0,i=c.length;i>h;){switch(d=c[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!=(l=this.charset)?l[d]:void 0)&&(d=this.charset[d]),this.x>=this.cols&&(this.lines[this.y+this.ybase][this.x]=[this.curAttr,"⏎"],this.x=0,this.next_line()),this.screen[this.y+this.ybase][this.x]=[this.curAttr,d],this.x++,this.updateRange(this.y),d>"＀"&&"￯">d)){if(this.cols<2||this.x>=this.cols){this.screen[this.y+this.ybase][this.x-1]=[this.curAttr," "];break}this.screen[this.y+this.ybase][this.x]=[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(k=this.currentParam,";"!==k[0]){console.error("Unknown DECUDK: "+k);break}if(k=k.slice(1),m=k.split("|",2),n=m[0],e=m[1],!e){console.error("No type for inline DECUDK: "+k);break}switch(n){case"HTML":if(!this.html_escapes_enabled){console.log("HTML escapes are disabled");break}if(g='
'+e+"
",this.native_scroll)this.next_line(),this.html[this.y]=g,this.updateRange(this.y),this.next_line();else for(this.lines[this.y+this.ybase][this.x]=[this.curAttr,g],j=0;jthis.scrollBottom&&(this.y--,this.scroll()),j++;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 "+n+" for DECUDK")}break;case"$q":switch(k=this.currentParam,o=!1,k){case'"q':k='0"q';break;case'"p':k='61"p';break;case"r":k=""+(this.scrollTop+1)+";"+(this.scrollBottom+1)+"r";break;case"m":k="0m";break;default:console.error("Unknown DCS Pt: %s.",k),k=""}this.send("P"+ +o+"$r"+k+"\\");break;case"+q":k=this.currentParam,o=!1,this.send("P"+ +o+"+r"+k+"\\");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<75)for(b=setTimeout(function(){})-6,this.write("\r\n --8<------8<-- Sectioned --8<------8<-- \r\n\r\n");b--;)b!==this.t_bell&&b!==this.t_queue&&b!==this.t_blink&&clearTimeout(b);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.prefixMode?(this.leavePrefix(),d(a)):!this.native_scroll&&this.selectMode?(this.keySelect(a,c),d(a)):(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;if(this.skipNextKey===!1)return this.skipNextKey=null,!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,h;if(f=this.cols,g=this.rows,this.compute_char_size(),h=this.parent.getBoundingClientRect(),this.cols=Math.floor(h.width/this.char_size.width),this.rows=Math.floor(h.height/this.char_size.height),this.element.style["padding-bottom"]=h.height%this.char_size.height+"px",f!==this.cols||g!==this.rows){if(this.ctl("Resize",this.cols,this.rows),fthis.cols)for(c=this.screen.length;c--;)for(;this.screen[c].length>this.cols;)this.screen[c].pop();if(this.setupStops(f),d=g,dthis.rows)for(;d-->this.rows;)this.screen.length>this.rows+this.ybase&&this.screen.pop(),this.children.length>this.rows&&(b=this.children.pop(),null!=b&&b.parentNode.removeChild(b));return this.y>=this.rows&&(this.y=this.rows-1),this.x>=this.cols&&(this.x=this.cols-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,d;for(d=this.screen[b],c=[this.eraseAttr()," "];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=[];b>18,c=this.curAttr>>9&511,b=511&this.curAttr,f=a.length,e=0;f>e;)g=a[e],g>=30&&37>=g?c=g-30:g>=40&&47>=g?b=g-40:g>=90&&97>=g?(g+=8,c=g-90):g>=100&&107>=g?(g+=8,b=g-100):0===g?(d=this.defAttr>>18,c=this.defAttr>>9&511,b=511&this.defAttr):1===g?d|=1:4===g?d|=2:5===g?d|=4:7===g?d|=8:8===g?d|=16:22===g?d&=-2:24===g?d&=-3:25===g?d&=-5:27===g?d&=-9:28===g?d&=-17:39===g?c=this.defAttr>>9&511:49===g?b=511&this.defAttr:38===g?2===a[e+1]?(e+=2,c="#"+a[e]&255+a[e+1]&255+a[e+2]&255,e+=2):5===a[e+1]&&(e+=2,c=255&a[e]):48===g?2===a[e+1]?(e+=2,b="#"+a[e]&255+a[e+1]&255+a[e+2]&255,e+=2):5===a[e+1]&&(e+=2,b=255&a[e]):100===g?(c=this.defAttr>>9&511,b=511&this.defAttr):console.error("Unknown SGR attribute: %d.",g),e++;return this.curAttr=d<<18|c<<9|b},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,f;for(d=a[0],1>d&&(d=1),f=this.y+this.ybase,c=this.x,b=[this.eraseAttr()," "],e=[];d--&&cb&&(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,c,d;for(c=a[0],1>c&&(c=1),d=this.y+this.ybase;c--;)this.screen.splice(d,0,this.blank_line(!0)),this.native_scroll?this.screen.pop():(b=this.rows-1-this.scrollBottom,b=this.rows-1+this.ybase-b+1,this.screen.splice(b,1));return this.updateRange(this.y),this.updateRange(this.native_scroll?this.screen.length-1:this.scrollBottom)},a.prototype.deleteLines=function(a){var b,c,d;for(c=a[0],1>c&&(c=1),d=this.y+this.ybase;c--;)this.native_scroll?this.screen.push(this.blank_line(!0)):(b=this.rows-1-this.scrollBottom,b=this.rows-1+this.ybase-b,this.screen.splice(b+1,0,this.blankLine(!0))),this.screen.splice(this.y,1);return this.updateRange(this.y),this.updateRange(this.native_scroll?this.screen.length-1:this.scrollBottom)},a.prototype.deleteChars=function(a){var b,c,d,e;for(c=a[0],1>c&&(c=1),e=this.y+this.ybase,b=[this.eraseAttr()," "],d=[];c--;)this.screen[e].splice(this.x,1),d.push(this.screen[e].push(b));return d},a.prototype.eraseChars=function(a){var b,c,d,e,f;for(d=a[0],1>d&&(d=1),f=this.y+this.ybase,c=this.x,b=[this.eraseAttr()," "],e=[];d--&&cb&&(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.lines,ybase:this.ybase,ydisp:this.ydisp,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.lines=this.normal.lines,this.ybase=this.normal.ybase,this.ydisp=this.normal.ydisp,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;if(!this.native_scroll){for(b=a[0]||1;b--;)this.screen.splice(this.ybase+this.scrollTop,1),this.screen.splice(this.ybase+this.scrollBottom,0,this.blank_line());return this.updateRange(this.scrollTop),this.updateRange(this.scrollBottom)}},a.prototype.scrollDown=function(a){var b;if(!this.native_scroll){for(b=a[0]||1;b--;)this.screen.splice(this.ybase+this.scrollBottom,1),this.screen.splice(this.ybase+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.lines[this.ybase+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.lines[this.ybase+h],d=e;g>d;)f[d]=[b,f[d][1]],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.lines[this.ybase+h],d=e;g>d;)f[d]=[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,h;for(h=a[0],e=a[1],b=a[2],g=a[3],c=[this.eraseAttr()," "];b+1>h;){for(f=this.lines[this.ybase+h],d=e;g>d;)f[d]=c,d++;h++}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,d;for(d=params[0],c=this.ybase+this.rows,a=[this.eraseAttr()," "];d--;)for(b=this.ybase;c>b;)this.lines[b].splice(this.x+1,0,a),this.lines[b].pop(),b++;return this.maxRange()},a.prototype.deleteColumns=function(){var a,b,c,d;for(d=params[0],c=this.ybase+this.rows,a=[this.eraseAttr()," "];d--;)for(b=this.ybase;c>b;)this.lines[b].splice(this.x,1),this.lines[b].push(a),b++;return this.maxRange()},a.prototype.get_html_height_in_lines=function(a){var b,c;return c=document.createElement("div"),c.innerHTML=a,this.element.appendChild(c),b=c.getBoundingClientRect().height,this.element.removeChild(c),Math.ceil(b/this.char_size.height)},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 b,d,e,h,i,k,l;return h=function(a){return k.send("S"+a)},e=function(){var a,b,c;return c=arguments[0],a=2<=arguments.length?j.call(arguments,1):[],b=a.join(","),"Resize"===c?k.send("R"+b):void 0},l="https:"===location.protocol?"wss://":"ws://",l+=document.location.host+"/ws"+location.pathname,k=new WebSocket(l),k.addEventListener("open",function(){return console.log("WebSocket open",arguments),k.send("R"+i.cols+","+i.rows),f=(new Date).getTime()}),k.addEventListener("error",function(){return console.log("WebSocket error",arguments)}),k.addEventListener("message",function(a){return setTimeout(function(){return i.write(a.data)},1)}),k.addEventListener("close",function(){return console.log("WebSocket closed",arguments),setTimeout(function(){return i.write("Closed"),i.skipNextKey=!0,i.element.classList.add("dead")},1),g=!0,(new Date).getTime()-f>6e4?open("","_self").close():void 0}),i=new c(a("#wrapper")[0],h,e),addEventListener("beforeunload",function(){return g?void 0:"This will exit the terminal session"}),b=function(a){var b,c;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=a.element.clientHeight,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),a.vt200Mouse?(f({__proto__:b,type:"mouseup"}),d(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;f(b)}else{if(a.applicationKeypad||a.native_scroll)return!0;a.scroll_display(b.deltaY>0?5:-5)}return 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,w,x,y,z;if(!this.native_scroll&&b-a>=this.rows/3&&(s=this.element.parentNode,null!=s&&s.removeChild(this.element)),this.native_scroll&&this.missing_lines){for(k=m=1,t=this.missing_lines;t>=1?t>=m:m>=t;k=t>=1?++m:--m)this.new_line();this.missing_lines=0}for(b=Math.min(b,this.screen.length-1),l=p=u=a,v=b;v>=u?v>=p:p>=v;l=v>=u?++p:--p){for(y=l+this.ydisp,o=this.screen[y],r="",z=l!==this.y||this.cursorHidden||!this.native_scroll&&this.ydisp!==this.ybase&&!this.selectMode?-(1/0):this.x,c=this.defAttr,k=q=0,w=this.cols-1;w>=0?w>=q:q>=w;k=w>=0?++q:--q){if(g=o[k][0],e=o[k][1],g!==c&&(c!==this.defAttr&&(r+=""),g!==this.defAttr&&(f=[],r+=">9&511,i=g>>18,1&i&&f.push("bold"),2&i&&f.push("underline"),4&i&&f.push("blink"),8&i&&f.push("reverse-video"),16&i&&f.push("invisible"),1&i&&8>h&&(h+=8),f.push("bg-color-"+d),f.push("fg-color-"+h),r+='class="',r+=f.join(" "),r+='">')),k===z&&(r+=''),e.length>1)r+=e;else switch(e){case"&":r+="&";break;case"<":r+="<";break;case">":r+=">";break;default:" "===e?r+='':" ">=e?r+=" ":(e>"＀"&&"￯">e&&k++,r+=e)}k===z&&(r+=""),c=g}c!==this.defAttr&&(r+=""),this.children[l].innerHTML=r}if(null!=s&&s.appendChild(this.element),this.native_scroll){x=this.html;for(n in x)j=x[n],this.element.insertBefore(j,this.children[n]);return this.html={},this.parent.scrollTop=this.parent.scrollHeight}},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(){var a;return this.native_scroll?(this.screen.shift(),this.screen.push(this.blank_line()),this.refreshStart=Math.max(this.refreshStart-1,0),this.missing_lines++,this.missing_lines>=this.rows?this.refresh(0,this.rows-1):void 0):(++this.ybase===this.scrollback&&(this.ybase=this.ybase/2|0,this.screen=this.screen.slice(-(this.ybase+this.rows)+1)),this.ydisp=this.ybase,a=this.ybase+this.rows-1,a-=this.rows-1-this.scrollBottom,a===this.screen.length?this.screen.push(this.blank_line()):this.screen.splice(a,0,this.blank_line()),0!==this.scrollTop&&(0!==this.ybase&&(this.ybase--,this.ydisp=this.ybase),this.screen.splice(this.ybase+this.scrollTop,1)),this.updateRange(this.scrollTop),this.updateRange(this.scrollBottom))},a.prototype.scroll_display=function(a){return this.native_scroll?this.parent.scrollTop+=a*this.char_size.height:(this.ydisp+=a,this.ydisp>this.ybase?this.ydisp=this.ybase:this.ydisp<0&&(this.ydisp=0),this.refresh(0,this.rows-1))},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.native_scroll?this.rows: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,o;for(this.refreshStart=this.y,this.refreshEnd=this.y,this.native_scroll||this.ybase!==this.ydisp&&(this.ydisp=this.ybase,this.maxRange()),h=0,i=c.length;i>h;){switch(d=c[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!=(l=this.charset)?l[d]:void 0)&&(d=this.charset[d]),this.x>=this.cols&&(this.screen[this.y+this.ybase][this.x]=[this.curAttr,"⏎"],this.x=0,this.next_line()),this.screen[this.y+this.ybase][this.x]=[this.curAttr,d],this.x++,this.updateRange(this.y),d>"＀"&&"￯">d)){if(this.cols<2||this.x>=this.cols){this.screen[this.y+this.ybase][this.x-1]=[this.curAttr," "];break}this.screen[this.y+this.ybase][this.x]=[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(k=this.currentParam,";"!==k[0]){console.error("Unknown DECUDK: "+k);break}if(k=k.slice(1),m=k.split("|",2),n=m[0],e=m[1],!e){console.error("No type for inline DECUDK: "+k);break}switch(n){case"HTML":if(!this.html_escapes_enabled){console.log("HTML escapes are disabled");break}if(g='
'+e+"
",this.native_scroll)this.next_line(),this.html[this.y]=g,this.updateRange(this.y),this.next_line();else for(this.screen[this.y+this.ybase][this.x]=[this.curAttr,g],j=0;jthis.scrollBottom&&(this.y--,this.scroll()),j++;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 "+n+" for DECUDK")}break;case"$q":switch(k=this.currentParam,o=!1,k){case'"q':k='0"q';break;case'"p':k='61"p';break;case"r":k=""+(this.scrollTop+1)+";"+(this.scrollBottom+1)+"r";break;case"m":k="0m";break;default:console.error("Unknown DCS Pt: %s.",k),k=""}this.send("P"+ +o+"$r"+k+"\\");break;case"+q":k=this.currentParam,o=!1,this.send("P"+ +o+"+r"+k+"\\");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<75)for(b=setTimeout(function(){})-6,this.write("\r\n --8<------8<-- Sectioned --8<------8<-- \r\n\r\n");b--;)b!==this.t_bell&&b!==this.t_queue&&b!==this.t_blink&&clearTimeout(b);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.prefixMode?(this.leavePrefix(),d(a)):!this.native_scroll&&this.selectMode?(this.keySelect(a,c),d(a)):(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;if(this.skipNextKey===!1)return this.skipNextKey=null,!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,h;if(f=this.cols,g=this.rows,this.compute_char_size(),h=this.parent.getBoundingClientRect(),this.cols=Math.floor(h.width/this.char_size.width),this.rows=Math.floor(h.height/this.char_size.height),this.element.style["padding-bottom"]=h.height%this.char_size.height+"px",f!==this.cols||g!==this.rows){if(this.ctl("Resize",this.cols,this.rows),fthis.cols)for(c=this.screen.length;c--;)for(;this.screen[c].length>this.cols;)this.screen[c].pop();if(this.setupStops(f),d=g,dthis.rows)for(;d-->this.rows;)this.screen.length>this.rows+this.ybase&&this.screen.pop(),this.children.length>this.rows&&(b=this.children.pop(),null!=b&&b.parentNode.removeChild(b));return this.y>=this.rows&&(this.y=this.rows-1),this.x>=this.cols&&(this.x=this.cols-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,d;for(d=this.screen[b],c=[this.eraseAttr()," "];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=[];b>18,c=this.curAttr>>9&511,b=511&this.curAttr,f=a.length,e=0;f>e;)g=a[e],g>=30&&37>=g?c=g-30:g>=40&&47>=g?b=g-40:g>=90&&97>=g?(g+=8,c=g-90):g>=100&&107>=g?(g+=8,b=g-100):0===g?(d=this.defAttr>>18,c=this.defAttr>>9&511,b=511&this.defAttr):1===g?d|=1:4===g?d|=2:5===g?d|=4:7===g?d|=8:8===g?d|=16:22===g?d&=-2:24===g?d&=-3:25===g?d&=-5:27===g?d&=-9:28===g?d&=-17:39===g?c=this.defAttr>>9&511:49===g?b=511&this.defAttr:38===g?2===a[e+1]?(e+=2,c="#"+a[e]&255+a[e+1]&255+a[e+2]&255,e+=2):5===a[e+1]&&(e+=2,c=255&a[e]):48===g?2===a[e+1]?(e+=2,b="#"+a[e]&255+a[e+1]&255+a[e+2]&255,e+=2):5===a[e+1]&&(e+=2,b=255&a[e]):100===g?(c=this.defAttr>>9&511,b=511&this.defAttr):console.error("Unknown SGR attribute: %d.",g),e++;return this.curAttr=d<<18|c<<9|b},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,f;for(d=a[0],1>d&&(d=1),f=this.y+this.ybase,c=this.x,b=[this.eraseAttr()," "],e=[];d--&&cb&&(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,c,d;for(c=a[0],1>c&&(c=1),d=this.y+this.ybase;c--;)this.screen.splice(d,0,this.blank_line(!0)),this.native_scroll?this.screen.pop():(b=this.rows-1-this.scrollBottom,b=this.rows-1+this.ybase-b+1,this.screen.splice(b,1));return this.updateRange(this.y),this.updateRange(this.native_scroll?this.screen.length-1:this.scrollBottom)},a.prototype.deleteLines=function(a){var b,c,d;for(c=a[0],1>c&&(c=1),d=this.y+this.ybase;c--;)this.native_scroll?this.screen.push(this.blank_line(!0)):(b=this.rows-1-this.scrollBottom,b=this.rows-1+this.ybase-b,this.screen.splice(b+1,0,this.blank_line(!0))),this.screen.splice(this.y,1);return this.updateRange(this.y),this.updateRange(this.native_scroll?this.screen.length-1:this.scrollBottom)},a.prototype.deleteChars=function(a){var b,c,d,e;for(c=a[0],1>c&&(c=1),e=this.y+this.ybase,b=[this.eraseAttr()," "],d=[];c--;)this.screen[e].splice(this.x,1),d.push(this.screen[e].push(b));return d},a.prototype.eraseChars=function(a){var b,c,d,e,f;for(d=a[0],1>d&&(d=1),f=this.y+this.ybase,c=this.x,b=[this.eraseAttr()," "],e=[];d--&&cb&&(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,ybase:this.ybase,ydisp:this.ydisp,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.ybase=this.normal.ybase,this.ydisp=this.normal.ydisp,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;if(!this.native_scroll){for(b=a[0]||1;b--;)this.screen.splice(this.ybase+this.scrollTop,1),this.screen.splice(this.ybase+this.scrollBottom,0,this.blank_line());return this.updateRange(this.scrollTop),this.updateRange(this.scrollBottom)}},a.prototype.scrollDown=function(a){var b;if(!this.native_scroll){for(b=a[0]||1;b--;)this.screen.splice(this.ybase+this.scrollBottom,1),this.screen.splice(this.ybase+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.ybase+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[this.ybase+h],d=e;g>d;)f[d]=[b,f[d][1]],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[this.ybase+h],d=e;g>d;)f[d]=[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,h;for(h=a[0],e=a[1],b=a[2],g=a[3],c=[this.eraseAttr()," "];b+1>h;){for(f=this.screen[this.ybase+h],d=e;g>d;)f[d]=c,d++;h++}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,d;for(d=params[0],c=this.ybase+this.rows,a=[this.eraseAttr()," "];d--;)for(b=this.ybase;c>b;)this.screen[b].splice(this.x+1,0,a),this.screen[b].pop(),b++;return this.maxRange()},a.prototype.deleteColumns=function(){var a,b,c,d;for(d=params[0],c=this.ybase+this.rows,a=[this.eraseAttr()," "];d--;)for(b=this.ybase;c>b;)this.screen[b].splice(this.x,1),this.screen[b].push(a),b++;return this.maxRange()},a.prototype.get_html_height_in_lines=function(a){var b,c;return c=document.createElement("div"),c.innerHTML=a,this.element.appendChild(c),b=c.getBoundingClientRect().height,this.element.removeChild(c),Math.ceil(b/this.char_size.height)},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 b3e8140..2308995 100644 --- a/coffees/term.coffee +++ b/coffees/term.coffee @@ -397,7 +397,8 @@ class Terminal end = Math.min(end, @screen.length - 1) for j in [start..end] - line = @screen[row + @ydisp] + row = j + @ydisp + line = @screen[row] out = "" if j is @y and not @cursorHidden and ( @@ -527,10 +528,10 @@ class Terminal # pushing is faster than splicing # when they amount to the same # behavior. - @screen.push @blankLine() + @screen.push @blank_line() else # add our new line - @screen.splice row, 0, @blankLine() + @screen.splice row, 0, @blank_line() if @scrollTop isnt 0 if @ybase isnt 0 @@ -624,7 +625,7 @@ class Terminal if ch >= " " ch = @charset[ch] if @charset?[ch] if @x >= @cols - @lines[@y + @ybase][@x] = [@curAttr, '\u23CE'] + @screen[@y + @ybase][@x] = [@curAttr, '\u23CE'] @x = 0 @next_line() @@ -1075,7 +1076,7 @@ class Terminal @updateRange @y @next_line() else - @lines[@y + @ybase][@x] = [ + @screen[@y + @ybase][@x] = [ @curAttr html ] @@ -2016,7 +2017,7 @@ class Terminal else j = @rows - 1 - @scrollBottom j = @rows - 1 + @ybase - j - @screen.splice j + 1, 0, @blankLine(true) + @screen.splice j + 1, 0, @blank_line(true) @screen.splice @y, 1 @updateRange @y @@ -2301,7 +2302,7 @@ class Terminal when 1049, 47, 1047 # alt screen buffer unless @normal normal = - lines: @lines + lines: @screen ybase: @ybase ydisp: @ydisp x: @x @@ -2434,7 +2435,7 @@ class Terminal @cursorHidden = true when 1049, 47, 1047 # normal screen buffer - clearing it first if @normal - @lines = @normal.lines + @screen = @normal.lines @ybase = @normal.ybase @ydisp = @normal.ydisp @x = @normal.x @@ -2536,7 +2537,7 @@ class Terminal # CSI Ps b Repeat the preceding graphic character Ps times (REP). repeatPrecedingCharacter: (params) -> param = params[0] or 1 - line = @lines[@ybase + @y] + line = @screen[@ybase + @y] ch = line[@x - 1] or [@defAttr, " "] line[@x++] = ch while param-- @@ -2710,7 +2711,7 @@ class Terminal r = params[3] attr = params[4] while t < b + 1 - line = @lines[@ybase + t] + line = @screen[@ybase + t] i = l while i < r line[i] = [attr, line[i][1]] @@ -2869,7 +2870,7 @@ class Terminal b = params[3] r = params[4] while t < b + 1 - line = @lines[@ybase + t] + line = @screen[@ybase + t] i = l while i < r line[i] = [line[i][0], String.fromCharCode(ch)] @@ -2907,7 +2908,7 @@ class Terminal r = params[3] ch = [@eraseAttr(), " "] while t < b + 1 - line = @lines[@ybase + t] + line = @screen[@ybase + t] i = l while i < r line[i] = ch @@ -2991,8 +2992,8 @@ class Terminal while param-- i = @ybase while i < l - @lines[i].splice @x + 1, 0, ch - @lines[i].pop() + @screen[i].splice @x + 1, 0, ch + @screen[i].pop() i++ @maxRange() @@ -3007,8 +3008,8 @@ class Terminal while param-- i = @ybase while i < l - @lines[i].splice @x, 1 - @lines[i].push ch + @screen[i].splice @x, 1 + @screen[i].push ch i++ @maxRange()