From: Shuanglei Tao Date: Sat, 13 May 2017 11:51:52 +0000 (+0800) Subject: Upgrade to xterm.js 2.6.0 X-Git-Url: http://git.prime8.dev/?a=commitdiff_plain;h=153fc94855a2bc968f8fe0c83485754ff05f4a57;p=ttyd.git Upgrade to xterm.js 2.6.0 --- diff --git a/html/js/app.js b/html/js/app.js index ad1687d..f284d12 100644 --- a/html/js/app.js +++ b/html/js/app.js @@ -48,14 +48,13 @@ }); window.addEventListener('beforeunload', unloadCallback); term.fit(); - term.focus(); }); while (terminalContainer.firstChild) { terminalContainer.removeChild(terminalContainer.firstChild); } - term.open(terminalContainer); + term.open(terminalContainer, true); }; ws.onmessage = function(event) { diff --git a/html/package.json b/html/package.json index 7ae0337..2b49179 100644 --- a/html/package.json +++ b/html/package.json @@ -15,6 +15,6 @@ "dependencies": { "gulp": "^3.9.1", "gulp-inline-source": "^3.0.0", - "xterm": "^2.5.0" + "xterm": "^2.6.0" } } diff --git a/html/yarn.lock b/html/yarn.lock index e480dfe..4f1c5ee 100644 --- a/html/yarn.lock +++ b/html/yarn.lock @@ -1413,9 +1413,9 @@ wrappy@1: version "4.0.1" resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.1.tgz#a5c6d532be656e23db820efb943a1f04998d63af" -xterm@^2.5.0: - version "2.5.0" - resolved "https://registry.yarnpkg.com/xterm/-/xterm-2.5.0.tgz#5a6239ba08a40640127e80b3d8180df34a06b499" +xterm@^2.6.0: + version "2.6.0" + resolved "https://registry.yarnpkg.com/xterm/-/xterm-2.6.0.tgz#d8daa6d9c3ebee0c850b156cd2f92fbfc8fdfb3e" yargs@~3.10.0: version "3.10.0" diff --git a/src/index.html b/src/index.html index 6e9f529..e2ec8b2 100644 --- a/src/index.html +++ b/src/index.html @@ -8,8 +8,8 @@ +}},h.q=function(t,e,i,r){" "===r&&t.setCursorStyle(e)},h.r=function(t,e){return t.setScrollRegion(e)},h.s=function(t,e){return t.saveCursor(e)},h.u=function(t,e){return t.restoreCursor(e)},h[r.C0.CAN]=function(t,e,i,r,s){return s.setState(l.NORMAL)};var l;!function(t){t[t.NORMAL=0]="NORMAL",t[t.ESCAPED=1]="ESCAPED",t[t.CSI_PARAM=2]="CSI_PARAM",t[t.CSI=3]="CSI",t[t.OSC=4]="OSC",t[t.CHARSET=5]="CHARSET",t[t.DCS=6]="DCS",t[t.IGNORE=7]="IGNORE"}(l||(l={}));var c=function(){function t(t,e){this._inputHandler=t,this._terminal=e,this._state=l.NORMAL}return t.prototype.parse=function(t){var e,i,c,u,m=t.length;for(this._position=0,this._terminal.surrogate_high&&(t=this._terminal.surrogate_high+t,this._terminal.surrogate_high="");this._position":this._terminal.log("Switching back to normal keypad."),this._terminal.applicationKeypad=!1,this._terminal.viewport.syncScrollArea(),this._state=l.NORMAL;break;default:this._state=l.NORMAL,this._terminal.error("Unknown ESC control: %s.",i)}break;case l.CHARSET:i in s.CHARSETS?(e=s.CHARSETS[i],"/"===i&&this.skipNextChar()):e=s.DEFAULT_CHARSET,this._terminal.setgCharset(this._terminal.gcharset,e),this._terminal.gcharset=null,this._state=l.NORMAL;break;case l.OSC:if(i===r.C0.ESC||i===r.C0.BEL){switch(i===r.C0.ESC&&this._position++,this._terminal.params.push(this._terminal.currentParam),this._terminal.params[0]){case 0:case 1:case 2:this._terminal.params[1]&&(this._terminal.title=this._terminal.params[1],this._terminal.handleTitle(this._terminal.title));break;case 3:break;case 4:case 5:break;case 10:case 11:case 12:case 13:case 14:case 15:case 16:case 17:case 18:case 19:break;case 46:break;case 50:break;case 51:break;case 52:break;case 104:case 105:case 110:case 111:case 112:case 113:case 114:case 115:case 116:case 117:case 118:}this._terminal.params=[],this._terminal.currentParam=0,this._state=l.NORMAL}else this._terminal.params.length?this._terminal.currentParam+=i:i>="0"&&i<="9"?this._terminal.currentParam=10*this._terminal.currentParam+i.charCodeAt(0)-48:";"===i&&(this._terminal.params.push(this._terminal.currentParam),this._terminal.currentParam="");break;case l.CSI_PARAM:if(i in o){o[i](this);break}this.finalizeParam(),this._state=l.CSI;case l.CSI:i in h?h[i](this._inputHandler,this._terminal.params,this._terminal.prefix,this._terminal.postfix,this):this._terminal.error("Unknown CSI code: %s.",i),this._state=l.NORMAL,this._terminal.prefix="",this._terminal.postfix="";break;case l.DCS:if(i===r.C0.ESC||i===r.C0.BEL){switch(i===r.C0.ESC&&this._position++,this._terminal.prefix){case"":break;case"$q":var p=this._terminal.currentParam,f=!1;switch(p){case'"q':p='0"q';break;case'"p':p='61"p';break;case"r":p=""+(this._terminal.scrollTop+1)+";"+(this._terminal.scrollBottom+1)+"r";break;case"m":p="0m";break;default:this._terminal.error("Unknown DCS Pt: %s.",p),p=""}this._terminal.send(r.C0.ESC+"P"+ +f+"$r"+p+r.C0.ESC+"\\");break;case"+p":break;case"+q":p=this._terminal.currentParam,f=!1,this._terminal.send(r.C0.ESC+"P"+ +f+"+r"+p+r.C0.ESC+"\\");break;default:this._terminal.error("Unknown DCS prefix: %s.",this._terminal.prefix)}this._terminal.currentParam=0,this._terminal.prefix="",this._state=l.NORMAL}else this._terminal.currentParam?this._terminal.currentParam+=i:this._terminal.prefix||"$"===i||"+"===i?2===this._terminal.prefix.length?this._terminal.currentParam=i:this._terminal.prefix+=i:this._terminal.currentParam=i;break;case l.IGNORE:i!==r.C0.ESC&&i!==r.C0.BEL||(i===r.C0.ESC&&this._position++,this._state=l.NORMAL)}}},t.prototype.setState=function(t){this._state=t},t.prototype.setPrefix=function(t){this._terminal.prefix=t},t.prototype.setPostfix=function(t){this._terminal.postfix=t},t.prototype.setParam=function(t){this._terminal.currentParam=t},t.prototype.getParam=function(){return this._terminal.currentParam},t.prototype.finalizeParam=function(){this._terminal.params.push(this._terminal.currentParam),this._terminal.currentParam=0},t.prototype.skipNextChar=function(){this._position++},t}();i.Parser=c},{"./Charsets":1,"./EscapeSequences":3}],8:[function(t,e,i){"use strict";function r(t){var e=t.ownerDocument,i=e.createElement("span");i.innerHTML="hello world",t.appendChild(i);var r=i.offsetWidth,s=i.offsetHeight;i.style.fontWeight="bold";var n=i.offsetWidth,a=i.offsetHeight;return t.removeChild(i),r!==n||s!==a}Object.defineProperty(i,"__esModule",{value:!0});var s,n=5;!function(t){t[t.BOLD=1]="BOLD",t[t.UNDERLINE=2]="UNDERLINE",t[t.BLINK=4]="BLINK",t[t.INVERSE=8]="INVERSE",t[t.INVISIBLE=16]="INVISIBLE"}(s||(s={}));var a=null,o=function(){function t(t){this._terminal=t,this._refreshRowsQueue=[],this._refreshFramesSkipped=0,this._refreshAnimationFrame=null,null===a&&(a=r(this._terminal.element))}return t.prototype.queueRefresh=function(t,e){this._refreshRowsQueue.push({start:t,end:e}),this._refreshAnimationFrame||(this._refreshAnimationFrame=window.requestAnimationFrame(this._refreshLoop.bind(this)))},t.prototype._refreshLoop=function(){var t=this._terminal.writeBuffer.length>0&&this._refreshFramesSkipped++<=n;if(t)return void(this._refreshAnimationFrame=window.requestAnimationFrame(this._refreshLoop.bind(this)));this._refreshFramesSkipped=0;var e,i;if(this._refreshRowsQueue.length>4)e=0,i=this._terminal.rows-1;else{e=this._refreshRowsQueue[0].start,i=this._refreshRowsQueue[0].end;for(var r=1;ri&&(i=this._refreshRowsQueue[r].end)}this._refreshRowsQueue=[],this._refreshAnimationFrame=null,this._refresh(e,i)},t.prototype._refresh=function(t,e){var i,r,n,o,h,l,c,u,m,p,f,d,_,y,C;document.activeElement;for(e-t>=this._terminal.rows/2&&(C=this._terminal.element.parentNode,C&&this._terminal.element.removeChild(this._terminal.rowContainer)),u=this._terminal.cols,r=t,e>=this._terminal.rows&&(this._terminal.log("`end` is too large. Most likely a bad CSR."),e=this._terminal.rows-1);r<=e;r++)if(y=r+this._terminal.ydisp,o=this._terminal.lines.get(y),o&&this._terminal.children[r]){for(h="",i=this._terminal.y===r-(this._terminal.ybase-this._terminal.ydisp)&&this._terminal.cursorState&&!this._terminal.cursorHidden?this._terminal.x:-1,p=this._terminal.defAttr,n=0;n"),m!==this._terminal.defAttr))if(m===-1)h+='';else{var g=[];f=511&m,d=m>>9&511,_=m>>18,_&s.BOLD&&(a||g.push("xterm-bold"),d<8&&(d+=8)),_&s.UNDERLINE&&g.push("xterm-underline"),_&s.BLINK&&g.push("xterm-blink"),_&s.INVERSE&&(f=[d,d=f][0],1&_&&d<8&&(d+=8)),_&s.INVISIBLE&&g.push("xterm-hidden"),_&s.INVERSE&&(257===f&&(f=15),256===d&&(d=0)),f<256&&g.push("xterm-bg-color-"+f),d<256&&g.push("xterm-color-"+d),h+="'),l){case"&":h+="&";break;case"<":h+="<";break;case">":h+=">";break;default:h+=l<=" "?" ":l}2===c&&(h+=""),p=m}p!==this._terminal.defAttr&&(h+=""),this._terminal.children[r].innerHTML=h}C&&this._terminal.element.appendChild(this._terminal.rowContainer),this._terminal.emit("refresh",{element:this._terminal.element,start:t,end:e})},t}();i.Renderer=o},{}],9:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var r=function(){function t(t,e,i,r){var s=this;this.terminal=t,this.viewportElement=e,this.scrollArea=i,this.charMeasure=r,this.currentRowHeight=0,this.lastRecordedBufferLength=0,this.lastRecordedViewportHeight=0,this.terminal.on("scroll",this.syncScrollArea.bind(this)),this.terminal.on("resize",this.syncScrollArea.bind(this)),this.viewportElement.addEventListener("scroll",this.onScroll.bind(this)),setTimeout(function(){return s.syncScrollArea()},0)}return t.prototype.refresh=function(){if(this.charMeasure.height>0){var t=this.charMeasure.height!==this.currentRowHeight;t&&(this.currentRowHeight=this.charMeasure.height,this.viewportElement.style.lineHeight=this.charMeasure.height+"px",this.terminal.rowContainer.style.lineHeight=this.charMeasure.height+"px");var e=this.lastRecordedViewportHeight!==this.terminal.rows;(t||e)&&(this.lastRecordedViewportHeight=this.terminal.rows,this.viewportElement.style.height=this.charMeasure.height*this.terminal.rows+"px"),this.scrollArea.style.height=this.charMeasure.height*this.lastRecordedBufferLength+"px"}},t.prototype.syncScrollArea=function(){this.lastRecordedBufferLength!==this.terminal.lines.length?(this.lastRecordedBufferLength=this.terminal.lines.length,this.refresh()):this.lastRecordedViewportHeight!==this.terminal.rows?this.refresh():this.charMeasure.height!==this.currentRowHeight&&this.refresh();var t=this.terminal.ydisp*this.currentRowHeight;this.viewportElement.scrollTop!==t&&(this.viewportElement.scrollTop=t)},t.prototype.onScroll=function(t){var e=Math.round(this.viewportElement.scrollTop/this.currentRowHeight),i=e-this.terminal.ydisp;this.terminal.scrollDisp(i,!0)},t.prototype.onWheel=function(t){if(0!==t.deltaY){var e=1;t.deltaMode===WheelEvent.DOM_DELTA_LINE?e=this.currentRowHeight:t.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(e=this.currentRowHeight*this.terminal.rows),this.viewportElement.scrollTop+=t.deltaY*e,t.preventDefault()}},t}();i.Viewport=r},{}],10:[function(t,e,i){"use strict";function r(t){var e=String.fromCharCode(32),i=String.fromCharCode(160),r=new RegExp(i,"g"),s=t.split("\n").map(function(t){var i=t.replace(/\s+$/g,"").replace(r,e);return i}).join("\n");return s}function s(t,e){var i=window.getSelection().toString(),s=r(i);e.browser.isMSIE?window.clipboardData.setData("Text",s):t.clipboardData.setData("text/plain",s),t.preventDefault()}function n(t,e){t.stopPropagation();var i,r=function(i){return e.handler(i),e.textarea.value="",e.cancel(t)};e.browser.isMSIE?window.clipboardData&&(i=window.clipboardData.getData("Text"),r(i)):t.clipboardData&&(i=t.clipboardData.getData("text/plain"),r(i))}function a(t,e){var i=document.getSelection(),s=r(i.toString()),n=!1,a=t.clientX,o=t.clientY;if(i.rangeCount){for(var h=i.getRangeAt(0),l=h.getClientRects(),c=0;cu.left&&au.top&&othis._length)for(var e=this._length;e=t;s--)this._array[this._getCyclicIndex(s+i.length)]=this._array[this._getCyclicIndex(s)];for(var s=0;sthis.maxLength?(this._startIndex+=this._length+i.length-this.maxLength,this._length=this.maxLength):this._length+=i.length}},t.prototype.trimStart=function(t){t>this._length&&(t=this._length),this._startIndex+=t,this._length-=t},t.prototype.shiftElements=function(t,e,i){if(!(e<=0)){if(t<0||t>=this._length)throw new Error("start argument out of range");if(t+i<0)throw new Error("Cannot shift elements in list beyond index 0");if(i>0){for(var r=e-1;r>=0;r--)this.set(t+r+i,this.get(t+r));var s=t+e+i-this._length;if(s>0)for(this._length+=s;this._length>this.maxLength;)this._length--,this._startIndex++}else for(var r=0;r=0}Object.defineProperty(i,"__esModule",{value:!0}),i.contains=r},{}],15:[function(e,i,r){"use strict";function s(t){var e=this;if(!(this instanceof s))return new s(arguments[0],arguments[1],arguments[2]);e.browser=S,e.cancel=s.cancel,d.EventEmitter.call(this),"number"==typeof t&&(t={cols:arguments[0],rows:arguments[1],handler:arguments[2]}),t=t||{},Object.keys(s.defaults).forEach(function(i){null==t[i]&&(t[i]=s.options[i],s[i]!==s.defaults[i]&&(t[i]=s[i])),e[i]=t[i]}),8===t.colors.length?t.colors=t.colors.concat(s._colors.slice(8)):16===t.colors.length?t.colors=t.colors.concat(s._colors.slice(16)):10===t.colors.length?t.colors=t.colors.slice(0,-2).concat(s._colors.slice(8,-2),t.colors.slice(-2)):18===t.colors.length&&(t.colors=t.colors.concat(s._colors.slice(16,-2),t.colors.slice(-2))),this.colors=t.colors,this.options=t,this.parent=t.body||t.parent||(E?E.getElementsByTagName("body")[0]:null),this.cols=t.cols||t.geometry[0],this.rows=t.rows||t.geometry[1],this.geometry=[this.cols,this.rows],t.handler&&this.on("data",t.handler),this.ybase=0,this.ydisp=0,this.x=0,this.y=0,this.cursorState=0,this.cursorHidden=!1,this.convertEol,this.queue="",this.scrollTop=0,this.scrollBottom=this.rows-1,this.customKeydownHandler=null,this.cursorBlinkInterval=null,this.applicationKeypad=!1,this.applicationCursor=!1,this.originMode=!1,this.insertMode=!1,this.wraparoundMode=!0,this.normal=null,this.charset=null,this.gcharset=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.readable=!0,this.writable=!0,this.defAttr=131840,this.curAttr=this.defAttr,this.params=[],this.currentParam=0,this.prefix="",this.postfix="",this.inputHandler=new v.InputHandler(this),this.parser=new b.Parser(this.inputHandler,this),this.renderer=this.renderer||null,this.linkifier=this.linkifier||new w.Linkifier,this.writeBuffer=[],this.writeInProgress=!1,this.xoffSentToCatchUp=!1,this.writeStopped=!1,this.surrogate_high="",this.lines=new C.CircularList(this.scrollback);for(var i=this.rows;i--;)this.lines.push(this.blankLine());this.tabs,this.setupStops(),this.userScrolling=!1}function n(t,e,i,r){Array.isArray(t)||(t=[t]),t.forEach(function(t){t.addEventListener(e,i,r||!1)})}function a(t,e,i,r){t.removeEventListener(e,i,r||!1)}function o(t,e){if(this.cancelEvents||e)return t.preventDefault(),t.stopPropagation(),!1}function h(t,e){function i(){this.constructor=t}i.prototype=e.prototype,t.prototype=new i}function l(t,e){var i=t.browser.isMac&&e.altKey&&!e.ctrlKey&&!e.metaKey||t.browser.isMSWindows&&e.altKey&&e.ctrlKey&&!e.metaKey;return"keypress"==e.type?i:i&&(!e.keyCode||e.keyCode>47)}function c(t,e,i){var r=t<<16|e<<8|i;if(null!=c._cache[r])return c._cache[r];for(var n,a,o,h,l,u=1/0,m=-1,p=0;p>16&255,t>>8&255,255&t]);return e}(),s.defaults={colors:s.colors,theme:"default",convertEol:!1,termName:"xterm",geometry:[80,24],cursorBlink:!1,cursorStyle:"block",visualBell:!1,popOnBell:!1,scrollback:1e3,screenKeys:!1,debug:!1,cancelEvents:!1,disableStdin:!1,useFlowControl:!1,tabStopWidth:8},s.options={},s.focus=null,u(p(s.defaults),function(t){s[t]=s.defaults[t],s.options[t]=s.defaults[t]}),s.prototype.focus=function(){return this.textarea.focus()},s.prototype.getOption=function(t,e){if(!(t in s.defaults))throw new Error('No option with key "'+t+'"');return"undefined"!=typeof this.options[t]?this.options[t]:this[t]},s.prototype.setOption=function(t,e){if(!(t in s.defaults))throw new Error('No option with key "'+t+'"');switch(t){case"scrollback":if(this.options[t]!==e){if(this.lines.length>e){var i=this.lines.length-e,r=this.ydisp-i<0;this.lines.trimStart(i),this.ybase=Math.max(this.ybase-i,0),this.ydisp=Math.max(this.ydisp-i,0),r&&this.refresh(0,this.rows-1)}this.lines.maxLength=e,this.viewport.syncScrollArea()}}switch(this[t]=e,this.options[t]=e,t){case"cursorBlink":this.setCursorBlinking(e);break;case"cursorStyle":this.element.classList.toggle("xterm-cursor-style-underline","underline"===e),this.element.classList.toggle("xterm-cursor-style-bar","bar"===e);break;case"tabStopWidth":this.setupStops()}},s.prototype.restartCursorBlinking=function(){this.setCursorBlinking(this.options.cursorBlink)},s.prototype.setCursorBlinking=function(t){if(this.element.classList.toggle("xterm-cursor-blink",t),this.clearCursorBlinkingInterval(),t){var e=this;this.cursorBlinkInterval=setInterval(function(){e.element.classList.toggle("xterm-cursor-blink-on")},L)}},s.prototype.clearCursorBlinkingInterval=function(){this.element.classList.remove("xterm-cursor-blink-on"),this.cursorBlinkInterval&&(clearInterval(this.cursorBlinkInterval),this.cursorBlinkInterval=null)},s.bindFocus=function(t){n(t.textarea,"focus",function(e){t.sendFocus&&t.send(g.C0.ESC+"[I"),t.element.classList.add("focus"),t.showCursor(),t.restartCursorBlinking.apply(t),s.focus=t,t.emit("focus",{terminal:t})})},s.prototype.blur=function(){return this.textarea.blur()},s.bindBlur=function(t){n(t.textarea,"blur",function(e){t.refresh(t.y,t.y),t.sendFocus&&t.send(g.C0.ESC+"[O"),t.element.classList.remove("focus"),t.clearCursorBlinkingInterval.apply(t),s.focus=null,t.emit("blur",{terminal:t})})},s.prototype.initGlobal=function(){function t(t){y.rightClickHandler.call(this,t,e)}var e=this;s.bindKeys(this),s.bindFocus(this),s.bindBlur(this),n(this.element,"copy",function(t){y.copyHandler.call(this,t,e)}),n(this.textarea,"paste",function(t){y.pasteHandler.call(this,t,e)}),n(this.element,"paste",function(t){y.pasteHandler.call(this,t,e)}),e.browser.isFirefox?n(this.element,"mousedown",function(e){2==e.button&&t(e)}):n(this.element,"contextmenu",t)},s.bindKeys=function(t){n(t.element,"keydown",function(e){E.activeElement==this&&t.keyDown(e)},!0),n(t.element,"keypress",function(e){E.activeElement==this&&t.keyPress(e)},!0),n(t.element,"keyup",function(e){m(e)||t.focus(t)},!0),n(t.textarea,"keydown",function(e){t.keyDown(e)},!0),n(t.textarea,"keypress",function(e){t.keyPress(e),this.value=""},!0),n(t.textarea,"compositionstart",t.compositionHelper.compositionstart.bind(t.compositionHelper)),n(t.textarea,"compositionupdate",t.compositionHelper.compositionupdate.bind(t.compositionHelper)),n(t.textarea,"compositionend",t.compositionHelper.compositionend.bind(t.compositionHelper)),t.on("refresh",t.compositionHelper.updateCompositionElements.bind(t.compositionHelper)),t.on("refresh",function(e){t.queueLinkification(e.start,e.end)})},s.prototype.insertRow=function(t){return"object"!=typeof t&&(t=E.createElement("div")),this.rowContainer.appendChild(t),this.children.push(t),t},s.prototype.open=function(t,e){var i=this,r=0;if(this.parent=t||this.parent,!this.parent)throw new Error("Terminal requires a parent element.");for(this.context=this.parent.ownerDocument.defaultView,this.document=this.parent.ownerDocument,this.body=this.document.getElementsByTagName("body")[0],this.element=this.document.createElement("div"),this.element.classList.add("terminal"),this.element.classList.add("xterm"),this.element.classList.add("xterm-theme-"+this.theme),this.setCursorBlinking(this.options.cursorBlink),this.element.style.height,this.element.setAttribute("tabindex",0),this.viewportElement=E.createElement("div"),this.viewportElement.classList.add("xterm-viewport"),this.element.appendChild(this.viewportElement),this.viewportScrollArea=E.createElement("div"),this.viewportScrollArea.classList.add("xterm-scroll-area"),this.viewportElement.appendChild(this.viewportScrollArea),this.rowContainer=E.createElement("div"),this.rowContainer.classList.add("xterm-rows"),this.element.appendChild(this.rowContainer),this.children=[],this.linkifier.attachToDom(E,this.children),this.helperContainer=E.createElement("div"),this.helperContainer.classList.add("xterm-helpers"),this.element.appendChild(this.helperContainer),this.textarea=E.createElement("textarea"),this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this.textarea.addEventListener("focus",function(){i.emit("focus",{terminal:i})}),this.textarea.addEventListener("blur",function(){i.emit("blur",{terminal:i})}),this.helperContainer.appendChild(this.textarea),this.compositionView=E.createElement("div"),this.compositionView.classList.add("composition-view"),this.compositionHelper=new f.CompositionHelper(this.textarea,this.compositionView,this),this.helperContainer.appendChild(this.compositionView),this.charSizeStyleElement=E.createElement("style"),this.helperContainer.appendChild(this.charSizeStyleElement);r2047&&(e=2047),t.push(192|e>>6),t.push(128|63&e))}else{if(255===e)return t.push(0);e>127&&(e=127),t.push(e)}}function r(t,e){if(l.vt300Mouse){t&=3,e.x-=32,e.y-=32;var r=g.C0.ESC+"[24";if(0===t)r+="1";else if(1===t)r+="3";else if(2===t)r+="5";else{if(3===t)return;r+="0"}return r+="~["+e.x+","+e.y+"]\r",void l.send(r)}if(l.decLocator)return t&=3,e.x-=32,e.y-=32,0===t?t=2:1===t?t=4:2===t?t=6:3===t&&(t=3),void l.send(g.C0.ESC+"["+t+";"+(3===t?4:0)+";"+e.y+";"+e.x+";"+(e.page||0)+"&w");if(l.urxvtMouse)return e.x-=32,e.y-=32,e.x++,e.y++,void l.send(g.C0.ESC+"["+t+";"+e.x+";"+e.y+"M");if(l.sgrMouse)return e.x-=32,e.y-=32,void l.send(g.C0.ESC+"[<"+((3===(3&t)?t&-4:t)-32)+";"+e.x+";"+e.y+(3===(3&t)?"m":"M"));var r=[];i(r,t),i(r,e.x),i(r,e.y),l.send(g.C0.ESC+"[M"+String.fromCharCode.apply(String,r))}function s(t){var e,i,r,s,n;switch(t.overrideType||t.type){case"mousedown":e=null!=t.button?+t.button:null!=t.which?t.which-1:null,l.browser.isMSIE&&(e=1===e?0:4===e?1:e);break;case"mouseup":e=3;break;case"DOMMouseScroll":e=t.detail<0?64:65;break;case"wheel":e=t.wheelDeltaY>0?64:65}return i=t.shiftKey?4:0,r=t.metaKey?8:0,s=t.ctrlKey?16:0,n=i|r|s,l.vt200Mouse?n&=s:l.normalMouse||(n=0),e=32+(n<<2)+e}function o(t){var e,i,r;if(null!=t.pageX){for(e=t.pageX,i=t.pageY,r=l.element;r&&r!==l.document.documentElement;)e-=r.offsetLeft,i-=r.offsetTop,r="offsetParent"in r?r.offsetParent:r.parentNode;return e=Math.ceil(e/l.charMeasure.width),i=Math.ceil(i/l.charMeasure.height),e<0&&(e=0),e>l.cols&&(e=l.cols),i<0&&(i=0),i>l.rows&&(i=l.rows),e+=32,i+=32,{x:e,y:i,type:"wheel"}}}var h=this.element,l=this,c=32;n(h,"mousedown",function(i){if(l.mouseEvents)return t(i),l.focus(),l.vt200Mouse?(i.overrideType="mouseup",t(i),l.cancel(i)):(l.normalMouse&&n(l.document,"mousemove",e),l.x10Mouse||n(l.document,"mouseup",function i(r){return t(r),l.normalMouse&&a(l.document,"mousemove",e),a(l.document,"mouseup",i),l.cancel(r)}),l.cancel(i))}),n(h,"wheel",function(e){if(l.mouseEvents&&!(l.x10Mouse||l.vt300Mouse||l.decLocator))return t(e),l.cancel(e)}),n(h,"wheel",function(t){if(!l.mouseEvents)return l.viewport.onWheel(t),l.cancel(t)})},s.prototype.destroy=function(){this.readable=!1,this.writable=!1,this._events={},this.handler=function(){},this.write=function(){},this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)},s.prototype.refresh=function(t,e){this.renderer&&this.renderer.queueRefresh(t,e)},s.prototype.queueLinkification=function(t,e){if(this.linkifier)for(var i=t;i<=e;i++)this.linkifier.linkifyRow(i)},s.prototype.showCursor=function(){this.cursorState||(this.cursorState=1,this.refresh(this.y,this.y))},s.prototype.scroll=function(){var t;this.lines.length===this.lines.maxLength&&(this.lines.trimStart(1),this.ybase--,0!==this.ydisp&&this.ydisp--),this.ybase++,this.userScrolling||(this.ydisp=this.ybase),t=this.ybase+this.rows-1,t-=this.rows-1-this.scrollBottom,t===this.lines.length?this.lines.push(this.blankLine()):this.lines.splice(t,0,this.blankLine()),0!==this.scrollTop&&(0!==this.ybase&&(this.ybase--,this.userScrolling||(this.ydisp=this.ybase)),this.lines.splice(this.ybase+this.scrollTop,1)),this.updateRange(this.scrollTop),this.updateRange(this.scrollBottom),this.emit("scroll",this.ydisp)},s.prototype.scrollDisp=function(t,e){t<0?this.userScrolling=!0:t+this.ydisp>=this.ybase&&(this.userScrolling=!1),this.ydisp+=t,this.ydisp>this.ybase?this.ydisp=this.ybase:this.ydisp<0&&(this.ydisp=0), +e||this.emit("scroll",this.ydisp),this.refresh(0,this.rows-1)},s.prototype.scrollPages=function(t){this.scrollDisp(t*(this.rows-1))},s.prototype.scrollToTop=function(){this.scrollDisp(-this.ydisp)},s.prototype.scrollToBottom=function(){this.scrollDisp(this.ybase-this.ydisp)},s.prototype.write=function(t){if(this.writeBuffer.push(t),this.options.useFlowControl&&!this.xoffSentToCatchUp&&this.writeBuffer.length>=A&&(this.send(g.C0.DC3),this.xoffSentToCatchUp=!0),!this.writeInProgress&&this.writeBuffer.length>0){this.writeInProgress=!0;var e=this;setTimeout(function(){e.innerWrite()})}},s.prototype.innerWrite=function(){for(var t=this.writeBuffer.splice(0,M);t.length>0;){var e=t.shift();e.length;this.xoffSentToCatchUp&&0===t.length&&0===this.writeBuffer.length&&(this.send(g.C0.DC1),this.xoffSentToCatchUp=!1),this.refreshStart=this.y,this.refreshEnd=this.y,this.parser.parse(e),this.updateRange(this.y),this.refresh(this.refreshStart,this.refreshEnd)}if(this.writeBuffer.length>0){var i=this;setTimeout(function(){i.innerWrite()},0)}else this.writeInProgress=!1},s.prototype.writeln=function(t){this.write(t+"\r\n")},s.prototype.attachCustomKeydownHandler=function(t){this.customKeydownHandler=t},s.prototype.setHypertextLinkHandler=function(t){if(!this.linkifier)throw new Error("Cannot attach a hypertext link handler before Terminal.open is called");this.linkifier.setHypertextLinkHandler(t),this.refresh(0,this.rows-1)},s.prototype.setHypertextValidationCallback=function(t){if(!this.linkifier)throw new Error("Cannot attach a hypertext validation callback before Terminal.open is called");this.linkifier.setHypertextValidationCallback(t),this.refresh(0,this.rows-1)},s.prototype.registerLinkMatcher=function(t,e,i){if(this.linkifier){var r=this.linkifier.registerLinkMatcher(t,e,i);return this.refresh(0,this.rows-1),r}},s.prototype.deregisterLinkMatcher=function(t){this.linkifier&&this.linkifier.deregisterLinkMatcher(t)&&this.refresh(0,this.rows-1)},s.prototype.keyDown=function(t){if(this.customKeydownHandler&&this.customKeydownHandler(t)===!1)return!1;if(this.restartCursorBlinking(),!this.compositionHelper.keydown.bind(this.compositionHelper)(t))return this.ybase!==this.ydisp&&this.scrollToBottom(),!1;var e=this.evaluateKeyEscapeSequence(t);return e.key===g.C0.DC3?this.writeStopped=!0:e.key===g.C0.DC1&&(this.writeStopped=!1),e.scrollDisp?(this.scrollDisp(e.scrollDisp),this.cancel(t,!0)):!!l(this,t)||(e.cancel&&this.cancel(t,!0),!e.key||(this.emit("keydown",t),this.emit("key",e.key,t),this.showCursor(),this.handler(e.key),this.cancel(t,!0)))},s.prototype.evaluateKeyEscapeSequence=function(t){var e={cancel:!1,key:void 0,scrollDisp:void 0},i=t.shiftKey<<0|t.altKey<<1|t.ctrlKey<<2|t.metaKey<<3;switch(t.keyCode){case 8:if(t.shiftKey){e.key=g.C0.BS;break}e.key=g.C0.DEL;break;case 9:if(t.shiftKey){e.key=g.C0.ESC+"[Z";break}e.key=g.C0.HT,e.cancel=!0;break;case 13:e.key=g.C0.CR,e.cancel=!0;break;case 27:e.key=g.C0.ESC,e.cancel=!0;break;case 37:i?(e.key=g.C0.ESC+"[1;"+(i+1)+"D",e.key==g.C0.ESC+"[1;3D"&&(e.key=this.browser.isMac?g.C0.ESC+"b":g.C0.ESC+"[1;5D")):this.applicationCursor?e.key=g.C0.ESC+"OD":e.key=g.C0.ESC+"[D";break;case 39:i?(e.key=g.C0.ESC+"[1;"+(i+1)+"C",e.key==g.C0.ESC+"[1;3C"&&(e.key=this.browser.isMac?g.C0.ESC+"f":g.C0.ESC+"[1;5C")):this.applicationCursor?e.key=g.C0.ESC+"OC":e.key=g.C0.ESC+"[C";break;case 38:i?(e.key=g.C0.ESC+"[1;"+(i+1)+"A",e.key==g.C0.ESC+"[1;3A"&&(e.key=g.C0.ESC+"[1;5A")):this.applicationCursor?e.key=g.C0.ESC+"OA":e.key=g.C0.ESC+"[A";break;case 40:i?(e.key=g.C0.ESC+"[1;"+(i+1)+"B",e.key==g.C0.ESC+"[1;3B"&&(e.key=g.C0.ESC+"[1;5B")):this.applicationCursor?e.key=g.C0.ESC+"OB":e.key=g.C0.ESC+"[B";break;case 45:t.shiftKey||t.ctrlKey||(e.key=g.C0.ESC+"[2~");break;case 46:i?e.key=g.C0.ESC+"[3;"+(i+1)+"~":e.key=g.C0.ESC+"[3~";break;case 36:i?e.key=g.C0.ESC+"[1;"+(i+1)+"H":this.applicationCursor?e.key=g.C0.ESC+"OH":e.key=g.C0.ESC+"[H";break;case 35:i?e.key=g.C0.ESC+"[1;"+(i+1)+"F":this.applicationCursor?e.key=g.C0.ESC+"OF":e.key=g.C0.ESC+"[F";break;case 33:t.shiftKey?e.scrollDisp=-(this.rows-1):e.key=g.C0.ESC+"[5~";break;case 34:t.shiftKey?e.scrollDisp=this.rows-1:e.key=g.C0.ESC+"[6~";break;case 112:i?e.key=g.C0.ESC+"[1;"+(i+1)+"P":e.key=g.C0.ESC+"OP";break;case 113:i?e.key=g.C0.ESC+"[1;"+(i+1)+"Q":e.key=g.C0.ESC+"OQ";break;case 114:i?e.key=g.C0.ESC+"[1;"+(i+1)+"R":e.key=g.C0.ESC+"OR";break;case 115:i?e.key=g.C0.ESC+"[1;"+(i+1)+"S":e.key=g.C0.ESC+"OS";break;case 116:i?e.key=g.C0.ESC+"[15;"+(i+1)+"~":e.key=g.C0.ESC+"[15~";break;case 117:i?e.key=g.C0.ESC+"[17;"+(i+1)+"~":e.key=g.C0.ESC+"[17~";break;case 118:i?e.key=g.C0.ESC+"[18;"+(i+1)+"~":e.key=g.C0.ESC+"[18~";break;case 119:i?e.key=g.C0.ESC+"[19;"+(i+1)+"~":e.key=g.C0.ESC+"[19~";break;case 120:i?e.key=g.C0.ESC+"[20;"+(i+1)+"~":e.key=g.C0.ESC+"[20~";break;case 121:i?e.key=g.C0.ESC+"[21;"+(i+1)+"~":e.key=g.C0.ESC+"[21~";break;case 122:i?e.key=g.C0.ESC+"[23;"+(i+1)+"~":e.key=g.C0.ESC+"[23~";break;case 123:i?e.key=g.C0.ESC+"[24;"+(i+1)+"~":e.key=g.C0.ESC+"[24~";break;default:!t.ctrlKey||t.shiftKey||t.altKey||t.metaKey?this.browser.isMac||!t.altKey||t.ctrlKey||t.metaKey||(t.keyCode>=65&&t.keyCode<=90?e.key=g.C0.ESC+String.fromCharCode(t.keyCode+32):192===t.keyCode?e.key=g.C0.ESC+"`":t.keyCode>=48&&t.keyCode<=57&&(e.key=g.C0.ESC+(t.keyCode-48))):t.keyCode>=65&&t.keyCode<=90?e.key=String.fromCharCode(t.keyCode-64):32===t.keyCode?e.key=String.fromCharCode(0):t.keyCode>=51&&t.keyCode<=55?e.key=String.fromCharCode(t.keyCode-51+27):56===t.keyCode?e.key=String.fromCharCode(127):219===t.keyCode?e.key=String.fromCharCode(27):220===t.keyCode?e.key=String.fromCharCode(28):221===t.keyCode&&(e.key=String.fromCharCode(29))}return e},s.prototype.setgLevel=function(t){this.glevel=t,this.charset=this.charsets[t]},s.prototype.setgCharset=function(t,e){this.charsets[t]=e,this.glevel===t&&(this.charset=e)},s.prototype.keyPress=function(t){var e;if(this.cancel(t),t.charCode)e=t.charCode;else if(null==t.which)e=t.keyCode;else{if(0===t.which||0===t.charCode)return!1;e=t.which}return!(!e||(t.altKey||t.ctrlKey||t.metaKey)&&!l(this,t))&&(e=String.fromCharCode(e),this.emit("keypress",e,t),this.emit("key",e,t),this.showCursor(),this.handler(e),!1)},s.prototype.send=function(t){var e=this;this.queue||setTimeout(function(){e.handler(e.queue),e.queue=""},1),this.queue+=t},s.prototype.bell=function(){if(this.visualBell){var t=this;this.element.style.borderColor="white",setTimeout(function(){t.element.style.borderColor=""},10),this.popOnBell&&this.focus()}},s.prototype.log=function(){if(this.debug&&this.context.console&&this.context.console.log){var t=Array.prototype.slice.call(arguments);this.context.console.log.apply(this.context.console,t)}},s.prototype.error=function(){if(this.debug&&this.context.console&&this.context.console.error){var t=Array.prototype.slice.call(arguments);this.context.console.error.apply(this.context.console,t)}},s.prototype.resize=function(t,e){if(!isNaN(t)&&!isNaN(e)){var i,r,s,n,a;if(t!==this.cols||e!==this.rows){if(t<1&&(t=1),e<1&&(e=1),s=this.cols,s0&&this.lines.length<=this.ybase+this.y+a+1?(this.ybase--,a++,this.ydisp>0&&this.ydisp--):this.lines.push(this.blankLine())),this.children.lengthe;)if(this.lines.length>e+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++)),this.children.length>e){if(i=this.children.shift(),!i)continue;i.parentNode.removeChild(i)}this.rows=e,this.y>=e&&(this.y=e-1),a&&(this.y+=a),this.x>=t&&(this.x=t-1),this.scrollTop=0,this.scrollBottom=e-1,this.charMeasure.measure(),this.refresh(0,this.rows-1),this.normal=null,this.geometry=[this.cols,this.rows],this.emit("resize",{terminal:this,cols:t,rows:e})}}},s.prototype.updateRange=function(t){tthis.refreshEnd&&(this.refreshEnd=t)},s.prototype.maxRange=function(){this.refreshStart=0,this.refreshEnd=this.rows-1},s.prototype.setupStops=function(t){for(null!=t?this.tabs[t]||(t=this.prevStop(t)):(this.tabs={},t=0);t0;);return t>=this.cols?this.cols-1:t<0?0:t},s.prototype.nextStop=function(t){for(null==t&&(t=this.x);!this.tabs[++t]&&t=this.cols?this.cols-1:t<0?0:t},s.prototype.eraseRight=function(t,e){var i=this.lines.get(this.ybase+e);if(i){for(var r=[this.eraseAttr()," ",1];tthis.scrollBottom&&(this.y--,this.scroll()),this.x>=this.cols&&this.x--},s.prototype.reverseIndex=function(){this.y===this.scrollTop?(this.lines.shiftElements(this.y+this.ybase,this.rows-1,1),this.lines.set(this.y+this.ybase,this.blankLine(!0)),this.updateRange(this.scrollTop),this.updateRange(this.scrollBottom)):this.y--},s.prototype.reset=function(){this.options.rows=this.rows,this.options.cols=this.cols;var t=this.customKeydownHandler,e=this.cursorBlinkInterval;s.call(this,this.options),this.customKeydownHandler=t,this.cursorBlinkInterval=e,this.refresh(0,this.rows-1),this.viewport.syncScrollArea()},s.prototype.tabSet=function(){this.tabs[this.x]=!0},s.prototype.matchColor=c,c._cache={},c.distance=function(t,e,i,r,s,n){return Math.pow(30*(t-r),2)+Math.pow(59*(e-s),2)+Math.pow(11*(i-n),2)},s.EventEmitter=d.EventEmitter,s.inherits=h,s.on=n,s.off=a,s.cancel=o,i.exports=s},{"./CompositionHelper":2,"./EscapeSequences":3,"./EventEmitter":4,"./InputHandler":5,"./Linkifier":6,"./Parser":7,"./Renderer":8,"./Viewport":9,"./handlers/Clipboard":10,"./utils/Browser":11,"./utils/CharMeasure":12,"./utils/CircularList":13}]},{},[15])(15)}); @@ -17,6 +17,6 @@ this.scrollDisp(this.ybase-this.ydisp)},s.prototype.write=function(t){if(this.wr
- +