From 3345f4973f8269bdabdc5943d2f3241a3728fc33 Mon Sep 17 00:00:00 2001 From: Yusen Date: Wed, 13 Jan 2016 21:55:51 +0800 Subject: [PATCH] Fix: right-click menu problem on windows, focus change parent scrollTop --- build/sh.js | 15 ++++++++------- build/sh.min.js | 4 ++-- public/style.css | 3 +-- src/index.js | 13 ++++++------- 4 files changed, 17 insertions(+), 18 deletions(-) diff --git a/build/sh.js b/build/sh.js index 3b2a755..21cf2ef 100644 --- a/build/sh.js +++ b/build/sh.js @@ -422,18 +422,17 @@ Terminal.prototype.open = function (parent) { button = button === 1 ? 0 : button === 4 ? 1 : button; } - // If user select text - if (utils.getSelection()) return; - // Not right button - if (button !== 2) return that.focus(); + if (button !== 2) return; that.element.contentEditable = true; - that.element.focus(); setTimeout(function() { - that.inputElement.focus(); that.element.contentEditable = 'inherit'; // 'false'; - }, 1); + var selection = utils.getSelection(); + // If user doesn't select text or ignore one space selection on mac + if (!selection || (Terminal.isMac && selection === ' ')) + that.inputElement.focus(); + }, Terminal.isMac ? 1 : 400); }, !0); events.on(this.inputElement, "paste", function (c) { setTimeout(function () { @@ -475,6 +474,8 @@ Terminal.prototype.sizeToFit = function () { c.parentNode.removeChild(c); a.parentNode.removeChild(a); + + console.log('sizeToFit:', v, k) this.resize(v, k) }; diff --git a/build/sh.min.js b/build/sh.min.js index 13e6a41..268e6da 100644 --- a/build/sh.min.js +++ b/build/sh.min.js @@ -1,2 +1,2 @@ -!function(e){if("object"==typeof exports)module.exports=e();else if("function"==typeof define&&define.amd)define(e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.Terminal=e()}}(function(){return function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a="function"==typeof require&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}for(var i="function"==typeof require&&require,o=0;ov;v++)k[v].apply(this,c)},EventEmitter.prototype.listeners=function(a){return this._events[a]=this._events[a]||[]},module.exports={EventEmitter:EventEmitter,on:on,off:off,cancel:cancel}},{}],3:[function(_dereq_,module){function Terminal(cols,rows){events.EventEmitter.call(this);var f;"object"==typeof cols&&(f=cols,cols=f.cols,rows=f.rows),this._options=f||{},this.cols=cols||Terminal.geometry[0],this.rows=rows||Terminal.geometry[1];var theme=this._options.theme;("string"==typeof theme||theme instanceof String)&&(theme=themes.defaults[theme]),theme||(theme=themes.defaults["default"]),this.colors=themes.colors(theme),this.resetState(cols,rows)}var events=_dereq_("./events"),utils=_dereq_("./utils"),themes=_dereq_("./themes"),charsets=_dereq_("./charsets"),s=1;utils.inherits(Terminal,events.EventEmitter),Terminal.termName="xterm",Terminal.geometry=[80,24],Terminal.visualBell=!1,Terminal.popOnBell=!1,Terminal.scrollback=1e3,Terminal.screenKeys=!1,Terminal.programFeatures=!1,Terminal.debug=!1,Terminal.focus=null,Terminal.prototype.resetState=function(){this.cursorState=this.y=this.x=this.ydisp=this.ybase=0,this.convertEol=this.cursorHidden=!1,this.state=0,this.queue="",this.writeQueue="",this.scrollTop=0,this.scrollBottom=this.rows-1,this.wraparoundMode=this.insertMode=this.originMode=this.applicationCursor=this.applicationKeypad=!1,this.normal=null,this.virtualAltKey=this.virtualCtrlKey=this.selectionMode=!1,this.gcharset=this.charset=null,this.glevel=0,this.charsets=[null],this.decLocator,this.x10Mouse,this.vt200Mouse,this.vt300Mouse,this.normalMouse,this.mouseEvents,this.sendFocus,this.utfMouse,this.sgrMouse,this.urxvtMouse,this.element,this.children,this.refreshStart,this.refreshEnd,this.savedX,this.savedY,this.savedCols,this.writable=this.readable=!0,this.curAttr=this.defAttr=131840,this.params=[],this.currentParam=0,this.postfix=this.prefix="",this.lines=[];for(var i=this.rows;i--;)this.lines.push(this.blankLine());this.tabs,this.setupStops()},Terminal.prototype.focus=function(){Terminal.focus&&Terminal.focus!==this&&Terminal.focus.blur(),Terminal.focus=this,this.sendFocus&&this.send(""),this.showCursor(),this.inputElement.focus()},Terminal.prototype.blur=function(){Terminal.focus===this&&(Terminal.focus=null,this.redrawCursor(),this.sendFocus&&this.send(""),this.inputElement.blur())},Terminal.prototype.toggleVirtualCtrlKey=function(){this.virtualCtrlKey=!this.virtualCtrlKey,this.ctrlKeyElement.className=this.virtualCtrlKey?"active":""},Terminal.prototype.toggleVirtualAltKey=function(){this.virtualAltKey=!this.virtualAltKey,this.altKeyElement.className=this.virtualAltKey?"active":""},Terminal.prototype.applyVirtualKey=function(a){if(!this.virtualCtrlKey&&!this.virtualAltKey)return a;var c={altGraphKey:a.altGraphKey,altKey:a.altKey,charCode:a.charCode,ctrlKey:a.ctrlKey,keyCode:a.keyCode,metKey:a.metaKey,shiftKey:a.shiftKey,type:a.type,which:a.which,preventDefault:function(){a.preventDefault&&a.preventDefault()},stopPropagation:function(){a.stopPropagation&&a.stopPropagation()}};return this.virtualCtrlKey&&(c.ctrlKey=!0,this.toggleVirtualCtrlKey()),this.virtualAltKey&&(c.altKey=!0,this.toggleVirtualAltKey()),c},Terminal.prototype.bindKeys=function(){if(Terminal.focus!=this){var that=this;events.on(this.tabKeyElement,"touchend",function(){that.keyDown({keyCode:9})},!0),events.on(this.ctrlKeyElement,"touchend",function(){that.toggleVirtualCtrlKey()},!0),events.on(this.altKeyElement,"touchend",function(){that.toggleVirtualAltKey()},!0),events.on(this.escKeyElement,"touchend",function(){that.keyDown({keyCode:27})},!0),events.on(this.leftKeyElement,"touchend",function(){that.keyDown({keyCode:37})},!0),events.on(this.downKeyElement,"touchend",function(){that.keyDown({keyCode:40})},!0),events.on(this.upKeyElement,"touchend",function(){that.keyDown({keyCode:38})},!0),events.on(this.rightKeyElement,"touchend",function(){that.keyDown({keyCode:39})},!0);for(var v=0,y=[this.tabKeyElement,this.ctrlKeyElement,this.altKeyElement,this.escKeyElement,this.leftKeyElement,this.downKeyElement,this.upKeyElement,this.rightKeyElement,this.screenKeysElement];v=c.keyCode&&-1===[91,92,93,144,145].indexOf(c.keyCode)&&that.inputElement.focus(),!Terminal.isMac&&k&&c.shiftKey&&document.execCommand&&(document.execCommand("copy",!0,null),events.cancel(c))})}},Terminal.prototype.open=function(parent){var y,that=this,E=0;for(this.element=document.createElement("div"),this.element.className="terminal",this.element.spellcheck=!1,this.children=[];Ev&&(c.innerHTML+="W",!(c.offsetWidth>k));v++);for(c.innerHTML="W",k=1;maxH>k&&(c.innerHTML+="
W",!(c.offsetHeight>f));k++);c.parentNode.removeChild(c),a.parentNode.removeChild(a),this.resize(v,k)}},Terminal.prototype.bindMouse=function(){function a(a){var c,k,p,y;switch(a.type){case"mousedown":c=null!=a.button?+a.button:null!=a.which?a.which-1:null,~navigator.userAgent.indexOf("MSIE")&&(c=1===c?0:4===c?1:c);break;case"mouseup":c=3;break;case"DOMMouseScroll":c=0>a.detail?64:65;break;case"mousewheel":c=0c?a.push(c):(c>2046&&(c=2046),a.push(192|c>>6),a.push(128|63&c)):(c>254&&(c=254),a.push(c))}function f(a,c){if(s.vt300Mouse){a&=3,c.x-=32,c.y-=32;var f="[24";if(0===a)f+="1";else if(1===a)f+="3";else if(2===a)f+="5";else{if(3===a)return;f+="0"}f+="~["+c.x+","+c.y+"]\r",s.send(f)}else s.decLocator?(a&=3,c.x-=32,c.y-=32,0===a?a=2:1===a?a=4:2===a?a=6:3===a&&(a=3),s.send("["+a+";"+(3===a?4:0)+";"+c.y+";"+c.x+";"+(c.page||0)+"&w")):s.urxvtMouse?(c.x-=32,c.y-=32,s.send("["+a+";"+c.x+";"+c.y+"M")):s.sgrMouse?(c.x-=32,c.y-=32,s.send("[<"+(3===(3&a)?-4&a:a)+";"+c.x+";"+c.y+(3===(3&a)?"m":"M"))):(f=[],y(f,a),y(f,c.x),y(f,c.y),s.send(""+String.fromCharCode.apply(String,f)))}function u(a){if(null!=a.pageX){for(var c=a.pageX,f=a.target;"terminal-row"!==f.className;)if(f=f.parentNode,null==f)return;for(var k=f;k!==document.documentElement;)c-=k.offsetLeft,k=k.parentNode;return c=Math.ceil(c/f.offsetWidth*s.cols),f=parseInt(f.getAttribute("data-row")||1,10),1>c&&(c=1),1>f&&(f=1),c>s.cols&&(c=s.cols),f>s.rows&&(f=s.rows),{x:c+32,y:f+32,down:"mousedown"===a.type,up:"mouseup"===a.type,wheel:a.type===p,move:"mousemove"===a.type}}}var q=this.element,s=this,F=32,p="onmousewheel"in window?"mousewheel":"DOMMouseScroll";events.on(q,"mousedown",function(f){if(s.mouseEvents){if(a(f),s.selectionMode||s.focus(),s.vt200Mouse)return a({__proto__:f,type:"mouseup"}),events.cancel(f);if(s.normalMouse&&events.on(document,"mousemove",c),!s.x10Mouse){var p=function(f){return a(f),events.off(document,"mousemove",c),events.off(document,"mouseup",p),events.off(document,"mousedown",p),cancel(f)};events.on(document,"mouseup",p),events.on(document,"mousedown",p)}return events.cancel(f)}}),events.on(q,"mouseup",function(){window.getSelection&&0a.detail?-5:5:0=this.rows/2&&(H=this.element.parentNode)&&H.removeChild(this.element),p=this.cols,f=a;k>=f;f++){for(y=f+this.ydisp,z=this.lines[y],s="",y=f===this.y&&this.cursorState&&this.ydisp===this.ybase&&!this.cursorHidden?this.x:-1,x=this.defAttr,v=0;p>v;v++){switch(q=z[v][0],u=z[v][1],v===y&&(t=q,q=-1),q!==x&&(x!==this.defAttr&&(s+=""),q!==this.defAttr&&(s+=">9&511,x=511&t):(F=511&t,x=t>>9&511),A=t>>18):(F=511&q,x=q>>9&511,A=q>>18),s+='style="',!L&&-1===q&&(s+="outline:1px solid "+this.colors[x]+";"),1&A&&(Terminal.brokenBold||(s+="font-weight:bold;"),8>x&&(x+=8)),2&A&&(s+="text-decoration:underline;"),256!==F&&(s+="background-color:"+this.colors[F]+";"),257!==x&&(s+="color:"+this.colors[x]+";"),s+='">')),u){case"&":s+="&";break;case"<":s+="<";break;case">":s+=">";break;default:s=" ">=u?s+" ":s+u}x=q}x!==this.defAttr&&(s+=""),this.children[f].innerHTML=s}H&&H.appendChild(this.element)},Terminal.prototype.redrawCursor=function(){this.refresh(this.y,this.y)},Terminal.prototype.showCursor=function(){this.cursorState||(this.cursorState=1),this.redrawCursor()},Terminal.prototype.scroll=function(){var a;++this.ybase===Terminal.scrollback&&(this.ybase=this.ybase/2|0,this.lines=this.lines.slice(-(this.ybase+this.rows)+1)),this.ydisp=this.ybase,a=this.ybase+this.rows-1,a-=this.rows-1-this.scrollBottom,a===this.lines.length?this.lines.push(this.blankLine()):this.lines.splice(a,0,this.blankLine()),0!==this.scrollTop&&(0!==this.ybase&&(this.ybase--,this.ydisp=this.ybase),this.lines.splice(this.ybase+this.scrollTop,1)),this.updateRange(this.scrollTop),this.updateRange(this.scrollBottom)},Terminal.prototype.scrollDisp=function(a){this.ydisp+=a,this.ydisp>this.ybase?this.ydisp=this.ybase:0>this.ydisp&&(this.ydisp=0),this.refresh(0,this.rows-1)},Terminal.prototype.write=function(a){var that=this;this.writeQueue||setTimeout(function(){that._write(that.writeQueue),that.writeQueue=""},1),this.writeQueue+=a},Terminal.prototype._write=function(a){var f,k=a.length,y=0;for(this.refreshEnd=this.refreshStart=this.y,this.ybase!==this.ydisp&&(this.ydisp=this.ybase,this.maxRange());k>y;y++)switch(f=a[y],this.state){case 0:switch(f){case"":this.bell();break;case"\n":case" ":case"\f":this.convertEol&&(this.x=0),this.y++,this.y>this.scrollBottom&&(this.y--,this.scroll());break;case"\r":this.x=0;break;case"\b":0=" "&&(this.charset&&this.charset[f]&&(f=this.charset[f]),this.x>=this.cols&&(this.x=0,this.y++,this.y>this.scrollBottom&&(this.y--,this.scroll())),this.lines[this.y+this.ybase][this.x]=[this.curAttr,f],this.x++,this.updateRange(this.y))}break;case 1:switch(f){case"[":this.params=[],this.currentParam=0,this.state=2;break;case"]":this.params=[],this.currentParam=0,this.state=3;break;case"P":this.params=[],this.currentParam=0,this.state=5;break;case"_":this.state=6;break;case"^":this.state=6;break;case"c":this.reset();break;case"E":this.x=0;case"D":this.index();break;case"M":this.reverseIndex();break;case"%":this.setgLevel(0),this.setgCharset(0,Terminal.charsets.US),this.state=0,y++;break;case"(":case")":case"*":case"+":case"-":case".":switch(f){case"(":this.gcharset=0;break;case")":this.gcharset=1;break;case"*":this.gcharset=2;break;case"+":this.gcharset=3;break;case"-":this.gcharset=1;break;case".":this.gcharset=2}this.state=4;break;case"/":this.gcharset=3,this.state=4,y--;break;case"N":break;case"O":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=0;break;case"8":this.restoreCursor(),this.state=0;break;case"#":this.state=0,y++;break;case"H":this.tabSet();break;case"=":this.log("Serial port requested application keypad."),this.applicationKeypad=!0,this.state=0;break;case">":this.log("Switching back to normal keypad."),this.applicationKeypad=!1,this.state=0;break;default:this.state=0,this.error("Unknown ESC control: %s.",f)}break;case 4:switch(f){case"0":f=Terminal.charsets.SCLD;break;case"A":f=Terminal.charsets.UK;break;case"B":f=Terminal.charsets.US;break;case"4":f=Terminal.charsets.Dutch;break;case"C":case"5":f=Terminal.charsets.Finnish;break;case"R":f=Terminal.charsets.French;break;case"Q":f=Terminal.charsets.FrenchCanadian;break;case"K":f=Terminal.charsets.German;break;case"Y":f=Terminal.charsets.Italian;break;case"E":case"6":f=Terminal.charsets.NorwegianDanish;break;case"Z":f=Terminal.charsets.Spanish;break;case"H":case"7":f=Terminal.charsets.Swedish;break;case"=":f=Terminal.charsets.Swiss;break;case"/":f=Terminal.charsets.ISOLatin,y++;break;default:f=Terminal.charsets.US}this.setgCharset(this.gcharset,f),this.gcharset=null,this.state=0;break;case 3:if(""===f||""===f){switch(""===f&&y++,this.params.push(this.currentParam),this.params[0]){case 0:case 1:case 2:this.params[1]&&(this.title=this.params[1],this.handleTitle(this.title))}this.params=[],this.state=this.currentParam=0}else this.params.length?this.currentParam+=f:f>="0"&&"9">=f?this.currentParam=10*this.currentParam+f.charCodeAt(0)-48:";"===f&&(this.params.push(this.currentParam),this.currentParam="");break;case 2:if("?"===f||">"===f||"!"===f){this.prefix=f;break}if(f>="0"&&"9">=f){this.currentParam=10*this.currentParam+f.charCodeAt(0)-48;break}if("$"===f||'"'===f||" "===f||"'"===f){this.postfix=f;break}if(this.params.push(this.currentParam),this.currentParam=0,";"===f)break;switch(this.state=0,f){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.charAttributes(this.params);break;case"n":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":2>this.params.length&&!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":switch(this.prefix){case"!":this.softReset(this.params)}break;default:this.error("Unknown CSI code: %s.",f)}this.postfix=this.prefix="";break;case 5:if(""===f||""===f){switch(""===f&&y++,this.prefix){case"":break;case"$q":f=this.currentParam;var v=!1;switch(f){case'"q':f='0"q';break;case'"p':f='61"p';break;case"r":f=""+(this.scrollTop+1)+";"+(this.scrollBottom+1)+"r";break;case"m":f="0m";break;default:this.error("Unknown DCS Pt: %s.",f),f=""}this.send("P"+ +v+"$r"+f+"\\");break;case"+p":break;case"+q":f=this.currentParam,v=!1,this.send("P"+ +v+"+r"+f+"\\");break;default:this.error("Unknown DCS prefix: %s.",this.prefix)}this.currentParam=0,this.prefix="",this.state=0}else this.currentParam?this.currentParam+=f:this.prefix||"$"===f||"+"===f?2===this.prefix.length?this.currentParam=f:this.prefix+=f:this.currentParam=f;break;case 6:(""===f||""===f)&&(""===f&&y++,this.state=0)}this.updateRange(this.y),this.refresh(this.refreshStart,this.refreshEnd)},Terminal.prototype.writeln=function(a){this.write(a+"\r\n")},Terminal.prototype.keyDown=function(a){a=this.applyVirtualKey(a);var c=this,k=null;switch(a.keyCode){case 8:if(a.shiftKey){k="\b";break}if(a.altKey){k="";break}k="";break;case 9:if(a.shiftKey){k="";break}k=" ";break;case 13:k="\r";break;case 27:k="";break;case 37:if(this.applicationCursor){k="OD";break}if(a.altKey){k="b";break}k="";break;case 39:if(this.applicationCursor){k="OC";break}if(a.altKey){k="f";break}k="";break;case 38:if(this.applicationCursor){k="OA";break}if(a.ctrlKey)return this.scrollDisp(-1),t(a);k="";break;case 40:if(this.applicationCursor){k="OB";break}if(a.ctrlKey)return this.scrollDisp(1),t(a);k="";break;case 46:k="[3~";break;case 45:k="[2~";break;case 36:if(this.applicationKeypad){k="OH";break}k="OH";break;case 35:if(this.applicationKeypad){k="OF";break}k="OF";break;case 33:if(a.shiftKey)return this.scrollDisp(-(this.rows-1)),events.cancel(a);k="[5~";break;case 34:if(a.shiftKey)return this.scrollDisp(this.rows-1),events.cancel(a);k="[6~";break;case 112:k="OP";break;case 113:k="OQ";break;case 114:k="OR";break;case 115:k="OS";break;case 116:k="[15~";break;case 117:k="[17~";break;case 118:k="[18~";break;case 119:k="[19~";break;case 120:k="[20~";break;case 121:k="[21~";break;case 122:k="[23~";break;case 123:k="[24~";break;default:a.ctrlKey&&!a.altKey?!Terminal.isMac&&a.shiftKey&&86===a.keyCode?(k="",setTimeout(function(){c.commitInput("",a)},20)):65<=a.keyCode&&90>=a.keyCode?k=String.fromCharCode(a.keyCode-64):32===a.keyCode?k=String.fromCharCode(0):51<=a.keyCode&&55>=a.keyCode?k=String.fromCharCode(a.keyCode-51+27):56===a.keyCode?k=String.fromCharCode(127):219===a.keyCode?k=String.fromCharCode(27):221===a.keyCode&&(k=String.fromCharCode(29)):Terminal.isMac&&a.metaKey&&86===a.keyCode?(k="",setTimeout(function(){c.commitInput("",a)},20)):!a.ctrlKey&&(!Terminal.isMac&&a.altKey||Terminal.isMac&&a.metaKey)&&(65<=a.keyCode&&90>=a.keyCode?k=""+String.fromCharCode(a.keyCode+32):192===a.keyCode?k="`":48<=a.keyCode&&57>=a.keyCode&&(k=""+(a.keyCode-48)))}return k?(this.commitInput(k,a),events.cancel(a)):(""!==k&&this.showBufferedText(),!0)},Terminal.prototype.showBufferedText=function(){var a=this.inputElement;setTimeout(function(){0w&&(w=1),1>h&&(h=1),v=this.cols,w>v)for(f=[this.defAttr," "],k=this.lines.length;k--;)for(;this.lines[k].lengthw)for(k=this.lines.length;k--;)for(;this.lines[k].length>w;)this.lines[k].pop();if(this.setupStops(v),this.cols=w,v=this.rows,h>v)for(f=this.element;v++h)for(;v-->h;)this.lines.length>h+this.ybase&&this.lines.pop(),this.children.length>h&&(f=this.children.pop(),f&&f.parentNode.removeChild(f));this.rows=h,this.y>=h&&(this.y=h-1),this.x>=w&&(this.x=w-1),this.scrollTop=0,this.scrollBottom=h-1,this.refresh(0,this.rows-1),this.normal=null,this.showSize(w,h),this.emit("resize",w,h)},Terminal.prototype.showSize=function(a,c){var k=this.sizeIndicatorElement;k.innerHTML=a+"x"+c,k.style.display="block",void 0!=this.showSizeTimeout&&clearTimeout(this.showSizeTimeout),this.showSizeTimeout=setTimeout(function(){k.style.display="none"},2e3)},Terminal.prototype.updateRange=function(a){athis.refreshEnd&&(this.refreshEnd=a)},Terminal.prototype.maxRange=function(){this.refreshStart=0,this.refreshEnd=this.rows-1},Terminal.prototype.setupStops=function(a){for(null!=a?this.tabs[a]||(a=this.prevStop(a)):(this.tabs={},a=0);a0;);return a>=this.cols?this.cols-1:0>a?0:a},Terminal.prototype.nextStop=function(a){for(null==a&&(a=this.x);!this.tabs[++a]&&a=this.cols?this.cols-1:0>a?0:a},Terminal.prototype.eraseRight=function(a,c){for(var k=this.lines[this.ybase+c],f=[this.curAttr," "];athis.scrollBottom&&(this.y--,this.scroll()),this.state=0},Terminal.prototype.reverseIndex=function(){var a;this.y--,this.ya&&(a=1),this.y-=a,0>this.y&&(this.y=0)},Terminal.prototype.cursorDown=function(a){a=a[0],1>a&&(a=1),this.y+=a,this.y>=this.rows&&(this.y=this.rows-1)},Terminal.prototype.cursorForward=function(a){a=a[0],1>a&&(a=1),this.x+=a,this.x>=this.cols&&(this.x=this.cols-1)},Terminal.prototype.cursorBackward=function(a){a=a[0],1>a&&(a=1),this.x-=a,0>this.x&&(this.x=0)},Terminal.prototype.cursorPos=function(a){var c;c=a[0]-1,a=2<=a.length?a[1]-1:0,0>c?c=0:c>=this.rows&&(c=this.rows-1),0>a?a=0:a>=this.cols&&(a=this.cols-1),this.x=a,this.y=c},Terminal.prototype.eraseInDisplay=function(a){switch(a[0]){case 0:for(this.eraseRight(this.x,this.y),a=this.y+1;ak;k++)if(f=a[k],f>=30&&37>=f)this.curAttr=-261633&this.curAttr|f-30<<9;else if(f>=40&&47>=f)this.curAttr=-512&this.curAttr|f-40;else if(f>=90&&97>=f)f+=8,this.curAttr=-261633&this.curAttr|f-90<<9;else if(f>=100&&107>=f)f+=8,this.curAttr=-512&this.curAttr|f-100;else if(0===f)this.curAttr=this.defAttr;else if(1===f)this.curAttr|=262144;else if(4===f)this.curAttr|=524288;else if(7===f||27===f){if(7===f){if(this.curAttr>>18&4)continue;this.curAttr|=1048576}else if(27===f){if(4&~(this.curAttr>>18))continue;this.curAttr&=-1048577}f=511&this.curAttr,v=this.curAttr>>9&511,this.curAttr=-262144&this.curAttr|f<<9|v}else 22===f?this.curAttr&=-262145:24===f?this.curAttr&=-524289:39===f?(this.curAttr&=-261633,this.curAttr|=(this.defAttr>>9&511)<<9):49===f?(this.curAttr&=-512,this.curAttr|=511&this.defAttr):38===f?5===a[k+1]&&(k+=2,f=255&a[k],this.curAttr=-261633&this.curAttr|f<<9):48===f&&5===a[k+1]&&(k+=2,f=255&a[k],this.curAttr=-512&this.curAttr|f)},Terminal.prototype.deviceStatus=function(a){if(this.prefix){if("?"===this.prefix)switch(a[0]){case 6:this.send("[?"+(this.y+1)+";"+(this.x+1)+"R")}}else switch(a[0]){case 5:this.send("");break;case 6:this.send("["+(this.y+1)+";"+(this.x+1)+"R")}},Terminal.prototype.insertChars=function(a){var c,k,f; -for(a=a[0],1>a&&(a=1),c=this.y+this.ybase,k=this.x,f=[this.curAttr," "];a--&&ka&&(a=1),this.y+=a,this.y>=this.rows&&(this.y=this.rows-1),this.x=0},Terminal.prototype.cursorPrecedingLine=function(a){a=a[0],1>a&&(a=1),this.y-=a,0>this.y&&(this.y=0),this.x=0},Terminal.prototype.cursorCharAbsolute=function(a){a=a[0],1>a&&(a=1),this.x=a-1},Terminal.prototype.insertLines=function(a){var c,k;for(a=a[0],1>a&&(a=1),c=this.y+this.ybase,k=this.rows-1-this.scrollBottom,k=this.rows-1+this.ybase-k+1;a--;)this.lines.splice(c,0,this.blankLine(!0)),this.lines.splice(k,1);this.updateRange(this.y),this.updateRange(this.scrollBottom)},Terminal.prototype.deleteLines=function(a){var c,k;for(a=a[0],1>a&&(a=1),c=this.y+this.ybase,k=this.rows-1-this.scrollBottom,k=this.rows-1+this.ybase-k;a--;)this.lines.splice(k+1,0,this.blankLine(!0)),this.lines.splice(c,1);this.updateRange(this.y),this.updateRange(this.scrollBottom)},Terminal.prototype.deleteChars=function(a){var c,k;for(a=a[0],1>a&&(a=1),c=this.y+this.ybase,k=[this.curAttr," "];a--;)this.lines[c].splice(this.x,1),this.lines[c].push(k)},Terminal.prototype.eraseChars=function(a){var c,k,f;for(a=a[0],1>a&&(a=1),c=this.y+this.ybase,k=this.x,f=[this.curAttr," "];a--&&ka&&(a=1),this.x=a-1,this.x>=this.cols&&(this.x=this.cols-1)},Terminal.prototype.HPositionRelative=function(a){a=a[0],1>a&&(a=1),this.x+=a,this.x>=this.cols&&(this.x=this.cols-1)},Terminal.prototype.sendDeviceAttributes=function(a){0"===this.prefix&&(this.is("xterm")?this.send("[>0;276;0c"):this.is("rxvt-unicode")?this.send("[>85;95;0c"):this.is("linux")?this.send(a[0]+"c"):this.is("screen")&&this.send("[>83;40003;0c")):this.is("xterm")||this.is("rxvt-unicode")||this.is("screen")?this.send("[?1;2c"):this.is("linux")&&this.send("[?6c"))},Terminal.prototype.linePosAbsolute=function(a){a=a[0],1>a&&(a=1),this.y=a-1,this.y>=this.rows&&(this.y=this.rows-1)},Terminal.prototype.VPositionRelative=function(a){a=a[0],1>a&&(a=1),this.y+=a,this.y>=this.rows&&(this.y=this.rows-1)},Terminal.prototype.HVPosition=function(a){1>a[0]&&(a[0]=1),1>a[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)},Terminal.prototype.setMode=function(a){if("object"==typeof a)for(var k=a.length,v=0;k>v;v++)this.setMode(a[v]);else if(this.prefix){if("?"===this.prefix)switch(a){case 1:this.applicationCursor=!0;break;case 2:this.setgCharset(0,Terminal.charsets.US),this.setgCharset(1,Terminal.charsets.US),this.setgCharset(2,Terminal.charsets.US),this.setgCharset(3,Terminal.charsets.US);break;case 3:this.savedCols=this.cols,this.resize(132,this.rows);break;case 6:this.originMode=!0;break;case 7:this.wraparoundMode=!0;break;case 9:case 1e3:case 1002:case 1003:this.x10Mouse=9===a,this.vt200Mouse=1e3===a,this.normalMouse=a>1e3,this.mouseEvents=!0,this.element.style.cursor="default",this.log("Binding to mouse events.");break;case 1004:this.sendFocus=!0;break;case 1005:this.utfMouse=!0;break;case 1006:this.sgrMouse=!0;break;case 1015:this.urxvtMouse=!0;break;case 25:this.cursorHidden=!1;break;case 1049:case 47:case 1047:this.normal||(a={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=a,this.showCursor())}}else switch(a){case 4:this.insertMode=!0}},Terminal.prototype.resetMode=function(a){if("object"==typeof a)for(var c=a.length,k=0;c>k;k++)this.resetMode(a[k]);else if(this.prefix){if("?"===this.prefix)switch(a){case 1:this.applicationCursor=!1;break;case 3:132===this.cols&&this.savedCols&&this.resize(this.savedCols,this.rows),delete this.savedCols;break;case 6:this.originMode=!1;break;case 7:this.wraparoundMode=!1;break;case 9:case 1e3:case 1002:case 1003:this.mouseEvents=this.normalMouse=this.vt200Mouse=this.x10Mouse=!1,this.element.style.cursor="";break;case 1004:this.sendFocus=!1;break;case 1005:this.utfMouse=!1;break;case 1006:this.sgrMouse=!1;break;case 1015:this.urxvtMouse=!1;break;case 25:this.cursorHidden=!0;break;case 1049:case 47:case 1047:this.normal&&(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 switch(a){case 4:this.insertMode=!1}},Terminal.prototype.setScrollRegion=function(a){this.prefix||(this.scrollTop=(a[0]||1)-1,this.scrollBottom=(a[1]||this.rows)-1,this.y=this.x=0)},Terminal.prototype.saveCursor=function(){this.savedX=this.x,this.savedY=this.y},Terminal.prototype.restoreCursor=function(){this.x=this.savedX||0,this.y=this.savedY||0},Terminal.prototype.cursorForwardTab=function(a){for(a=a[0]||1;a--;)this.x=this.nextStop()},Terminal.prototype.scrollUp=function(a){for(a=a[0]||1;a--;)this.lines.splice(this.ybase+this.scrollTop,1),this.lines.splice(this.ybase+this.scrollBottom,0,this.blankLine());this.updateRange(this.scrollTop),this.updateRange(this.scrollBottom)},Terminal.prototype.scrollDown=function(a){for(a=a[0]||1;a--;)this.lines.splice(this.ybase+this.scrollBottom,1),this.lines.splice(this.ybase+this.scrollTop,0,this.blankLine());this.updateRange(this.scrollTop),this.updateRange(this.scrollBottom)},Terminal.prototype.initMouseTracking=function(){},Terminal.prototype.resetTitleModes=function(){},Terminal.prototype.cursorBackwardTab=function(a){for(a=a[0]||1;a--;)this.x=this.prevStop()},Terminal.prototype.repeatPrecedingCharacter=function(a){a=a[0]||1;for(var c=this.lines[this.ybase+this.y],k=c[this.x-1]||[this.defAttr," "];a--;)c[this.x++]=k},Terminal.prototype.tabClear=function(a){a=a[0],0>=a?delete this.tabs[this.x]:3===a&&(this.tabs={})},Terminal.prototype.mediaCopy=function(){},Terminal.prototype.setResources=function(){},Terminal.prototype.disableModifiers=function(){},Terminal.prototype.setPointerMode=function(){},Terminal.prototype.softReset=function(){this.applicationCursor=this.applicationKeypad=this.wraparoundMode=this.originMode=this.insertMode=this.cursorHidden=!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]},Terminal.prototype.requestAnsiMode=function(){},Terminal.prototype.requestPrivateMode=function(){},Terminal.prototype.setConformanceLevel=function(){},Terminal.prototype.loadLEDs=function(){},Terminal.prototype.setCursorStyle=function(){},Terminal.prototype.setCharProtectionAttr=function(){},Terminal.prototype.restorePrivateValues=function(){},Terminal.prototype.setAttrInRectangle=function(a){for(var z,u,c=a[0],k=a[1],f=a[2],v=a[3],s=a[4];f+1>c;c++)for(z=this.lines[this.ybase+c],u=k;v>u;u++)z[u]=[s,z[u][1]];this.updateRange(a[0]),this.updateRange(a[2])},Terminal.prototype.savePrivateValues=function(){},Terminal.prototype.manipulateWindow=function(){},Terminal.prototype.reverseAttrInRectangle=function(){},Terminal.prototype.setTitleModeFeature=function(){},Terminal.prototype.setWarningBellVolume=function(){},Terminal.prototype.setMarginBellVolume=function(){},Terminal.prototype.copyRectangle=function(){},Terminal.prototype.enableFilterRectangle=function(){},Terminal.prototype.requestParameters=function(){},Terminal.prototype.selectChangeExtent=function(){},Terminal.prototype.fillRectangle=function(a){for(var z,u,c=a[0],k=a[1],f=a[2],v=a[3],s=a[4];v+1>k;k++)for(z=this.lines[this.ybase+k],u=f;s>u;u++)z[u]=[z[u][0],String.fromCharCode(c)];this.updateRange(a[1]),this.updateRange(a[3])},Terminal.prototype.enableLocatorReporting=function(){},Terminal.prototype.eraseRectangle=function(a){var s,z,u,c=a[0],k=a[1],f=a[2],v=a[3];for(u=[this.curAttr," "];f+1>c;c++)for(s=this.lines[this.ybase+c],z=k;v>z;z++)s[z]=u;this.updateRange(a[0]),this.updateRange(a[2])},Terminal.prototype.setLocatorEvents=function(){},Terminal.prototype.selectiveEraseRectangle=function(){},Terminal.prototype.requestLocatorPosition=function(){},Terminal.prototype.insertColumns=function(){for(var f,a=params[0],c=this.ybase+this.rows,k=[this.curAttr," "];a--;)for(f=this.ybase;c>f;f++)this.lines[f].splice(this.x+1,0,k),this.lines[f].pop();this.maxRange()},Terminal.prototype.deleteColumns=function(){for(var f,a=params[0],c=this.ybase+this.rows,k=[this.curAttr," "];a--;)for(f=this.ybase;c>f;f++)this.lines[f].splice(this.x,1),this.lines[f].push(k);this.maxRange()},Terminal.charsets=charsets,Terminal.isMac=~navigator.userAgent.indexOf("Mac"),Terminal.isMSIE=~navigator.userAgent.indexOf("MSIE"),Terminal.themes=themes,module.exports=Terminal},{"./charsets":1,"./events":2,"./themes":4,"./utils":5}],4:[function(_dereq_,module){var TANGO_COLORS=["#2e3436","#cc0000","#4e9a06","#c4a000","#3465a4","#75507b","#06989a","#d3d7cf","#555753","#ef2929","#8ae234","#fce94f","#729fcf","#ad7fa8","#34e2e2","#eeeeec"],initColors=function(colors){function out(a,c,f){y.push("#"+hex(a)+hex(c)+hex(f))}function hex(a){return a=a.toString(16),2>a.length?"0"+a:a}var v,y=colors,f=[0,95,135,175,215,255];for(v=0;216>v;v++)out(f[v/36%6|0],f[v/6%6|0],f[v%6]);for(v=0;24>v;v++)f=8+10*v,out(f,f,f);return y},DEFAULT_COLORS=initColors(TANGO_COLORS.slice()),mergeColors=function(themeColors,defaultColors){return 8===themeColors.length?themeColors=themeColors.concat(defaultColors.slice(8)):16===themeColors.length?themeColors=themeColors.concat(defaultColors.slice(16)):10===themeColors.length?themeColors=themeColors.slice(0,-2).concat(defaultColors.slice(8,-2),themeColors.slice(-2)):18===themeColors.length&&(themeColors=themeColors.concat(defaultColors.slice(16,-2),themeColors.slice(-2))),themeColors},colors=function(theme){var colors=theme.palette.slice();return colors[256]=theme.background||"#000000",colors[257]=theme.foreground||"#f0f0f0",mergeColors(colors,DEFAULT_COLORS)},defaults={"default":{palette:["#000000","#c81908","#00c01d","#c8c221","#0033c5","#c73ac5","#00c6c7","#c7c7c7","#686868","#8a8a8a","#67f86e","#fff970","#6678fc","#ff7cfd","#65fdff","#ffffff"]},blazer:{palette:["#262626","#dbbdbd","#bddbbd","#dbdbbd","#bdbddb","#dbbddb","#bddbdb","#ffffff"],name:"blazer"},chalkboard:{foreground:"#d9e6f2",background:"#29262f",cursor:"#d9e6f2",cursor_text:"#29262f",palette:["#000000","#c37372","#72c373","#c2c372","#7372c3","#c372c2","#72c2c3","#d9d9d9","#323232","#dbaaaa","#aadbaa","#dadbaa","#aaaadb","#dbaada","#aadadb","#ffffff"],name:"chalkboard"},dark_pastel:{foreground:"#ffffff",background:"#000000",cursor:"#bbbbbb",cursor_text:"#ffffff",palette:["#000000","#ff5555","#55ff55","#ffff55","#5555ff","#ff55ff","#55ffff","#bbbbbb","#555555","#ff5555","#55ff55","#ffff55","#5555ff","#ff55ff","#55ffff","#ffffff"],name:"dark_pastel"},desert:{foreground:"#ffffff",background:"#333333",cursor:"#00ff00",cursor_text:"#000000",palette:["#4d4d4d","#ff2b2b","#98fb98","#f0e68c","#cd853f","#ffdead","#ffa0a0","#f5deb3","#555555","#ff5555","#55ff55","#ffff55","#87ceff","#ff55ff","#ffd700","#ffffff"],name:"desert"},espresso:{foreground:"#ffffff",background:"#323232",cursor:"#d6d6d6",cursor_text:"#ffffff",palette:["#343434","#d25151","#a5c261","#ffc66d","#6c99bb","#d197d9","#bed6ff","#eeeeec","#535353","#f00c0c","#c2e075","#e1e38b","#8ab7d9","#efb5f7","#dcf3ff","#ffffff"],name:"espresso"},github:{foreground:"#3e3e3e",background:"#f4f4f4",cursor:"#3f3f3f",cursor_text:"#f4f4f4",palette:["#3e3e3e","#970b16","#07962a","#f8eec7","#003e8a","#e94691","#89d1ec","#ffffff","#666666","#de0000","#87d5a2","#f1d007","#2e6cba","#ffa29f","#1cfafe","#ffffff"],name:"github"},grass:{foreground:"#fff0a5",background:"#13773c",cursor:"#8c2800",cursor_text:"#ffffff",palette:["#000000","#bb0000","#00bb00","#e7b000","#0000a3","#950061","#00bbbb","#bbbbbb","#555555","#bb0000","#00bb00","#e7b000","#0000bb","#ff55ff","#55ffff","#ffffff"],name:"grass"},homebrew:{foreground:"#00ff00",background:"#000000",cursor:"#23ff18",cursor_text:"#ff0017",palette:["#000000","#990000","#00a600","#999900","#0000b2","#b200b2","#00a6b2","#bfbfbf","#666666","#e50000","#00d900","#e5e500","#0000ff","#e500e5","#00e5e5","#e5e5e5"],name:"homebrew"},hurtado:{foreground:"#dadbda",background:"#000000",cursor:"#bbbbbb",cursor_text:"#ffffff",palette:["#575757","#ff1b00","#a5df55","#fbe74a","#486387","#fc5ef0","#85e9fe","#cbcbcb","#252525","#d41c00","#a5df55","#fbe749","#89bdff","#bf00c0","#85e9fe","#dbdbdb"],name:"hurtado"},idletoes:{foreground:"#ffffff",background:"#323232",cursor:"#d6d6d6",cursor_text:"#000000",palette:["#323232","#d25252","#7fe173","#ffc66d","#4098ff","#f57fff","#bed6ff","#eeeeec","#535353","#f07070","#9dff90","#ffe48b","#5eb7f7","#ff9dff","#dcf4ff","#ffffff"],name:"idletoes"},kibble:{foreground:"#f7f7f7",background:"#0e100a",cursor:"#9fda9c",cursor_text:"#000000",palette:["#4d4d4d","#c70031","#29cf13","#d8e30e","#3449d1","#8400ff","#0798ab","#e2d1e3","#5a5a5a","#f01578","#6ce05c","#f3f79e","#97a4f7","#c495f0","#68f2e0","#ffffff"],name:"kibble"},man_page:{foreground:"#000000",background:"#fef49c",cursor:"#7f7f7f",cursor_text:"#000000",palette:["#000000","#cc0000","#00a600","#999900","#0000b2","#b200b2","#00a6b2","#cccccc","#666666","#e50000","#00d900","#e5e500","#0000ff","#e500e5","#00e5e5","#e5e5e5"],name:"man_page"},monokai_soda:{foreground:"#c4c4b5",background:"#191919",cursor:"#f6f6ec",cursor_text:"#c4c4b5",palette:["#191919","#f3005f","#97e023","#fa8419","#9c64fe","#f3005f","#57d1ea","#c4c4b5","#615e4b","#f3005f","#97e023","#dfd561","#9c64fe","#f3005f","#57d1ea","#f6f6ee"],name:"monokai_soda"},neopolitan:{foreground:"#ffffff",background:"#17130f",cursor:"#ffffff",cursor_text:"#ffffff",palette:["#17130f","#800000","#61ce3c","#fbde2d","#253b76","#ff0080","#8da6ce","#f8f8f8","#17130f","#800000","#61ce3c","#fbde2d","#253b76","#ff0080","#8da6ce","#f8f8f8"],name:"neopolitan"},novel:{foreground:"#3b2322",background:"#dfdbc3",cursor:"#73635a",cursor_text:"#000000",palette:["#000000","#cc0000","#009600","#d06b00","#0000cc","#cc00cc","#0087cc","#cccccc","#7f7f7f","#cc0000","#009600","#d06b00","#0000cc","#cc00cc","#0086cb","#ffffff"],name:"novel"},ocean:{foreground:"#ffffff",background:"#224fbc",cursor:"#7f7f7f",cursor_text:"#ffffff",palette:["#000000","#990000","#00a600","#999900","#0000b2","#b200b2","#00a6b2","#bfbfbf","#666666","#e50000","#00d900","#e5e500","#0000ff","#e500e5","#00e5e5","#e5e5e5"],name:"ocean"},pro:{foreground:"#f2f2f2",background:"#000000",cursor:"#4d4d4d",cursor_text:"#ffffff",palette:["#000000","#990000","#00a600","#999900","#1f08db","#b200b2","#00a6b2","#bfbfbf","#666666","#e50000","#00d900","#e5e500","#0000ff","#e500e5","#00e5e5","#e5e5e5"],name:"pro"},red_sands:{foreground:"#d7c9a7",background:"#79241e",cursor:"#ffffff",cursor_text:"#000000",palette:["#000000","#ff3f00","#00bb00","#e7b000","#0071ff","#bb00bb","#00bbbb","#bbbbbb","#555555","#bb0000","#00bb00","#e7b000","#0071ae","#ff55ff","#55ffff","#ffffff"],name:"red_sands"},seafoam_pastel:{foreground:"#d3e7d3",background:"#243434",cursor:"#576479",cursor_text:"#323232",palette:["#757575","#825d4d","#718c61","#ada16d","#4d7b82","#8a7167","#719393","#e0e0e0","#8a8a8a","#cf9379","#98d9aa","#fae79d","#79c3cf","#d6b2a1","#ade0e0","#e0e0e0"],name:"seafoam_pastel"},solarized_darcula:{foreground:"#d2d8d9",background:"#3d3f41",cursor:"#708183",cursor_text:"#002731",palette:["#25292a","#f24840","#629655","#b68800","#2075c7","#797fd4","#15968d","#d2d8d9","#25292a","#f24840","#629655","#b68800","#2075c7","#797fd4","#15968d","#d2d8d9"],name:"solarized_darcula"},solarized_dark:{foreground:"#708183",background:"#001e26",cursor:"#708183",cursor_text:"#002731",palette:["#002731","#d01b24","#728905","#a57705","#2075c7","#c61b6e","#259185","#e9e2cb","#001e26","#bd3612","#465a61","#52676f","#708183","#5856b9","#81908f","#fcf4dc"],name:"solarized_dark"},solarized_light:{foreground:"#52676f",background:"#fcf4dc",cursor:"#52676f",cursor_text:"#e9e2cb",palette:["#002731","#d01b24","#728905","#a57705","#2075c7","#c61b6e","#259185","#e9e2cb","#001e26","#bd3612","#465a61","#52676f","#708183","#5856b9","#81908f","#fcf4dc"],name:"solarized_light"},symfonic:{foreground:"#ffffff",background:"#000000",cursor:"#dc322f",cursor_text:"#ffffff",palette:["#000000","#dc322f","#56db3a","#ff8400","#0084d4","#b729d9","#ccccff","#ffffff","#1b1d21","#dc322f","#56db3a","#ff8400","#0084d4","#b729d9","#ccccff","#ffffff"],name:"symfonic"},terminal_basic:{foreground:"#000000",background:"#ffffff",cursor:"#7f7f7f",cursor_text:"#000000",palette:["#000000","#990000","#00a600","#999900","#0000b2","#b200b2","#00a6b2","#bfbfbf","#666666","#e50000","#00d900","#e5e500","#0000ff","#e500e5","#00e5e5","#e5e5e5"],name:"terminal_basic"},vaughn:{foreground:"#dcdccc",background:"#25234e",cursor:"#ff5555",cursor_text:"#ffffff",palette:["#24234f","#705050","#60b48a","#dfaf8f","#5555ff","#f08cc3","#8cd0d3","#709080","#709080","#dca3a3","#60b48a","#f0dfaf","#5555ff","#ec93d3","#93e0e3","#ffffff"],name:"vaughn"},zenburn:{foreground:"#dcdccc",background:"#3f3f3f",cursor:"#73635a",cursor_text:"#000000",palette:["#4d4d4d","#705050","#60b48a","#f0dfaf","#506070","#dc8cc3","#8cd0d3","#dcdccc","#709080","#dca3a3","#c3bf9f","#e0cf9f","#94bff3","#ec93d3","#93e0e3","#ffffff"],name:"zenburn"}};module.exports={defaults:defaults,colors:colors}},{}],5:[function(_dereq_,module){function inherits(a,c){function k(){this.constructor=a}k.prototype=c.prototype,a.prototype=new k}function isVisible(el){var eap,rect=el.getBoundingClientRect(),docEl=document.documentElement,vWidth=window.innerWidth||docEl.clientWidth,vHeight=window.innerHeight||docEl.clientHeight,efp=function(x,y){return document.elementFromPoint(x,y)},contains="contains"in el?"contains":"compareDocumentPosition",has="contains"==contains?1:16;return rect.right<0||rect.bottom<0||rect.left>vWidth||rect.top>vHeight?!1:(eap=efp(rect.left,rect.top))==el||el[contains](eap)==has||(eap=efp(rect.right,rect.top))==el||el[contains](eap)==has||(eap=efp(rect.right,rect.bottom))==el||el[contains](eap)==has||(eap=efp(rect.left,rect.bottom))==el||el[contains](eap)==has}function getSelection(){return"undefined"!=typeof window.getSelection?window.getSelection().toString():"undefined"!=typeof document.selection&&"Text"==document.selection.type?document.selection.createRange().htmlText:null}function isBoldBroken(){var a=document.createElement("span");a.innerHTML="hello world",document.body.appendChild(a);var c=a.scrollWidth;a.style.fontWeight="bold";var k=a.scrollWidth;return document.body.removeChild(a),c!==k}module.exports={inherits:inherits,isBoldBroken:isBoldBroken,isVisible:isVisible,getSelection:getSelection}},{}]},{},[3])(3)}); \ No newline at end of file +!function(e){if("object"==typeof exports)module.exports=e();else if("function"==typeof define&&define.amd)define(e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.Terminal=e()}}(function(){var define,module,exports;return function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o=c.keyCode&&-1===[91,92,93,144,145].indexOf(c.keyCode))&&that.inputElement.focus();!Terminal.isMac&&(k&&c.shiftKey&&document.execCommand)&&(document.execCommand("copy",!0,null),events.cancel(c))})}};Terminal.prototype.open=function(parent){var that=this,E=0,y;this.element=document.createElement("div");this.element.className="terminal";this.element.spellcheck=false;for(this.children=[];Ev&&!(c.innerHTML+="W",c.offsetWidth>k);v++);c.innerHTML="W";for(k=1;maxH>k&&!(c.innerHTML+="
W",c.offsetHeight>f);k++);c.parentNode.removeChild(c);a.parentNode.removeChild(a);console.log("sizeToFit:",v,k);this.resize(v,k)};Terminal.prototype.bindMouse=function(){function a(a){var c,k,p,y;switch(a.type){case"mousedown":c=null!=a.button?+a.button:null!=a.which?a.which-1:null;~navigator.userAgent.indexOf("MSIE")&&(c=1===c?0:4===c?1:c);break;case"mouseup":c=3;break;case"DOMMouseScroll":c=0>a.detail?64:65;break;case"mousewheel":c=0c?a.push(c):(2046>6),a.push(128|c&63)):(254c&&(c=1);1>f&&(f=1);c>s.cols&&(c=s.cols);f>s.rows&&(f=s.rows);return{x:c+32,y:f+32,down:"mousedown"===a.type,up:"mouseup"===a.type,wheel:a.type===p,move:"mousemove"===a.type}}}var q=this.element,s=this,F=32,p="onmousewheel"in window?"mousewheel":"DOMMouseScroll";events.on(q,"mousedown",function(f){if(s.mouseEvents){a(f);s.selectionMode||s.focus();if(s.vt200Mouse)return a({__proto__:f,type:"mouseup"}),events.cancel(f);s.normalMouse&&events.on(document,"mousemove",c);if(!s.x10Mouse){var p=function(f){a(f);events.off(document,"mousemove",c);events.off(document,"mouseup",p);events.off(document,"mousedown",p);return cancel(f)};events.on(document,"mouseup",p);events.on(document,"mousedown",p)}return events.cancel(f)}});events.on(q,"mouseup",function(a){window.getSelection&&0a.detail?-5:5):s.scrollDisp(0=this.rows/2&&(H=this.element.parentNode)&&H.removeChild(this.element);p=this.cols;for(f=a;f<=k;f++){y=f+this.ydisp;z=this.lines[y];s="";y=f===this.y&&this.cursorState&&this.ydisp===this.ybase&&!this.cursorHidden?this.x:-1;x=this.defAttr;for(v=0;v"),q!==this.defAttr&&(s+=">9&511,x=t&511):(F=t&511,x=t>>9&511),A=t>>18):(F=q&511,x=q>>9&511,A=q>>18),s+='style="',!L&&-1===q&&(s+="outline:1px solid "+this.colors[x]+";"),A&1&&(Terminal.brokenBold||(s+="font-weight:bold;"),8>x&&(x+=8)),A&2&&(s+="text-decoration:underline;"),256!==F&&(s+="background-color:"+this.colors[F]+";"),257!==x&&(s+="color:"+this.colors[x]+";"),s+='">'));switch(u){case"&":s+="&";break;case"<":s+="<";break;case">":s+=">";break;default:s=" ">=u?s+" ":s+u}x=q}x!==this.defAttr&&(s+="");this.children[f].innerHTML=s}H&&H.appendChild(this.element)};Terminal.prototype.redrawCursor=function(){this.refresh(this.y,this.y)};Terminal.prototype.showCursor=function(){this.cursorState||(this.cursorState=1);this.redrawCursor()};Terminal.prototype.scroll=function(){var a;++this.ybase===Terminal.scrollback&&(this.ybase=this.ybase/2|0,this.lines=this.lines.slice(-(this.ybase+this.rows)+1));this.ydisp=this.ybase;a=this.ybase+this.rows-1;a-=this.rows-1-this.scrollBottom;a===this.lines.length?this.lines.push(this.blankLine()):this.lines.splice(a,0,this.blankLine());0!==this.scrollTop&&(0!==this.ybase&&(this.ybase--,this.ydisp=this.ybase),this.lines.splice(this.ybase+this.scrollTop,1));this.updateRange(this.scrollTop);this.updateRange(this.scrollBottom)};Terminal.prototype.scrollDisp=function(a){this.ydisp+=a;this.ydisp>this.ybase?this.ydisp=this.ybase:0>this.ydisp&&(this.ydisp=0);this.refresh(0,this.rows-1)};Terminal.prototype.write=function(a){var that=this;this.writeQueue||setTimeout(function(){that._write(that.writeQueue);that.writeQueue=""},1);this.writeQueue+=a};Terminal.prototype._write=function(a){var k=a.length,y=0,f;this.refreshEnd=this.refreshStart=this.y;this.ybase!==this.ydisp&&(this.ydisp=this.ybase,this.maxRange());for(;ythis.scrollBottom&&(this.y--,this.scroll());break;case"\r":this.x=0;break;case"\b":0=this.cols&&(this.x=0,this.y++,this.y>this.scrollBottom&&(this.y--,this.scroll())),this.lines[this.y+this.ybase][this.x]=[this.curAttr,f],this.x++,this.updateRange(this.y))}break;case 1:switch(f){case"[":this.params=[];this.currentParam=0;this.state=2;break;case"]":this.params=[];this.currentParam=0;this.state=3;break;case"P":this.params=[];this.currentParam=0;this.state=5;break;case"_":this.state=6;break;case"^":this.state=6;break;case"c":this.reset();break;case"E":this.x=0;case"D":this.index();break;case"M":this.reverseIndex();break;case"%":this.setgLevel(0);this.setgCharset(0,Terminal.charsets.US);this.state=0;y++;break;case"(":case")":case"*":case"+":case"-":case".":switch(f){case"(":this.gcharset=0;break;case")":this.gcharset=1;break;case"*":this.gcharset=2;break;case"+":this.gcharset=3;break;case"-":this.gcharset=1;break;case".":this.gcharset=2}this.state=4;break;case"/":this.gcharset=3;this.state=4;y--;break;case"N":break;case"O":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=0;break;case"8":this.restoreCursor();this.state=0;break;case"#":this.state=0;y++;break;case"H":this.tabSet();break;case"=":this.log("Serial port requested application keypad.");this.applicationKeypad=!0;this.state=0;break;case">":this.log("Switching back to normal keypad.");this.applicationKeypad=!1;this.state=0;break;default:this.state=0,this.error("Unknown ESC control: %s.",f)}break;case 4:switch(f){case"0":f=Terminal.charsets.SCLD;break;case"A":f=Terminal.charsets.UK;break;case"B":f=Terminal.charsets.US;break;case"4":f=Terminal.charsets.Dutch;break;case"C":case"5":f=Terminal.charsets.Finnish;break;case"R":f=Terminal.charsets.French;break;case"Q":f=Terminal.charsets.FrenchCanadian;break;case"K":f=Terminal.charsets.German;break;case"Y":f=Terminal.charsets.Italian;break;case"E":case"6":f=Terminal.charsets.NorwegianDanish;break;case"Z":f=Terminal.charsets.Spanish;break;case"H":case"7":f=Terminal.charsets.Swedish;break;case"=":f=Terminal.charsets.Swiss;break;case"/":f=Terminal.charsets.ISOLatin;y++;break;default:f=Terminal.charsets.US}this.setgCharset(this.gcharset,f);this.gcharset=null;this.state=0;break;case 3:if(""===f||""===f){""===f&&y++;this.params.push(this.currentParam);switch(this.params[0]){case 0:case 1:case 2:this.params[1]&&(this.title=this.params[1],this.handleTitle(this.title))}this.params=[];this.state=this.currentParam=0}else this.params.length?this.currentParam+=f:"0"<=f&&"9">=f?this.currentParam=10*this.currentParam+f.charCodeAt(0)-48:";"===f&&(this.params.push(this.currentParam),this.currentParam="");break;case 2:if("?"===f||">"===f||"!"===f){this.prefix=f;break}if("0"<=f&&"9">=f){this.currentParam=10*this.currentParam+f.charCodeAt(0)-48;break}if("$"===f||'"'===f||" "===f||"'"===f){this.postfix=f;break}this.params.push(this.currentParam);this.currentParam=0;if(";"===f)break;this.state=0;switch(f){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.charAttributes(this.params);break;case"n":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":2>this.params.length&&!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":switch(this.prefix){case"!":this.softReset(this.params)}break;default:this.error("Unknown CSI code: %s.",f)}this.postfix=this.prefix="";break;case 5:if(""===f||""===f){""===f&&y++;switch(this.prefix){case"":break;case"$q":f=this.currentParam;var v=!1;switch(f){case'"q':f='0"q';break;case'"p':f='61"p';break;case"r":f=""+(this.scrollTop+1)+";"+(this.scrollBottom+1)+"r";break;case"m":f="0m";break;default:this.error("Unknown DCS Pt: %s.",f),f=""}this.send("P"+ +v+"$r"+f+"\\");break;case"+p":break;case"+q":f=this.currentParam;v=!1;this.send("P"+ +v+"+r"+f+"\\");break;default:this.error("Unknown DCS prefix: %s.",this.prefix)}this.currentParam=0;this.prefix="";this.state=0}else this.currentParam?this.currentParam+=f:!this.prefix&&"$"!==f&&"+"!==f?this.currentParam=f:2===this.prefix.length?this.currentParam=f:this.prefix+=f;break;case 6:if(""===f||""===f)""===f&&y++,this.state=0}this.updateRange(this.y);this.refresh(this.refreshStart,this.refreshEnd)};Terminal.prototype.writeln=function(a){this.write(a+"\r\n")};Terminal.prototype.keyDown=function(a){a=this.applyVirtualKey(a);var c=this,k=null;switch(a.keyCode){case 8:if(a.shiftKey){k="\b";break}else if(a.altKey){k="";break}k="";break;case 9:if(a.shiftKey){k="";break}k=" ";break;case 13:k="\r";break;case 27:k="";break;case 37:if(this.applicationCursor){k="OD";break}else if(a.altKey){k="b";break}k="";break;case 39:if(this.applicationCursor){k="OC";break}else if(a.altKey){k="f";break}k="";break;case 38:if(this.applicationCursor){k="OA";break}if(a.ctrlKey)return this.scrollDisp(-1),t(a);k="";break;case 40:if(this.applicationCursor){k="OB";break}if(a.ctrlKey)return this.scrollDisp(1),t(a);k="";break;case 46:k="[3~";break;case 45:k="[2~";break;case 36:if(this.applicationKeypad){k="OH";break}k="OH";break;case 35:if(this.applicationKeypad){k="OF";break}k="OF";break;case 33:if(a.shiftKey)return this.scrollDisp(-(this.rows-1)),events.cancel(a);k="[5~";break;case 34:if(a.shiftKey)return this.scrollDisp(this.rows-1),events.cancel(a);k="[6~";break;case 112:k="OP";break;case 113:k="OQ";break;case 114:k="OR";break;case 115:k="OS";break;case 116:k="[15~";break;case 117:k="[17~";break;case 118:k="[18~";break;case 119:k="[19~";break;case 120:k="[20~";break;case 121:k="[21~";break;case 122:k="[23~";break;case 123:k="[24~";break;default:if(a.ctrlKey&&!a.altKey)!Terminal.isMac&&a.shiftKey&&86===a.keyCode?(k="",setTimeout(function(){c.commitInput("",a)},20)):65<=a.keyCode&&90>=a.keyCode?k=String.fromCharCode(a.keyCode-64):32===a.keyCode?k=String.fromCharCode(0):51<=a.keyCode&&55>=a.keyCode?k=String.fromCharCode(a.keyCode-51+27):56===a.keyCode?k=String.fromCharCode(127):219===a.keyCode?k=String.fromCharCode(27):221===a.keyCode&&(k=String.fromCharCode(29));else if(Terminal.isMac&&a.metaKey&&86===a.keyCode)k="",setTimeout(function(){c.commitInput("",a)},20);else if(!a.ctrlKey&&(!Terminal.isMac&&a.altKey||Terminal.isMac&&a.metaKey))65<=a.keyCode&&90>=a.keyCode?k=""+String.fromCharCode(a.keyCode+32):192===a.keyCode?k="`":48<=a.keyCode&&57>=a.keyCode&&(k=""+(a.keyCode-48))}if(k)return this.commitInput(k,a),events.cancel(a);""!==k&&this.showBufferedText();return!0};Terminal.prototype.showBufferedText=function(){var a=this.inputElement;setTimeout(function(){0w)for(k=this.lines.length;k--;)for(;this.lines[k].length>w;)this.lines[k].pop();this.setupStops(v);this.cols=w;v=this.rows;if(vh){for(;v-- >h;){if(this.lines.length>h+this.ybase)this.lines.pop();if(this.children.length>h){f=this.children.pop();if(f)f.parentNode.removeChild(f)}}}this.rows=h;if(this.y>=h)this.y=h-1;if(this.x>=w)this.x=w-1;this.scrollTop=0;this.scrollBottom=h-1;this.refresh(0,this.rows-1);this.normal=null;this.showSize(w,h);this.emit("resize",w,h)};Terminal.prototype.showSize=function(a,c){var k=this.sizeIndicatorElement;k.innerHTML=a+"x"+c;k.style.display="block";void 0!=this.showSizeTimeout&&clearTimeout(this.showSizeTimeout);this.showSizeTimeout=setTimeout(function(){k.style.display="none"},2e3)};Terminal.prototype.updateRange=function(a){athis.refreshEnd&&(this.refreshEnd=a)};Terminal.prototype.maxRange=function(){this.refreshStart=0;this.refreshEnd=this.rows-1};Terminal.prototype.setupStops=function(a){null!=a?this.tabs[a]||(a=this.prevStop(a)):(this.tabs={},a=0);for(;a=this.cols?this.cols-1:0>a?0:a};Terminal.prototype.nextStop=function(a){null==a&&(a=this.x);for(;!this.tabs[++a]&&a=this.cols?this.cols-1:0>a?0:a};Terminal.prototype.eraseRight=function(a,c){for(var k=this.lines[this.ybase+c],f=[this.curAttr," "];athis.scrollBottom&&(this.y--,this.scroll());this.state=0};Terminal.prototype.reverseIndex=function(){var a;this.y--;this.ya&&(a=1);this.y-=a;0>this.y&&(this.y=0)};Terminal.prototype.cursorDown=function(a){a=a[0];1>a&&(a=1);this.y+=a;this.y>=this.rows&&(this.y=this.rows-1)};Terminal.prototype.cursorForward=function(a){a=a[0];1>a&&(a=1);this.x+=a;this.x>=this.cols&&(this.x=this.cols-1)};Terminal.prototype.cursorBackward=function(a){a=a[0];1>a&&(a=1);this.x-=a;0>this.x&&(this.x=0)};Terminal.prototype.cursorPos=function(a){var c;c=a[0]-1;a=2<=a.length?a[1]-1:0;0>c?c=0:c>=this.rows&&(c=this.rows-1);0>a?a=0:a>=this.cols&&(a=this.cols-1);this.x=a;this.y=c};Terminal.prototype.eraseInDisplay=function(a){switch(a[0]){case 0:this.eraseRight(this.x,this.y);for(a=this.y+1;a=f)this.curAttr=this.curAttr&-261633|f-30<<9;else if(40<=f&&47>=f)this.curAttr=this.curAttr&-512|f-40;else if(90<=f&&97>=f)f+=8,this.curAttr=this.curAttr&-261633|f-90<<9;else if(100<=f&&107>=f)f+=8,this.curAttr=this.curAttr&-512|f-100;else if(0===f)this.curAttr=this.defAttr;else if(1===f)this.curAttr|=262144;else if(4===f)this.curAttr|=524288;else if(7===f||27===f){if(7===f){if(this.curAttr>>18&4)continue;this.curAttr|=1048576}else if(27===f){if(~(this.curAttr>>18)&4)continue;this.curAttr&=-1048577}f=this.curAttr&511;v=this.curAttr>>9&511;this.curAttr=this.curAttr&-262144|f<<9|v}else 22===f?this.curAttr&=-262145:24===f?this.curAttr&=-524289:39===f?(this.curAttr&=-261633,this.curAttr|=(this.defAttr>>9&511)<<9):49===f?(this.curAttr&=-512,this.curAttr|=this.defAttr&511):38===f?5===a[k+1]&&(k+=2,f=a[k]&255,this.curAttr=this.curAttr&-261633|f<<9):48===f&&5===a[k+1]&&(k+=2,f=a[k]&255,this.curAttr=this.curAttr&-512|f); +};Terminal.prototype.deviceStatus=function(a){if(this.prefix){if("?"===this.prefix)switch(a[0]){case 6:this.send("[?"+(this.y+1)+";"+(this.x+1)+"R")}}else switch(a[0]){case 5:this.send("");break;case 6:this.send("["+(this.y+1)+";"+(this.x+1)+"R")}};Terminal.prototype.insertChars=function(a){var c,k,f;a=a[0];1>a&&(a=1);c=this.y+this.ybase;k=this.x;for(f=[this.curAttr," "];a--&&ka&&(a=1);this.y+=a;this.y>=this.rows&&(this.y=this.rows-1);this.x=0};Terminal.prototype.cursorPrecedingLine=function(a){a=a[0];1>a&&(a=1);this.y-=a;0>this.y&&(this.y=0);this.x=0};Terminal.prototype.cursorCharAbsolute=function(a){a=a[0];1>a&&(a=1);this.x=a-1};Terminal.prototype.insertLines=function(a){var c,k;a=a[0];1>a&&(a=1);c=this.y+this.ybase;k=this.rows-1-this.scrollBottom;for(k=this.rows-1+this.ybase-k+1;a--;)this.lines.splice(c,0,this.blankLine(!0)),this.lines.splice(k,1);this.updateRange(this.y);this.updateRange(this.scrollBottom)};Terminal.prototype.deleteLines=function(a){var c,k;a=a[0];1>a&&(a=1);c=this.y+this.ybase;k=this.rows-1-this.scrollBottom;for(k=this.rows-1+this.ybase-k;a--;)this.lines.splice(k+1,0,this.blankLine(!0)),this.lines.splice(c,1);this.updateRange(this.y);this.updateRange(this.scrollBottom)};Terminal.prototype.deleteChars=function(a){var c,k;a=a[0];1>a&&(a=1);c=this.y+this.ybase;for(k=[this.curAttr," "];a--;)this.lines[c].splice(this.x,1),this.lines[c].push(k)};Terminal.prototype.eraseChars=function(a){var c,k,f;a=a[0];1>a&&(a=1);c=this.y+this.ybase;k=this.x;for(f=[this.curAttr," "];a--&&ka&&(a=1);this.x=a-1;this.x>=this.cols&&(this.x=this.cols-1)};Terminal.prototype.HPositionRelative=function(a){a=a[0];1>a&&(a=1);this.x+=a;this.x>=this.cols&&(this.x=this.cols-1)};Terminal.prototype.sendDeviceAttributes=function(a){0"===this.prefix&&(this.is("xterm")?this.send("[>0;276;0c"):this.is("rxvt-unicode")?this.send("[>85;95;0c"):this.is("linux")?this.send(a[0]+"c"):this.is("screen")&&this.send("[>83;40003;0c")):this.is("xterm")||this.is("rxvt-unicode")||this.is("screen")?this.send("[?1;2c"):this.is("linux")&&this.send("[?6c"))};Terminal.prototype.linePosAbsolute=function(a){a=a[0];1>a&&(a=1);this.y=a-1;this.y>=this.rows&&(this.y=this.rows-1)};Terminal.prototype.VPositionRelative=function(a){a=a[0];1>a&&(a=1);this.y+=a;this.y>=this.rows&&(this.y=this.rows-1)};Terminal.prototype.HVPosition=function(a){1>a[0]&&(a[0]=1);1>a[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)};Terminal.prototype.setMode=function(a){if("object"===typeof a)for(var k=a.length,v=0;v=a?delete this.tabs[this.x]:3===a&&(this.tabs={})};Terminal.prototype.mediaCopy=function(a){};Terminal.prototype.setResources=function(a){};Terminal.prototype.disableModifiers=function(a){};Terminal.prototype.setPointerMode=function(a){};Terminal.prototype.softReset=function(a){this.applicationCursor=this.applicationKeypad=this.wraparoundMode=this.originMode=this.insertMode=this.cursorHidden=!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]};Terminal.prototype.requestAnsiMode=function(a){};Terminal.prototype.requestPrivateMode=function(a){};Terminal.prototype.setConformanceLevel=function(a){};Terminal.prototype.loadLEDs=function(a){};Terminal.prototype.setCursorStyle=function(a){};Terminal.prototype.setCharProtectionAttr=function(a){};Terminal.prototype.restorePrivateValues=function(a){};Terminal.prototype.setAttrInRectangle=function(a){for(var c=a[0],k=a[1],f=a[2],v=a[3],s=a[4],z,u;ca.length?"0"+a:a}var y=colors,f=[0,95,135,175,215,255],v;for(v=0;216>v;v++)out(f[v/36%6|0],f[v/6%6|0],f[v%6]);for(v=0;24>v;v++)f=8+10*v,out(f,f,f);return y};var DEFAULT_COLORS=initColors(TANGO_COLORS.slice());var mergeColors=function(themeColors,defaultColors){if(themeColors.length===8){themeColors=themeColors.concat(defaultColors.slice(8))}else if(themeColors.length===16){themeColors=themeColors.concat(defaultColors.slice(16))}else if(themeColors.length===10){themeColors=themeColors.slice(0,-2).concat(defaultColors.slice(8,-2),themeColors.slice(-2))}else if(themeColors.length===18){themeColors=themeColors.concat(defaultColors.slice(16,-2),themeColors.slice(-2))}return themeColors};var colors=function(theme){var colors=theme.palette.slice();colors[256]=theme.background||"#000000";colors[257]=theme.foreground||"#f0f0f0";return mergeColors(colors,DEFAULT_COLORS)};var defaults={"default":{palette:["#000000","#c81908","#00c01d","#c8c221","#0033c5","#c73ac5","#00c6c7","#c7c7c7","#686868","#8a8a8a","#67f86e","#fff970","#6678fc","#ff7cfd","#65fdff","#ffffff"]},blazer:{palette:["#262626","#dbbdbd","#bddbbd","#dbdbbd","#bdbddb","#dbbddb","#bddbdb","#ffffff"],name:"blazer"},chalkboard:{foreground:"#d9e6f2",background:"#29262f",cursor:"#d9e6f2",cursor_text:"#29262f",palette:["#000000","#c37372","#72c373","#c2c372","#7372c3","#c372c2","#72c2c3","#d9d9d9","#323232","#dbaaaa","#aadbaa","#dadbaa","#aaaadb","#dbaada","#aadadb","#ffffff"],name:"chalkboard"},dark_pastel:{foreground:"#ffffff",background:"#000000",cursor:"#bbbbbb",cursor_text:"#ffffff",palette:["#000000","#ff5555","#55ff55","#ffff55","#5555ff","#ff55ff","#55ffff","#bbbbbb","#555555","#ff5555","#55ff55","#ffff55","#5555ff","#ff55ff","#55ffff","#ffffff"],name:"dark_pastel"},desert:{foreground:"#ffffff",background:"#333333",cursor:"#00ff00",cursor_text:"#000000",palette:["#4d4d4d","#ff2b2b","#98fb98","#f0e68c","#cd853f","#ffdead","#ffa0a0","#f5deb3","#555555","#ff5555","#55ff55","#ffff55","#87ceff","#ff55ff","#ffd700","#ffffff"],name:"desert"},espresso:{foreground:"#ffffff",background:"#323232",cursor:"#d6d6d6",cursor_text:"#ffffff",palette:["#343434","#d25151","#a5c261","#ffc66d","#6c99bb","#d197d9","#bed6ff","#eeeeec","#535353","#f00c0c","#c2e075","#e1e38b","#8ab7d9","#efb5f7","#dcf3ff","#ffffff"],name:"espresso"},github:{foreground:"#3e3e3e",background:"#f4f4f4",cursor:"#3f3f3f",cursor_text:"#f4f4f4",palette:["#3e3e3e","#970b16","#07962a","#f8eec7","#003e8a","#e94691","#89d1ec","#ffffff","#666666","#de0000","#87d5a2","#f1d007","#2e6cba","#ffa29f","#1cfafe","#ffffff"],name:"github"},grass:{foreground:"#fff0a5",background:"#13773c",cursor:"#8c2800",cursor_text:"#ffffff",palette:["#000000","#bb0000","#00bb00","#e7b000","#0000a3","#950061","#00bbbb","#bbbbbb","#555555","#bb0000","#00bb00","#e7b000","#0000bb","#ff55ff","#55ffff","#ffffff"],name:"grass"},homebrew:{foreground:"#00ff00",background:"#000000",cursor:"#23ff18",cursor_text:"#ff0017",palette:["#000000","#990000","#00a600","#999900","#0000b2","#b200b2","#00a6b2","#bfbfbf","#666666","#e50000","#00d900","#e5e500","#0000ff","#e500e5","#00e5e5","#e5e5e5"],name:"homebrew"},hurtado:{foreground:"#dadbda",background:"#000000",cursor:"#bbbbbb",cursor_text:"#ffffff",palette:["#575757","#ff1b00","#a5df55","#fbe74a","#486387","#fc5ef0","#85e9fe","#cbcbcb","#252525","#d41c00","#a5df55","#fbe749","#89bdff","#bf00c0","#85e9fe","#dbdbdb"],name:"hurtado"},idletoes:{foreground:"#ffffff",background:"#323232",cursor:"#d6d6d6",cursor_text:"#000000",palette:["#323232","#d25252","#7fe173","#ffc66d","#4098ff","#f57fff","#bed6ff","#eeeeec","#535353","#f07070","#9dff90","#ffe48b","#5eb7f7","#ff9dff","#dcf4ff","#ffffff"],name:"idletoes"},kibble:{foreground:"#f7f7f7",background:"#0e100a",cursor:"#9fda9c",cursor_text:"#000000",palette:["#4d4d4d","#c70031","#29cf13","#d8e30e","#3449d1","#8400ff","#0798ab","#e2d1e3","#5a5a5a","#f01578","#6ce05c","#f3f79e","#97a4f7","#c495f0","#68f2e0","#ffffff"],name:"kibble"},man_page:{foreground:"#000000",background:"#fef49c",cursor:"#7f7f7f",cursor_text:"#000000",palette:["#000000","#cc0000","#00a600","#999900","#0000b2","#b200b2","#00a6b2","#cccccc","#666666","#e50000","#00d900","#e5e500","#0000ff","#e500e5","#00e5e5","#e5e5e5"],name:"man_page"},monokai_soda:{foreground:"#c4c4b5",background:"#191919",cursor:"#f6f6ec",cursor_text:"#c4c4b5",palette:["#191919","#f3005f","#97e023","#fa8419","#9c64fe","#f3005f","#57d1ea","#c4c4b5","#615e4b","#f3005f","#97e023","#dfd561","#9c64fe","#f3005f","#57d1ea","#f6f6ee"],name:"monokai_soda"},neopolitan:{foreground:"#ffffff",background:"#17130f",cursor:"#ffffff",cursor_text:"#ffffff",palette:["#17130f","#800000","#61ce3c","#fbde2d","#253b76","#ff0080","#8da6ce","#f8f8f8","#17130f","#800000","#61ce3c","#fbde2d","#253b76","#ff0080","#8da6ce","#f8f8f8"],name:"neopolitan"},novel:{foreground:"#3b2322",background:"#dfdbc3",cursor:"#73635a",cursor_text:"#000000",palette:["#000000","#cc0000","#009600","#d06b00","#0000cc","#cc00cc","#0087cc","#cccccc","#7f7f7f","#cc0000","#009600","#d06b00","#0000cc","#cc00cc","#0086cb","#ffffff"],name:"novel"},ocean:{foreground:"#ffffff",background:"#224fbc",cursor:"#7f7f7f",cursor_text:"#ffffff",palette:["#000000","#990000","#00a600","#999900","#0000b2","#b200b2","#00a6b2","#bfbfbf","#666666","#e50000","#00d900","#e5e500","#0000ff","#e500e5","#00e5e5","#e5e5e5"],name:"ocean"},pro:{foreground:"#f2f2f2",background:"#000000",cursor:"#4d4d4d",cursor_text:"#ffffff",palette:["#000000","#990000","#00a600","#999900","#1f08db","#b200b2","#00a6b2","#bfbfbf","#666666","#e50000","#00d900","#e5e500","#0000ff","#e500e5","#00e5e5","#e5e5e5"],name:"pro"},red_sands:{foreground:"#d7c9a7",background:"#79241e",cursor:"#ffffff",cursor_text:"#000000",palette:["#000000","#ff3f00","#00bb00","#e7b000","#0071ff","#bb00bb","#00bbbb","#bbbbbb","#555555","#bb0000","#00bb00","#e7b000","#0071ae","#ff55ff","#55ffff","#ffffff"],name:"red_sands"},seafoam_pastel:{foreground:"#d3e7d3",background:"#243434",cursor:"#576479",cursor_text:"#323232",palette:["#757575","#825d4d","#718c61","#ada16d","#4d7b82","#8a7167","#719393","#e0e0e0","#8a8a8a","#cf9379","#98d9aa","#fae79d","#79c3cf","#d6b2a1","#ade0e0","#e0e0e0"],name:"seafoam_pastel"},solarized_darcula:{foreground:"#d2d8d9",background:"#3d3f41",cursor:"#708183",cursor_text:"#002731",palette:["#25292a","#f24840","#629655","#b68800","#2075c7","#797fd4","#15968d","#d2d8d9","#25292a","#f24840","#629655","#b68800","#2075c7","#797fd4","#15968d","#d2d8d9"],name:"solarized_darcula"},solarized_dark:{foreground:"#708183",background:"#001e26",cursor:"#708183",cursor_text:"#002731",palette:["#002731","#d01b24","#728905","#a57705","#2075c7","#c61b6e","#259185","#e9e2cb","#001e26","#bd3612","#465a61","#52676f","#708183","#5856b9","#81908f","#fcf4dc"],name:"solarized_dark"},solarized_light:{foreground:"#52676f",background:"#fcf4dc",cursor:"#52676f",cursor_text:"#e9e2cb",palette:["#002731","#d01b24","#728905","#a57705","#2075c7","#c61b6e","#259185","#e9e2cb","#001e26","#bd3612","#465a61","#52676f","#708183","#5856b9","#81908f","#fcf4dc"],name:"solarized_light"},symfonic:{foreground:"#ffffff",background:"#000000",cursor:"#dc322f",cursor_text:"#ffffff",palette:["#000000","#dc322f","#56db3a","#ff8400","#0084d4","#b729d9","#ccccff","#ffffff","#1b1d21","#dc322f","#56db3a","#ff8400","#0084d4","#b729d9","#ccccff","#ffffff"],name:"symfonic"},terminal_basic:{foreground:"#000000",background:"#ffffff",cursor:"#7f7f7f",cursor_text:"#000000",palette:["#000000","#990000","#00a600","#999900","#0000b2","#b200b2","#00a6b2","#bfbfbf","#666666","#e50000","#00d900","#e5e500","#0000ff","#e500e5","#00e5e5","#e5e5e5"],name:"terminal_basic"},vaughn:{foreground:"#dcdccc",background:"#25234e",cursor:"#ff5555",cursor_text:"#ffffff",palette:["#24234f","#705050","#60b48a","#dfaf8f","#5555ff","#f08cc3","#8cd0d3","#709080","#709080","#dca3a3","#60b48a","#f0dfaf","#5555ff","#ec93d3","#93e0e3","#ffffff"],name:"vaughn"},zenburn:{foreground:"#dcdccc",background:"#3f3f3f",cursor:"#73635a",cursor_text:"#000000",palette:["#4d4d4d","#705050","#60b48a","#f0dfaf","#506070","#dc8cc3","#8cd0d3","#dcdccc","#709080","#dca3a3","#c3bf9f","#e0cf9f","#94bff3","#ec93d3","#93e0e3","#ffffff"],name:"zenburn"}};module.exports={defaults:defaults,colors:colors}},{}],5:[function(_dereq_,module,exports){function inherits(a,c){function k(){this.constructor=a}k.prototype=c.prototype;a.prototype=new k}function isVisible(el){var eap,rect=el.getBoundingClientRect(),docEl=document.documentElement,vWidth=window.innerWidth||docEl.clientWidth,vHeight=window.innerHeight||docEl.clientHeight,efp=function(x,y){return document.elementFromPoint(x,y)},contains="contains"in el?"contains":"compareDocumentPosition",has=contains=="contains"?1:16;if(rect.right<0||rect.bottom<0||rect.left>vWidth||rect.top>vHeight)return false;return(eap=efp(rect.left,rect.top))==el||el[contains](eap)==has||(eap=efp(rect.right,rect.top))==el||el[contains](eap)==has||(eap=efp(rect.right,rect.bottom))==el||el[contains](eap)==has||(eap=efp(rect.left,rect.bottom))==el||el[contains](eap)==has}function getSelection(){var html="";if(typeof window.getSelection!="undefined"){return window.getSelection().toString()}else if(typeof document.selection!="undefined"){if(document.selection.type=="Text"){return document.selection.createRange().htmlText}}return null}function isBoldBroken(){var a=document.createElement("span");a.innerHTML="hello world";document.body.appendChild(a);var c=a.scrollWidth;a.style.fontWeight="bold";var k=a.scrollWidth;document.body.removeChild(a);return c!==k}module.exports={inherits:inherits,isBoldBroken:isBoldBroken,isVisible:isVisible,getSelection:getSelection}},{}]},{},[3])(3)}); \ No newline at end of file diff --git a/public/style.css b/public/style.css index 1c9485a..c814279 100644 --- a/public/style.css +++ b/public/style.css @@ -80,8 +80,7 @@ body { line-height: 18px; } .terminal-container .terminal-input { - position: absolute; - top: 0; + position: fixed; left: -1000%; background: rgba(255,255,255,0.75); color: black; diff --git a/src/index.js b/src/index.js index 020475b..e7602e5 100644 --- a/src/index.js +++ b/src/index.js @@ -303,18 +303,17 @@ Terminal.prototype.open = function (parent) { button = button === 1 ? 0 : button === 4 ? 1 : button; } - // If user select text - if (utils.getSelection()) return; - // Not right button - if (button !== 2) return that.focus(); + if (button !== 2) return; that.element.contentEditable = true; - that.element.focus(); setTimeout(function() { - that.inputElement.focus(); that.element.contentEditable = 'inherit'; // 'false'; - }, 1); + var selection = utils.getSelection(); + // If user doesn't select text or ignore one space selection on mac + if (!selection || (Terminal.isMac && selection === ' ')) + that.inputElement.focus(); + }, Terminal.isMac ? 1 : 400); }, !0); events.on(this.inputElement, "paste", function (c) { setTimeout(function () {