function VT100(a){this.urlRE=typeof linkifyURLs=="undefined"||linkifyURLs<=0?null:RegExp("(?:http|https|ftp)://(?:[^:@/ \u00a0]*(?::[^@/ \u00a0]*)?@)?(?:[1-9][0-9]{0,2}(?:[.][1-9][0-9]{0,2}){3}|[0-9a-fA-F]{0,4}(?::{1,2}[0-9a-fA-F]{1,4})+|(?!-)[^[!\"#$%&'()*+,/:;<=>?@\\^_`{|}~\u0000- -\u00a0]+)(?::[1-9][0-9]*)?(?:/(?:(?![/ \u00a0]|[,.)}\"'!]+[ \u00a0]|[,.)}\"'!]+$).)*)*|"+(linkifyURLs<=1?"":"(?:[^:@/ \u00a0]*(?::[^@/ \u00a0]*)?@)?(?:[1-9][0-9]{0,2}(?:[.][1-9][0-9]{0,2}){3}|localhost|(?:(?!-)[^.[!\"#$%&'()*+,/:;<=>?@\\^_`{|}~\u0000- -\u00a0]+[.]){2,}(?:(?:com|net|org|edu|gov|aero|asia|biz|cat|coop|info|int|jobs|mil|mobi|museum|name|pro|tel|travel|ac|ad|ae|af|ag|ai|al|am|an|ao|aq|ar|as|at|au|aw|ax|az|ba|bb|bd|be|bf|bg|bh|bi|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|cr|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|ee|eg|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|in|io|iq|ir|is|it|je|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|mv|mw|mx|my|mz|na|nc|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|ps|pt|pw|py|qa|re|ro|rs|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tl|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw|arpa)(?![a-zA-Z0-9])|[Xx][Nn]--[-a-zA-Z0-9]+))(?::[1-9][0-9]{0,4})?(?:/(?:(?![/ \u00a0]|[,.)}\"'!]+[ \u00a0]|[,.)}\"'!]+$).)*)*|")+
"(?:mailto:)"+(linkifyURLs<=1?"":"?")+"[-_.+a-zA-Z0-9]+@(?!-)[-a-zA-Z0-9]+(?:[.](?!-)[-a-zA-Z0-9]+)?[.](?:(?:com|net|org|edu|gov|aero|asia|biz|cat|coop|info|int|jobs|mil|mobi|museum|name|pro|tel|travel|ac|ad|ae|af|ag|ai|al|am|an|ao|aq|ar|as|at|au|aw|ax|az|ba|bb|bd|be|bf|bg|bh|bi|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|cr|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|ee|eg|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|in|io|iq|ir|is|it|je|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|mv|mw|mx|my|mz|na|nc|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|ps|pt|pw|py|qa|re|ro|rs|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tl|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw|arpa)(?![a-zA-Z0-9])|[Xx][Nn]--[-a-zA-Z0-9]+)(?:[?](?:(?![ \u00a0]|[,.)}\"'!]+[ \u00a0]|[,.)}\"'!]+$).)*)?");
this.getUserSettings();this.initializeElements(a);this.maxScrollbackLines=500;this.npar=0;this.par=[];this.isQuestionMark=false;this.savedX=[];this.savedY=[];this.savedAttr=[];this.savedUseGMap=0;this.savedGMap=[this.Latin1Map,this.VT100GraphicsMap,this.CodePage437Map,this.DirectToFontMap];this.savedValid=[];this.statusString=this.respondString="";this.internalClipboard=undefined;this.reset(true)}
VT100.prototype.reset=function(a){this.isEsc=0;this.needWrap=false;this.autoWrapMode=true;this.printing=this.mouseReporting=this.offsetMode=this.crLfMode=this.cursorKeyMode=this.applKeyMode=this.insertMode=this.toggleMeta=this.dispCtrl=false;typeof this.printWin!="undefined"&&this.printWin&&!this.printWin.closed&&this.printWin.close();this.printWin=null;this.utfEnabled=this.utfPreferred;this.utfChar=this.utfCount=0;this.color="ansi0 bgAnsi15";this.style="";this.attr=240;this.useGMap=0;this.GMap=[this.Latin1Map,
this.VT100GraphicsMap,this.CodePage437Map,this.DirectToFontMap];this.translate=this.GMap[this.useGMap];this.top=0;this.bottom=this.terminalHeight;this.lastCharacter=" ";this.userTabStop=[];if(a)for(a=0;a<2;a++)for(;this.console[a].firstChild;)this.console[a].removeChild(this.console[a].firstChild);this.enableAlternateScreen(false);this.gotoXY(0,0);this.showCursor();this.isInverted=false;this.refreshInvertedState();this.clearRegion(0,0,this.terminalWidth,this.terminalHeight,this.color,this.style)};
VT100.prototype.addListener=function(a,b,c){a.addEventListener?a.addEventListener(b,c,false):a.attachEvent("on"+b,c)};
VT100.prototype.getUserSettings=function(){this.signature=1;this.utfPreferred=true;this.visualBell=typeof suppressAllAudio!="undefined"&&suppressAllAudio;this.autoprint=true;if(this.visualBell)this.signature=Math.floor(16807*this.signature+1)%-2147483649;if(typeof userCSSList!="undefined")for(var a=0;a<userCSSList.length;++a){for(var b=userCSSList[a][0],c=0;c<b.length;++c)this.signature=Math.floor(16807*this.signature+b.charCodeAt(c))%-2147483649;if(userCSSList[a][1])this.signature=Math.floor(16807*
this.signature+1)%-2147483649}a="shellInABox="+this.signature+":";b=document.cookie.indexOf(a);if(b>=0){b=document.cookie.substr(b+a.length).replace(/([0-1]*).*/,"$1");if(b.length==3+(typeof userCSSList=="undefined"?0:userCSSList.length)){this.utfPreferred=b.charAt(0)!="0";this.visualBell=b.charAt(1)!="0";this.autoprint=b.charAt(2)!="0";if(typeof userCSSList!="undefined")for(a=0;a<userCSSList.length;++a)userCSSList[a][2]=b.charAt(a+3)!="0"}}this.utfEnabled=this.utfPreferred};
VT100.prototype.storeUserSettings=function(){var a="shellInABox="+this.signature+":"+(this.utfEnabled?"1":"0")+(this.visualBell?"1":"0")+(this.autoprint?"1":"0");if(typeof userCSSList!="undefined")for(var b=0;b<userCSSList.length;++b)a+=userCSSList[b][2]?"1":"0";b=new Date;b.setDate(b.getDate()+3653);document.cookie=a+";expires="+b.toGMTString()};
VT100.prototype.initializeUserCSSStyles=function(){this.usercssActions=[];if(typeof userCSSList!="undefined"){for(var a="",b="",c=1,d=0,e=0;e<=userCSSList.length;++e){if(e<userCSSList.length){var g=userCSSList[e][0],j=userCSSList[e][1],f=userCSSList[e][2],h=userCSSList[e][3]||"",k=document.createElement("link"),l=document.createAttribute("id");l.nodeValue="usercss-"+e;k.setAttributeNode(l);l=document.createAttribute("rel");l.nodeValue="stylesheet";k.setAttributeNode(l);l=document.createAttribute("href");
l.nodeValue=h+"usercss-"+e+".css";k.setAttributeNode(l);h=document.createAttribute("type");h.nodeValue="text/css";k.setAttributeNode(h);document.getElementsByTagName("head")[0].appendChild(k);k.disabled=!f}if(j||e==userCSSList.length){if(d!=0&&(e-d>1||!c))a+="<hr />";c=e-d<1;a+=b;b="";for(k=d;k<e;++k)this.usercssActions[this.usercssActions.length]=function(m,o,n,q){return function(){for(var t=m.getChildById(m.menu,"beginusercss"),s=-1,u=-1,v=q;v>0;++u){if(t.tagName=="LI")if(++s>=n){--v;var p=m.usercss.childNodes[u];
if(typeof p.textContent=="undefined"){var r=p.innerText;p.innerHTML="";p.appendChild(document.createTextNode(r))}else p.textContent=p.textContent;r=document.getElementById("usercss-"+s);if(s==o){r.disabled=q==1?!r.disabled:false;if(!r.disabled)p.innerHTML='<img src="enabled.gif" />'+p.innerHTML}else r.disabled=true;userCSSList[s][2]=!r.disabled}t=t.nextSibling}}}(this,k,d,e-d);if(e==userCSSList.length)break;d=e}b+="<li>"+(f?'<img src="enabled.gif" />':"")+g+"</li>"}this.usercss.innerHTML=a}};
VT100.prototype.initializeElements=function(a){if(a)this.container=a;else if(!(this.container=document.getElementById("vt100"))){this.container=document.createElement("div");this.container.id="vt100";document.body.appendChild(this.container)}if(!this.getChildById(this.container,"reconnect")||!this.getChildById(this.container,"menu")||!this.getChildById(this.container,"scrollable")||!this.getChildById(this.container,"console")||!this.getChildById(this.container,"alt_console")||!this.getChildById(this.container,
"ieprobe")||!this.getChildById(this.container,"padding")||!this.getChildById(this.container,"cursor")||!this.getChildById(this.container,"lineheight")||!this.getChildById(this.container,"usercss")||!this.getChildById(this.container,"space")||!this.getChildById(this.container,"input")||!this.getChildById(this.container,"cliphelper")){a="";try{if(typeof navigator.mimeTypes["audio/x-wav"].enabledPlugin.name!="undefined")a=typeof suppressAllAudio!="undefined"&&suppressAllAudio?"":'<embed classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" id="beep_embed" src="beep.wav" autostart="false" volume="100" enablejavascript="true" type="audio/x-wav" height="16" width="200" style="position:absolute;left:-1000px;top:-1000px" />'}catch(b){}this.container.innerHTML=
'<div id="reconnect" style="visibility: hidden"><input type="button" value="Connect" onsubmit="return false" /></div><div id="cursize" style="visibility: hidden"></div><div id="menu"></div><div id="scrollable"><pre id="lineheight">&nbsp;</pre><pre id="console"><pre></pre><div id="ieprobe"><span>&nbsp;</span></div></pre><pre id="alt_console" style="display: none"></pre><div id="padding"></div><pre id="cursor">&nbsp;</pre></div><div class="hidden"><div id="usercss"></div><pre><div><span id="space"></span></div></pre><input type="textfield" id="input" /><input type="textfield" id="cliphelper" />'+
(typeof suppressAllAudio!="undefined"&&suppressAllAudio?"":a+'<bgsound id="beep_bgsound" loop=1 />')+"</div>"}if(typeof suppressAllAudio!="undefined"&&suppressAllAudio)this.beeper=undefined;else{this.beeper=this.getChildById(this.container,"beep_embed");if(!this.beeper||!this.beeper.Play){this.beeper=this.getChildById(this.container,"beep_bgsound");if(!this.beeper||typeof this.beeper.src=="undefined")this.beeper=undefined}}this.reconnectBtn=this.getChildById(this.container,"reconnect");this.curSizeBox=
this.getChildById(this.container,"cursize");this.menu=this.getChildById(this.container,"menu");this.scrollable=this.getChildById(this.container,"scrollable");this.lineheight=this.getChildById(this.container,"lineheight");this.console=[this.getChildById(this.container,"console"),this.getChildById(this.container,"alt_console")];a=this.getChildById(this.container,"ieprobe");this.padding=this.getChildById(this.container,"padding");this.cursor=this.getChildById(this.container,"cursor");this.usercss=this.getChildById(this.container,
"usercss");this.space=this.getChildById(this.container,"space");this.input=this.getChildById(this.container,"input");this.cliphelper=this.getChildById(this.container,"cliphelper");this.initializeUserCSSStyles();this.cursorWidth=this.cursor.clientWidth;this.cursorHeight=this.lineheight.clientHeight;this.isIE=a.offsetTop>1;a=undefined;this.console.innerHTML="";a=parseInt(this.getCurrentComputedStyle(document.body,"marginTop"));for(var c=parseInt(this.getCurrentComputedStyle(document.body,"marginLeft")),
d=parseInt(this.getCurrentComputedStyle(document.body,"marginRight")),e=this.container.offsetLeft,g=this.container.offsetTop,j=this.container;j=j.offsetParent;){e+=j.offsetLeft;g+=j.offsetTop}this.isEmbedded=a!=g||c!=e||(window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth)-d!=e+this.container.offsetWidth;if(!this.isEmbedded){this.indicateSize=false;setTimeout(function(k){return function(){k.indicateSize=true}}(this),100);this.addListener(window,"resize",function(k){return function(){k.hideContextMenu();
k.resizer();k.showCurrentSize()}}(this));document.body.style.margin="0px";try{document.body.style.overflow="hidden"}catch(f){}try{document.body.oncontextmenu=function(){return false}}catch(h){}}this.hideContextMenu();this.addListener(this.reconnectBtn.firstChild,"click",function(k){return function(){var l=k.reconnect();k.input.focus();return l}}(this));this.addListener(this.input,"blur",function(k){return function(){k.blurCursor()}}(this));this.addListener(this.input,"focus",function(k){return function(){k.focusCursor()}}(this));
this.addListener(this.input,"keydown",function(k){return function(l){if(!l)l=window.event;return k.keyDown(l)}}(this));this.addListener(this.input,"keypress",function(k){return function(l){if(!l)l=window.event;return k.keyPressed(l)}}(this));this.addListener(this.input,"keyup",function(k){return function(l){if(!l)l=window.event;return k.keyUp(l)}}(this));a=function(k,l){return function(m){if(!m)m=window.event;return k.mouseEvent(m,l)}};this.addListener(this.scrollable,"mousedown",a(this,0));this.addListener(this.scrollable,
"mouseup",a(this,1));this.addListener(this.scrollable,"click",a(this,2));this.top=this.numScrollbackLines=this.cursorY=this.cursorX=this.currentScreen=0;this.bottom=2147483647;this.resizer();this.focusCursor();this.input.focus()};VT100.prototype.getChildById=function(a,b){var c=a.all||a.getElementsByTagName("*");if(typeof c.namedItem=="undefined"){for(var d=0;d<c.length;d++)if(c[d].id==b)return c[d];return null}else return(c=(a.all||a.getElementsByTagName("*")).namedItem(b))?c[0]||c:null};
VT100.prototype.getCurrentComputedStyle=function(a,b){return typeof a.currentStyle!="undefined"?a.currentStyle[b]:document.defaultView.getComputedStyle(a,null)[b]};VT100.prototype.reconnect=function(){return false};VT100.prototype.showReconnect=function(a){this.reconnectBtn.style.visibility=a?"":"hidden"};
VT100.prototype.repairElements=function(a){for(a=a.firstChild;a;a=a.nextSibling)if(!a.clientHeight){var b=document.createElement(a.tagName);b.style.cssText=a.style.cssText;b.className=a.className;if(a.tagName=="DIV")for(var c=a.firstChild;c;c=c.nextSibling){var d=document.createElement(c.tagName);d.style.cssText=c.style.cssText;d.style.className=c.style.className;this.setTextContent(d,this.getTextContent(c));b.appendChild(d)}else this.setTextContent(b,this.getTextContent(a));a.parentNode.replaceChild(b,
a);a=b}};VT100.prototype.resized=function(){};
VT100.prototype.resizer=function(){var a=document.createElement("pre");this.setTextContent(a," ");a.id="cursor";a.style.cssText=this.cursor.style.cssText;this.cursor.parentNode.insertBefore(a,this.cursor);if(a.clientHeight){this.cursor.parentNode.removeChild(this.cursor);this.cursor=a;this.repairElements(this.console[0]);this.repairElements(this.console[1]);this.cursor.style.width=this.cursorWidth+"px";this.cursor.style.height=this.cursorHeight+"px";a=this.console[this.currentScreen];var b=(this.isEmbedded?
this.container.clientHeight:window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight)-1,c=b%this.cursorHeight;this.scrollable.style.height=(b>0?b:0)+"px";this.padding.style.height=(c>0?c:0)+"px";b=this.terminalHeight;this.updateWidth();this.updateHeight();c=this.cursorX;var d=this.cursorY+this.numScrollbackLines;for(this.updateNumScrollbackLines();this.currentScreen&&this.numScrollbackLines>0;){a.removeChild(a.firstChild);this.numScrollbackLines--}d-=this.numScrollbackLines;
if(c<0)c=0;else if(c>this.terminalWidth){c=this.terminalWidth-1;if(c<0)c=0}if(d<0)d=0;else if(d>this.terminalHeight){d=this.terminalHeight-1;if(d<0)d=0}if(this.bottom>this.terminalHeight||this.bottom==b)this.bottom=this.terminalHeight;if(this.top>=this.bottom){this.top=this.bottom-1;if(this.top<0)this.top=0}this.truncateLines(this.terminalWidth);this.putString(c,d,"",undefined);this.scrollable.scrollTop=this.numScrollbackLines*this.cursorHeight+1;a=a.firstChild;for(b=0;b<this.numScrollbackLines;b++){a.className=
"scrollback";a=a.nextSibling}for(;a;){a.className="";a=a.nextSibling}this.reconnectBtn.style.left=(this.terminalWidth*this.cursorWidth-this.reconnectBtn.clientWidth)/2+"px";this.reconnectBtn.style.top=(this.terminalHeight*this.cursorHeight-this.reconnectBtn.clientHeight)/2+"px";this.resized(this.terminalWidth,this.terminalHeight)}else a.parentNode.removeChild(a)};
VT100.prototype.showCurrentSize=function(){if(this.indicateSize){this.curSizeBox.innerHTML=""+this.terminalWidth+"x"+this.terminalHeight;this.curSizeBox.style.left=(this.terminalWidth*this.cursorWidth-this.curSizeBox.clientWidth)/2+"px";this.curSizeBox.style.top=(this.terminalHeight*this.cursorHeight-this.curSizeBox.clientHeight)/2+"px";this.curSizeBox.style.visibility="";this.curSizeTimeout&&clearTimeout(this.curSizeTimeout);this.curSizeTimeout=setTimeout(function(a){return function(){a.curSizeTimeout=
null;a.curSizeBox.style.visibility="hidden"}}(this),1E3)}};VT100.prototype.selection=function(){try{return""+(window.getSelection&&window.getSelection()||document.selection&&document.selection.type=="Text"&&document.selection.createRange().text||"")}catch(a){}return""};VT100.prototype.cancelEvent=function(a){try{a.stopPropagation();a.preventDefault()}catch(b){}try{a.cancelBubble=true;a.returnValue=false;a.button=0;a.keyCode=0}catch(c){}return false};
VT100.prototype.mouseEvent=function(a,b){var c=this.selection();if((b==1||b==2)&&!c.length)this.input.focus();for(var d=this.container.offsetLeft,e=this.container.offsetTop,g=this.container;g=g.offsetParent;){d+=g.offsetLeft;e+=g.offsetTop}g=(a.clientX-d)/this.cursorWidth;var j=(a.clientY-e+this.scrollable.offsetTop)/this.cursorHeight-this.numScrollbackLines,f=true;if(g>=this.terminalWidth){g=this.terminalWidth-1;f=false}if(g<0){g=0;f=false}if(j>=this.terminalHeight){j=this.terminalHeight-1;f=false}if(j<
0){j=0;f=false}var h=b!=0?3:typeof a.pageX!="undefined"?a.button:[undefined,0,2,0,1,0,1,0][a.button];if(h!=undefined){if(a.shiftKey)h|=4;if(a.altKey||a.metaKey)h|=8;if(a.ctrlKey)h|=16}if(this.mouseReporting&&!c.length&&(b!=0||!a.shiftKey))if(f||b!=0)if(h!=undefined){c="\u001b[M"+String.fromCharCode(h+32)+String.fromCharCode(g+33)+String.fromCharCode(j+33);b!=2&&this.keysPressed(c);return this.cancelEvent(a)}if(h==2&&!a.shiftKey){b==0&&this.showContextMenu(a.clientX-d,a.clientY-e);return this.cancelEvent(a)}if(this.mouseReporting)try{a.shiftKey=
false}catch(k){}return true};VT100.prototype.replaceChar=function(a,b,c){for(var d=-1;;){d=a.indexOf(b,d+1);if(d<0)break;a=a.substr(0,d)+c+a.substr(d+1)}return a};VT100.prototype.htmlEscape=function(a){return this.replaceChar(this.replaceChar(this.replaceChar(this.replaceChar(a,"&","&amp;"),"<","&lt;"),'"',"&quot;")," ","\u00a0")};VT100.prototype.getTextContent=function(a){return a.textContent||(typeof a.textContent=="undefined"?a.innerText:"")};
VT100.prototype.setTextContent=function(a,b){if(this.urlRE&&this.urlRE.test(b)){for(var c="";;){var d=0;if(RegExp.leftContext!=null){c+=this.htmlEscape(RegExp.leftContext);d+=RegExp.leftContext.length}var e=this.htmlEscape(RegExp.lastMatch),g=e;if(e.indexOf("http://")<0&&e.indexOf("https://")<0&&e.indexOf("ftp://")<0&&e.indexOf("mailto:")<0){g=e.indexOf("/");var j=e.indexOf("@"),f=e.indexOf("?");g=j>0&&(j<f||f<0)&&(g<0||f>0&&g>f)?"mailto:"+e:(e.indexOf("ftp.")==0?"ftp://":"http://")+e}c+='<a target="vt100Link" href="'+
g+'">'+e+"</a>";d+=RegExp.lastMatch.length;b=b.substr(d);if(!this.urlRE.test(b)){if(RegExp.rightContext!=null)c+=this.htmlEscape(RegExp.rightContext);break}}a.innerHTML=c}else if(typeof a.textContent=="undefined"){if(a.innerText!=b)try{a.innerText=b}catch(h){a.innerHTML="";a.appendChild(document.createTextNode(this.replaceChar(b," ","\u00a0")))}}else if(a.textContent!=b)a.textContent=b};
VT100.prototype.insertBlankLine=function(a,b,c){b||(b="ansi0 bgAnsi15");c||(c="");var d;if(b!="ansi0 bgAnsi15"&&!c){d=document.createElement("pre");this.setTextContent(d,"\n")}else{d=document.createElement("div");var e=document.createElement("span");e.style.cssText=c;e.style.className=b;this.setTextContent(e,this.spaces(this.terminalWidth));d.appendChild(e)}d.style.height=this.cursorHeight+"px";b=this.console[this.currentScreen];b.childNodes.length>a?b.insertBefore(d,b.childNodes[a]):b.appendChild(d)};
VT100.prototype.updateWidth=function(){return this.terminalWidth=Math.floor(this.console[this.currentScreen].offsetWidth/this.cursorWidth)};VT100.prototype.updateHeight=function(){return this.terminalHeight=this.isEmbedded?Math.floor((this.container.clientHeight-1)/this.cursorHeight):Math.floor(((window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight)-1)/this.cursorHeight)};
VT100.prototype.updateNumScrollbackLines=function(){var a=Math.floor(this.console[this.currentScreen].offsetHeight/this.cursorHeight)-this.terminalHeight;return this.numScrollbackLines=a<0?0:a};
VT100.prototype.truncateLines=function(a){if(a<0)a=0;for(var b=this.console[this.currentScreen].firstChild;b;b=b.nextSibling)if(b.tagName=="DIV"){for(var c=0,d=b.firstChild;d;d=d.nextSibling){var e=this.getTextContent(d),g=e.length;if(c+g>a){for(this.setTextContent(d,e.substr(0,a-c));d.nextSibling;)b.removeChild(b.lastChild);break}c+=g}for(d=b.lastChild;d&&d.className=="ansi0 bgAnsi15"&&!d.style.cssText.length;){e=this.getTextContent(d);for(c=e.length;c--;)if(e.charAt(c)!=" "&&e.charAt(c)!="\u00a0"){c+
1!=e.length&&this.setTextContent(e.substr(0,c+1));d=null;break}if(d){e=d;if(d=d.previousSibling)b.removeChild(e);else{e=document.createElement("pre");e.style.height=this.cursorHeight+"px";this.setTextContent(e,"\n");b.parentNode.replaceChild(e,b)}}}}};
VT100.prototype.putString=function(a,b,c,d,e){d||(d="ansi0 bgAnsi15");e||(e="");var g=b+this.numScrollbackLines,j,f,h,k=0,l=this.console[this.currentScreen];if(!c.length&&(g>=l.childNodes.length||l.childNodes[g].tagName!="DIV"))b=null;else{for(;l.childNodes.length<=g;)this.insertBlankLine(g);j=l.childNodes[g];if(j.tagName!="DIV"){b=document.createElement("div");b.style.height=this.cursorHeight+"px";b.innerHTML="<span></span>";l.replaceChild(b,j);j=b}b=j.firstChild;for(var m;b.nextSibling&&k<a;){m=
this.getTextContent(b).length;if(k+m>a)break;k+=m;b=b.nextSibling}if(c.length){h=this.getTextContent(b);m=b.className;var o=b.style.cssText;if(k+h.length<a){if(m!="ansi0 bgAnsi15"||o!=""){b=document.createElement("span");j.appendChild(b);b.className="ansi0 bgAnsi15";b.style.cssText="";m="ansi0 bgAnsi15";o="";k+=h.length;h=""}do h+=" ";while(k+h.length<a)}var n=c.length-h.length+a-k;if(m!=d||o!=e&&(o||e)){if(k==a){if(!(c.length>=h.length)){f=document.createElement("span");j.insertBefore(f,b);this.setTextContent(b,
h.substr(c.length));b=f}}else{var q=h.substr(a+c.length-k);this.setTextContent(b,h.substr(0,a-k));k=a;f=document.createElement("span");if(b.nextSibling){j.insertBefore(f,b.nextSibling);b=f;if(q.length){f=document.createElement("span");f.className=m;f.style.cssText=o;this.setTextContent(f,q);j.insertBefore(f,b.nextSibling)}}else{j.appendChild(f);b=f;if(q.length){f=document.createElement("span");f.className=m;f.style.cssText=o;this.setTextContent(f,q);j.appendChild(f)}}}h=c;b.className=d;b.style.cssText=
e}else h=h.substr(0,a-k)+c+h.substr(a+c.length-k);this.setTextContent(b,h);for(f=b.nextSibling;n>0&&f;){h=this.getTextContent(f);m=h.length;if(m<=n){j.removeChild(f);n-=m;f=b.nextSibling}else{this.setTextContent(f,h.substr(n));break}}if(f&&b.className==f.className&&b.style.cssText==f.style.cssText){this.setTextContent(b,this.getTextContent(b)+this.getTextContent(f));j.removeChild(f)}}}this.cursorX=a+c.length;if(this.cursorX>=this.terminalWidth){this.cursorX=this.terminalWidth-1;if(this.cursorX<0)this.cursorX=
0}d=a=-1;if(!this.cursor.style.visibility){k=this.cursorX-k;if(b){d=b.offsetTop+b.offsetParent.offsetTop;h=this.getTextContent(b);e=k-h.length;if(e<0){this.setTextContent(this.cursor,h.charAt(k));a=b.offsetLeft+k*b.offsetWidth/h.length}else{if(e==0)a=b.offsetLeft+b.offsetWidth;if(b.nextSibling){h=this.getTextContent(b.nextSibling);this.setTextContent(this.cursor,h.charAt(e));if(a<0)a=b.nextSibling.offsetLeft+e*b.offsetWidth/h.length}else this.setTextContent(this.cursor," ")}}else this.setTextContent(this.cursor,
" ")}if(a>=0)this.cursor.style.left=a+(this.isIE?1:0)+"px";else{this.setTextContent(this.space,this.spaces(this.cursorX));this.cursor.style.left=this.space.offsetWidth+l.offsetLeft+"px"}this.cursorY=g-this.numScrollbackLines;this.cursor.style.top=d>=0?d+"px":g*this.cursorHeight+l.offsetTop+"px";if(c.length){if((f=b.previousSibling)&&b.className==f.className&&b.style.cssText==f.style.cssText){this.setTextContent(b,this.getTextContent(f)+this.getTextContent(b));j.removeChild(f)}for(b=j.lastChild;b&&
b.className=="ansi0 bgAnsi15"&&!b.style.cssText.length;){h=this.getTextContent(b);for(c=h.length;c--;)if(h.charAt(c)!=" "&&h.charAt(c)!="\u00a0"){c+1!=h.length&&this.setTextContent(h.substr(0,c+1));b=null;break}if(b){f=b;if(b=b.previousSibling)j.removeChild(f);else{c=document.createElement("pre");c.style.height=this.cursorHeight+"px";this.setTextContent(c,"\n");j.parentNode.replaceChild(c,j)}}}}};
VT100.prototype.gotoXY=function(a,b){if(a>=this.terminalWidth)a=this.terminalWidth-1;if(a<0)a=0;var c,d;if(this.offsetMode){c=this.top;d=this.bottom}else{c=0;d=this.terminalHeight}if(b>=d)b=d-1;if(b<c)b=c;this.putString(a,b,"",undefined);this.needWrap=false};VT100.prototype.gotoXaY=function(a,b){this.gotoXY(a,this.offsetMode?this.top+b:b)};
VT100.prototype.refreshInvertedState=function(){if(this.isInverted)this.scrollable.className+=" inverted";else this.scrollable.className=this.scrollable.className.replace(/ *inverted/,"")};
VT100.prototype.enableAlternateScreen=function(a){if((a?1:0)==this.currentScreen)this.resizer();else{a&&this.saveCursor();this.currentScreen=a?1:0;this.console[1-this.currentScreen].style.display="none";this.console[this.currentScreen].style.display="";this.resizer();if(a){this.gotoXY(0,0);this.clearRegion(0,0,this.terminalWidth,this.terminalHeight)}else this.restoreCursor()}};VT100.prototype.hideCursor=function(){if(this.cursor.style.visibility!="hidden"){this.cursor.style.visibility="hidden";return true}return false};
VT100.prototype.showCursor=function(a,b){if(this.cursor.style.visibility){this.cursor.style.visibility="";this.putString(a==undefined?this.cursorX:a,b==undefined?this.cursorY:b,"",undefined);return true}return false};VT100.prototype.scrollBack=function(){var a=this.scrollable.scrollTop-this.scrollable.clientHeight;this.scrollable.scrollTop=a<0?0:a};
VT100.prototype.scrollFore=function(){var a=this.scrollable.scrollTop+this.scrollable.clientHeight;this.scrollable.scrollTop=a>this.numScrollbackLines*this.cursorHeight+1?this.numScrollbackLines*this.cursorHeight+1:a};VT100.prototype.spaces=function(a){for(var b="";a-- >0;)b+=" ";return b};
VT100.prototype.clearRegion=function(a,b,c,d,e,g){c+=a;if(a<0)a=0;if(c>this.terminalWidth)c=this.terminalWidth;if(!((c-=a)<=0)){d+=b;if(b<0)b=0;if(d>this.terminalHeight)d=this.terminalHeight;if(!((d-=b)<=0))if(!this.numScrollbackLines&&c==this.terminalWidth&&d==this.terminalHeight&&(e==undefined||e=="ansi0 bgAnsi15")&&!g){for(a=this.console[this.currentScreen];a.lastChild;)a.removeChild(a.lastChild);this.putString(this.cursorX,this.cursorY,"",undefined)}else{var j=this.hideCursor(),f=this.cursorX,
h=this.cursorY;c=this.spaces(c);for(d=b+d;d-- >b;)this.putString(a,d,c,e,g);j?this.showCursor(f,h):this.putString(f,h,"",undefined)}}};
VT100.prototype.copyLineSegment=function(a,b,c,d,e){var g=[],j=[],f=[],h=this.console[this.currentScreen];if(d>=h.childNodes.length){g[0]=this.spaces(e);j[0]=undefined;f[0]=undefined}else{h=h.childNodes[d];if(h.tagName!="DIV"||!h.childNodes.length){g[0]=this.spaces(e);j[0]=undefined;f[0]=undefined}else{d=0;for(h=h.firstChild;h&&e>0;h=h.nextSibling){var k=this.getTextContent(h),l=k.length;if(d+l>c){var m=c>d?c-d:0;g[g.length]=k.substr(m,e);j[j.length]=h.className;f[f.length]=h.style.cssText;e-=l-m}d+=
l}if(e>0){g[g.length]=this.spaces(e);j[j.length]=undefined;f[f.length]=undefined}}}c=this.hideCursor();e=this.cursorX;d=this.cursorY;for(h=0;h<g.length;h++){this.putString(a,b-this.numScrollbackLines,g[h],j[h]?j[h]:"ansi0 bgAnsi15",f[h]);a+=g[h].length}c?this.showCursor(e,d):this.putString(e,d,"",undefined)};
VT100.prototype.scrollRegion=function(a,b,c,d,e,g,j,f){var h=e<0?-e:0,k=e>0?e:0,l=g<0?-g:0,m=g>0?g:0,o=null;c+=a;if(a<h)a=h;if(c>this.terminalWidth-k)c=this.terminalWidth-k;if((c-=a)<=0)o=1;d+=b;if(b<l)b=l;if(d>this.terminalHeight-m)d=this.terminalHeight-m;if((d-=b)<0)o=1;if(!o){if(f&&f.indexOf("underline"))f=f.replace(/text-decoration:underline;/,"");h=this.numScrollbackLines-(this.scrollable.scrollTop-1)/this.cursorHeight;k=this.hideCursor();l=this.cursorX;m=this.cursorY;o=this.console[this.currentScreen];
if(!e&&!a&&c==this.terminalWidth)if(g<0)if(!this.currentScreen&&b==-g&&d==this.terminalHeight+g){for(;o.childNodes.length<this.terminalHeight;)this.insertBlankLine(this.terminalHeight);for(var n=0;n<b;n++)this.insertBlankLine(o.childNodes.length,j,f);for(this.updateNumScrollbackLines();this.numScrollbackLines>(this.currentScreen?0:this.maxScrollbackLines);){o.removeChild(o.firstChild);this.numScrollbackLines--}n=this.numScrollbackLines;for(a=-g;n-- >0&&a-- >0;)o.childNodes[n].className="scrollback"}else{for(n=
-g;n-- >0&&o.childNodes.length>this.numScrollbackLines+b+g;)o.removeChild(o.childNodes[this.numScrollbackLines+b+g]);if(this.numScrollbackLines>0||o.childNodes.length>this.numScrollbackLines+b+d+g)for(n=-g;n-- >0;)this.insertBlankLine(this.numScrollbackLines+b+d+g,j,f)}else{for(n=g;n-- >0&&o.childNodes.length>this.numScrollbackLines+b+d;)o.removeChild(o.childNodes[this.numScrollbackLines+b+d]);for(n=g;n--;)this.insertBlankLine(this.numScrollbackLines+b,j,f)}else{if(g<=0)for(n=b+this.numScrollbackLines;n<
b+this.numScrollbackLines+d;n++)this.copyLineSegment(a+e,n+g,a,n,c);else for(n=b+this.numScrollbackLines+d;n-- >b+this.numScrollbackLines;)this.copyLineSegment(a+e,n+g,a,n,c);if(e>0)this.clearRegion(a,b,e,d,j,f);else e<0&&this.clearRegion(a+c+e,b,-e,d,j,f);if(g>0)this.clearRegion(a,b,c,g,j,f);else g<0&&this.clearRegion(a,b+d+g,c,-g,j,f)}this.scrollable.scrollTop=(this.numScrollbackLines-h)*this.cursorHeight+1;k?this.showCursor(l,m):this.putString(l,m,"",undefined)}};
VT100.prototype.copy=function(a){if(a==undefined)a=this.selection();this.internalClipboard=undefined;if(a.length){try{this.cliphelper.value=a;this.cliphelper.select();this.cliphelper.createTextRange().execCommand("copy")}catch(b){this.internalClipboard=a}this.cliphelper.value=""}};VT100.prototype.copyLast=function(){this.copy(this.lastSelection)};
VT100.prototype.pasteFnc=function(){var a=undefined;if(this.internalClipboard!=undefined)a=this.internalClipboard;else try{this.cliphelper.value="";this.cliphelper.createTextRange().execCommand("paste");a=this.cliphelper.value}catch(b){}this.cliphelper.value="";if(a&&this.menu.style.visibility=="hidden")return function(){this.keysPressed(""+a)}};VT100.prototype.toggleUTF=function(){this.utfPreferred=this.utfEnabled=!this.utfEnabled};VT100.prototype.toggleBell=function(){this.visualBell=!this.visualBell};
VT100.prototype.about=function(){alert("VT100 Terminal Emulator 2.10 (revision 186)\nCopyright 2008-2009 by Markus Gutschke\nFor more information check http://shellinabox.com")};VT100.prototype.hideContextMenu=function(){this.menu.style.visibility="hidden";this.menu.style.top="-100px";this.menu.style.left="-100px";this.menu.style.width="0px";this.menu.style.height="0px"};VT100.prototype.extendContextMenu=function(){};
VT100.prototype.showContextMenu=function(a,b){this.menu.innerHTML='<table class="popup" cellpadding="0" cellspacing="0"><tr><td><ul id="menuentries"><li id="beginclipboard">Copy</li><li id="endclipboard">Paste</li><hr /><li id="reset">Reset</li><hr /><li id="beginconfig">'+(this.utfEnabled?'<img src="enabled.gif" />':"")+'Unicode</li><li id="endconfig">'+(this.visualBell?'<img src="enabled.gif" />':"")+"Visual Bell</li>"+(this.usercss.firstChild?'<hr id="beginusercss" />'+this.usercss.innerHTML+'<hr id="endusercss" />':
"<hr />")+'<li id="about">About...</li></ul></td></tr></table>';var c=this.menu.firstChild,d=this.getChildById(c,"menuentries");this.lastSelection=this.selection();if(!this.lastSelection.length)d.firstChild.className="disabled";var e=this.pasteFnc();if(!e)d.childNodes[1].className="disabled";e=[this.copyLast,e,this.reset,this.toggleUTF,this.toggleBell];for(var g=0;g<this.usercssActions.length;++g)e[e.length]=this.usercssActions[g];e[e.length]=this.about;this.extendContextMenu(d,e);d=d.firstChild;
for(g=0;d;d=d.nextSibling)if(d.tagName=="LI"){if(d.className!="disabled"){this.addListener(d,"mouseover",function(j,f){return function(){f.className="hover"}}(this,d));this.addListener(d,"mouseout",function(j,f){return function(){f.className=""}}(this,d));this.addListener(d,"mousedown",function(j,f){return function(h){j.hideContextMenu();f.call(j);j.storeUserSettings();return j.cancelEvent(h||window.event)}}(this,e[g]));this.addListener(d,"mouseup",function(j){return function(f){return j.cancelEvent(f||
window.event)}}(this));this.addListener(d,"mouseclick",function(j){return function(f){return j.cancelEvent(f||window.event)}}())}g++}if(a+c.clientWidth>this.container.offsetWidth)a=this.container.offsetWidth-c.clientWidth;if(a<0)a=0;if(b+c.clientHeight>this.container.offsetHeight)b=this.container.offsetHeight-c.clientHeight;if(b<0)b=0;c.style.left=a+"px";c.style.top=b+"px";this.menu.style.left="0px";this.menu.style.top="0px";this.menu.style.width=this.container.offsetWidth+"px";this.menu.style.height=
this.container.offsetHeight+"px";this.addListener(this.menu,"click",function(j){return function(){j.hideContextMenu()}}(this));this.menu.style.visibility=""};VT100.prototype.keysPressed=function(a){for(var b=0;b<a.length;b++){var c=a.charCodeAt(b);this.vt100(c>=7&&c<=15||c==24||c==26||c==27||c>=32?String.fromCharCode(c):"<"+c+">")}};
VT100.prototype.applyModifiers=function(a,b){if(a){if(b.ctrlKey)if(a>=32&&a<=127)switch(a){case 51:a=27;break;case 52:a=28;break;case 53:a=29;break;case 54:a=30;break;case 55:a=31;break;case 56:a=127;break;case 63:a=127;break;default:a&=31;break}return String.fromCharCode(a)}};
VT100.prototype.handleKey=function(a){var b,c;if(typeof a.charCode!="undefined"){b=a.charCode;c=a.keyCode}else{b=a.keyCode;c=undefined}if(b)c=undefined;b=this.applyModifiers(b,a);if(b!=undefined)this.scrollable.scrollTop=this.numScrollbackLines*this.cursorHeight+1;else{if((a.altKey||a.metaKey)&&!a.shiftKey&&!a.ctrlKey)switch(c){case 33:b="\u001b<";break;case 34:b="\u001b>";break;case 37:b="\u001bb";break;case 38:b="\u001bp";break;case 39:b="\u001bf";break;case 40:b="\u001bn";break;case 46:b="\u001bd";
break;default:break}else if(a.shiftKey&&!a.ctrlKey&&!a.altKey&&!a.metaKey)switch(c){case 33:this.scrollBack();return;case 34:this.scrollFore();return;default:break}if(b==undefined){switch(c){case 8:b="";break;case 9:b="\t";break;case 10:b="\n";break;case 13:b=this.crLfMode?"\r\n":"\r";break;case 16:return;case 17:return;case 18:return;case 19:return;case 20:return;case 27:b="\u001b";break;case 33:b="\u001b[5~";break;case 34:b="\u001b[6~";break;case 35:b="\u001bOF";break;case 36:b="\u001bOH";break;
case 37:b=this.cursorKeyMode?"\u001bOD":"\u001b[D";break;case 38:b=this.cursorKeyMode?"\u001bOA":"\u001b[A";break;case 39:b=this.cursorKeyMode?"\u001bOC":"\u001b[C";break;case 40:b=this.cursorKeyMode?"\u001bOB":"\u001b[B";break;case 45:b="\u001b[2~";break;case 46:b="\u001b[3~";break;case 91:return;case 92:return;case 93:return;case 96:b=this.applyModifiers(48,a);break;case 97:b=this.applyModifiers(49,a);break;case 98:b=this.applyModifiers(50,a);break;case 99:b=this.applyModifiers(51,a);break;case 100:b=
this.applyModifiers(52,a);break;case 101:b=this.applyModifiers(53,a);break;case 102:b=this.applyModifiers(54,a);break;case 103:b=this.applyModifiers(55,a);break;case 104:b=this.applyModifiers(56,a);break;case 105:b=this.applyModifiers(58,a);break;case 106:b=this.applyModifiers(42,a);break;case 107:b=this.applyModifiers(43,a);break;case 109:b=this.applyModifiers(45,a);break;case 110:b=this.applyModifiers(46,a);break;case 111:b=this.applyModifiers(47,a);break;case 112:b="\u001bOP";break;case 113:b=
"\u001bOQ";break;case 114:b="\u001bOR";break;case 115:b="\u001bOS";break;case 116:b="\u001b[15~";break;case 117:b="\u001b[17~";break;case 118:b="\u001b[18~";break;case 119:b="\u001b[19~";break;case 120:b="\u001b[20~";break;case 121:b="\u001b[21~";break;case 122:b="\u001b[23~";break;case 123:b="\u001b[24~";break;case 144:return;case 145:return;case 186:b=this.applyModifiers(59,a);break;case 187:b=this.applyModifiers(61,a);break;case 188:b=this.applyModifiers(44,a);break;case 189:b=this.applyModifiers(45,
a);break;case 190:b=this.applyModifiers(46,a);break;case 191:b=this.applyModifiers(47,a);break;case 192:b=this.applyModifiers(96,a);break;case 219:b=this.applyModifiers(91,a);break;case 220:b=this.applyModifiers(92,a);break;case 221:b=this.applyModifiers(93,a);break;case 222:b=this.applyModifiers(39,a);break;default:return}this.scrollable.scrollTop=this.numScrollbackLines*this.cursorHeight+1}}if(a.shiftKey||a.ctrlKey||a.altKey||a.metaKey){var d,e,g;if((c=b.substr(0,2))=="\u001b["){for(e=c;e.length<
b.length&&(d=b.charCodeAt(e.length))>=48&&d<=57;)e=b.substr(0,e.length+1);g=b.substr(e.length);if(e.length>2)e+=";"}else if(c=="\u001bO"){e=c;g=b.substr(2)}if(e!=undefined)b=e+((a.shiftKey?1:0)+(a.altKey|a.metaKey?2:0)+(a.ctrlKey?4:0))+g;else if(b.length==1&&(a.altKey||a.metaKey))b="\u001b"+b}this.menu.style.visibility=="hidden"&&this.keysPressed(b)};
VT100.prototype.inspect=function(a,b){if(b==undefined)b=0;var c="";if(typeof a=="object"&&++b<2){c="[\r\n";for(i in a){c+=this.spaces(b*2)+i+" -> ";try{c+=this.inspect(a[i],b)}catch(d){c+="???\r\n"}}c+="]\r\n"}else c+=(""+a).replace(/\n/g," ").replace(/ +/g," ")+"\r\n";return c};VT100.prototype.checkComposedKeys=function(){var a=this.input.value;if(a.length){this.input.value="";this.menu.style.visibility=="hidden"&&this.keysPressed(a)}};
VT100.prototype.fixEvent=function(a){if(a.ctrlKey&&a.altKey){var b=[];b.charCode=a.charCode;b.keyCode=a.keyCode;b.ctrlKey=false;b.shiftKey=a.shiftKey;b.altKey=false;b.metaKey=a.metaKey;return b}if(a.shiftKey){var c=b=undefined;switch(this.lastNormalKeyDownEvent.keyCode){case 39:b=39;c=34;break;case 44:b=44;c=60;break;case 45:b=45;c=95;break;case 46:b=46;c=62;break;case 47:b=47;c=63;break;case 48:b=48;c=41;break;case 49:b=49;c=33;break;case 50:b=50;c=64;break;case 51:b=51;c=35;break;case 52:b=52;c=
36;break;case 53:b=53;c=37;break;case 54:b=54;c=94;break;case 55:b=55;c=38;break;case 56:b=56;c=42;break;case 57:b=57;c=40;break;case 59:b=59;c=58;break;case 61:b=61;c=43;break;case 91:b=91;c=123;break;case 92:b=92;c=124;break;case 93:b=93;c=125;break;case 96:b=96;c=126;break;case 109:b=45;c=95;break;case 111:b=47;c=63;break;case 186:b=59;c=58;break;case 187:b=61;c=43;break;case 188:b=44;c=60;break;case 189:b=45;c=95;break;case 190:b=46;c=62;break;case 191:b=47;c=63;break;case 192:b=96;c=126;break;
case 219:b=91;c=123;break;case 220:b=92;c=124;break;case 221:b=93;c=125;break;case 222:b=39;c=34;break;default:break}if(c&&(a.charCode==b||a.charCode==0)){b=[];b.charCode=c;b.keyCode=a.keyCode;b.ctrlKey=a.ctrlKey;b.shiftKey=a.shiftKey;b.altKey=a.altKey;b.metaKey=a.metaKey;return b}}return a};
VT100.prototype.keyDown=function(a){this.checkComposedKeys(a);this.lastKeyDownEvent=this.lastKeyPressedEvent=undefined;this.lastNormalKeyDownEvent=a;var b=a.keyCode==32||a.keyCode>=48&&a.keyCode<=57||a.keyCode>=65&&a.keyCode<=90,c=b||a.keyCode>=96&&a.keyCode<=105||a.keyCode==226,d=c||a.keyCode==59||a.keyCode==61||a.keyCode==106||a.keyCode==107||a.keyCode>=109&&a.keyCode<=111||a.keyCode>=186&&a.keyCode<=192||a.keyCode>=219&&a.keyCode<=222||a.keyCode==252;try{if(navigator.appName=="Konqueror")d|=a.keyCode<
128}catch(e){}if((a.charCode||a.keyCode)&&(c&&(a.ctrlKey||a.altKey||a.metaKey)&&!a.shiftKey&&!(a.ctrlKey&&a.altKey)||this.catchModifiersEarly&&d&&!c&&(a.ctrlKey||a.altKey||a.metaKey)||!d)){this.lastKeyDownEvent=a;d=[];d.ctrlKey=a.ctrlKey;d.shiftKey=a.shiftKey;d.altKey=a.altKey;d.metaKey=a.metaKey;if(b){d.charCode=a.keyCode;d.keyCode=0}else{d.charCode=0;d.keyCode=a.keyCode;if(!c&&a.shiftKey)d=this.fixEvent(d)}this.handleKey(d);this.lastNormalKeyDownEvent=undefined;try{a.stopPropagation();a.preventDefault()}catch(g){}try{a.cancelBubble=
true;a.returnValue=false;a.keyCode=0}catch(j){}return false}return true};VT100.prototype.keyPressed=function(a){if(this.lastKeyDownEvent)this.lastKeyDownEvent=undefined;else this.handleKey(a.altKey||a.metaKey?this.fixEvent(a):a);try{a.preventDefault()}catch(b){}try{a.cancelBubble=true;a.returnValue=false;a.keyCode=0}catch(c){}this.lastNormalKeyDownEvent=undefined;this.lastKeyPressedEvent=a;return false};
VT100.prototype.keyUp=function(a){if(this.lastKeyPressedEvent)(a.target||a.srcElement).value="";else{this.checkComposedKeys(a);if(this.lastNormalKeyDownEvent){this.catchModifiersEarly=true;var b=a.keyCode==32||a.keyCode>=48&&a.keyCode<=57||a.keyCode>=65&&a.keyCode<=90,c=b||a.keyCode>=96&&a.keyCode<=105,d=[];d.ctrlKey=a.ctrlKey;d.shiftKey=a.shiftKey;d.altKey=a.altKey;d.metaKey=a.metaKey;if(b){d.charCode=a.keyCode;d.keyCode=0}else{d.charCode=0;d.keyCode=a.keyCode;if(!c&&(a.ctrlKey||a.altKey||a.metaKey))d=
this.fixEvent(d)}this.lastNormalKeyDownEvent=undefined;this.handleKey(d)}}try{a.cancelBubble=true;a.returnValue=false;a.keyCode=0}catch(e){}this.lastKeyPressedEvent=this.lastKeyDownEvent=undefined;return false};
VT100.prototype.animateCursor=function(a){if(!this.cursorInterval)this.cursorInterval=setInterval(function(b){return function(){b.animateCursor();b.checkComposedKeys()}}(this),500);if(a!=undefined||this.cursor.className!="inactive")this.cursor.className=a?"inactive":this.cursor.className=="bright"?"dim":"bright"};VT100.prototype.blurCursor=function(){this.animateCursor(true)};VT100.prototype.focusCursor=function(){this.animateCursor(false)};
VT100.prototype.flashScreen=function(){this.isInverted=!this.isInverted;this.refreshInvertedState();this.isInverted=!this.isInverted;setTimeout(function(a){return function(){a.refreshInvertedState()}}(this),100)};VT100.prototype.beep=function(){if(this.visualBell)this.flashScreen();else try{this.beeper.Play()}catch(a){try{this.beeper.src="beep.wav"}catch(b){}}};VT100.prototype.bs=function(){if(this.cursorX>0){this.gotoXY(this.cursorX-1,this.cursorY);this.needWrap=false}};
VT100.prototype.ht=function(a){if(a==undefined)a=1;for(var b=this.cursorX;a-- >0;)for(;b++<this.terminalWidth;){var c=this.userTabStop[b];if(c!=false)if(c)break;else if(b%8==0)break}if(b>this.terminalWidth-1)b=this.terminalWidth-1;b!=this.cursorX&&this.gotoXY(b,this.cursorY)};VT100.prototype.rt=function(a){if(a==undefined)a=1;for(var b=this.cursorX;a-- >0;)for(;b-- >0;){var c=this.userTabStop[b];if(c!=false)if(c)break;else if(b%8==0)break}if(b<0)b=0;b!=this.cursorX&&this.gotoXY(b,this.cursorY)};
VT100.prototype.cr=function(){this.gotoXY(0,this.cursorY);this.needWrap=false};VT100.prototype.lf=function(a){if(a==undefined)a=1;else{if(a>this.terminalHeight)a=this.terminalHeight;if(a<1)a=1}for(;a-- >0;)if(this.cursorY==this.bottom-1){this.scrollRegion(0,this.top+1,this.terminalWidth,this.bottom-this.top-1,0,-1,this.color,this.style);offset=undefined}else this.cursorY<this.terminalHeight-1&&this.gotoXY(this.cursorX,this.cursorY+1)};
VT100.prototype.ri=function(a){if(a==undefined)a=1;else{if(a>this.terminalHeight)a=this.terminalHeight;if(a<1)a=1}for(;a-- >0;)if(this.cursorY==this.top)this.scrollRegion(0,this.top,this.terminalWidth,this.bottom-this.top-1,0,1,this.color,this.style);else this.cursorY>0&&this.gotoXY(this.cursorX,this.cursorY-1);this.needWrap=false};VT100.prototype.respondID=function(){this.respondString+="\u001b[?6c"};VT100.prototype.respondSecondaryDA=function(){this.respondString+="\u001b[>0;0;0c"};
VT100.prototype.updateStyle=function(){this.style="";if(this.attr&512)this.style="text-decoration:underline;";var a=this.attr>>4&15,b=this.attr&15;if(this.attr&256){var c=a;a=b;b=c}if((this.attr&1280)==1024)b=8;else if(this.attr&2048)b|=8;if(this.attr&4096)a^=8;if(a==b)if((b^=8)==7)b=8;if(a==7&&b>=8)if((b-=8)==7)b=8;this.color="ansi"+b+" bgAnsi"+a};VT100.prototype.setAttrColors=function(a){if(a!=this.attr){this.attr=a;this.updateStyle()}};
VT100.prototype.saveCursor=function(){this.savedX[this.currentScreen]=this.cursorX;this.savedY[this.currentScreen]=this.cursorY;this.savedAttr[this.currentScreen]=this.attr;this.savedUseGMap=this.useGMap;for(var a=0;a<4;a++)this.savedGMap[a]=this.GMap[a];this.savedValid[this.currentScreen]=true};
VT100.prototype.restoreCursor=function(){if(this.savedValid[this.currentScreen]){this.attr=this.savedAttr[this.currentScreen];this.updateStyle();this.useGMap=this.savedUseGMap;for(var a=0;a<4;a++)this.GMap[a]=this.savedGMap[a];this.translate=this.GMap[this.useGMap];this.needWrap=false;this.gotoXY(this.savedX[this.currentScreen],this.savedY[this.currentScreen])}};
VT100.prototype.setMode=function(a){for(var b=0;b<=this.npar;b++)if(this.isQuestionMark)switch(this.par[b]){case 1:this.cursorKeyMode=a;break;case 3:break;case 5:this.isInverted=a;this.refreshInvertedState();break;case 6:this.offsetMode=a;break;case 7:this.autoWrapMode=a;break;case 1E3:case 9:this.mouseReporting=a;break;case 25:(this.cursorNeedsShowing=a)?this.showCursor():this.hideCursor();break;case 1047:case 1049:case 47:this.enableAlternateScreen(a);break;default:break}else switch(this.par[b]){case 3:this.dispCtrl=
a;break;case 4:this.insertMode=a;break;case 20:this.crLfMode=a;break;default:break}};VT100.prototype.statusReport=function(){this.respondString+="\u001b[0n"};VT100.prototype.cursorReport=function(){this.respondString+="\u001b["+(this.cursorY+(this.offsetMode?this.top+1:1))+";"+(this.cursorX+1)+"R"};VT100.prototype.setCursorAttr=function(){};
VT100.prototype.openPrinterWindow=function(){var a=true;try{if(!this.printWin||this.printWin.closed){this.printWin=window.open("","print-output","width=800,height=600,directories=no,location=no,menubar=yes,status=no,toolbar=no,titlebar=yes,scrollbars=yes,resizable=yes");this.printWin.document.body.innerHTML='<link rel="stylesheet" href="'+document.location.protocol+"//"+document.location.host+document.location.pathname.replace(/[^/]*$/,"")+'print-styles.css" type="text/css">\n<div id="options"><input id="autoprint" type="checkbox"'+
(this.autoprint?" checked":"")+'>Automatically, print page(s) when job is ready</input></div>\n<div id="spacer"><input type="checkbox">&nbsp;</input></div><pre id="print"></pre>\n';var b=this.printWin.document.getElementById("autoprint");this.addListener(b,"click",function(d,e){return function(){d.autoprint=e.checked;d.storeUserSettings();return false}}(this,b));this.printWin.document.title="ShellInABox Printer Output"}}catch(c){a=false}a&=this.printWin&&!this.printWin.closed&&(this.printWin.innerWidth||
this.printWin.document.documentElement.clientWidth||this.printWin.document.body.clientWidth)>1;if(!a&&this.printing==100){this.printing=true;setTimeout(function(d){return function(){if(!d||d.closed||(d.innerWidth||d.document.documentElement.clientWidth||d.document.body.clientWidth)<=1)alert("Attempted to print, but a popup blocker prevented the printer window from opening")}}(this.printWin),2E3)}return a};
VT100.prototype.sendToPrinter=function(a){this.openPrinterWindow();try{var b=this.printWin.document,c=b.getElementById("print");if(c.lastChild&&c.lastChild.nodeName=="#text")c.lastChild.textContent+=this.replaceChar(a," ","\u00a0");else c.appendChild(b.createTextNode(this.replaceChar(a," ","\u00a0")))}catch(d){}};
VT100.prototype.sendControlToPrinter=function(a){try{switch(a){case 9:this.openPrinterWindow();var b=this.printWin.document.getElementById("print");this.sendToPrinter(this.spaces(8-(b.lastChild&&b.lastChild.nodeName=="#text"?b.lastChild.textContent.length:0)%8));break;case 10:break;case 12:this.openPrinterWindow();var c=this.printWin.document.createElement("div");c.className="pagebreak";c.innerHTML="<hr />";this.printWin.document.getElementById("print").appendChild(c);break;case 13:this.openPrinterWindow();
var d=this.printWin.document.createElement("br");this.printWin.document.getElementById("print").appendChild(d);break;case 27:this.isEsc=1;break;default:switch(this.isEsc){case 1:this.isEsc=0;switch(a){case 91:this.isEsc=2;break;default:break}break;case 2:this.npar=0;this.par=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];this.isEsc=3;if(this.isQuestionMark=a==63)break;case 3:if(a==59){this.npar++;break}else if(a>=48&&a<=57){var e=this.par[this.npar];if(e==undefined)e=0;this.par[this.npar]=10*e+(a&15);break}else this.isEsc=
4;case 4:this.isEsc=0;if(this.isQuestionMark)break;switch(a){case 105:this.csii(this.par[0]);break;default:break}break;default:this.isEsc=0;break}break}}catch(g){}};VT100.prototype.csiAt=function(a){if(a==0)a=1;if(a>this.terminalWidth-this.cursorX)a=this.terminalWidth-this.cursorX;this.scrollRegion(this.cursorX,this.cursorY,this.terminalWidth-this.cursorX-a,1,a,0,this.color,this.style);this.needWrap=false};
VT100.prototype.csii=function(a){switch(a){case 0:window.print();break;case 4:try{if(this.printing&&this.printWin&&!this.printWin.closed){for(var b=this.printWin.document.getElementById("print");b.lastChild&&b.lastChild.tagName=="DIV"&&b.lastChild.className=="pagebreak";)b.removeChild(b.lastChild);this.autoprint&&this.printWin.print()}}catch(c){}this.printing=false;break;case 5:if(!this.printing&&this.printWin&&!this.printWin.closed)this.printWin.document.getElementById("print").innerHTML="";this.printing=
100;break;default:break}};
VT100.prototype.csiJ=function(a){switch(a){case 0:this.clearRegion(this.cursorX,this.cursorY,this.terminalWidth-this.cursorX,1,this.color,this.style);this.cursorY<this.terminalHeight-2&&this.clearRegion(0,this.cursorY+1,this.terminalWidth,this.terminalHeight-this.cursorY-1,this.color,this.style);break;case 1:this.cursorY>0&&this.clearRegion(0,0,this.terminalWidth,this.cursorY,this.color,this.style);this.clearRegion(0,this.cursorY,this.cursorX+1,1,this.color,this.style);break;case 2:this.clearRegion(0,
0,this.terminalWidth,this.terminalHeight,this.color,this.style);break;default:return}needWrap=false};VT100.prototype.csiK=function(a){switch(a){case 0:this.clearRegion(this.cursorX,this.cursorY,this.terminalWidth-this.cursorX,1,this.color,this.style);break;case 1:this.clearRegion(0,this.cursorY,this.cursorX+1,1,this.color,this.style);break;case 2:this.clearRegion(0,this.cursorY,this.terminalWidth,1,this.color,this.style);break;default:return}needWrap=false};
VT100.prototype.csiL=function(a){if(!(this.cursorY>=this.bottom)){if(a==0)a=1;if(a>this.bottom-this.cursorY)a=this.bottom-this.cursorY;this.scrollRegion(0,this.cursorY,this.terminalWidth,this.bottom-this.cursorY-a,0,a,this.color,this.style);needWrap=false}};
VT100.prototype.csiM=function(a){if(!(this.cursorY>=this.bottom)){if(a==0)a=1;if(a>this.bottom-this.cursorY)a=bottom-cursorY;this.scrollRegion(0,this.cursorY+a,this.terminalWidth,this.bottom-this.cursorY-a,0,-a,this.color,this.style);needWrap=false}};
VT100.prototype.csim=function(){for(var a=0;a<=this.npar;a++)switch(this.par[a]){case 0:this.attr=240;break;case 1:this.attr=this.attr&-1025|2048;break;case 2:this.attr=this.attr&-2049|1024;break;case 4:this.attr|=512;break;case 5:this.attr|=4096;break;case 7:this.attr|=256;break;case 10:this.translate=this.GMap[this.useGMap];this.toggleMeta=this.dispCtrl=false;break;case 11:this.translate=this.CodePage437Map;this.dispCtrl=true;this.toggleMeta=false;break;case 12:this.translate=this.CodePage437Map;
this.toggleMeta=this.dispCtrl=true;break;case 21:case 22:this.attr&=-3073;break;case 24:this.attr&=-513;break;case 25:this.attr&=-4097;break;case 27:this.attr&=-257;break;case 38:this.attr=this.attr&-3088|512;break;case 39:this.attr&=-3600;break;case 49:this.attr|=240;break;default:if(this.par[a]>=30&&this.par[a]<=37)this.attr=this.attr&-16|this.par[a]-30;else if(this.par[a]>=40&&this.par[a]<=47)this.attr=this.attr&-241|this.par[a]-40<<4;break}this.updateStyle()};
VT100.prototype.csiP=function(a){if(a==0)a=1;if(a>this.terminalWidth-this.cursorX)a=this.terminalWidth-this.cursorX;this.scrollRegion(this.cursorX+a,this.cursorY,this.terminalWidth-this.cursorX-a,1,-a,0,this.color,this.style);needWrap=false};VT100.prototype.csiX=function(a){a==0&&a++;if(a>this.terminalWidth-this.cursorX)a=this.terminalWidth-this.cursorX;this.clearRegion(this.cursorX,this.cursorY,a,1,this.color,this.style);needWrap=false};VT100.prototype.settermCommand=function(){};
VT100.prototype.doControl=function(a){if(this.printing){this.sendControlToPrinter(a);return""}var b="";switch(a){case 0:break;case 8:this.bs();break;case 9:this.ht();break;case 10:case 11:case 12:case 132:this.lf();if(!this.crLfMode)break;case 13:this.cr();break;case 133:this.cr();this.lf();break;case 14:this.useGMap=1;this.translate=this.GMap[1];this.dispCtrl=true;break;case 15:this.useGMap=0;this.translate=this.GMap[0];this.dispCtrl=false;break;case 24:case 26:this.isEsc=0;break;case 27:this.isEsc=
1;break;case 127:break;case 136:this.userTabStop[this.cursorX]=true;break;case 141:this.ri();break;case 142:this.isEsc=18;break;case 143:this.isEsc=19;break;case 154:this.respondID();break;case 155:this.isEsc=2;break;case 7:if(this.isEsc!=17){this.beep();break}default:switch(this.isEsc){case 1:this.isEsc=0;switch(a){case 37:this.isEsc=13;break;case 40:this.isEsc=8;break;case 45:case 41:this.isEsc=9;break;case 46:case 42:this.isEsc=10;break;case 47:case 43:this.isEsc=11;break;case 35:this.isEsc=7;
break;case 55:this.saveCursor();break;case 56:this.restoreCursor();break;case 62:this.applKeyMode=false;break;case 61:this.applKeyMode=true;break;case 68:this.lf();break;case 69:this.cr();this.lf();break;case 77:this.ri();break;case 78:this.isEsc=18;break;case 79:this.isEsc=19;break;case 72:this.userTabStop[this.cursorX]=true;break;case 90:this.respondID();break;case 91:this.isEsc=2;break;case 93:this.isEsc=15;break;case 99:this.reset();break;case 103:this.flashScreen();break;default:break}break;
case 15:switch(a){case 48:case 49:case 50:this.statusString="";this.isEsc=17;break;case 80:this.npar=0;this.par=[0,0,0,0,0,0,0];this.isEsc=16;break;case 82:this.isEsc=0;break;default:this.isEsc=0;break}break;case 16:if(a>=48&&a<=57||a>=65&&a<=70||a>=97&&a<=102){this.par[this.npar++]=a>57?(a&223)-55:a&15;if(this.npar==7)this.isEsc=0}else this.isEsc=0;break;case 2:this.npar=0;this.par=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];this.isEsc=3;if(a==91){this.isEsc=6;break}else if(this.isQuestionMark=a==63)break;
case 5:case 3:if(a==59){this.npar++;break}else if(a>=48&&a<=57){var c=this.par[this.npar];if(c==undefined)c=0;this.par[this.npar]=10*c+(a&15);break}else if(this.isEsc==5){switch(a){case 99:this.par[0]==0&&this.respondSecondaryDA();break;case 109:break;case 110:break;case 112:break;default:break}this.isEsc=0;break}else this.isEsc=4;case 4:this.isEsc=0;if(this.isQuestionMark){switch(a){case 104:this.setMode(true);break;case 108:this.setMode(false);break;case 99:this.setCursorAttr(this.par[2],this.par[1]);
break;default:break}this.isQuestionMark=false;break}switch(a){case 33:this.isEsc=12;break;case 62:if(!this.npar)this.isEsc=5;break;case 71:case 96:this.gotoXY(this.par[0]-1,this.cursorY);break;case 65:this.gotoXY(this.cursorX,this.cursorY-(this.par[0]?this.par[0]:1));break;case 66:case 101:this.gotoXY(this.cursorX,this.cursorY+(this.par[0]?this.par[0]:1));break;case 67:case 97:this.gotoXY(this.cursorX+(this.par[0]?this.par[0]:1),this.cursorY);break;case 68:this.gotoXY(this.cursorX-(this.par[0]?this.par[0]:
1),this.cursorY);break;case 69:this.gotoXY(0,this.cursorY+(this.par[0]?this.par[0]:1));break;case 70:this.gotoXY(0,this.cursorY-(this.par[0]?this.par[0]:1));break;case 100:this.gotoXaY(this.cursorX,this.par[0]-1);break;case 72:case 102:this.gotoXaY(this.par[1]-1,this.par[0]-1);break;case 73:this.ht(this.par[0]?this.par[0]:1);break;case 64:this.csiAt(this.par[0]);break;case 105:this.csii(this.par[0]);break;case 74:this.csiJ(this.par[0]);break;case 75:this.csiK(this.par[0]);break;case 76:this.csiL(this.par[0]);
break;case 77:this.csiM(this.par[0]);break;case 109:this.csim();break;case 80:this.csiP(this.par[0]);break;case 88:this.csiX(this.par[0]);break;case 83:this.lf(this.par[0]?this.par[0]:1);break;case 84:this.ri(this.par[0]?this.par[0]:1);break;case 99:this.par[0]||this.respondID();break;case 103:if(this.par[0]==0)this.userTabStop[this.cursorX]=false;else if(this.par[0]==2||this.par[0]==3){this.userTabStop=[];for(a=0;a<this.terminalWidth;a++)this.userTabStop[a]=false}break;case 104:this.setMode(true);
break;case 108:this.setMode(false);break;case 110:switch(this.par[0]){case 5:this.statusReport();break;case 6:this.cursorReport();break;default:break}break;case 113:break;case 114:a=this.par[0]?this.par[0]:1;c=this.par[1]?this.par[1]:this.terminalHeight;if(a<c&&c<=this.terminalHeight){this.top=a-1;this.bottom=c;this.gotoXaY(0,0)}break;case 98:a=this.par[0]?this.par[0]:1;if(a>this.terminalWidth*this.terminalHeight)a=this.terminalWidth*this.terminalHeight;for(;a-- >0;)b+=this.lastCharacter;break;case 115:this.saveCursor();
break;case 117:this.restoreCursor();break;case 90:this.rt(this.par[0]?this.par[0]:1);break;case 93:this.settermCommand();break;default:break}break;case 12:a=="p"&&this.reset();this.isEsc=0;break;case 13:this.isEsc=0;switch(a){case 64:this.utfEnabled=false;break;case 71:case 56:this.utfEnabled=true;break;default:break}break;case 6:this.isEsc=0;break;case 7:this.isEsc=0;break;case 8:case 9:case 10:case 11:c=this.isEsc-8;this.isEsc=0;switch(a){case 48:this.GMap[c]=this.VT100GraphicsMap;break;case 66:case 66:this.GMap[c]=
this.Latin1Map;break;case 85:this.GMap[c]=this.CodePage437Map;break;case 75:this.GMap[c]=this.DirectToFontMap;break;default:break}if(this.useGMap==c)this.translate=this.GMap[c];break;case 17:if(a==7){if(this.statusString&&this.statusString.charAt(0)==";")this.statusString=this.statusString.substr(1);try{window.status=this.statusString}catch(d){}this.isEsc=0}else this.statusString+=String.fromCharCode(a);break;case 18:case 19:if(a<256){a=this.GMap[this.isEsc-18+2][this.toggleMeta?a|128:a];if((a&65280)==
61440)a&=255;else if(a==65279||a>=8202&&a<=8207){this.isEsc=0;break}}this.lastCharacter=String.fromCharCode(a);b+=this.lastCharacter;this.isEsc=0;break;default:this.isEsc=0;break}break}return b};
VT100.prototype.renderString=function(a,b){if(this.printing){this.sendToPrinter(a);b&&this.showCursor()}else{var c=a.length;if(c>this.terminalWidth-this.cursorX){c=this.terminalWidth-this.cursorX;if(c<=0)return;a=a.substr(0,c-1)+a.charAt(a.length-1)}if(b)this.cursor.style.visibility="";this.putString(this.cursorX,this.cursorY,a,this.color,this.style)}};
VT100.prototype.vt100=function(a){this.cursorNeedsShowing=this.hideCursor();for(var b=this.respondString="",c=0;c<a.length;c++){var d=a.charCodeAt(c);if(this.utfEnabled)if(d>127)if(this.utfCount>0&&(d&192)==128){this.utfChar=this.utfChar<<6|d&63;if(--this.utfCount<=0)d=this.utfChar>65535||this.utfChar<0?65533:this.utfChar;else continue}else{if((d&224)==192){this.utfCount=1;this.utfChar=d&31}else if((d&240)==224){this.utfCount=2;this.utfChar=d&15}else if((d&248)==240){this.utfCount=3;this.utfChar=
d&7}else if((d&252)==248){this.utfCount=4;this.utfChar=d&3}else if((d&254)==252){this.utfCount=5;this.utfChar=d&1}else this.utfCount=0;continue}else this.utfCount=0;if((d>=32&&d<=127||d>=160||this.utfEnabled&&d>=128||!(this.dispCtrl?this.ctrlAlways:this.ctrlAction)[d&31])&&(d!=127||this.dispCtrl)&&this.isEsc==0){if(d<256)d=this.translate[this.toggleMeta?d|128:d];if((d&65280)==61440)d&=255;else if(d==65279||d>=8202&&d<=8207)continue;if(!this.printing){if(this.needWrap||this.insertMode)if(b){this.renderString(b);
b=""}if(this.needWrap){this.cr();this.lf()}this.insertMode&&this.scrollRegion(this.cursorX,this.cursorY,this.terminalWidth-this.cursorX-1,1,1,0,this.color,this.style)}this.lastCharacter=String.fromCharCode(d);b+=this.lastCharacter;if(!this.printing&&this.cursorX+b.length>=this.terminalWidth)this.needWrap=this.autoWrapMode}else{if(b){this.renderString(b);b=""}d=this.doControl(d);if(d.length)this.respondString+=this.vt100(d)}}if(b)this.renderString(b,this.cursorNeedsShowing);else this.cursorNeedsShowing&&
this.showCursor();return this.respondString};
VT100.prototype.Latin1Map=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,
146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255];
VT100.prototype.VT100GraphicsMap=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,8594,8592,8593,8595,47,9608,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,160,9670,9618,9225,9228,9229,9226,176,177,9617,9227,9496,9488,9484,9492,9532,63488,63489,9472,63491,63492,9500,9508,9524,9516,9474,8804,8805,960,8800,163,183,127,128,129,130,131,132,
133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255];
VT100.prototype.CodePage437Map=[0,9786,9787,9829,9830,9827,9824,8226,9688,9675,9689,9794,9792,9834,9835,9788,9654,9664,8597,8252,182,167,9644,8616,8593,8595,8594,8592,8735,8596,9650,9660,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,8962,
199,252,233,226,228,224,229,231,234,235,232,239,238,236,196,197,201,230,198,244,246,242,251,249,255,214,220,162,163,165,8359,402,225,237,243,250,241,209,170,186,191,8976,172,189,188,161,171,187,9617,9618,9619,9474,9508,9569,9570,9558,9557,9571,9553,9559,9565,9564,9563,9488,9492,9524,9516,9500,9472,9532,9566,9567,9562,9556,9577,9574,9568,9552,9580,9575,9576,9572,9573,9561,9560,9554,9555,9579,9578,9496,9484,9608,9604,9612,9616,9600,945,223,915,960,931,963,181,964,934,920,937,948,8734,966,949,8745,8801,
177,8805,8804,8992,8993,247,8776,176,8729,183,8730,8319,178,9632,160];
VT100.prototype.DirectToFontMap=[61440,61441,61442,61443,61444,61445,61446,61447,61448,61449,61450,61451,61452,61453,61454,61455,61456,61457,61458,61459,61460,61461,61462,61463,61464,61465,61466,61467,61468,61469,61470,61471,61472,61473,61474,61475,61476,61477,61478,61479,61480,61481,61482,61483,61484,61485,61486,61487,61488,61489,61490,61491,61492,61493,61494,61495,61496,61497,61498,61499,61500,61501,61502,61503,61504,61505,61506,61507,61508,61509,61510,61511,61512,61513,61514,61515,61516,61517,
61518,61519,61520,61521,61522,61523,61524,61525,61526,61527,61528,61529,61530,61531,61532,61533,61534,61535,61536,61537,61538,61539,61540,61541,61542,61543,61544,61545,61546,61547,61548,61549,61550,61551,61552,61553,61554,61555,61556,61557,61558,61559,61560,61561,61562,61563,61564,61565,61566,61567,61568,61569,61570,61571,61572,61573,61574,61575,61576,61577,61578,61579,61580,61581,61582,61583,61584,61585,61586,61587,61588,61589,61590,61591,61592,61593,61594,61595,61596,61597,61598,61599,61600,61601,
61602,61603,61604,61605,61606,61607,61608,61609,61610,61611,61612,61613,61614,61615,61616,61617,61618,61619,61620,61621,61622,61623,61624,61625,61626,61627,61628,61629,61630,61631,61632,61633,61634,61635,61636,61637,61638,61639,61640,61641,61642,61643,61644,61645,61646,61647,61648,61649,61650,61651,61652,61653,61654,61655,61656,61657,61658,61659,61660,61661,61662,61663,61664,61665,61666,61667,61668,61669,61670,61671,61672,61673,61674,61675,61676,61677,61678,61679,61680,61681,61682,61683,61684,61685,
61686,61687,61688,61689,61690,61691,61692,61693,61694,61695];VT100.prototype.ctrlAction=[true,false,false,false,false,false,false,true,true,true,true,true,true,true,true,true,false,false,false,false,false,false,false,false,true,false,true,true,false,false,false,false];VT100.prototype.ctrlAlways=[true,false,false,false,false,false,false,false,true,false,true,false,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,true,false,false,false,false];
