Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

xterm-addon-webgl

Package Overview
Dependencies
Maintainers
1
Versions
345
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

xterm-addon-webgl - npm Package Compare versions

Comparing version 0.3.0 to 0.4.0-beta.10

2

lib/xterm-addon-webgl.js

@@ -1,2 +0,2 @@

!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.WebglAddon=e():t.WebglAddon=e()}(window,function(){return function(t){var e={};function i(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,i),o.l=!0,o.exports}return i.m=t,i.c=e,i.d=function(t,e,r){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(i.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)i.d(r,o,function(e){return t[e]}.bind(null,o));return r},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=11)}([function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.DEFAULT_COLOR=256,e.DEFAULT_ATTR=256|e.DEFAULT_COLOR<<9,e.CHAR_DATA_ATTR_INDEX=0,e.CHAR_DATA_CHAR_INDEX=1,e.CHAR_DATA_WIDTH_INDEX=2,e.CHAR_DATA_CODE_INDEX=3,e.NULL_CELL_CHAR="",e.NULL_CELL_WIDTH=1,e.NULL_CELL_CODE=0,e.WHITESPACE_CELL_CHAR=" ",e.WHITESPACE_CELL_WIDTH=1,e.WHITESPACE_CELL_CODE=32},function(t,e,i){"use strict";function r(t,e,i){var r=o(t.createShader(e));if(t.shaderSource(r,i),t.compileShader(r),t.getShaderParameter(r,t.COMPILE_STATUS))return r;console.error(t.getShaderInfoLog(r)),t.deleteShader(r)}function o(t){if(!t)throw new Error("value must not be falsy");return t}Object.defineProperty(e,"__esModule",{value:!0}),e.PROJECTION_MATRIX=new Float32Array([2,0,0,0,0,-2,0,0,0,0,1,0,-1,1,0,1]),e.createProgram=function(t,e,i){var n=o(t.createProgram());if(t.attachShader(n,o(r(t,t.VERTEX_SHADER,e))),t.attachShader(n,o(r(t,t.FRAGMENT_SHADER,i))),t.linkProgram(n),t.getProgramParameter(n,t.LINK_STATUS))return n;console.error(t.getProgramInfoLog(n)),t.deleteProgram(n)},e.createShader=r,e.expandFloat32Array=function(t,e){for(var i=Math.min(2*t.length,e),r=new Float32Array(i),o=0;o<t.length;o++)r[o]=t[o];return r},e.throwIfFalsy=o},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=i(0),o={css:"",rgba:0};e.generateConfig=function(t,e,i,r){var n={foreground:r.foreground,background:r.background,cursor:o,cursorAccent:o,selection:o,ansi:r.ansi.slice()};return{devicePixelRatio:window.devicePixelRatio,scaledCharWidth:t,scaledCharHeight:e,fontFamily:i.getOption("fontFamily"),fontSize:i.getOption("fontSize"),fontWeight:i.getOption("fontWeight"),fontWeightBold:i.getOption("fontWeightBold"),allowTransparency:i.getOption("allowTransparency"),colors:n}},e.configEquals=function(t,e){for(var i=0;i<t.colors.ansi.length;i++)if(t.colors.ansi[i].rgba!==e.colors.ansi[i].rgba)return!1;return t.devicePixelRatio===e.devicePixelRatio&&t.fontFamily===e.fontFamily&&t.fontSize===e.fontSize&&t.fontWeight===e.fontWeight&&t.fontWeightBold===e.fontWeightBold&&t.allowTransparency===e.allowTransparency&&t.scaledCharWidth===e.scaledCharWidth&&t.scaledCharHeight===e.scaledCharHeight&&t.colors.foreground===e.colors.foreground&&t.colors.background===e.colors.background},e.is256Color=function(t){return t<r.DEFAULT_COLOR}},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.INVERTED_DEFAULT_COLOR=257,e.DIM_OPACITY=.5,e.CHAR_ATLAS_CELL_SPACING=1},function(t,e,i){"use strict";function r(t,e,i,r){if(void 0===i&&(i=0),void 0===r&&(r=t.length),i>=t.length)return t;i=(t.length+i)%t.length,r=r>=t.length?t.length:(t.length+r)%t.length;for(var o=i;o<r;++o)t[o]=e;return t}Object.defineProperty(e,"__esModule",{value:!0}),e.fill=function(t,e,i,o){return t.fill?t.fill(e,i,o):r(t,e,i,o)},e.fillFallback=r,e.concat=function(t,e){var i=new t.constructor(t.length+e.length);return i.set(t),i.set(e,t.length),i}},function(t,e,i){"use strict";var r,o=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])})(t,e)},function(t,e){function i(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)});Object.defineProperty(e,"__esModule",{value:!0});var n=i(12),s=i(14),a=i(16),l=i(9),c=i(19),h=i(3),_=i(6),d=i(20),u=i(0),f=i(7),p=i(21);e.INDICIES_PER_CELL=4;var v=function(t){function i(e,i,r){var o=t.call(this)||this;o._terminal=e,o._colors=i,o._model=new _.RenderModel,o._core=o._terminal._core,o._applyBgLuminanceBasedSelection(),o._renderLayers=[new s.LinkRenderLayer(o._core.screenElement,2,o._colors,o._core),new a.CursorRenderLayer(o._core.screenElement,3,o._colors)],o.dimensions={scaledCharWidth:0,scaledCharHeight:0,scaledCellWidth:0,scaledCellHeight:0,scaledCharLeft:0,scaledCharTop:0,scaledCanvasWidth:0,scaledCanvasHeight:0,canvasWidth:0,canvasHeight:0,actualCellWidth:0,actualCellHeight:0},o._devicePixelRatio=window.devicePixelRatio,o._updateDimensions(),o._canvas=document.createElement("canvas");var l={antialias:!1,depth:!1,preserveDrawingBuffer:r};if(o._gl=o._canvas.getContext("webgl2",l),!o._gl)throw new Error("WebGL2 not supported");return o._core.screenElement.appendChild(o._canvas),o._rectangleRenderer=new c.RectangleRenderer(o._terminal,o._colors,o._gl,o.dimensions),o._glyphRenderer=new n.GlyphRenderer(o._terminal,o._colors,o._gl,o.dimensions),o.onCharSizeChanged(),o}return o(i,t),i.prototype.dispose=function(){this._renderLayers.forEach(function(t){return t.dispose()}),this._core.screenElement.removeChild(this._canvas),t.prototype.dispose.call(this)},i.prototype._applyBgLuminanceBasedSelection=function(){f.getLuminance(this._colors.background)>.5?this._colors.selection={css:"#000",rgba:255}:this._colors.selection={css:"#fff",rgba:4294967295}},i.prototype.setColors=function(t){var e=this;this._colors=t,this._applyBgLuminanceBasedSelection(),this._renderLayers.forEach(function(t){t.setColors(e._terminal,e._colors),t.reset(e._terminal)}),this._rectangleRenderer.setColors(),this._glyphRenderer.setColors(),this._refreshCharAtlas(),this._model.clear()},i.prototype.onDevicePixelRatioChange=function(){this._devicePixelRatio!==window.devicePixelRatio&&(this._devicePixelRatio=window.devicePixelRatio,this.onResize(this._terminal.cols,this._terminal.rows))},i.prototype.onResize=function(t,e){var i=this;this._updateDimensions(),this._model.resize(this._terminal.cols,this._terminal.rows),this._rectangleRenderer.onResize(),this._renderLayers.forEach(function(t){return t.resize(i._terminal,i.dimensions)}),this._canvas.width=this.dimensions.scaledCanvasWidth,this._canvas.height=this.dimensions.scaledCanvasHeight,this._canvas.style.width=this.dimensions.canvasWidth+"px",this._canvas.style.height=this.dimensions.canvasHeight+"px",this._core.screenElement.style.width=this.dimensions.canvasWidth+"px",this._core.screenElement.style.height=this.dimensions.canvasHeight+"px",this._glyphRenderer.setDimensions(this.dimensions),this._glyphRenderer.onResize(),this._refreshCharAtlas(),this._model.clear()},i.prototype.onCharSizeChanged=function(){this.onResize(this._terminal.cols,this._terminal.rows)},i.prototype.onBlur=function(){var t=this;this._renderLayers.forEach(function(e){return e.onBlur(t._terminal)})},i.prototype.onFocus=function(){var t=this;this._renderLayers.forEach(function(e){return e.onFocus(t._terminal)})},i.prototype.onSelectionChanged=function(t,e,i){var r=this;this._renderLayers.forEach(function(o){return o.onSelectionChanged(r._terminal,t,e,i)}),this._updateSelectionModel(t,e),this._rectangleRenderer.updateSelection(this._model.selection,i),this._glyphRenderer.updateSelection(this._model,i),this._core.refresh(0,this._terminal.rows-1)},i.prototype.onCursorMove=function(){var t=this;this._renderLayers.forEach(function(e){return e.onCursorMove(t._terminal)})},i.prototype.onOptionsChanged=function(){var t=this;this._renderLayers.forEach(function(e){return e.onOptionsChanged(t._terminal)}),this._updateDimensions(),this._refreshCharAtlas()},i.prototype._refreshCharAtlas=function(){if(!(this.dimensions.scaledCharWidth<=0&&this.dimensions.scaledCharHeight<=0)){var t=l.acquireCharAtlas(this._terminal,this._colors,this.dimensions.scaledCharWidth,this.dimensions.scaledCharHeight);if(!("getRasterizedGlyph"in t))throw new Error("The webgl renderer only works with the webgl char atlas");this._charAtlas=t,this._charAtlas.warmUp(),this._glyphRenderer.setAtlas(this._charAtlas)}},i.prototype.clear=function(){var t=this;this._renderLayers.forEach(function(e){return e.reset(t._terminal)})},i.prototype.registerCharacterJoiner=function(t){return-1},i.prototype.deregisterCharacterJoiner=function(t){return!1},i.prototype.renderRows=function(t,e){var i=this;this._renderLayers.forEach(function(r){return r.onGridChanged(i._terminal,t,e)}),this._glyphRenderer.beginFrame()&&this._model.clear(),this._updateModel(t,e),this._rectangleRenderer.render(),this._glyphRenderer.render(this._model,this._model.selection.hasSelection)},i.prototype._updateModel=function(t,i){for(var r=this._core,o=t;o<=i;o++){var n=o+r.buffer.ydisp,s=r.buffer.lines.get(n);this._model.lineLengths[o]=0;for(var a=0;a<r.cols;a++){var l=s.get(a),c=l[u.CHAR_DATA_CHAR_INDEX],d=l[u.CHAR_DATA_CODE_INDEX],f=p.getCompatAttr(s,a),v=(o*r.cols+a)*e.INDICIES_PER_CELL;if(d!==u.NULL_CELL_CODE&&(this._model.lineLengths[o]=a+1),this._model.cells[v]!==d||this._model.cells[v+1]!==f){var C=f>>18,g=511&f,m=f>>9&511;if(8&C){var y=g;g=m,(m=y)===u.DEFAULT_COLOR&&(m=h.INVERTED_DEFAULT_COLOR),g===u.DEFAULT_COLOR&&(g=h.INVERTED_DEFAULT_COLOR)}m+=r.options.drawBoldTextInBrightColors&&!!(1&C)&&m<8&&m!==h.INVERTED_DEFAULT_COLOR?8:0,c.length>1&&(d|=_.COMBINED_CHAR_BIT_MASK),this._model.cells[v]=d,this._model.cells[v+1]=f,this._model.cells[v+2]=g,this._model.cells[v+3]=m,this._glyphRenderer.updateCell(a,o,d,f,g,m,c)}}}this._rectangleRenderer.updateBackgrounds(this._model)},i.prototype._updateSelectionModel=function(t,e){var i=this._terminal;if(t&&e&&(t[0]!==e[0]||t[1]!==e[1])){var r=t[1]-i.buffer.viewportY,o=e[1]-i.buffer.viewportY,n=Math.max(r,0),s=Math.min(o,i.rows-1);n>=i.rows||s<0?this._model.clearSelection():(this._model.selection.hasSelection=!0,this._model.selection.viewportStartRow=r,this._model.selection.viewportEndRow=o,this._model.selection.viewportCappedStartRow=n,this._model.selection.viewportCappedEndRow=s,this._model.selection.startCol=t[0],this._model.selection.endCol=e[0])}else this._model.clearSelection()},i.prototype._updateDimensions=function(){this._core._charSizeService.width&&this._core._charSizeService.height&&(this.dimensions.scaledCharWidth=Math.floor(this._core._charSizeService.width*this._devicePixelRatio),this.dimensions.scaledCharHeight=Math.ceil(this._core._charSizeService.height*this._devicePixelRatio),this.dimensions.scaledCellHeight=Math.floor(this.dimensions.scaledCharHeight*this._terminal.getOption("lineHeight")),this.dimensions.scaledCharTop=1===this._terminal.getOption("lineHeight")?0:Math.round((this.dimensions.scaledCellHeight-this.dimensions.scaledCharHeight)/2),this.dimensions.scaledCellWidth=this.dimensions.scaledCharWidth+Math.round(this._terminal.getOption("letterSpacing")),this.dimensions.scaledCharLeft=Math.floor(this._terminal.getOption("letterSpacing")/2),this.dimensions.scaledCanvasHeight=this._terminal.rows*this.dimensions.scaledCellHeight,this.dimensions.scaledCanvasWidth=this._terminal.cols*this.dimensions.scaledCellWidth,this.dimensions.canvasHeight=Math.round(this.dimensions.scaledCanvasHeight/this._devicePixelRatio),this.dimensions.canvasWidth=Math.round(this.dimensions.scaledCanvasWidth/this._devicePixelRatio),this.dimensions.actualCellHeight=this.dimensions.scaledCellHeight/this._devicePixelRatio,this.dimensions.actualCellWidth=this.dimensions.scaledCellWidth/this._devicePixelRatio)},i}(d.Disposable);e.WebglRenderer=v},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=i(4);e.RENDER_MODEL_INDICIES_PER_CELL=4,e.COMBINED_CHAR_BIT_MASK=2147483648;var o=function(){function t(){this.cells=new Uint32Array(0),this.lineLengths=new Uint32Array(0),this.selection={hasSelection:!1,viewportStartRow:0,viewportEndRow:0,viewportCappedStartRow:0,viewportCappedEndRow:0,startCol:0,endCol:0}}return t.prototype.resize=function(t,i){var r=t*i*e.RENDER_MODEL_INDICIES_PER_CELL;r!==this.cells.length&&(this.cells=new Uint32Array(r),this.lineLengths=new Uint32Array(i))},t.prototype.clear=function(){r.fill(this.cells,0,0),r.fill(this.lineLengths,0,0),this.clearSelection()},t.prototype.clearSelection=function(){this.selection.hasSelection=!1,this.selection.viewportStartRow=0,this.selection.viewportEndRow=0,this.selection.viewportCappedStartRow=0,this.selection.viewportCappedEndRow=0,this.selection.startCol=0,this.selection.endCol=0},t}();e.RenderModel=o},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.getLuminance=function(t){return(.299*(t.rgba>>24&255)+.587*(t.rgba>>16&255)+.114*(t.rgba>>8&255))/255}},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=i(9),o=i(1),n=function(){function t(t,e,i,r,o){this._container=t,this._alpha=r,this._colors=o,this._scaledCharWidth=0,this._scaledCharHeight=0,this._scaledCellWidth=0,this._scaledCellHeight=0,this._scaledCharLeft=0,this._scaledCharTop=0,this._currentGlyphIdentifier={chars:"",code:0,bg:0,fg:0,bold:!1,dim:!1,italic:!1},this._canvas=document.createElement("canvas"),this._canvas.classList.add("xterm-"+e+"-layer"),this._canvas.style.zIndex=i.toString(),this._initCanvas(),this._container.appendChild(this._canvas)}return t.prototype.dispose=function(){this._container.removeChild(this._canvas),this._charAtlas&&this._charAtlas.dispose()},t.prototype._initCanvas=function(){this._ctx=o.throwIfFalsy(this._canvas.getContext("2d",{alpha:this._alpha})),this._alpha||this._clearAll()},t.prototype.onOptionsChanged=function(t){},t.prototype.onBlur=function(t){},t.prototype.onFocus=function(t){},t.prototype.onCursorMove=function(t){},t.prototype.onGridChanged=function(t,e,i){},t.prototype.onSelectionChanged=function(t,e,i,r){void 0===r&&(r=!1)},t.prototype.setColors=function(t,e){this._refreshCharAtlas(t,e)},t.prototype._setTransparency=function(t,e){if(e!==this._alpha){var i=this._canvas;this._alpha=e,this._canvas=this._canvas.cloneNode(),this._initCanvas(),this._container.replaceChild(this._canvas,i),this._refreshCharAtlas(t,this._colors),this.onGridChanged(t,0,t.rows-1)}},t.prototype._refreshCharAtlas=function(t,e){this._scaledCharWidth<=0&&this._scaledCharHeight<=0||(this._charAtlas=r.acquireCharAtlas(t,e,this._scaledCharWidth,this._scaledCharHeight),this._charAtlas.warmUp())},t.prototype.resize=function(t,e){this._scaledCellWidth=e.scaledCellWidth,this._scaledCellHeight=e.scaledCellHeight,this._scaledCharWidth=e.scaledCharWidth,this._scaledCharHeight=e.scaledCharHeight,this._scaledCharLeft=e.scaledCharLeft,this._scaledCharTop=e.scaledCharTop,this._canvas.width=e.scaledCanvasWidth,this._canvas.height=e.scaledCanvasHeight,this._canvas.style.width=e.canvasWidth+"px",this._canvas.style.height=e.canvasHeight+"px",this._alpha||this._clearAll(),this._refreshCharAtlas(t,this._colors)},t.prototype._fillCells=function(t,e,i,r){this._ctx.fillRect(t*this._scaledCellWidth,e*this._scaledCellHeight,i*this._scaledCellWidth,r*this._scaledCellHeight)},t.prototype._fillBottomLineAtCells=function(t,e,i){void 0===i&&(i=1),this._ctx.fillRect(t*this._scaledCellWidth,(e+1)*this._scaledCellHeight-window.devicePixelRatio-1,i*this._scaledCellWidth,window.devicePixelRatio)},t.prototype._fillLeftLineAtCell=function(t,e){this._ctx.fillRect(t*this._scaledCellWidth,e*this._scaledCellHeight,window.devicePixelRatio,this._scaledCellHeight)},t.prototype._strokeRectAtCell=function(t,e,i,r){this._ctx.lineWidth=window.devicePixelRatio,this._ctx.strokeRect(t*this._scaledCellWidth+window.devicePixelRatio/2,e*this._scaledCellHeight+window.devicePixelRatio/2,i*this._scaledCellWidth-window.devicePixelRatio,r*this._scaledCellHeight-window.devicePixelRatio)},t.prototype._clearAll=function(){this._alpha?this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height):(this._ctx.fillStyle=this._colors.background.css,this._ctx.fillRect(0,0,this._canvas.width,this._canvas.height))},t.prototype._clearCells=function(t,e,i,r){this._alpha?this._ctx.clearRect(t*this._scaledCellWidth,e*this._scaledCellHeight,i*this._scaledCellWidth,r*this._scaledCellHeight):(this._ctx.fillStyle=this._colors.background.css,this._ctx.fillRect(t*this._scaledCellWidth,e*this._scaledCellHeight,i*this._scaledCellWidth,r*this._scaledCellHeight))},t.prototype._fillCharTrueColor=function(t,e,i,r){this._ctx.font=this._getFont(t,!1,!1),this._ctx.textBaseline="middle",this._clipRow(t,r),this._ctx.fillText(e.getChars(),i*this._scaledCellWidth+this._scaledCharLeft,r*this._scaledCellHeight+this._scaledCharTop+this._scaledCharHeight/2)},t.prototype._clipRow=function(t,e){this._ctx.beginPath(),this._ctx.rect(0,e*this._scaledCellHeight,t.cols*this._scaledCellWidth,this._scaledCellHeight),this._ctx.clip()},t.prototype._getFont=function(t,e,i){return(i?"italic":"")+" "+(e?t.getOption("fontWeightBold"):t.getOption("fontWeight"))+" "+t.getOption("fontSize")*window.devicePixelRatio+"px "+t.getOption("fontFamily")},t}();e.BaseRenderLayer=n},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=i(2),o=i(15),n=[];e.acquireCharAtlas=function(t,e,i,s){for(var a=r.generateConfig(i,s,t,e),l=0;l<n.length;l++){var c=(h=n[l]).ownedBy.indexOf(t);if(c>=0){if(r.configEquals(h.config,a))return h.atlas;1===h.ownedBy.length?(h.atlas.dispose(),n.splice(l,1)):h.ownedBy.splice(c,1);break}}for(l=0;l<n.length;l++){var h=n[l];if(r.configEquals(h.config,a))return h.ownedBy.push(t),h.atlas}var _={atlas:new o.WebglCharAtlas(document,a),config:a,ownedBy:[t]};return n.push(_),_.atlas},e.removeTerminalFromCache=function(t){for(var e=0;e<n.length;e++){var i=n[e].ownedBy.indexOf(t);if(-1!==i){1===n[e].ownedBy.length?(n[e].atlas.dispose(),n.splice(e,1)):n[e].ownedBy.splice(i,1);break}}}},function(t,e,i){"use strict";var r,o=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])})(t,e)},function(t,e){function i(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)});Object.defineProperty(e,"__esModule",{value:!0});var n=i(17),s=i(0),a=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.content=0,e.fg=0,e.bg=0,e.combinedData="",e}return o(e,t),e.fromCharData=function(t){var i=new e;return i.setFromCharData(t),i},e.prototype.isCombined=function(){return 2097152&this.content},e.prototype.getWidth=function(){return this.content>>22},e.prototype.getChars=function(){return 2097152&this.content?this.combinedData:2097151&this.content?n.stringFromCodePoint(2097151&this.content):""},e.prototype.getCode=function(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content},e.prototype.setFromCharData=function(t){this.fg=t[s.CHAR_DATA_ATTR_INDEX],this.bg=0;var e=!1;if(t[s.CHAR_DATA_CHAR_INDEX].length>2)e=!0;else if(2===t[s.CHAR_DATA_CHAR_INDEX].length){var i=t[s.CHAR_DATA_CHAR_INDEX].charCodeAt(0);if(55296<=i&&i<=56319){var r=t[s.CHAR_DATA_CHAR_INDEX].charCodeAt(1);56320<=r&&r<=57343?this.content=1024*(i-55296)+r-56320+65536|t[s.CHAR_DATA_WIDTH_INDEX]<<22:e=!0}else e=!0}else this.content=t[s.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|t[s.CHAR_DATA_WIDTH_INDEX]<<22;e&&(this.combinedData=t[s.CHAR_DATA_CHAR_INDEX],this.content=2097152|t[s.CHAR_DATA_WIDTH_INDEX]<<22)},e.prototype.getAsCharData=function(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]},e}(i(18).AttributeData);e.CellData=a},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=i(5),o=function(){function t(t){this._preserveDrawingBuffer=t}return t.prototype.activate=function(t){if(!t.element)throw new Error("Cannot activate WebglRendererAddon before Terminal.open");var e=t._core._renderService,i=t._core._colorManager.colors;e.setRenderer(new r.WebglRenderer(t,i,this._preserveDrawingBuffer))},t.prototype.dispose=function(){throw new Error("WebglRendererAddon.dispose Not yet implemented")},t}();e.WebglAddon=o},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=i(1),o=i(5),n=i(6),s=i(4),a=i(13),l=i(0),c=i(7),h="#version 300 es\nlayout (location = 0) in vec2 a_unitquad;\nlayout (location = 1) in vec2 a_cellpos;\nlayout (location = 2) in vec2 a_offset;\nlayout (location = 3) in vec2 a_size;\nlayout (location = 4) in vec2 a_texcoord;\nlayout (location = 5) in vec2 a_texsize;\n\nuniform mat4 u_projection;\nuniform vec2 u_resolution;\n\nout vec2 v_texcoord;\n\nvoid main() {\n vec2 zeroToOne = (a_offset / u_resolution) + a_cellpos + (a_unitquad * a_size);\n gl_Position = u_projection * vec4(zeroToOne, 0.0, 1.0);\n v_texcoord = a_texcoord + a_unitquad * a_texsize;\n}",_="#version 300 es\nprecision lowp float;\n\nin vec2 v_texcoord;\n\nuniform sampler2D u_texture;\n\nout vec4 outColor;\n\nvoid main() {\n outColor = texture(u_texture, v_texcoord);\n}",d=10*Float32Array.BYTES_PER_ELEMENT,u=function(){function t(t,e,i,o){this._terminal=t,this._colors=e,this._gl=i,this._dimensions=o,this._activeBuffer=0,this._vertices={count:0,attributes:new Float32Array(0),attributesBuffers:[new Float32Array(0),new Float32Array(0)],selectionAttributes:new Float32Array(0)};var n=this._gl,s=r.throwIfFalsy(r.createProgram(n,h,_));this._program=s,this._projectionLocation=r.throwIfFalsy(n.getUniformLocation(this._program,"u_projection")),this._resolutionLocation=r.throwIfFalsy(n.getUniformLocation(this._program,"u_resolution")),this._textureLocation=r.throwIfFalsy(n.getUniformLocation(this._program,"u_texture")),this._vertexArrayObject=n.createVertexArray(),n.bindVertexArray(this._vertexArrayObject);var a=new Float32Array([0,0,1,0,0,1,1,1]),l=n.createBuffer();n.bindBuffer(n.ARRAY_BUFFER,l),n.bufferData(n.ARRAY_BUFFER,a,n.STATIC_DRAW),n.enableVertexAttribArray(0),n.vertexAttribPointer(0,2,this._gl.FLOAT,!1,0,0);var c=new Uint8Array([0,1,3,0,2,3]),u=n.createBuffer();n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,u),n.bufferData(n.ELEMENT_ARRAY_BUFFER,c,n.STATIC_DRAW),this._attributesBuffer=r.throwIfFalsy(n.createBuffer()),n.bindBuffer(n.ARRAY_BUFFER,this._attributesBuffer),n.enableVertexAttribArray(2),n.vertexAttribPointer(2,2,n.FLOAT,!1,d,0),n.vertexAttribDivisor(2,1),n.enableVertexAttribArray(3),n.vertexAttribPointer(3,2,n.FLOAT,!1,d,2*Float32Array.BYTES_PER_ELEMENT),n.vertexAttribDivisor(3,1),n.enableVertexAttribArray(4),n.vertexAttribPointer(4,2,n.FLOAT,!1,d,4*Float32Array.BYTES_PER_ELEMENT),n.vertexAttribDivisor(4,1),n.enableVertexAttribArray(5),n.vertexAttribPointer(5,2,n.FLOAT,!1,d,6*Float32Array.BYTES_PER_ELEMENT),n.vertexAttribDivisor(5,1),n.enableVertexAttribArray(1),n.vertexAttribPointer(1,2,n.FLOAT,!1,d,8*Float32Array.BYTES_PER_ELEMENT),n.vertexAttribDivisor(1,1),this._atlasTexture=r.throwIfFalsy(n.createTexture()),n.bindTexture(n.TEXTURE_2D,this._atlasTexture),n.texImage2D(n.TEXTURE_2D,0,n.RGBA,1,1,0,n.RGBA,n.UNSIGNED_BYTE,new Uint8Array([0,0,255,255])),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE),n.enable(n.BLEND),n.blendFunc(n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA),this.onResize()}return t.prototype.beginFrame=function(){return!this._atlas||this._atlas.beginFrame()},t.prototype.updateCell=function(t,e,i,r,o,n,s){this._updateCell(this._vertices.attributes,t,e,i,r,o,n,s)},t.prototype._updateCell=function(t,e,i,r,o,n,a,c){var h=10*(i*this._terminal.cols+e);if(r!==l.NULL_CELL_CODE&&r!==l.WHITESPACE_CELL_CODE&&void 0!==r){var _;if(!this._atlas)throw new Error("atlas must be set before updating cell");(_=c&&c.length>1?this._atlas.getRasterizedGlyphCombinedChar(c,o,n,a):this._atlas.getRasterizedGlyph(r,o,n,a))?(t[h]=-_.offset.x+this._dimensions.scaledCharLeft,t[h+1]=-_.offset.y+this._dimensions.scaledCharTop,t[h+2]=_.size.x/this._dimensions.scaledCanvasWidth,t[h+3]=_.size.y/this._dimensions.scaledCanvasHeight,t[h+4]=_.texturePositionClipSpace.x,t[h+5]=_.texturePositionClipSpace.y,t[h+6]=_.sizeClipSpace.x,t[h+7]=_.sizeClipSpace.y):s.fill(t,0,h,h+10-1-2)}else s.fill(t,0,h,h+10-1-2)},t.prototype.updateSelection=function(t,e){var i=this._terminal;this._vertices.selectionAttributes=a.slice(this._vertices.attributes,0);var r=c.getLuminance(this._colors.background),o=r>.5?7:0,n=r>.5?0:7;if(e)for(var s=t.selection.startCol,l=t.selection.endCol-s,h=t.selection.viewportCappedEndRow-t.selection.viewportCappedStartRow+1,_=t.selection.viewportCappedStartRow;_<t.selection.viewportCappedStartRow+h;_++)this._updateSelectionRange(s,s+l,_,t,n,o);else{s=t.selection.viewportStartRow===t.selection.viewportCappedStartRow?t.selection.startCol:0;var d=t.selection.viewportCappedStartRow===t.selection.viewportCappedEndRow?t.selection.endCol:i.cols;this._updateSelectionRange(s,d,t.selection.viewportCappedStartRow,t,n,o);var u=Math.max(t.selection.viewportCappedEndRow-t.selection.viewportCappedStartRow-1,0);for(_=t.selection.viewportCappedStartRow+1;_<=t.selection.viewportCappedStartRow+u;_++)this._updateSelectionRange(0,d,_,t,n,o);if(t.selection.viewportCappedStartRow!==t.selection.viewportCappedEndRow){var f=t.selection.viewportEndRow===t.selection.viewportCappedEndRow?t.selection.endCol:i.cols;this._updateSelectionRange(0,f,t.selection.viewportCappedEndRow,t,n,o)}}},t.prototype._updateSelectionRange=function(t,e,i,r,s,a){for(var l,c=this._terminal,h=i+c.buffer.viewportY,_=t;_<e;_++){var d=(i*this._terminal.cols+_)*o.INDICIES_PER_CELL,u=r.cells[d+1];if(u=-262144&u|s<<9|a,r.cells[d]&n.COMBINED_CHAR_BIT_MASK){l||(l=c.buffer.getLine(h));var f=l.getCell(_).char;this._updateCell(this._vertices.selectionAttributes,_,i,r.cells[d],u,s,a,f)}else this._updateCell(this._vertices.selectionAttributes,_,i,r.cells[d],u,s,a)}},t.prototype.onResize=function(){var t=this._terminal,e=this._gl;e.viewport(0,0,e.canvas.width,e.canvas.height);var i=t.cols*t.rows*10;if(this._vertices.count!==i){this._vertices.count=i,this._vertices.attributes=new Float32Array(i);for(var r=0;r<this._vertices.attributesBuffers.length;r++)this._vertices.attributesBuffers[r]=new Float32Array(i);for(var o=0,n=0;n<t.rows;n++)for(var s=0;s<t.cols;s++)this._vertices.attributes[o+8]=s/t.cols,this._vertices.attributes[o+9]=n/t.rows,o+=10}},t.prototype.setColors=function(){},t.prototype.render=function(t,e){if(this._atlas){var i=this._gl;i.useProgram(this._program),i.bindVertexArray(this._vertexArrayObject),this._activeBuffer=(this._activeBuffer+1)%2;for(var o=this._vertices.attributesBuffers[this._activeBuffer],n=0,s=0;s<t.lineLengths.length;s++){var a=s*this._terminal.cols*10,l=(e?this._vertices.selectionAttributes:this._vertices.attributes).subarray(a,a+10*t.lineLengths[s]);o.set(l,n),n+=l.length}i.bindBuffer(i.ARRAY_BUFFER,this._attributesBuffer),i.bufferData(i.ARRAY_BUFFER,o.subarray(0,n),i.STREAM_DRAW),this._atlas.hasCanvasChanged&&(this._atlas.hasCanvasChanged=!1,i.uniform1i(this._textureLocation,0),i.activeTexture(i.TEXTURE0+0),i.bindTexture(i.TEXTURE_2D,this._atlasTexture),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,i.RGBA,i.UNSIGNED_BYTE,this._atlas.cacheCanvas),i.generateMipmap(i.TEXTURE_2D)),i.uniformMatrix4fv(this._projectionLocation,!1,r.PROJECTION_MATRIX),i.uniform2f(this._resolutionLocation,i.canvas.width,i.canvas.height),i.drawElementsInstanced(i.TRIANGLES,6,i.UNSIGNED_BYTE,0,n/10)}},t.prototype.setAtlas=function(t){var e=this._gl;this._atlas=t,e.bindTexture(e.TEXTURE_2D,this._atlasTexture),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,t.cacheCanvas),e.generateMipmap(e.TEXTURE_2D)},t.prototype.setDimensions=function(t){this._dimensions=t},t}();e.GlyphRenderer=u},function(t,e,i){"use strict";function r(t,e,i){void 0===e&&(e=0),void 0===i&&(i=t.length),e<0&&(e=(t.length+e)%t.length),i=i>=t.length?t.length:(t.length+i)%t.length,e=Math.min(e,i);for(var r=new t.constructor(i-e),o=0;o<i-e;++o)r[o]=t[o+e];return r}Object.defineProperty(e,"__esModule",{value:!0}),e.slice=function(t,e,i){return t.slice?t.slice(e,i):r(t,e,i)},e.sliceFallback=r},function(t,e,i){"use strict";var r,o=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])})(t,e)},function(t,e){function i(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)});Object.defineProperty(e,"__esModule",{value:!0});var n=i(8),s=i(3),a=i(2),l=function(t){function e(e,i,r,o){var n=t.call(this,e,"link",i,!0,r)||this;return o.linkifier.onLinkHover(function(t){return n._onLinkHover(t)}),o.linkifier.onLinkLeave(function(t){return n._onLinkLeave(t)}),n}return o(e,t),e.prototype.resize=function(e,i){t.prototype.resize.call(this,e,i),this._state=void 0},e.prototype.reset=function(t){this._clearCurrentLink()},e.prototype._clearCurrentLink=function(){if(this._state){this._clearCells(this._state.x1,this._state.y1,this._state.cols-this._state.x1,1);var t=this._state.y2-this._state.y1-1;t>0&&this._clearCells(0,this._state.y1+1,this._state.cols,t),this._clearCells(0,this._state.y2,this._state.x2,1),this._state=void 0}},e.prototype._onLinkHover=function(t){if(t.fg===s.INVERTED_DEFAULT_COLOR?this._ctx.fillStyle=this._colors.background.css:void 0!==t.fg&&a.is256Color(t.fg)?this._ctx.fillStyle=this._colors.ansi[t.fg].css:this._ctx.fillStyle=this._colors.foreground.css,t.y1===t.y2)this._fillBottomLineAtCells(t.x1,t.y1,t.x2-t.x1);else{this._fillBottomLineAtCells(t.x1,t.y1,t.cols-t.x1);for(var e=t.y1+1;e<t.y2;e++)this._fillBottomLineAtCells(0,e,t.cols);this._fillBottomLineAtCells(0,t.y2,t.x2)}this._state=t},e.prototype._onLinkLeave=function(t){this._clearCurrentLink()},e}(n.BaseRenderLayer);e.LinkRenderLayer=l},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=i(3),o=i(0),n=i(2),s=i(1),a=1024,l=1024,c=Math.floor(.8*l),h={css:"rgba(0, 0, 0, 0)",rgba:0},_={offset:{x:0,y:0},texturePosition:{x:0,y:0},texturePositionClipSpace:{x:0,y:0},size:{x:0,y:0},sizeClipSpace:{x:0,y:0}},d=2,u=function(){function t(t,e){this._config=e,this._didWarmUp=!1,this._cacheMap={},this._cacheMapCombined={},this._currentRowY=0,this._currentRowX=0,this._currentRowHeight=0,this.hasCanvasChanged=!1,this._workBoundingBox={top:0,left:0,bottom:0,right:0},this.cacheCanvas=t.createElement("canvas"),this.cacheCanvas.width=a,this.cacheCanvas.height=l,this._cacheCtx=s.throwIfFalsy(this.cacheCanvas.getContext("2d",{alpha:!0})),this._tmpCanvas=t.createElement("canvas"),this._tmpCanvas.width=2*this._config.scaledCharWidth+2*d,this._tmpCanvas.height=this._config.scaledCharHeight+2*d,this._tmpCtx=s.throwIfFalsy(this._tmpCanvas.getContext("2d",{alpha:this._config.allowTransparency})),t.body.appendChild(this.cacheCanvas)}return t.prototype.dispose=function(){this.cacheCanvas.parentElement&&this.cacheCanvas.parentElement.removeChild(this.cacheCanvas)},t.prototype.warmUp=function(){this._didWarmUp||(this._doWarmUp(),this._didWarmUp=!0)},t.prototype._doWarmUp=function(){for(var t,e=33;e<126;e++){var i=this._drawToCache(e,o.DEFAULT_ATTR,o.DEFAULT_COLOR,o.DEFAULT_COLOR);this._cacheMap[e]=((t={})[o.DEFAULT_ATTR]=i,t)}},t.prototype.beginFrame=function(){return this._currentRowY>c&&(this._cacheCtx.clearRect(0,0,a,l),this._cacheMap={},this._currentRowHeight=0,this._currentRowX=0,this._currentRowY=0,this._doWarmUp(),!0)},t.prototype.getRasterizedGlyphCombinedChar=function(t,e,i,r){var o=this._cacheMapCombined[t];o||(o={},this._cacheMapCombined[t]=o);var n=o[e];return n||(n=this._drawToCache(t,e,i,r),o[e]=n),n},t.prototype.getRasterizedGlyph=function(t,e,i,r){var o=this._cacheMap[t];o||(o={},this._cacheMap[t]=o);var n=o[e];return n||(n=this._drawToCache(t,e,i,r),o[e]=n),n},t.prototype._getColorFromAnsiIndex=function(t){if(t>=this._config.colors.ansi.length)throw new Error("No color found for idx "+t);return this._config.colors.ansi[t]},t.prototype._getBackgroundColor=function(t){return this._config.allowTransparency?h:t===r.INVERTED_DEFAULT_COLOR?this._config.colors.foreground:n.is256Color(t)?this._getColorFromAnsiIndex(t):this._config.colors.background},t.prototype._getForegroundColor=function(t){return t===r.INVERTED_DEFAULT_COLOR?this._config.colors.background:n.is256Color(t)?this._getColorFromAnsiIndex(t):this._config.colors.foreground},t.prototype._drawToCache=function(t,e,i,o){var n="number"==typeof t?String.fromCharCode(t):t;this.hasCanvasChanged=!0;var s=e>>18,c=!!(1&s),h=!!(32&s),u=!!(64&s);this._tmpCtx.save();var f=this._getBackgroundColor(i);this._tmpCtx.globalCompositeOperation="copy",this._tmpCtx.fillStyle=f.css,this._tmpCtx.fillRect(0,0,this._tmpCanvas.width,this._tmpCanvas.height),this._tmpCtx.globalCompositeOperation="source-over";var p=c?this._config.fontWeightBold:this._config.fontWeight,v=u?"italic":"";this._tmpCtx.font=v+" "+p+" "+this._config.fontSize*this._config.devicePixelRatio+"px "+this._config.fontFamily,this._tmpCtx.textBaseline="top",this._tmpCtx.fillStyle=this._getForegroundColor(o).css,h&&(this._tmpCtx.globalAlpha=r.DIM_OPACITY),this._tmpCtx.fillText(n,d,d),this._tmpCtx.restore();var C=this._tmpCtx.getImageData(0,0,this._tmpCanvas.width,this._tmpCanvas.height);if(function(t,e){for(var i=!0,r=e.rgba>>>24,o=e.rgba>>>16&255,n=e.rgba>>>8&255,s=0;s<t.data.length;s+=4)t.data[s]===r&&t.data[s+1]===o&&t.data[s+2]===n?t.data[s+3]=0:i=!1;return i}(C,f))return _;var g=this._findGlyphBoundingBox(C,this._workBoundingBox),m=this._clipImageData(C,this._workBoundingBox);return this._currentRowX+this._config.scaledCharWidth>a&&(this._currentRowX=0,this._currentRowY+=this._currentRowHeight,this._currentRowHeight=0),g.texturePosition.x=this._currentRowX,g.texturePosition.y=this._currentRowY,g.texturePositionClipSpace.x=this._currentRowX/a,g.texturePositionClipSpace.y=this._currentRowY/l,this._currentRowHeight=Math.max(this._currentRowHeight,g.size.y),this._currentRowX+=g.size.x,this._cacheCtx.putImageData(m,g.texturePosition.x,g.texturePosition.y),g},t.prototype._findGlyphBoundingBox=function(t,e){e.top=0;for(var i=!1,r=0;r<this._tmpCanvas.height;r++){for(var o=0;o<this._tmpCanvas.width;o++){var n=r*this._tmpCanvas.width*4+4*o+3;if(0!==t.data[n]){e.top=r,i=!0;break}}if(i)break}e.left=0,i=!1;for(o=0;o<this._tmpCanvas.width;o++){for(r=0;r<this._tmpCanvas.height;r++){n=r*this._tmpCanvas.width*4+4*o+3;if(0!==t.data[n]){e.left=o,i=!0;break}}if(i)break}e.right=this._tmpCanvas.width,i=!1;for(o=this._tmpCanvas.width-1;o>=0;o--){for(r=0;r<this._tmpCanvas.height;r++){n=r*this._tmpCanvas.width*4+4*o+3;if(0!==t.data[n]){e.right=o,i=!0;break}}if(i)break}e.bottom=this._tmpCanvas.height,i=!1;for(r=this._tmpCanvas.height-1;r>=0;r--){for(o=0;o<this._tmpCanvas.width;o++){n=r*this._tmpCanvas.width*4+4*o+3;if(0!==t.data[n]){e.bottom=r,i=!0;break}}if(i)break}return{texturePosition:{x:0,y:0},texturePositionClipSpace:{x:0,y:0},size:{x:e.right-e.left+1,y:e.bottom-e.top+1},sizeClipSpace:{x:(e.right-e.left+1)/a,y:(e.bottom-e.top+1)/l},offset:{x:-e.left+d,y:-e.top+d}}},t.prototype._clipImageData=function(t,e){for(var i=e.right-e.left+1,r=e.bottom-e.top+1,o=new Uint8ClampedArray(i*r*4),n=e.top;n<=e.bottom;n++)for(var s=e.left;s<=e.right;s++){var a=n*this._tmpCanvas.width*4+4*s,l=(n-e.top)*i*4+4*(s-e.left);o[l]=t.data[a],o[l+1]=t.data[a+1],o[l+2]=t.data[a+2],o[l+3]=t.data[a+3]}return new ImageData(o,i,r)},t}();e.WebglCharAtlas=u},function(t,e,i){"use strict";var r,o=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])})(t,e)},function(t,e){function i(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)});Object.defineProperty(e,"__esModule",{value:!0});var n=i(8),s=i(10),a=function(t){function e(e,i,r){var o=t.call(this,e,"cursor",i,!0,r)||this;return o._cell=new s.CellData,o._state={x:0,y:0,isFocused:!1,style:"",width:0},o._cursorRenderers={bar:o._renderBarCursor.bind(o),block:o._renderBlockCursor.bind(o),underline:o._renderUnderlineCursor.bind(o)},o}return o(e,t),e.prototype.resize=function(e,i){t.prototype.resize.call(this,e,i),this._state={x:0,y:0,isFocused:!1,style:"",width:0}},e.prototype.reset=function(t){this._clearCursor(),this._cursorBlinkStateManager&&(this._cursorBlinkStateManager.dispose(),this.onOptionsChanged(t))},e.prototype.onBlur=function(t){this._cursorBlinkStateManager&&this._cursorBlinkStateManager.pause(),t.refresh(t.buffer.cursorY,t.buffer.cursorY)},e.prototype.onFocus=function(t){this._cursorBlinkStateManager?this._cursorBlinkStateManager.resume(t):t.refresh(t.buffer.cursorY,t.buffer.cursorY)},e.prototype.onOptionsChanged=function(t){var e=this;t.getOption("cursorBlink")?this._cursorBlinkStateManager||(this._cursorBlinkStateManager=new l(t,function(){e._render(t,!0)})):this._cursorBlinkStateManager&&this._cursorBlinkStateManager.dispose(),t.refresh(t.buffer.cursorY,t.buffer.cursorY)},e.prototype.onCursorMove=function(t){this._cursorBlinkStateManager&&this._cursorBlinkStateManager.restartBlinkAnimation(t)},e.prototype.onGridChanged=function(t,e,i){!this._cursorBlinkStateManager||this._cursorBlinkStateManager.isPaused?this._render(t,!1):this._cursorBlinkStateManager.restartBlinkAnimation(t)},e.prototype._render=function(t,e){if(t._core.cursorState&&!t._core.cursorHidden){var i=t.buffer.baseY+t.buffer.cursorY,r=i-t.buffer.viewportY;if(r<0||r>=t.rows)this._clearCursor();else if(t._core.buffer.lines.get(i).loadCell(t.buffer.cursorX,this._cell),void 0!==this._cell.content){if(!c(t)){this._clearCursor(),this._ctx.save(),this._ctx.fillStyle=this._colors.cursor.css;var o=t.getOption("cursorStyle");return o&&"block"!==o?this._cursorRenderers[o](t,t.buffer.cursorX,r,this._cell):this._renderBlurCursor(t,t.buffer.cursorX,r,this._cell),this._ctx.restore(),this._state.x=t.buffer.cursorX,this._state.y=r,this._state.isFocused=!1,this._state.style=o,void(this._state.width=this._cell.getWidth())}if(!this._cursorBlinkStateManager||this._cursorBlinkStateManager.isCursorVisible){if(this._state){if(this._state.x===t.buffer.cursorX&&this._state.y===r&&this._state.isFocused===c(t)&&this._state.style===t.getOption("cursorStyle")&&this._state.width===this._cell.getWidth())return;this._clearCursor()}this._ctx.save(),this._cursorRenderers[t.getOption("cursorStyle")||"block"](t,t.buffer.cursorX,r,this._cell),this._ctx.restore(),this._state.x=t.buffer.cursorX,this._state.y=r,this._state.isFocused=!1,this._state.style=t.getOption("cursorStyle"),this._state.width=this._cell.getWidth()}else this._clearCursor()}}else this._clearCursor()},e.prototype._clearCursor=function(){this._state&&(this._clearCells(this._state.x,this._state.y,this._state.width,1),this._state={x:0,y:0,isFocused:!1,style:"",width:0})},e.prototype._renderBarCursor=function(t,e,i,r){this._ctx.save(),this._ctx.fillStyle=this._colors.cursor.css,this._fillLeftLineAtCell(e,i),this._ctx.restore()},e.prototype._renderBlockCursor=function(t,e,i,r){this._ctx.save(),this._ctx.fillStyle=this._colors.cursor.css,this._fillCells(e,i,r.getWidth(),1),this._ctx.fillStyle=this._colors.cursorAccent.css,this._fillCharTrueColor(t,r,e,i),this._ctx.restore()},e.prototype._renderUnderlineCursor=function(t,e,i,r){this._ctx.save(),this._ctx.fillStyle=this._colors.cursor.css,this._fillBottomLineAtCells(e,i),this._ctx.restore()},e.prototype._renderBlurCursor=function(t,e,i,r){this._ctx.save(),this._ctx.strokeStyle=this._colors.cursor.css,this._strokeRectAtCell(e,i,r.getWidth(),1),this._ctx.restore()},e}(n.BaseRenderLayer);e.CursorRenderLayer=a;var l=function(){function t(t,e){this._renderCallback=e,this.isCursorVisible=!0,c(t)&&this._restartInterval()}return Object.defineProperty(t.prototype,"isPaused",{get:function(){return!(this._blinkStartTimeout||this._blinkInterval)},enumerable:!0,configurable:!0}),t.prototype.dispose=function(){this._blinkInterval&&(window.clearInterval(this._blinkInterval),this._blinkInterval=void 0),this._blinkStartTimeout&&(window.clearTimeout(this._blinkStartTimeout),this._blinkStartTimeout=void 0),this._animationFrame&&(window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)},t.prototype.restartBlinkAnimation=function(t){var e=this;this.isPaused||(this._animationTimeRestarted=Date.now(),this.isCursorVisible=!0,this._animationFrame||(this._animationFrame=window.requestAnimationFrame(function(){e._renderCallback(),e._animationFrame=void 0})))},t.prototype._restartInterval=function(t){var e=this;void 0===t&&(t=600),this._blinkInterval&&window.clearInterval(this._blinkInterval),this._blinkStartTimeout=setTimeout(function(){if(e._animationTimeRestarted){var t=600-(Date.now()-e._animationTimeRestarted);if(e._animationTimeRestarted=void 0,t>0)return void e._restartInterval(t)}e.isCursorVisible=!1,e._animationFrame=window.requestAnimationFrame(function(){e._renderCallback(),e._animationFrame=void 0}),e._blinkInterval=setInterval(function(){if(e._animationTimeRestarted){var t=600-(Date.now()-e._animationTimeRestarted);return e._animationTimeRestarted=void 0,void e._restartInterval(t)}e.isCursorVisible=!e.isCursorVisible,e._animationFrame=window.requestAnimationFrame(function(){e._renderCallback(),e._animationFrame=void 0})},600)},t)},t.prototype.pause=function(){this.isCursorVisible=!0,this._blinkInterval&&(window.clearInterval(this._blinkInterval),this._blinkInterval=void 0),this._blinkStartTimeout&&(window.clearTimeout(this._blinkStartTimeout),this._blinkStartTimeout=void 0),this._animationFrame&&(window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)},t.prototype.resume=function(t){this._animationTimeRestarted=void 0,this._restartInterval(),this.restartBlinkAnimation(t)},t}();function c(t){return document.activeElement===t.textarea&&document.hasFocus()}},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.stringFromCodePoint=function(t){return t>65535?(t-=65536,String.fromCharCode(55296+(t>>10))+String.fromCharCode(t%1024+56320)):String.fromCharCode(t)},e.utf32ToString=function(t,e,i){void 0===e&&(e=0),void 0===i&&(i=t.length);for(var r="",o=e;o<i;++o){var n=t[o];n>65535?(n-=65536,r+=String.fromCharCode(55296+(n>>10))+String.fromCharCode(n%1024+56320)):r+=String.fromCharCode(n)}return r};var r=function(){function t(){this._interim=0}return t.prototype.clear=function(){this._interim=0},t.prototype.decode=function(t,e){var i=t.length;if(!i)return 0;var r=0,o=0;this._interim&&(56320<=(a=t.charCodeAt(o++))&&a<=57343?e[r++]=1024*(this._interim-55296)+a-56320+65536:(e[r++]=this._interim,e[r++]=a),this._interim=0);for(var n=o;n<i;++n){var s=t.charCodeAt(n);if(55296<=s&&s<=56319){if(++n>=i)return this._interim=s,r;var a;56320<=(a=t.charCodeAt(n))&&a<=57343?e[r++]=1024*(s-55296)+a-56320+65536:(e[r++]=s,e[r++]=a)}else e[r++]=s}return r},t}();e.StringToUtf32=r;var o=function(){function t(){this.interim=new Uint8Array(3)}return t.prototype.clear=function(){this.interim.fill(0)},t.prototype.decode=function(t,e){var i=t.length;if(!i)return 0;var r,o,n,s,a=0,l=0,c=0;if(this.interim[0]){var h=!1,_=this.interim[0];_&=192==(224&_)?31:224==(240&_)?15:7;for(var d=0,u=void 0;(u=63&this.interim[++d])&&d<4;)_<<=6,_|=u;for(var f=192==(224&this.interim[0])?2:224==(240&this.interim[0])?3:4,p=f-d;c<p;){if(c>=i)return 0;if(128!=(192&(u=t[c++]))){c--,h=!0;break}this.interim[d++]=u,_<<=6,_|=63&u}h||(2===f?_<128?c--:e[a++]=_:3===f?_<2048||_>=55296&&_<=57343||(e[a++]=_):_<65536||_>1114111||(e[a++]=_)),this.interim.fill(0)}for(var v=i-4,C=c;C<i;){for(;!(!(C<v)||128&(r=t[C])||128&(o=t[C+1])||128&(n=t[C+2])||128&(s=t[C+3]));)e[a++]=r,e[a++]=o,e[a++]=n,e[a++]=s,C+=4;if((r=t[C++])<128)e[a++]=r;else if(192==(224&r)){if(C>=i)return this.interim[0]=r,a;if(128!=(192&(o=t[C++]))){C--;continue}if((l=(31&r)<<6|63&o)<128){C--;continue}e[a++]=l}else if(224==(240&r)){if(C>=i)return this.interim[0]=r,a;if(128!=(192&(o=t[C++]))){C--;continue}if(C>=i)return this.interim[0]=r,this.interim[1]=o,a;if(128!=(192&(n=t[C++]))){C--;continue}if((l=(15&r)<<12|(63&o)<<6|63&n)<2048||l>=55296&&l<=57343)continue;e[a++]=l}else if(240==(248&r)){if(C>=i)return this.interim[0]=r,a;if(128!=(192&(o=t[C++]))){C--;continue}if(C>=i)return this.interim[0]=r,this.interim[1]=o,a;if(128!=(192&(n=t[C++]))){C--;continue}if(C>=i)return this.interim[0]=r,this.interim[1]=o,this.interim[2]=n,a;if(128!=(192&(s=t[C++]))){C--;continue}if((l=(7&r)<<18|(63&o)<<12|(63&n)<<6|63&s)<65536||l>1114111)continue;e[a++]=l}}return a},t}();e.Utf8ToUtf32=o},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=function(){function t(){this.fg=0,this.bg=0}return t.toColorRGB=function(t){return[t>>>16&255,t>>>8&255,255&t]},t.fromColorRGB=function(t){return(255&t[0])<<16|(255&t[1])<<8|255&t[2]},t.prototype.clone=function(){var e=new t;return e.fg=this.fg,e.bg=this.bg,e},t.prototype.isInverse=function(){return 67108864&this.fg},t.prototype.isBold=function(){return 134217728&this.fg},t.prototype.isUnderline=function(){return 268435456&this.fg},t.prototype.isBlink=function(){return 536870912&this.fg},t.prototype.isInvisible=function(){return 1073741824&this.fg},t.prototype.isItalic=function(){return 67108864&this.bg},t.prototype.isDim=function(){return 134217728&this.bg},t.prototype.getFgColorMode=function(){return 50331648&this.fg},t.prototype.getBgColorMode=function(){return 50331648&this.bg},t.prototype.isFgRGB=function(){return 50331648==(50331648&this.fg)},t.prototype.isBgRGB=function(){return 50331648==(50331648&this.bg)},t.prototype.isFgPalette=function(){return 16777216==(50331648&this.fg)||33554432==(50331648&this.fg)},t.prototype.isBgPalette=function(){return 16777216==(50331648&this.bg)||33554432==(50331648&this.bg)},t.prototype.isFgDefault=function(){return 0==(50331648&this.fg)},t.prototype.isBgDefault=function(){return 0==(50331648&this.bg)},t.prototype.getFgColor=function(){switch(50331648&this.fg){case 16777216:case 33554432:return 255&this.fg;case 50331648:return 16777215&this.fg;default:return-1}},t.prototype.getBgColor=function(){switch(50331648&this.bg){case 16777216:case 33554432:return 255&this.bg;case 50331648:return 16777215&this.bg;default:return-1}},t}();e.AttributeData=r},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=i(1),o=i(4),n=i(3),s=i(2),a=i(0),l="#version 300 es\nlayout (location = 0) in vec2 a_position;\nlayout (location = 1) in vec2 a_size;\nlayout (location = 2) in vec3 a_color;\nlayout (location = 3) in vec2 a_unitquad;\n\nuniform mat4 u_projection;\nuniform vec2 u_resolution;\n\nout vec3 v_color;\n\nvoid main() {\n vec2 zeroToOne = (a_position + (a_unitquad * a_size)) / u_resolution;\n gl_Position = u_projection * vec4(zeroToOne, 0.0, 1.0);\n v_color = a_color;\n}",c="#version 300 es\nprecision lowp float;\n\nin vec3 v_color;\n\nout vec4 outColor;\n\nvoid main() {\n outColor = vec4(v_color, 1);\n}",h=8,_=h*Float32Array.BYTES_PER_ELEMENT,d=20*h,u=function(){function t(t,e,i,o){this._terminal=t,this._colors=e,this._gl=i,this._dimensions=o,this._vertices={count:0,attributes:new Float32Array(d),selection:new Float32Array(3*h)};var n=this._gl;this._program=r.throwIfFalsy(r.createProgram(n,l,c)),this._resolutionLocation=r.throwIfFalsy(n.getUniformLocation(this._program,"u_resolution")),this._projectionLocation=r.throwIfFalsy(n.getUniformLocation(this._program,"u_projection")),this._vertexArrayObject=n.createVertexArray(),n.bindVertexArray(this._vertexArrayObject);var s=new Float32Array([0,0,1,0,0,1,1,1]),a=n.createBuffer();n.bindBuffer(n.ARRAY_BUFFER,a),n.bufferData(n.ARRAY_BUFFER,s,n.STATIC_DRAW),n.enableVertexAttribArray(3),n.vertexAttribPointer(3,2,this._gl.FLOAT,!1,0,0);var u=new Uint8Array([0,1,3,0,2,3]),f=n.createBuffer();n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,f),n.bufferData(n.ELEMENT_ARRAY_BUFFER,u,n.STATIC_DRAW),this._attributesBuffer=r.throwIfFalsy(n.createBuffer()),n.bindBuffer(n.ARRAY_BUFFER,this._attributesBuffer),n.enableVertexAttribArray(0),n.vertexAttribPointer(0,2,n.FLOAT,!1,_,0),n.vertexAttribDivisor(0,1),n.enableVertexAttribArray(1),n.vertexAttribPointer(1,2,n.FLOAT,!1,_,2*Float32Array.BYTES_PER_ELEMENT),n.vertexAttribDivisor(1,1),n.enableVertexAttribArray(2),n.vertexAttribPointer(2,4,n.FLOAT,!1,_,4*Float32Array.BYTES_PER_ELEMENT),n.vertexAttribDivisor(2,1),this._updateCachedColors()}return t.prototype.render=function(){var t=this._gl;t.useProgram(this._program),t.bindVertexArray(this._vertexArrayObject),t.uniformMatrix4fv(this._projectionLocation,!1,r.PROJECTION_MATRIX),t.uniform2f(this._resolutionLocation,t.canvas.width,t.canvas.height),t.bindBuffer(t.ARRAY_BUFFER,this._attributesBuffer),t.bufferData(t.ARRAY_BUFFER,this._vertices.attributes,t.DYNAMIC_DRAW),t.drawElementsInstanced(this._gl.TRIANGLES,6,t.UNSIGNED_BYTE,0,this._vertices.count),t.bindBuffer(t.ARRAY_BUFFER,this._attributesBuffer),t.bufferData(t.ARRAY_BUFFER,this._vertices.selection,t.DYNAMIC_DRAW),t.drawElementsInstanced(this._gl.TRIANGLES,6,t.UNSIGNED_BYTE,0,3)},t.prototype.onResize=function(){this._updateViewportRectangle()},t.prototype.setColors=function(){this._updateCachedColors(),this._updateViewportRectangle()},t.prototype._updateCachedColors=function(){this._bgFloat=this._colorToFloat32Array(this._colors.background),this._selectionFloat=this._colorToFloat32Array(this._colors.selection)},t.prototype._updateViewportRectangle=function(){this._addRectangleFloat(this._vertices.attributes,0,0,0,this._terminal.cols*this._dimensions.scaledCellWidth,this._terminal.rows*this._dimensions.scaledCellHeight,this._bgFloat)},t.prototype.updateSelection=function(t,e){var i=this._terminal;if(t.hasSelection)if(e){var r=t.startCol,n=t.endCol-r,s=t.viewportCappedEndRow-t.viewportCappedStartRow+1;this._addRectangleFloat(this._vertices.selection,0,r*this._dimensions.scaledCellWidth,t.viewportCappedStartRow*this._dimensions.scaledCellHeight,n*this._dimensions.scaledCellWidth,s*this._dimensions.scaledCellHeight,this._selectionFloat),o.fill(this._vertices.selection,0,h)}else{r=t.viewportStartRow===t.viewportCappedStartRow?t.startCol:0;var a=t.viewportCappedStartRow===t.viewportCappedEndRow?t.endCol:i.cols;this._addRectangleFloat(this._vertices.selection,0,r*this._dimensions.scaledCellWidth,t.viewportCappedStartRow*this._dimensions.scaledCellHeight,(a-r)*this._dimensions.scaledCellWidth,this._dimensions.scaledCellHeight,this._selectionFloat);var l=Math.max(t.viewportCappedEndRow-t.viewportCappedStartRow-1,0);if(this._addRectangleFloat(this._vertices.selection,h,0,(t.viewportCappedStartRow+1)*this._dimensions.scaledCellHeight,i.cols*this._dimensions.scaledCellWidth,l*this._dimensions.scaledCellHeight,this._selectionFloat),t.viewportCappedStartRow!==t.viewportCappedEndRow){var c=t.viewportEndRow===t.viewportCappedEndRow?t.endCol:i.cols;this._addRectangleFloat(this._vertices.selection,2*h,0,t.viewportCappedEndRow*this._dimensions.scaledCellHeight,c*this._dimensions.scaledCellWidth,this._dimensions.scaledCellHeight,this._selectionFloat)}else o.fill(this._vertices.selection,0,2*h)}else o.fill(this._vertices.selection,0,0)},t.prototype.updateBackgrounds=function(t){for(var e=this._terminal,i=this._vertices,r=1,o=0;o<e.rows;o++){for(var n=-1,s=a.DEFAULT_COLOR,l=0;l<e.cols;l++){var c=4*(o*e.cols+l),_=t.cells[c+2];if(_!==s){if(s!==a.DEFAULT_COLOR){var d=r++*h;this._updateRectangle(i,d,s,n,l,o)}n=l,s=_}}if(s!==a.DEFAULT_COLOR){d=r++*h;this._updateRectangle(i,d,s,n,e.cols,o)}}i.count=r},t.prototype._updateRectangle=function(t,e,i,o,a,l){var c=null;c=i===n.INVERTED_DEFAULT_COLOR?this._colors.foreground:s.is256Color(i)?this._colors.ansi[i]:this._colors.foreground,t.attributes.length<e+4&&(t.attributes=r.expandFloat32Array(t.attributes,this._terminal.rows*this._terminal.cols*h));var _=o*this._dimensions.scaledCellWidth,d=l*this._dimensions.scaledCellHeight,u=(c.rgba>>24&255)/255,f=(c.rgba>>16&255)/255,p=(c.rgba>>8&255)/255;this._addRectangle(t.attributes,e,_,d,(a-o)*this._dimensions.scaledCellWidth,this._dimensions.scaledCellHeight,u,f,p,1)},t.prototype._addRectangle=function(t,e,i,r,o,n,s,a,l,c){t[e]=i,t[e+1]=r,t[e+2]=o,t[e+3]=n,t[e+4]=s,t[e+5]=a,t[e+6]=l,t[e+7]=c},t.prototype._addRectangleFloat=function(t,e,i,r,o,n,s){t[e]=i,t[e+1]=r,t[e+2]=o,t[e+3]=n,t[e+4]=s[0],t[e+5]=s[1],t[e+6]=s[2],t[e+7]=s[3]},t.prototype._colorToFloat32Array=function(t){return new Float32Array([(t.rgba>>24&255)/255,(t.rgba>>16&255)/255,(t.rgba>>8&255)/255,(255&t.rgba)/255])},t}();e.RectangleRenderer=u},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=function(){function t(){this._disposables=[],this._isDisposed=!1}return t.prototype.dispose=function(){this._isDisposed=!0,this._disposables.forEach(function(t){return t.dispose()}),this._disposables.length=0},t.prototype.register=function(t){this._disposables.push(t)},t.prototype.unregister=function(t){var e=this._disposables.indexOf(t);-1!==e&&this._disposables.splice(e,1)},t}();e.Disposable=r},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=i(10);e.getCompatAttr=function(t,e){var i=new r.CellData;return t.loadCell(e,i),(-1===i.getBgColor()?256:i.getBgColor())|(-1===i.getFgColor()?256:i.getFgColor())<<9|((i.isBold()?1:0)|(i.isUnderline()?2:0)|(i.isBlink()?4:0)|(i.isInverse()?8:0)|(i.isDim()?32:0)|(i.isItalic()?64:0))<<18}}])});
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.WebglAddon=e():t.WebglAddon=e()}(window,function(){return function(t){var e={};function i(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,i),o.l=!0,o.exports}return i.m=t,i.c=e,i.d=function(t,e,r){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(i.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)i.d(r,o,function(e){return t[e]}.bind(null,o));return r},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=10)}([function(t,e,i){"use strict";function r(t,e,i){var r=o(t.createShader(e));if(t.shaderSource(r,i),t.compileShader(r),t.getShaderParameter(r,t.COMPILE_STATUS))return r;console.error(t.getShaderInfoLog(r)),t.deleteShader(r)}function o(t){if(!t)throw new Error("value must not be falsy");return t}Object.defineProperty(e,"__esModule",{value:!0}),e.PROJECTION_MATRIX=new Float32Array([2,0,0,0,0,-2,0,0,0,0,1,0,-1,1,0,1]),e.createProgram=function(t,e,i){var s=o(t.createProgram());if(t.attachShader(s,o(r(t,t.VERTEX_SHADER,e))),t.attachShader(s,o(r(t,t.FRAGMENT_SHADER,i))),t.linkProgram(s),t.getProgramParameter(s,t.LINK_STATUS))return s;console.error(t.getProgramInfoLog(s)),t.deleteProgram(s)},e.createShader=r,e.expandFloat32Array=function(t,e){for(var i=Math.min(2*t.length,e),r=new Float32Array(i),o=0;o<t.length;o++)r[o]=t[o];return r},e.throwIfFalsy=o},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.DEFAULT_COLOR=256,e.DEFAULT_ATTR=256|e.DEFAULT_COLOR<<9,e.CHAR_DATA_ATTR_INDEX=0,e.CHAR_DATA_CHAR_INDEX=1,e.CHAR_DATA_WIDTH_INDEX=2,e.CHAR_DATA_CODE_INDEX=3,e.NULL_CELL_CHAR="",e.NULL_CELL_WIDTH=1,e.NULL_CELL_CODE=0,e.WHITESPACE_CELL_CHAR=" ",e.WHITESPACE_CELL_WIDTH=1,e.WHITESPACE_CELL_CODE=32},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=i(3);e.RENDER_MODEL_INDICIES_PER_CELL=3,e.RENDER_MODEL_BG_OFFSET=1,e.RENDER_MODEL_FG_OFFSET=2,e.COMBINED_CHAR_BIT_MASK=2147483648;var o=function(){function t(){this.cells=new Uint32Array(0),this.lineLengths=new Uint32Array(0),this.selection={hasSelection:!1,viewportStartRow:0,viewportEndRow:0,viewportCappedStartRow:0,viewportCappedEndRow:0,startCol:0,endCol:0}}return t.prototype.resize=function(t,i){var r=t*i*e.RENDER_MODEL_INDICIES_PER_CELL;r!==this.cells.length&&(this.cells=new Uint32Array(r),this.lineLengths=new Uint32Array(i))},t.prototype.clear=function(){r.fill(this.cells,0,0),r.fill(this.lineLengths,0,0),this.clearSelection()},t.prototype.clearSelection=function(){this.selection.hasSelection=!1,this.selection.viewportStartRow=0,this.selection.viewportEndRow=0,this.selection.viewportCappedStartRow=0,this.selection.viewportCappedEndRow=0,this.selection.startCol=0,this.selection.endCol=0},t}();e.RenderModel=o},function(t,e,i){"use strict";function r(t,e,i,r){if(void 0===i&&(i=0),void 0===r&&(r=t.length),i>=t.length)return t;i=(t.length+i)%t.length,r=r>=t.length?t.length:(t.length+r)%t.length;for(var o=i;o<r;++o)t[o]=e;return t}Object.defineProperty(e,"__esModule",{value:!0}),e.fill=function(t,e,i,o){return t.fill?t.fill(e,i,o):r(t,e,i,o)},e.fillFallback=r,e.concat=function(t,e){var i=new t.constructor(t.length+e.length);return i.set(t),i.set(e,t.length),i}},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=i(5),o=i(0),s=function(){function t(t,e,i,r,o){this._container=t,this._alpha=r,this._colors=o,this._scaledCharWidth=0,this._scaledCharHeight=0,this._scaledCellWidth=0,this._scaledCellHeight=0,this._scaledCharLeft=0,this._scaledCharTop=0,this._canvas=document.createElement("canvas"),this._canvas.classList.add("xterm-"+e+"-layer"),this._canvas.style.zIndex=i.toString(),this._initCanvas(),this._container.appendChild(this._canvas)}return t.prototype.dispose=function(){this._container.removeChild(this._canvas),this._charAtlas&&this._charAtlas.dispose()},t.prototype._initCanvas=function(){this._ctx=o.throwIfFalsy(this._canvas.getContext("2d",{alpha:this._alpha})),this._alpha||this._clearAll()},t.prototype.onOptionsChanged=function(t){},t.prototype.onBlur=function(t){},t.prototype.onFocus=function(t){},t.prototype.onCursorMove=function(t){},t.prototype.onGridChanged=function(t,e,i){},t.prototype.onSelectionChanged=function(t,e,i,r){void 0===r&&(r=!1)},t.prototype.setColors=function(t,e){this._refreshCharAtlas(t,e)},t.prototype._setTransparency=function(t,e){if(e!==this._alpha){var i=this._canvas;this._alpha=e,this._canvas=this._canvas.cloneNode(),this._initCanvas(),this._container.replaceChild(this._canvas,i),this._refreshCharAtlas(t,this._colors),this.onGridChanged(t,0,t.rows-1)}},t.prototype._refreshCharAtlas=function(t,e){this._scaledCharWidth<=0&&this._scaledCharHeight<=0||(this._charAtlas=r.acquireCharAtlas(t,e,this._scaledCharWidth,this._scaledCharHeight),this._charAtlas.warmUp())},t.prototype.resize=function(t,e){this._scaledCellWidth=e.scaledCellWidth,this._scaledCellHeight=e.scaledCellHeight,this._scaledCharWidth=e.scaledCharWidth,this._scaledCharHeight=e.scaledCharHeight,this._scaledCharLeft=e.scaledCharLeft,this._scaledCharTop=e.scaledCharTop,this._canvas.width=e.scaledCanvasWidth,this._canvas.height=e.scaledCanvasHeight,this._canvas.style.width=e.canvasWidth+"px",this._canvas.style.height=e.canvasHeight+"px",this._alpha||this._clearAll(),this._refreshCharAtlas(t,this._colors)},t.prototype._fillCells=function(t,e,i,r){this._ctx.fillRect(t*this._scaledCellWidth,e*this._scaledCellHeight,i*this._scaledCellWidth,r*this._scaledCellHeight)},t.prototype._fillBottomLineAtCells=function(t,e,i){void 0===i&&(i=1),this._ctx.fillRect(t*this._scaledCellWidth,(e+1)*this._scaledCellHeight-window.devicePixelRatio-1,i*this._scaledCellWidth,window.devicePixelRatio)},t.prototype._fillLeftLineAtCell=function(t,e){this._ctx.fillRect(t*this._scaledCellWidth,e*this._scaledCellHeight,window.devicePixelRatio,this._scaledCellHeight)},t.prototype._strokeRectAtCell=function(t,e,i,r){this._ctx.lineWidth=window.devicePixelRatio,this._ctx.strokeRect(t*this._scaledCellWidth+window.devicePixelRatio/2,e*this._scaledCellHeight+window.devicePixelRatio/2,i*this._scaledCellWidth-window.devicePixelRatio,r*this._scaledCellHeight-window.devicePixelRatio)},t.prototype._clearAll=function(){this._alpha?this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height):(this._ctx.fillStyle=this._colors.background.css,this._ctx.fillRect(0,0,this._canvas.width,this._canvas.height))},t.prototype._clearCells=function(t,e,i,r){this._alpha?this._ctx.clearRect(t*this._scaledCellWidth,e*this._scaledCellHeight,i*this._scaledCellWidth,r*this._scaledCellHeight):(this._ctx.fillStyle=this._colors.background.css,this._ctx.fillRect(t*this._scaledCellWidth,e*this._scaledCellHeight,i*this._scaledCellWidth,r*this._scaledCellHeight))},t.prototype._fillCharTrueColor=function(t,e,i,r){this._ctx.font=this._getFont(t,!1,!1),this._ctx.textBaseline="middle",this._clipRow(t,r),this._ctx.fillText(e.getChars(),i*this._scaledCellWidth+this._scaledCharLeft,r*this._scaledCellHeight+this._scaledCharTop+this._scaledCharHeight/2)},t.prototype._clipRow=function(t,e){this._ctx.beginPath(),this._ctx.rect(0,e*this._scaledCellHeight,t.cols*this._scaledCellWidth,this._scaledCellHeight),this._ctx.clip()},t.prototype._getFont=function(t,e,i){return(i?"italic":"")+" "+(e?t.getOption("fontWeightBold"):t.getOption("fontWeight"))+" "+t.getOption("fontSize")*window.devicePixelRatio+"px "+t.getOption("fontFamily")},t}();e.BaseRenderLayer=s},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=i(6),o=i(15),s=[];e.acquireCharAtlas=function(t,e,i,n){for(var a=r.generateConfig(i,n,t,e),l=0;l<s.length;l++){var c=(h=s[l]).ownedBy.indexOf(t);if(c>=0){if(r.configEquals(h.config,a))return h.atlas;1===h.ownedBy.length?(h.atlas.dispose(),s.splice(l,1)):h.ownedBy.splice(c,1);break}}for(l=0;l<s.length;l++){var h=s[l];if(r.configEquals(h.config,a))return h.ownedBy.push(t),h.atlas}var _={atlas:new o.WebglCharAtlas(document,a),config:a,ownedBy:[t]};return s.push(_),_.atlas},e.removeTerminalFromCache=function(t){for(var e=0;e<s.length;e++){var i=s[e].ownedBy.indexOf(t);if(-1!==i){1===s[e].ownedBy.length?(s[e].atlas.dispose(),s.splice(e,1)):s[e].ownedBy.splice(i,1);break}}}},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r={css:"",rgba:0};e.generateConfig=function(t,e,i,o){var s={foreground:o.foreground,background:o.background,cursor:r,cursorAccent:r,selection:r,selectionOpaque:r,ansi:o.ansi.slice(),contrastCache:o.contrastCache};return{devicePixelRatio:window.devicePixelRatio,scaledCharWidth:t,scaledCharHeight:e,fontFamily:i.getOption("fontFamily"),fontSize:i.getOption("fontSize"),fontWeight:i.getOption("fontWeight"),fontWeightBold:i.getOption("fontWeightBold"),allowTransparency:i.getOption("allowTransparency"),drawBoldTextInBrightColors:i.getOption("drawBoldTextInBrightColors"),minimumContrastRatio:i.getOption("minimumContrastRatio"),colors:s}},e.configEquals=function(t,e){for(var i=0;i<t.colors.ansi.length;i++)if(t.colors.ansi[i].rgba!==e.colors.ansi[i].rgba)return!1;return t.devicePixelRatio===e.devicePixelRatio&&t.fontFamily===e.fontFamily&&t.fontSize===e.fontSize&&t.fontWeight===e.fontWeight&&t.fontWeightBold===e.fontWeightBold&&t.allowTransparency===e.allowTransparency&&t.scaledCharWidth===e.scaledCharWidth&&t.scaledCharHeight===e.scaledCharHeight&&t.drawBoldTextInBrightColors===e.drawBoldTextInBrightColors&&t.minimumContrastRatio===e.minimumContrastRatio&&t.colors.foreground===e.colors.foreground&&t.colors.background===e.colors.background},e.is256Color=function(t){return 16777216==(50331648&t)||33554432==(50331648&t)}},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.INVERTED_DEFAULT_COLOR=257,e.DIM_OPACITY=.5,e.CHAR_ATLAS_CELL_SPACING=1},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=function(){function t(){this.fg=0,this.bg=0}return t.toColorRGB=function(t){return[t>>>16&255,t>>>8&255,255&t]},t.fromColorRGB=function(t){return(255&t[0])<<16|(255&t[1])<<8|255&t[2]},t.prototype.clone=function(){var e=new t;return e.fg=this.fg,e.bg=this.bg,e},t.prototype.isInverse=function(){return 67108864&this.fg},t.prototype.isBold=function(){return 134217728&this.fg},t.prototype.isUnderline=function(){return 268435456&this.fg},t.prototype.isBlink=function(){return 536870912&this.fg},t.prototype.isInvisible=function(){return 1073741824&this.fg},t.prototype.isItalic=function(){return 67108864&this.bg},t.prototype.isDim=function(){return 134217728&this.bg},t.prototype.getFgColorMode=function(){return 50331648&this.fg},t.prototype.getBgColorMode=function(){return 50331648&this.bg},t.prototype.isFgRGB=function(){return 50331648==(50331648&this.fg)},t.prototype.isBgRGB=function(){return 50331648==(50331648&this.bg)},t.prototype.isFgPalette=function(){return 16777216==(50331648&this.fg)||33554432==(50331648&this.fg)},t.prototype.isBgPalette=function(){return 16777216==(50331648&this.bg)||33554432==(50331648&this.bg)},t.prototype.isFgDefault=function(){return 0==(50331648&this.fg)},t.prototype.isBgDefault=function(){return 0==(50331648&this.bg)},t.prototype.getFgColor=function(){switch(50331648&this.fg){case 16777216:case 33554432:return 255&this.fg;case 50331648:return 16777215&this.fg;default:return-1}},t.prototype.getBgColor=function(){switch(50331648&this.bg){case 16777216:case 33554432:return 255&this.bg;case 50331648:return 16777215&this.bg;default:return-1}},t}();e.AttributeData=r},function(t,e,i){"use strict";var r,o=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])})(t,e)},function(t,e){function i(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)});Object.defineProperty(e,"__esModule",{value:!0});var s=i(18),n=i(1),a=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.content=0,e.fg=0,e.bg=0,e.combinedData="",e}return o(e,t),e.fromCharData=function(t){var i=new e;return i.setFromCharData(t),i},e.prototype.isCombined=function(){return 2097152&this.content},e.prototype.getWidth=function(){return this.content>>22},e.prototype.getChars=function(){return 2097152&this.content?this.combinedData:2097151&this.content?s.stringFromCodePoint(2097151&this.content):""},e.prototype.getCode=function(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content},e.prototype.setFromCharData=function(t){this.fg=t[n.CHAR_DATA_ATTR_INDEX],this.bg=0;var e=!1;if(t[n.CHAR_DATA_CHAR_INDEX].length>2)e=!0;else if(2===t[n.CHAR_DATA_CHAR_INDEX].length){var i=t[n.CHAR_DATA_CHAR_INDEX].charCodeAt(0);if(55296<=i&&i<=56319){var r=t[n.CHAR_DATA_CHAR_INDEX].charCodeAt(1);56320<=r&&r<=57343?this.content=1024*(i-55296)+r-56320+65536|t[n.CHAR_DATA_WIDTH_INDEX]<<22:e=!0}else e=!0}else this.content=t[n.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|t[n.CHAR_DATA_WIDTH_INDEX]<<22;e&&(this.combinedData=t[n.CHAR_DATA_CHAR_INDEX],this.content=2097152|t[n.CHAR_DATA_WIDTH_INDEX]<<22)},e.prototype.getAsCharData=function(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]},e}(i(8).AttributeData);e.CellData=a},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=i(11),o=function(){function t(t){this._preserveDrawingBuffer=t}return t.prototype.activate=function(t){if(!t.element)throw new Error("Cannot activate WebglAddon before Terminal.open");this._terminal=t;var e=t._core._renderService,i=t._core._colorManager.colors;e.setRenderer(new r.WebglRenderer(t,i,this._preserveDrawingBuffer))},t.prototype.dispose=function(){if(!this._terminal)throw new Error("Cannot dispose WebglAddon because it is activated");var t=this._terminal._core._renderService;t.setRenderer(this._terminal._core._createRenderer()),t.onResize(this._terminal.cols,this._terminal.rows)},t}();e.WebglAddon=o},function(t,e,i){"use strict";var r,o=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])})(t,e)},function(t,e){function i(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)});Object.defineProperty(e,"__esModule",{value:!0});var s=i(12),n=i(14),a=i(17),l=i(5),c=i(19),h=i(2),_=i(20),u=i(1),d=i(21),f=i(9),p=function(t){function e(e,i,r){var o=t.call(this)||this;o._terminal=e,o._colors=i,o._model=new h.RenderModel,o._workCell=new f.CellData,o._onRequestRefreshRows=new d.EventEmitter,o._core=o._terminal._core,o._renderLayers=[new n.LinkRenderLayer(o._core.screenElement,2,o._colors,o._core),new a.CursorRenderLayer(o._core.screenElement,3,o._colors,o._onRequestRefreshRows)],o.dimensions={scaledCharWidth:0,scaledCharHeight:0,scaledCellWidth:0,scaledCellHeight:0,scaledCharLeft:0,scaledCharTop:0,scaledCanvasWidth:0,scaledCanvasHeight:0,canvasWidth:0,canvasHeight:0,actualCellWidth:0,actualCellHeight:0},o._devicePixelRatio=window.devicePixelRatio,o._updateDimensions(),o._canvas=document.createElement("canvas");var l={antialias:!1,depth:!1,preserveDrawingBuffer:r};if(o._gl=o._canvas.getContext("webgl2",l),!o._gl)throw new Error("WebGL2 not supported");return o._core.screenElement.appendChild(o._canvas),o._rectangleRenderer=new c.RectangleRenderer(o._terminal,o._colors,o._gl,o.dimensions),o._glyphRenderer=new s.GlyphRenderer(o._terminal,o._colors,o._gl,o.dimensions),o.onCharSizeChanged(),o._isAttached=document.body.contains(o._core.screenElement),o}return o(e,t),Object.defineProperty(e.prototype,"onRequestRefreshRows",{get:function(){return this._onRequestRefreshRows.event},enumerable:!0,configurable:!0}),e.prototype.dispose=function(){this._renderLayers.forEach(function(t){return t.dispose()}),this._core.screenElement.removeChild(this._canvas),t.prototype.dispose.call(this)},e.prototype.setColors=function(t){var e=this;this._colors=t,this._renderLayers.forEach(function(t){t.setColors(e._terminal,e._colors),t.reset(e._terminal)}),this._rectangleRenderer.setColors(),this._glyphRenderer.setColors(),this._refreshCharAtlas(),this._model.clear()},e.prototype.onDevicePixelRatioChange=function(){this._devicePixelRatio!==window.devicePixelRatio&&(this._devicePixelRatio=window.devicePixelRatio,this.onResize(this._terminal.cols,this._terminal.rows))},e.prototype.onResize=function(t,e){var i=this;this._updateDimensions(),this._model.resize(this._terminal.cols,this._terminal.rows),this._rectangleRenderer.onResize(),this._renderLayers.forEach(function(t){return t.resize(i._terminal,i.dimensions)}),this._canvas.width=this.dimensions.scaledCanvasWidth,this._canvas.height=this.dimensions.scaledCanvasHeight,this._canvas.style.width=this.dimensions.canvasWidth+"px",this._canvas.style.height=this.dimensions.canvasHeight+"px",this._core.screenElement.style.width=this.dimensions.canvasWidth+"px",this._core.screenElement.style.height=this.dimensions.canvasHeight+"px",this._glyphRenderer.setDimensions(this.dimensions),this._glyphRenderer.onResize(),this._refreshCharAtlas(),this._model.clear()},e.prototype.onCharSizeChanged=function(){this.onResize(this._terminal.cols,this._terminal.rows)},e.prototype.onBlur=function(){var t=this;this._renderLayers.forEach(function(e){return e.onBlur(t._terminal)})},e.prototype.onFocus=function(){var t=this;this._renderLayers.forEach(function(e){return e.onFocus(t._terminal)})},e.prototype.onSelectionChanged=function(t,e,i){var r=this;this._renderLayers.forEach(function(o){return o.onSelectionChanged(r._terminal,t,e,i)}),this._updateSelectionModel(t,e),this._rectangleRenderer.updateSelection(this._model.selection,i),this._glyphRenderer.updateSelection(this._model,i),this._onRequestRefreshRows.fire({start:0,end:this._terminal.rows-1})},e.prototype.onCursorMove=function(){var t=this;this._renderLayers.forEach(function(e){return e.onCursorMove(t._terminal)})},e.prototype.onOptionsChanged=function(){var t=this;this._renderLayers.forEach(function(e){return e.onOptionsChanged(t._terminal)}),this._updateDimensions(),this._refreshCharAtlas()},e.prototype._refreshCharAtlas=function(){if(this.dimensions.scaledCharWidth<=0&&this.dimensions.scaledCharHeight<=0)this._isAttached=!1;else{var t=l.acquireCharAtlas(this._terminal,this._colors,this.dimensions.scaledCharWidth,this.dimensions.scaledCharHeight);if(!("getRasterizedGlyph"in t))throw new Error("The webgl renderer only works with the webgl char atlas");this._charAtlas=t,this._charAtlas.warmUp(),this._glyphRenderer.setAtlas(this._charAtlas)}},e.prototype.clear=function(){var t=this;this._renderLayers.forEach(function(e){return e.reset(t._terminal)})},e.prototype.registerCharacterJoiner=function(t){return-1},e.prototype.deregisterCharacterJoiner=function(t){return!1},e.prototype.renderRows=function(t,e){var i=this;if(!this._isAttached){if(!(document.body.contains(this._core.screenElement)&&this._core._charSizeService.width&&this._core._charSizeService.height))return;this._updateDimensions(),this._refreshCharAtlas(),this._isAttached=!0}this._renderLayers.forEach(function(r){return r.onGridChanged(i._terminal,t,e)}),this._glyphRenderer.beginFrame()&&this._model.clear(),this._updateModel(t,e),this._rectangleRenderer.render(),this._glyphRenderer.render(this._model,this._model.selection.hasSelection)},e.prototype._updateModel=function(t,e){for(var i=this._core,r=t;r<=e;r++){var o=r+i.buffer.ydisp,s=i.buffer.lines.get(o);this._model.lineLengths[r]=0;for(var n=0;n<i.cols;n++){s.loadCell(n,this._workCell);var a=this._workCell.getChars(),l=this._workCell.getCode(),c=(r*i.cols+n)*h.RENDER_MODEL_INDICIES_PER_CELL;l!==u.NULL_CELL_CODE&&(this._model.lineLengths[r]=n+1),this._model.cells[c]===l&&this._model.cells[c+h.RENDER_MODEL_BG_OFFSET]===this._workCell.bg&&this._model.cells[c+h.RENDER_MODEL_FG_OFFSET]===this._workCell.fg||(a.length>1&&(l|=h.COMBINED_CHAR_BIT_MASK),this._model.cells[c]=l,this._model.cells[c+h.RENDER_MODEL_BG_OFFSET]=this._workCell.bg,this._model.cells[c+h.RENDER_MODEL_FG_OFFSET]=this._workCell.fg,this._glyphRenderer.updateCell(n,r,l,this._workCell.bg,this._workCell.fg,a))}}this._rectangleRenderer.updateBackgrounds(this._model)},e.prototype._updateSelectionModel=function(t,e){var i=this._terminal;if(t&&e&&(t[0]!==e[0]||t[1]!==e[1])){var r=t[1]-i.buffer.viewportY,o=e[1]-i.buffer.viewportY,s=Math.max(r,0),n=Math.min(o,i.rows-1);s>=i.rows||n<0?this._model.clearSelection():(this._model.selection.hasSelection=!0,this._model.selection.viewportStartRow=r,this._model.selection.viewportEndRow=o,this._model.selection.viewportCappedStartRow=s,this._model.selection.viewportCappedEndRow=n,this._model.selection.startCol=t[0],this._model.selection.endCol=e[0])}else this._model.clearSelection()},e.prototype._updateDimensions=function(){this._core._charSizeService.width&&this._core._charSizeService.height&&(this.dimensions.scaledCharWidth=Math.floor(this._core._charSizeService.width*this._devicePixelRatio),this.dimensions.scaledCharHeight=Math.ceil(this._core._charSizeService.height*this._devicePixelRatio),this.dimensions.scaledCellHeight=Math.floor(this.dimensions.scaledCharHeight*this._terminal.getOption("lineHeight")),this.dimensions.scaledCharTop=1===this._terminal.getOption("lineHeight")?0:Math.round((this.dimensions.scaledCellHeight-this.dimensions.scaledCharHeight)/2),this.dimensions.scaledCellWidth=this.dimensions.scaledCharWidth+Math.round(this._terminal.getOption("letterSpacing")),this.dimensions.scaledCharLeft=Math.floor(this._terminal.getOption("letterSpacing")/2),this.dimensions.scaledCanvasHeight=this._terminal.rows*this.dimensions.scaledCellHeight,this.dimensions.scaledCanvasWidth=this._terminal.cols*this.dimensions.scaledCellWidth,this.dimensions.canvasHeight=Math.round(this.dimensions.scaledCanvasHeight/this._devicePixelRatio),this.dimensions.canvasWidth=Math.round(this.dimensions.scaledCanvasWidth/this._devicePixelRatio),this.dimensions.actualCellHeight=this.dimensions.scaledCellHeight/this._devicePixelRatio,this.dimensions.actualCellWidth=this.dimensions.scaledCellWidth/this._devicePixelRatio)},e}(_.Disposable);e.WebglRenderer=p},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=i(0),o=i(2),s=i(3),n=i(13),a=i(1),l="#version 300 es\nlayout (location = 0) in vec2 a_unitquad;\nlayout (location = 1) in vec2 a_cellpos;\nlayout (location = 2) in vec2 a_offset;\nlayout (location = 3) in vec2 a_size;\nlayout (location = 4) in vec2 a_texcoord;\nlayout (location = 5) in vec2 a_texsize;\n\nuniform mat4 u_projection;\nuniform vec2 u_resolution;\n\nout vec2 v_texcoord;\n\nvoid main() {\n vec2 zeroToOne = (a_offset / u_resolution) + a_cellpos + (a_unitquad * a_size);\n gl_Position = u_projection * vec4(zeroToOne, 0.0, 1.0);\n v_texcoord = a_texcoord + a_unitquad * a_texsize;\n}",c="#version 300 es\nprecision lowp float;\n\nin vec2 v_texcoord;\n\nuniform sampler2D u_texture;\n\nout vec4 outColor;\n\nvoid main() {\n outColor = texture(u_texture, v_texcoord);\n}",h=10*Float32Array.BYTES_PER_ELEMENT,_=function(){function t(t,e,i,o){this._terminal=t,this._colors=e,this._gl=i,this._dimensions=o,this._activeBuffer=0,this._vertices={count:0,attributes:new Float32Array(0),attributesBuffers:[new Float32Array(0),new Float32Array(0)],selectionAttributes:new Float32Array(0)};var s=this._gl,n=r.throwIfFalsy(r.createProgram(s,l,c));this._program=n,this._projectionLocation=r.throwIfFalsy(s.getUniformLocation(this._program,"u_projection")),this._resolutionLocation=r.throwIfFalsy(s.getUniformLocation(this._program,"u_resolution")),this._textureLocation=r.throwIfFalsy(s.getUniformLocation(this._program,"u_texture")),this._vertexArrayObject=s.createVertexArray(),s.bindVertexArray(this._vertexArrayObject);var a=new Float32Array([0,0,1,0,0,1,1,1]),_=s.createBuffer();s.bindBuffer(s.ARRAY_BUFFER,_),s.bufferData(s.ARRAY_BUFFER,a,s.STATIC_DRAW),s.enableVertexAttribArray(0),s.vertexAttribPointer(0,2,this._gl.FLOAT,!1,0,0);var u=new Uint8Array([0,1,3,0,2,3]),d=s.createBuffer();s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,d),s.bufferData(s.ELEMENT_ARRAY_BUFFER,u,s.STATIC_DRAW),this._attributesBuffer=r.throwIfFalsy(s.createBuffer()),s.bindBuffer(s.ARRAY_BUFFER,this._attributesBuffer),s.enableVertexAttribArray(2),s.vertexAttribPointer(2,2,s.FLOAT,!1,h,0),s.vertexAttribDivisor(2,1),s.enableVertexAttribArray(3),s.vertexAttribPointer(3,2,s.FLOAT,!1,h,2*Float32Array.BYTES_PER_ELEMENT),s.vertexAttribDivisor(3,1),s.enableVertexAttribArray(4),s.vertexAttribPointer(4,2,s.FLOAT,!1,h,4*Float32Array.BYTES_PER_ELEMENT),s.vertexAttribDivisor(4,1),s.enableVertexAttribArray(5),s.vertexAttribPointer(5,2,s.FLOAT,!1,h,6*Float32Array.BYTES_PER_ELEMENT),s.vertexAttribDivisor(5,1),s.enableVertexAttribArray(1),s.vertexAttribPointer(1,2,s.FLOAT,!1,h,8*Float32Array.BYTES_PER_ELEMENT),s.vertexAttribDivisor(1,1),this._atlasTexture=r.throwIfFalsy(s.createTexture()),s.bindTexture(s.TEXTURE_2D,this._atlasTexture),s.texImage2D(s.TEXTURE_2D,0,s.RGBA,1,1,0,s.RGBA,s.UNSIGNED_BYTE,new Uint8Array([0,0,255,255])),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE),s.enable(s.BLEND),s.blendFunc(s.SRC_ALPHA,s.ONE_MINUS_SRC_ALPHA),this.onResize()}return t.prototype.beginFrame=function(){return!this._atlas||this._atlas.beginFrame()},t.prototype.updateCell=function(t,e,i,r,o,s){this._updateCell(this._vertices.attributes,t,e,i,r,o,s)},t.prototype._updateCell=function(t,e,i,r,o,n,l){var c=10*(i*this._terminal.cols+e);if(r!==a.NULL_CELL_CODE&&r!==a.WHITESPACE_CELL_CODE&&void 0!==r){var h;if(!this._atlas)throw new Error("atlas must be set before updating cell");(h=l&&l.length>1?this._atlas.getRasterizedGlyphCombinedChar(l,o,n):this._atlas.getRasterizedGlyph(r,o,n))?(t[c]=-h.offset.x+this._dimensions.scaledCharLeft,t[c+1]=-h.offset.y+this._dimensions.scaledCharTop,t[c+2]=h.size.x/this._dimensions.scaledCanvasWidth,t[c+3]=h.size.y/this._dimensions.scaledCanvasHeight,t[c+4]=h.texturePositionClipSpace.x,t[c+5]=h.texturePositionClipSpace.y,t[c+6]=h.sizeClipSpace.x,t[c+7]=h.sizeClipSpace.y):s.fill(t,0,c,c+10-1-2)}else s.fill(t,0,c,c+10-1-2)},t.prototype.updateSelection=function(t,e){var i=this._terminal;this._vertices.selectionAttributes=n.slice(this._vertices.attributes,0);var r=this._colors.selectionOpaque.rgba>>>8|50331648;if(e)for(var o=t.selection.startCol,s=t.selection.endCol-o,a=t.selection.viewportCappedEndRow-t.selection.viewportCappedStartRow+1,l=t.selection.viewportCappedStartRow;l<t.selection.viewportCappedStartRow+a;l++)this._updateSelectionRange(o,o+s,l,t,r);else{o=t.selection.viewportStartRow===t.selection.viewportCappedStartRow?t.selection.startCol:0;var c=t.selection.viewportCappedStartRow===t.selection.viewportCappedEndRow?t.selection.endCol:i.cols;this._updateSelectionRange(o,c,t.selection.viewportCappedStartRow,t,r);var h=Math.max(t.selection.viewportCappedEndRow-t.selection.viewportCappedStartRow-1,0);for(l=t.selection.viewportCappedStartRow+1;l<=t.selection.viewportCappedStartRow+h;l++)this._updateSelectionRange(0,c,l,t,r);if(t.selection.viewportCappedStartRow!==t.selection.viewportCappedEndRow){var _=t.selection.viewportEndRow===t.selection.viewportCappedEndRow?t.selection.endCol:i.cols;this._updateSelectionRange(0,_,t.selection.viewportCappedEndRow,t,r)}}},t.prototype._updateSelectionRange=function(t,e,i,r,s){for(var n,a=this._terminal,l=i+a.buffer.viewportY,c=t;c<e;c++){var h=(i*this._terminal.cols+c)*o.RENDER_MODEL_INDICIES_PER_CELL;if(r.cells[h]&o.COMBINED_CHAR_BIT_MASK){n||(n=a.buffer.getLine(l));var _=n.getCell(c).char;this._updateCell(this._vertices.selectionAttributes,c,i,r.cells[h],s,r.cells[h+o.RENDER_MODEL_FG_OFFSET],_)}else this._updateCell(this._vertices.selectionAttributes,c,i,r.cells[h],s,r.cells[h+o.RENDER_MODEL_FG_OFFSET])}},t.prototype.onResize=function(){var t=this._terminal,e=this._gl;e.viewport(0,0,e.canvas.width,e.canvas.height);var i=t.cols*t.rows*10;if(this._vertices.count!==i){this._vertices.count=i,this._vertices.attributes=new Float32Array(i);for(var r=0;r<this._vertices.attributesBuffers.length;r++)this._vertices.attributesBuffers[r]=new Float32Array(i);for(var o=0,s=0;s<t.rows;s++)for(var n=0;n<t.cols;n++)this._vertices.attributes[o+8]=n/t.cols,this._vertices.attributes[o+9]=s/t.rows,o+=10}},t.prototype.setColors=function(){},t.prototype.render=function(t,e){if(this._atlas){var i=this._gl;i.useProgram(this._program),i.bindVertexArray(this._vertexArrayObject),this._activeBuffer=(this._activeBuffer+1)%2;for(var o=this._vertices.attributesBuffers[this._activeBuffer],s=0,n=0;n<t.lineLengths.length;n++){var a=n*this._terminal.cols*10,l=(e?this._vertices.selectionAttributes:this._vertices.attributes).subarray(a,a+10*t.lineLengths[n]);o.set(l,s),s+=l.length}i.bindBuffer(i.ARRAY_BUFFER,this._attributesBuffer),i.bufferData(i.ARRAY_BUFFER,o.subarray(0,s),i.STREAM_DRAW),this._atlas.hasCanvasChanged&&(this._atlas.hasCanvasChanged=!1,i.uniform1i(this._textureLocation,0),i.activeTexture(i.TEXTURE0+0),i.bindTexture(i.TEXTURE_2D,this._atlasTexture),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,i.RGBA,i.UNSIGNED_BYTE,this._atlas.cacheCanvas),i.generateMipmap(i.TEXTURE_2D)),i.uniformMatrix4fv(this._projectionLocation,!1,r.PROJECTION_MATRIX),i.uniform2f(this._resolutionLocation,i.canvas.width,i.canvas.height),i.drawElementsInstanced(i.TRIANGLES,6,i.UNSIGNED_BYTE,0,s/10)}},t.prototype.setAtlas=function(t){var e=this._gl;this._atlas=t,e.bindTexture(e.TEXTURE_2D,this._atlasTexture),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,t.cacheCanvas),e.generateMipmap(e.TEXTURE_2D)},t.prototype.setDimensions=function(t){this._dimensions=t},t}();e.GlyphRenderer=_},function(t,e,i){"use strict";function r(t,e,i){void 0===e&&(e=0),void 0===i&&(i=t.length),e<0&&(e=(t.length+e)%t.length),i=i>=t.length?t.length:(t.length+i)%t.length,e=Math.min(e,i);for(var r=new t.constructor(i-e),o=0;o<i-e;++o)r[o]=t[o+e];return r}Object.defineProperty(e,"__esModule",{value:!0}),e.slice=function(t,e,i){return t.slice?t.slice(e,i):r(t,e,i)},e.sliceFallback=r},function(t,e,i){"use strict";var r,o=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])})(t,e)},function(t,e){function i(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)});Object.defineProperty(e,"__esModule",{value:!0});var s=i(4),n=i(7),a=i(6),l=function(t){function e(e,i,r,o){var s=t.call(this,e,"link",i,!0,r)||this;return o.linkifier.onLinkHover(function(t){return s._onLinkHover(t)}),o.linkifier.onLinkLeave(function(t){return s._onLinkLeave(t)}),s}return o(e,t),e.prototype.resize=function(e,i){t.prototype.resize.call(this,e,i),this._state=void 0},e.prototype.reset=function(t){this._clearCurrentLink()},e.prototype._clearCurrentLink=function(){if(this._state){this._clearCells(this._state.x1,this._state.y1,this._state.cols-this._state.x1,1);var t=this._state.y2-this._state.y1-1;t>0&&this._clearCells(0,this._state.y1+1,this._state.cols,t),this._clearCells(0,this._state.y2,this._state.x2,1),this._state=void 0}},e.prototype._onLinkHover=function(t){if(t.fg===n.INVERTED_DEFAULT_COLOR?this._ctx.fillStyle=this._colors.background.css:void 0!==t.fg&&a.is256Color(t.fg)?this._ctx.fillStyle=this._colors.ansi[t.fg].css:this._ctx.fillStyle=this._colors.foreground.css,t.y1===t.y2)this._fillBottomLineAtCells(t.x1,t.y1,t.x2-t.x1);else{this._fillBottomLineAtCells(t.x1,t.y1,t.cols-t.x1);for(var e=t.y1+1;e<t.y2;e++)this._fillBottomLineAtCells(0,e,t.cols);this._fillBottomLineAtCells(0,t.y2,t.x2)}this._state=t},e.prototype._onLinkLeave=function(t){this._clearCurrentLink()},e}(s.BaseRenderLayer);e.LinkRenderLayer=l},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=i(7),o=i(1),s=i(0),n=i(8),a=i(16),l=1024,c=1024,h=Math.floor(.8*c),_={css:"rgba(0, 0, 0, 0)",rgba:0},u={offset:{x:0,y:0},texturePosition:{x:0,y:0},texturePositionClipSpace:{x:0,y:0},size:{x:0,y:0},sizeClipSpace:{x:0,y:0}},d=2,f=function(){function t(t,e){this._config=e,this._didWarmUp=!1,this._cacheMap={},this._cacheMapCombined={},this._currentRowY=0,this._currentRowX=0,this._currentRowHeight=0,this.hasCanvasChanged=!1,this._workBoundingBox={top:0,left:0,bottom:0,right:0},this._workAttributeData=new n.AttributeData,this.cacheCanvas=t.createElement("canvas"),this.cacheCanvas.width=l,this.cacheCanvas.height=c,this._cacheCtx=s.throwIfFalsy(this.cacheCanvas.getContext("2d",{alpha:!0})),this._tmpCanvas=t.createElement("canvas"),this._tmpCanvas.width=2*this._config.scaledCharWidth+2*d,this._tmpCanvas.height=this._config.scaledCharHeight+2*d,this._tmpCtx=s.throwIfFalsy(this._tmpCanvas.getContext("2d",{alpha:this._config.allowTransparency})),t.body.appendChild(this.cacheCanvas)}return t.prototype.dispose=function(){this.cacheCanvas.parentElement&&this.cacheCanvas.parentElement.removeChild(this.cacheCanvas)},t.prototype.warmUp=function(){this._didWarmUp||(this._doWarmUp(),this._didWarmUp=!0)},t.prototype._doWarmUp=function(){for(var t,e,i=33;i<126;i++){var r=this._drawToCache(i,o.DEFAULT_COLOR,o.DEFAULT_COLOR);this._cacheMap[i]=((t={})[o.DEFAULT_COLOR]=((e={})[o.DEFAULT_COLOR]=r,e),t)}},t.prototype.beginFrame=function(){return this._currentRowY>h&&(this._cacheCtx.clearRect(0,0,l,c),this._cacheMap={},this._currentRowHeight=0,this._currentRowX=0,this._currentRowY=0,this._doWarmUp(),!0)},t.prototype.getRasterizedGlyphCombinedChar=function(t,e,i){var r,o=this._cacheMapCombined[t];o||(o={},this._cacheMapCombined[t]=o);var s=o[e];return s&&(r=s[i]),r||(r=this._drawToCache(t,e,i),o[e]||(o[e]={}),o[e][i]=r),r},t.prototype.getRasterizedGlyph=function(t,e,i){var r,o=this._cacheMap[t];o||(o={},this._cacheMap[t]=o);var s=o[e];return s&&(r=s[i]),r||(r=this._drawToCache(t,e,i),o[e]||(o[e]={}),o[e][i]=r),r},t.prototype._getColorFromAnsiIndex=function(t){if(t>=this._config.colors.ansi.length)throw new Error("No color found for idx "+t);return this._config.colors.ansi[t]},t.prototype._getBackgroundColor=function(t,e,i){if(this._config.allowTransparency)return _;switch(t){case 16777216:case 33554432:return this._getColorFromAnsiIndex(e);case 50331648:var r=n.AttributeData.toColorRGB(e);return{rgba:e<<8,css:"#"+p(r[0])+p(r[1])+p(r[2])};case 0:default:return i?this._config.colors.foreground:this._config.colors.background}},t.prototype._getForegroundCss=function(t,e,i,r,o,s,l,c){var h=this._getMinimumContrastCss(t,e,i,r,o,s,l,c);if(h)return h;switch(o){case 16777216:case 33554432:return this._config.drawBoldTextInBrightColors&&c&&s<8&&(s+=8),this._getColorFromAnsiIndex(s).css;case 50331648:var _=n.AttributeData.toColorRGB(s);return a.toCss(_[0],_[1],_[2]);case 0:default:return l?this._config.colors.background.css:this._config.colors.foreground.css}},t.prototype._resolveBackgroundRgba=function(t,e,i){switch(t){case 16777216:case 33554432:return this._getColorFromAnsiIndex(e).rgba;case 50331648:return e<<8;case 0:default:return i?this._config.colors.foreground.rgba:this._config.colors.background.rgba}},t.prototype._resolveForegroundRgba=function(t,e,i,r){switch(t){case 16777216:case 33554432:return this._config.drawBoldTextInBrightColors&&r&&e<8&&(e+=8),this._getColorFromAnsiIndex(e).rgba;case 50331648:return e<<8;case 0:default:return i?this._config.colors.background.rgba:this._config.colors.foreground.rgba}},t.prototype._getMinimumContrastCss=function(t,e,i,r,o,s,n,l){if(1!==this._config.minimumContrastRatio){var c=this._config.colors.contrastCache.getCss(t,r);if(void 0!==c)return c||void 0;var h=this._resolveBackgroundRgba(e,i,n),_=this._resolveForegroundRgba(o,s,n,l),u=a.ensureContrastRatioRgba(h,_,this._config.minimumContrastRatio);if(u){var d=a.toCss(u>>24&255,u>>16&255,u>>8&255);return this._config.colors.contrastCache.setCss(t,r,d),d}this._config.colors.contrastCache.setCss(t,r,null)}},t.prototype._drawToCache=function(t,e,i){var o="number"==typeof t?String.fromCharCode(t):t;this.hasCanvasChanged=!0,this._tmpCtx.save(),this._workAttributeData.fg=i,this._workAttributeData.bg=e;var s=!!this._workAttributeData.isBold(),n=!!this._workAttributeData.isInverse(),a=!!this._workAttributeData.isDim(),h=!!this._workAttributeData.isItalic(),_=this._workAttributeData.getFgColor(),f=this._workAttributeData.getFgColorMode(),p=this._workAttributeData.getBgColor(),g=this._workAttributeData.getBgColorMode();if(n){var v=_;_=p,p=v;var C=f;f=g,g=C}var m=this._getBackgroundColor(g,p,n);this._tmpCtx.globalCompositeOperation="copy",this._tmpCtx.fillStyle=m.css,this._tmpCtx.fillRect(0,0,this._tmpCanvas.width,this._tmpCanvas.height),this._tmpCtx.globalCompositeOperation="source-over";var y=s?this._config.fontWeightBold:this._config.fontWeight,R=h?"italic":"";this._tmpCtx.font=R+" "+y+" "+this._config.fontSize*this._config.devicePixelRatio+"px "+this._config.fontFamily,this._tmpCtx.textBaseline="top",this._tmpCtx.fillStyle=this._getForegroundCss(e,g,p,i,f,_,n,s),a&&(this._tmpCtx.globalAlpha=r.DIM_OPACITY),this._tmpCtx.fillText(o,d,d),this._tmpCtx.restore();var b=this._tmpCtx.getImageData(0,0,this._tmpCanvas.width,this._tmpCanvas.height);if(function(t,e){for(var i=!0,r=e.rgba>>>24,o=e.rgba>>>16&255,s=e.rgba>>>8&255,n=0;n<t.data.length;n+=4)t.data[n]===r&&t.data[n+1]===o&&t.data[n+2]===s?t.data[n+3]=0:i=!1;return i}(b,m))return u;var w=this._findGlyphBoundingBox(b,this._workBoundingBox),A=this._clipImageData(b,this._workBoundingBox);return this._currentRowX+this._config.scaledCharWidth>l&&(this._currentRowX=0,this._currentRowY+=this._currentRowHeight,this._currentRowHeight=0),w.texturePosition.x=this._currentRowX,w.texturePosition.y=this._currentRowY,w.texturePositionClipSpace.x=this._currentRowX/l,w.texturePositionClipSpace.y=this._currentRowY/c,this._currentRowHeight=Math.max(this._currentRowHeight,w.size.y),this._currentRowX+=w.size.x,this._cacheCtx.putImageData(A,w.texturePosition.x,w.texturePosition.y),w},t.prototype._findGlyphBoundingBox=function(t,e){e.top=0;for(var i=!1,r=0;r<this._tmpCanvas.height;r++){for(var o=0;o<this._tmpCanvas.width;o++){var s=r*this._tmpCanvas.width*4+4*o+3;if(0!==t.data[s]){e.top=r,i=!0;break}}if(i)break}e.left=0,i=!1;for(o=0;o<this._tmpCanvas.width;o++){for(r=0;r<this._tmpCanvas.height;r++){s=r*this._tmpCanvas.width*4+4*o+3;if(0!==t.data[s]){e.left=o,i=!0;break}}if(i)break}e.right=this._tmpCanvas.width,i=!1;for(o=this._tmpCanvas.width-1;o>=0;o--){for(r=0;r<this._tmpCanvas.height;r++){s=r*this._tmpCanvas.width*4+4*o+3;if(0!==t.data[s]){e.right=o,i=!0;break}}if(i)break}e.bottom=this._tmpCanvas.height,i=!1;for(r=this._tmpCanvas.height-1;r>=0;r--){for(o=0;o<this._tmpCanvas.width;o++){s=r*this._tmpCanvas.width*4+4*o+3;if(0!==t.data[s]){e.bottom=r,i=!0;break}}if(i)break}return{texturePosition:{x:0,y:0},texturePositionClipSpace:{x:0,y:0},size:{x:e.right-e.left+1,y:e.bottom-e.top+1},sizeClipSpace:{x:(e.right-e.left+1)/l,y:(e.bottom-e.top+1)/c},offset:{x:-e.left+d,y:-e.top+d}}},t.prototype._clipImageData=function(t,e){for(var i=e.right-e.left+1,r=e.bottom-e.top+1,o=new Uint8ClampedArray(i*r*4),s=e.top;s<=e.bottom;s++)for(var n=e.left;n<=e.right;n++){var a=s*this._tmpCanvas.width*4+4*n,l=(s-e.top)*i*4+4*(n-e.left);o[l]=t.data[a],o[l+1]=t.data[a+1],o[l+2]=t.data[a+2],o[l+3]=t.data[a+3]}return new ImageData(o,i,r)},t}();function p(t){var e=t.toString(16);return e.length<2?"0"+e:e}e.WebglCharAtlas=f},function(t,e,i){"use strict";function r(t){var e=t.toString(16);return e.length<2?"0"+e:e}function o(t,e,i){return"#"+r(t)+r(e)+r(i)}function s(t,e,i,r){return void 0===r&&(r=255),(t<<24|e<<16|i<<8|r)>>>0}function n(t){return a(t>>16&255,t>>8&255,255&t)}function a(t,e,i){var r=t/255,o=e/255,s=i/255;return.2126*(r<=.03928?r/12.92:Math.pow((r+.055)/1.055,2.4))+.7152*(o<=.03928?o/12.92:Math.pow((o+.055)/1.055,2.4))+.0722*(s<=.03928?s/12.92:Math.pow((s+.055)/1.055,2.4))}function l(t,e){return t<e?(e+.05)/(t+.05):(t+.05)/(e+.05)}function c(t,e,i){var r=n(t>>8),o=n(e>>8);if(l(r,o)<i)return o<r?h(t,e,i):_(t,e,i)}function h(t,e,i){for(var r=t>>24&255,o=t>>16&255,s=t>>8&255,n=e>>24&255,c=e>>16&255,h=e>>8&255,_=l(a(n,h,c),a(r,o,s));_<i&&(n>0||c>0||h>0);)n-=Math.max(0,Math.ceil(.1*n)),c-=Math.max(0,Math.ceil(.1*c)),_=l(a(n,h-=Math.max(0,Math.ceil(.1*h)),c),a(r,o,s));return(n<<24|c<<16|h<<8|255)>>>0}function _(t,e,i){for(var r=t>>24&255,o=t>>16&255,s=t>>8&255,n=e>>24&255,c=e>>16&255,h=e>>8&255,_=l(a(n,h,c),a(r,o,s));_<i&&(n<255||c<255||h<255);)n=Math.min(255,n+Math.ceil(.1*(255-n))),c=Math.min(255,c+Math.ceil(.1*(255-c))),_=l(a(n,h=Math.min(255,h+Math.ceil(.1*(255-h))),c),a(r,o,s));return(n<<24|c<<16|h<<8|255)>>>0}Object.defineProperty(e,"__esModule",{value:!0}),e.blend=function(t,e){var i=(255&e.rgba)/255;if(1===i)return{css:e.css,rgba:e.rgba};var r=e.rgba>>24&255,n=e.rgba>>16&255,a=e.rgba>>8&255,l=t.rgba>>24&255,c=t.rgba>>16&255,h=t.rgba>>8&255,_=l+Math.round((r-l)*i),u=c+Math.round((n-c)*i),d=h+Math.round((a-h)*i);return{css:o(_,u,d),rgba:s(_,u,d)}},e.fromCss=function(t){return{css:t,rgba:(parseInt(t.slice(1),16)<<8|255)>>>0}},e.toPaddedHex=r,e.toCss=o,e.toRgba=s,e.rgbRelativeLuminance=n,e.rgbRelativeLuminance2=a,e.contrastRatio=l,e.ensureContrastRatioRgba=c,e.ensureContrastRatio=function(t,e,i){var r,n,a,l=c(t.rgba,e.rgba,i);if(l)return{css:o(r=l>>24&255,n=l>>16&255,a=l>>8&255),rgba:s(r,n,a)}},e.reduceLuminance=h,e.increaseLuminance=_},function(t,e,i){"use strict";var r,o=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])})(t,e)},function(t,e){function i(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)});Object.defineProperty(e,"__esModule",{value:!0});var s=i(4),n=i(9),a=function(t){function e(e,i,r,o){var s=t.call(this,e,"cursor",i,!0,r)||this;return s._onRequestRefreshRowsEvent=o,s._cell=new n.CellData,s._state={x:0,y:0,isFocused:!1,style:"",width:0},s._cursorRenderers={bar:s._renderBarCursor.bind(s),block:s._renderBlockCursor.bind(s),underline:s._renderUnderlineCursor.bind(s)},s}return o(e,t),e.prototype.resize=function(e,i){t.prototype.resize.call(this,e,i),this._state={x:0,y:0,isFocused:!1,style:"",width:0}},e.prototype.reset=function(t){this._clearCursor(),this._cursorBlinkStateManager&&(this._cursorBlinkStateManager.dispose(),this.onOptionsChanged(t))},e.prototype.onBlur=function(t){this._cursorBlinkStateManager&&this._cursorBlinkStateManager.pause(),this._onRequestRefreshRowsEvent.fire({start:t.buffer.cursorY,end:t.buffer.cursorY})},e.prototype.onFocus=function(t){this._cursorBlinkStateManager?this._cursorBlinkStateManager.resume(t):this._onRequestRefreshRowsEvent.fire({start:t.buffer.cursorY,end:t.buffer.cursorY})},e.prototype.onOptionsChanged=function(t){var e,i=this;t.getOption("cursorBlink")?this._cursorBlinkStateManager||(this._cursorBlinkStateManager=new l(t,function(){i._render(t,!0)})):(null===(e=this._cursorBlinkStateManager)||void 0===e||e.dispose(),this._cursorBlinkStateManager=void 0),this._onRequestRefreshRowsEvent.fire({start:t.buffer.cursorY,end:t.buffer.cursorY})},e.prototype.onCursorMove=function(t){this._cursorBlinkStateManager&&this._cursorBlinkStateManager.restartBlinkAnimation(t)},e.prototype.onGridChanged=function(t,e,i){!this._cursorBlinkStateManager||this._cursorBlinkStateManager.isPaused?this._render(t,!1):this._cursorBlinkStateManager.restartBlinkAnimation(t)},e.prototype._render=function(t,e){if(t._core._coreService.isCursorInitialized&&!t._core._coreService.isCursorHidden){var i=t.buffer.baseY+t.buffer.cursorY,r=i-t.buffer.viewportY;if(r<0||r>=t.rows)this._clearCursor();else if(t._core.buffer.lines.get(i).loadCell(t.buffer.cursorX,this._cell),void 0!==this._cell.content){if(!c(t)){this._clearCursor(),this._ctx.save(),this._ctx.fillStyle=this._colors.cursor.css;var o=t.getOption("cursorStyle");return o&&"block"!==o?this._cursorRenderers[o](t,t.buffer.cursorX,r,this._cell):this._renderBlurCursor(t,t.buffer.cursorX,r,this._cell),this._ctx.restore(),this._state.x=t.buffer.cursorX,this._state.y=r,this._state.isFocused=!1,this._state.style=o,void(this._state.width=this._cell.getWidth())}if(!this._cursorBlinkStateManager||this._cursorBlinkStateManager.isCursorVisible){if(this._state){if(this._state.x===t.buffer.cursorX&&this._state.y===r&&this._state.isFocused===c(t)&&this._state.style===t.getOption("cursorStyle")&&this._state.width===this._cell.getWidth())return;this._clearCursor()}this._ctx.save(),this._cursorRenderers[t.getOption("cursorStyle")||"block"](t,t.buffer.cursorX,r,this._cell),this._ctx.restore(),this._state.x=t.buffer.cursorX,this._state.y=r,this._state.isFocused=!1,this._state.style=t.getOption("cursorStyle"),this._state.width=this._cell.getWidth()}else this._clearCursor()}}else this._clearCursor()},e.prototype._clearCursor=function(){this._state&&(this._clearCells(this._state.x,this._state.y,this._state.width,1),this._state={x:0,y:0,isFocused:!1,style:"",width:0})},e.prototype._renderBarCursor=function(t,e,i,r){this._ctx.save(),this._ctx.fillStyle=this._colors.cursor.css,this._fillLeftLineAtCell(e,i),this._ctx.restore()},e.prototype._renderBlockCursor=function(t,e,i,r){this._ctx.save(),this._ctx.fillStyle=this._colors.cursor.css,this._fillCells(e,i,r.getWidth(),1),this._ctx.fillStyle=this._colors.cursorAccent.css,this._fillCharTrueColor(t,r,e,i),this._ctx.restore()},e.prototype._renderUnderlineCursor=function(t,e,i,r){this._ctx.save(),this._ctx.fillStyle=this._colors.cursor.css,this._fillBottomLineAtCells(e,i),this._ctx.restore()},e.prototype._renderBlurCursor=function(t,e,i,r){this._ctx.save(),this._ctx.strokeStyle=this._colors.cursor.css,this._strokeRectAtCell(e,i,r.getWidth(),1),this._ctx.restore()},e}(s.BaseRenderLayer);e.CursorRenderLayer=a;var l=function(){function t(t,e){this._renderCallback=e,this.isCursorVisible=!0,c(t)&&this._restartInterval()}return Object.defineProperty(t.prototype,"isPaused",{get:function(){return!(this._blinkStartTimeout||this._blinkInterval)},enumerable:!0,configurable:!0}),t.prototype.dispose=function(){this._blinkInterval&&(window.clearInterval(this._blinkInterval),this._blinkInterval=void 0),this._blinkStartTimeout&&(window.clearTimeout(this._blinkStartTimeout),this._blinkStartTimeout=void 0),this._animationFrame&&(window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)},t.prototype.restartBlinkAnimation=function(t){var e=this;this.isPaused||(this._animationTimeRestarted=Date.now(),this.isCursorVisible=!0,this._animationFrame||(this._animationFrame=window.requestAnimationFrame(function(){e._renderCallback(),e._animationFrame=void 0})))},t.prototype._restartInterval=function(t){var e=this;void 0===t&&(t=600),this._blinkInterval&&window.clearInterval(this._blinkInterval),this._blinkStartTimeout=setTimeout(function(){if(e._animationTimeRestarted){var t=600-(Date.now()-e._animationTimeRestarted);if(e._animationTimeRestarted=void 0,t>0)return void e._restartInterval(t)}e.isCursorVisible=!1,e._animationFrame=window.requestAnimationFrame(function(){e._renderCallback(),e._animationFrame=void 0}),e._blinkInterval=setInterval(function(){if(e._animationTimeRestarted){var t=600-(Date.now()-e._animationTimeRestarted);return e._animationTimeRestarted=void 0,void e._restartInterval(t)}e.isCursorVisible=!e.isCursorVisible,e._animationFrame=window.requestAnimationFrame(function(){e._renderCallback(),e._animationFrame=void 0})},600)},t)},t.prototype.pause=function(){this.isCursorVisible=!0,this._blinkInterval&&(window.clearInterval(this._blinkInterval),this._blinkInterval=void 0),this._blinkStartTimeout&&(window.clearTimeout(this._blinkStartTimeout),this._blinkStartTimeout=void 0),this._animationFrame&&(window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)},t.prototype.resume=function(t){this._animationTimeRestarted=void 0,this._restartInterval(),this.restartBlinkAnimation(t)},t}();function c(t){return document.activeElement===t.textarea&&document.hasFocus()}},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.stringFromCodePoint=function(t){return t>65535?(t-=65536,String.fromCharCode(55296+(t>>10))+String.fromCharCode(t%1024+56320)):String.fromCharCode(t)},e.utf32ToString=function(t,e,i){void 0===e&&(e=0),void 0===i&&(i=t.length);for(var r="",o=e;o<i;++o){var s=t[o];s>65535?(s-=65536,r+=String.fromCharCode(55296+(s>>10))+String.fromCharCode(s%1024+56320)):r+=String.fromCharCode(s)}return r};var r=function(){function t(){this._interim=0}return t.prototype.clear=function(){this._interim=0},t.prototype.decode=function(t,e){var i=t.length;if(!i)return 0;var r=0,o=0;this._interim&&(56320<=(a=t.charCodeAt(o++))&&a<=57343?e[r++]=1024*(this._interim-55296)+a-56320+65536:(e[r++]=this._interim,e[r++]=a),this._interim=0);for(var s=o;s<i;++s){var n=t.charCodeAt(s);if(55296<=n&&n<=56319){if(++s>=i)return this._interim=n,r;var a;56320<=(a=t.charCodeAt(s))&&a<=57343?e[r++]=1024*(n-55296)+a-56320+65536:(e[r++]=n,e[r++]=a)}else e[r++]=n}return r},t}();e.StringToUtf32=r;var o=function(){function t(){this.interim=new Uint8Array(3)}return t.prototype.clear=function(){this.interim.fill(0)},t.prototype.decode=function(t,e){var i=t.length;if(!i)return 0;var r,o,s,n,a=0,l=0,c=0;if(this.interim[0]){var h=!1,_=this.interim[0];_&=192==(224&_)?31:224==(240&_)?15:7;for(var u=0,d=void 0;(d=63&this.interim[++u])&&u<4;)_<<=6,_|=d;for(var f=192==(224&this.interim[0])?2:224==(240&this.interim[0])?3:4,p=f-u;c<p;){if(c>=i)return 0;if(128!=(192&(d=t[c++]))){c--,h=!0;break}this.interim[u++]=d,_<<=6,_|=63&d}h||(2===f?_<128?c--:e[a++]=_:3===f?_<2048||_>=55296&&_<=57343||(e[a++]=_):_<65536||_>1114111||(e[a++]=_)),this.interim.fill(0)}for(var g=i-4,v=c;v<i;){for(;!(!(v<g)||128&(r=t[v])||128&(o=t[v+1])||128&(s=t[v+2])||128&(n=t[v+3]));)e[a++]=r,e[a++]=o,e[a++]=s,e[a++]=n,v+=4;if((r=t[v++])<128)e[a++]=r;else if(192==(224&r)){if(v>=i)return this.interim[0]=r,a;if(128!=(192&(o=t[v++]))){v--;continue}if((l=(31&r)<<6|63&o)<128){v--;continue}e[a++]=l}else if(224==(240&r)){if(v>=i)return this.interim[0]=r,a;if(128!=(192&(o=t[v++]))){v--;continue}if(v>=i)return this.interim[0]=r,this.interim[1]=o,a;if(128!=(192&(s=t[v++]))){v--;continue}if((l=(15&r)<<12|(63&o)<<6|63&s)<2048||l>=55296&&l<=57343)continue;e[a++]=l}else if(240==(248&r)){if(v>=i)return this.interim[0]=r,a;if(128!=(192&(o=t[v++]))){v--;continue}if(v>=i)return this.interim[0]=r,this.interim[1]=o,a;if(128!=(192&(s=t[v++]))){v--;continue}if(v>=i)return this.interim[0]=r,this.interim[1]=o,this.interim[2]=s,a;if(128!=(192&(n=t[v++]))){v--;continue}if((l=(7&r)<<18|(63&o)<<12|(63&s)<<6|63&n)<65536||l>1114111)continue;e[a++]=l}}return a},t}();e.Utf8ToUtf32=o},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=i(0),o=i(3),s=i(2),n="#version 300 es\nlayout (location = 0) in vec2 a_position;\nlayout (location = 1) in vec2 a_size;\nlayout (location = 2) in vec3 a_color;\nlayout (location = 3) in vec2 a_unitquad;\n\nuniform mat4 u_projection;\nuniform vec2 u_resolution;\n\nout vec3 v_color;\n\nvoid main() {\n vec2 zeroToOne = (a_position + (a_unitquad * a_size)) / u_resolution;\n gl_Position = u_projection * vec4(zeroToOne, 0.0, 1.0);\n v_color = a_color;\n}",a="#version 300 es\nprecision lowp float;\n\nin vec3 v_color;\n\nout vec4 outColor;\n\nvoid main() {\n outColor = vec4(v_color, 1);\n}",l=8,c=l*Float32Array.BYTES_PER_ELEMENT,h=20*l,_=function(){function t(t,e,i,o){this._terminal=t,this._colors=e,this._gl=i,this._dimensions=o,this._vertices={count:0,attributes:new Float32Array(h),selection:new Float32Array(3*l)};var s=this._gl;this._program=r.throwIfFalsy(r.createProgram(s,n,a)),this._resolutionLocation=r.throwIfFalsy(s.getUniformLocation(this._program,"u_resolution")),this._projectionLocation=r.throwIfFalsy(s.getUniformLocation(this._program,"u_projection")),this._vertexArrayObject=s.createVertexArray(),s.bindVertexArray(this._vertexArrayObject);var _=new Float32Array([0,0,1,0,0,1,1,1]),u=s.createBuffer();s.bindBuffer(s.ARRAY_BUFFER,u),s.bufferData(s.ARRAY_BUFFER,_,s.STATIC_DRAW),s.enableVertexAttribArray(3),s.vertexAttribPointer(3,2,this._gl.FLOAT,!1,0,0);var d=new Uint8Array([0,1,3,0,2,3]),f=s.createBuffer();s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,f),s.bufferData(s.ELEMENT_ARRAY_BUFFER,d,s.STATIC_DRAW),this._attributesBuffer=r.throwIfFalsy(s.createBuffer()),s.bindBuffer(s.ARRAY_BUFFER,this._attributesBuffer),s.enableVertexAttribArray(0),s.vertexAttribPointer(0,2,s.FLOAT,!1,c,0),s.vertexAttribDivisor(0,1),s.enableVertexAttribArray(1),s.vertexAttribPointer(1,2,s.FLOAT,!1,c,2*Float32Array.BYTES_PER_ELEMENT),s.vertexAttribDivisor(1,1),s.enableVertexAttribArray(2),s.vertexAttribPointer(2,4,s.FLOAT,!1,c,4*Float32Array.BYTES_PER_ELEMENT),s.vertexAttribDivisor(2,1),this._updateCachedColors()}return t.prototype.render=function(){var t=this._gl;t.useProgram(this._program),t.bindVertexArray(this._vertexArrayObject),t.uniformMatrix4fv(this._projectionLocation,!1,r.PROJECTION_MATRIX),t.uniform2f(this._resolutionLocation,t.canvas.width,t.canvas.height),t.bindBuffer(t.ARRAY_BUFFER,this._attributesBuffer),t.bufferData(t.ARRAY_BUFFER,this._vertices.attributes,t.DYNAMIC_DRAW),t.drawElementsInstanced(this._gl.TRIANGLES,6,t.UNSIGNED_BYTE,0,this._vertices.count),t.bindBuffer(t.ARRAY_BUFFER,this._attributesBuffer),t.bufferData(t.ARRAY_BUFFER,this._vertices.selection,t.DYNAMIC_DRAW),t.drawElementsInstanced(this._gl.TRIANGLES,6,t.UNSIGNED_BYTE,0,3)},t.prototype.onResize=function(){this._updateViewportRectangle()},t.prototype.setColors=function(){this._updateCachedColors(),this._updateViewportRectangle()},t.prototype._updateCachedColors=function(){this._bgFloat=this._colorToFloat32Array(this._colors.background),this._selectionFloat=this._colorToFloat32Array(this._colors.selectionOpaque)},t.prototype._updateViewportRectangle=function(){this._addRectangleFloat(this._vertices.attributes,0,0,0,this._terminal.cols*this._dimensions.scaledCellWidth,this._terminal.rows*this._dimensions.scaledCellHeight,this._bgFloat)},t.prototype.updateSelection=function(t,e){var i=this._terminal;if(t.hasSelection)if(e){var r=t.startCol,s=t.endCol-r,n=t.viewportCappedEndRow-t.viewportCappedStartRow+1;this._addRectangleFloat(this._vertices.selection,0,r*this._dimensions.scaledCellWidth,t.viewportCappedStartRow*this._dimensions.scaledCellHeight,s*this._dimensions.scaledCellWidth,n*this._dimensions.scaledCellHeight,this._selectionFloat),o.fill(this._vertices.selection,0,l)}else{r=t.viewportStartRow===t.viewportCappedStartRow?t.startCol:0;var a=t.viewportCappedStartRow===t.viewportCappedEndRow?t.endCol:i.cols;this._addRectangleFloat(this._vertices.selection,0,r*this._dimensions.scaledCellWidth,t.viewportCappedStartRow*this._dimensions.scaledCellHeight,(a-r)*this._dimensions.scaledCellWidth,this._dimensions.scaledCellHeight,this._selectionFloat);var c=Math.max(t.viewportCappedEndRow-t.viewportCappedStartRow-1,0);if(this._addRectangleFloat(this._vertices.selection,l,0,(t.viewportCappedStartRow+1)*this._dimensions.scaledCellHeight,i.cols*this._dimensions.scaledCellWidth,c*this._dimensions.scaledCellHeight,this._selectionFloat),t.viewportCappedStartRow!==t.viewportCappedEndRow){var h=t.viewportEndRow===t.viewportCappedEndRow?t.endCol:i.cols;this._addRectangleFloat(this._vertices.selection,2*l,0,t.viewportCappedEndRow*this._dimensions.scaledCellHeight,h*this._dimensions.scaledCellWidth,this._dimensions.scaledCellHeight,this._selectionFloat)}else o.fill(this._vertices.selection,0,2*l)}else o.fill(this._vertices.selection,0,0)},t.prototype.updateBackgrounds=function(t){for(var e=this._terminal,i=this._vertices,r=1,o=0;o<e.rows;o++){for(var n=-1,a=0,c=0,h=!1,_=0;_<e.cols;_++){var u=(o*e.cols+_)*s.RENDER_MODEL_INDICIES_PER_CELL,d=t.cells[u+s.RENDER_MODEL_BG_OFFSET],f=t.cells[u+s.RENDER_MODEL_FG_OFFSET],p=!!(67108864&f);if(d!==a||f!==c&&(h||p)){if(0!==a||h&&0!==c){var g=r++*l;this._updateRectangle(i,g,c,a,n,_,o)}n=_,a=d,c=f,h=p}}if(0!==a||h&&0!==c){g=r++*l;this._updateRectangle(i,g,c,a,n,e.cols,o)}}i.count=r},t.prototype._updateRectangle=function(t,e,i,o,s,n,a){var c;if(67108864&i)switch(50331648&i){case 16777216:case 33554432:c=this._colors.ansi[255&i].rgba;break;case 50331648:c=(16777215&i)<<8;break;case 0:default:c=this._colors.foreground.rgba}else switch(50331648&o){case 16777216:case 33554432:c=this._colors.ansi[255&o].rgba;break;case 50331648:c=(16777215&o)<<8;break;case 0:default:c=this._colors.background.rgba}t.attributes.length<e+4&&(t.attributes=r.expandFloat32Array(t.attributes,this._terminal.rows*this._terminal.cols*l));var h=s*this._dimensions.scaledCellWidth,_=a*this._dimensions.scaledCellHeight,u=(c>>24&255)/255,d=(c>>16&255)/255,f=(c>>8&255)/255;this._addRectangle(t.attributes,e,h,_,(n-s)*this._dimensions.scaledCellWidth,this._dimensions.scaledCellHeight,u,d,f,1)},t.prototype._addRectangle=function(t,e,i,r,o,s,n,a,l,c){t[e]=i,t[e+1]=r,t[e+2]=o,t[e+3]=s,t[e+4]=n,t[e+5]=a,t[e+6]=l,t[e+7]=c},t.prototype._addRectangleFloat=function(t,e,i,r,o,s,n){t[e]=i,t[e+1]=r,t[e+2]=o,t[e+3]=s,t[e+4]=n[0],t[e+5]=n[1],t[e+6]=n[2],t[e+7]=n[3]},t.prototype._colorToFloat32Array=function(t){return new Float32Array([(t.rgba>>24&255)/255,(t.rgba>>16&255)/255,(t.rgba>>8&255)/255,(255&t.rgba)/255])},t}();e.RectangleRenderer=_},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=function(){function t(){this._disposables=[],this._isDisposed=!1}return t.prototype.dispose=function(){this._isDisposed=!0,this._disposables.forEach(function(t){return t.dispose()}),this._disposables.length=0},t.prototype.register=function(t){this._disposables.push(t)},t.prototype.unregister=function(t){var e=this._disposables.indexOf(t);-1!==e&&this._disposables.splice(e,1)},t}();e.Disposable=r},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=function(){function t(){this._listeners=[],this._disposed=!1}return Object.defineProperty(t.prototype,"event",{get:function(){var t=this;return this._event||(this._event=function(e){return t._listeners.push(e),{dispose:function(){if(!t._disposed)for(var i=0;i<t._listeners.length;i++)if(t._listeners[i]===e)return void t._listeners.splice(i,1)}}}),this._event},enumerable:!0,configurable:!0}),t.prototype.fire=function(t){for(var e=[],i=0;i<this._listeners.length;i++)e.push(this._listeners[i]);for(i=0;i<e.length;i++)e[i].call(void 0,t)},t.prototype.dispose=function(){this._listeners&&(this._listeners.length=0),this._disposed=!0},t}();e.EventEmitter=r}])});
//# sourceMappingURL=xterm-addon-webgl.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Constants_1 = require("common/buffer/Constants");
var NULL_COLOR = {

@@ -15,3 +14,5 @@ css: '',

selection: NULL_COLOR,
ansi: colors.ansi.slice()
selectionOpaque: NULL_COLOR,
ansi: colors.ansi.slice(),
contrastCache: colors.contrastCache
};

@@ -27,2 +28,4 @@ return {

allowTransparency: terminal.getOption('allowTransparency'),
drawBoldTextInBrightColors: terminal.getOption('drawBoldTextInBrightColors'),
minimumContrastRatio: terminal.getOption('minimumContrastRatio'),
colors: clonedColors

@@ -46,2 +49,4 @@ };

a.scaledCharHeight === b.scaledCharHeight &&
a.drawBoldTextInBrightColors === b.drawBoldTextInBrightColors &&
a.minimumContrastRatio === b.minimumContrastRatio &&
a.colors.foreground === b.colors.foreground &&

@@ -52,5 +57,5 @@ a.colors.background === b.colors.background;

function is256Color(colorCode) {
return colorCode < Constants_1.DEFAULT_COLOR;
return (colorCode & 50331648) === 16777216 || (colorCode & 50331648) === 33554432;
}
exports.is256Color = is256Color;
//# sourceMappingURL=CharAtlasUtils.js.map

@@ -5,4 +5,5 @@ "use strict";

var Constants_2 = require("common/buffer/Constants");
var CharAtlasUtils_1 = require("./CharAtlasUtils");
var WebglUtils_1 = require("../WebglUtils");
var AttributeData_1 = require("common/buffer/AttributeData");
var Color_1 = require("browser/Color");
var TEXTURE_WIDTH = 1024;

@@ -34,2 +35,3 @@ var TEXTURE_HEIGHT = 1024;

this._workBoundingBox = { top: 0, left: 0, bottom: 0, right: 0 };
this._workAttributeData = new AttributeData_1.AttributeData();
this.cacheCanvas = document.createElement('canvas');

@@ -57,7 +59,9 @@ this.cacheCanvas.width = TEXTURE_WIDTH;

WebglCharAtlas.prototype._doWarmUp = function () {
var _a;
var _a, _b;
for (var i = 33; i < 126; i++) {
var rasterizedGlyph = this._drawToCache(i, Constants_2.DEFAULT_ATTR, Constants_2.DEFAULT_COLOR, Constants_2.DEFAULT_COLOR);
var rasterizedGlyph = this._drawToCache(i, Constants_2.DEFAULT_COLOR, Constants_2.DEFAULT_COLOR);
this._cacheMap[i] = (_a = {},
_a[Constants_2.DEFAULT_ATTR] = rasterizedGlyph,
_a[Constants_2.DEFAULT_COLOR] = (_b = {},
_b[Constants_2.DEFAULT_COLOR] = rasterizedGlyph,
_b),
_a);

@@ -78,3 +82,3 @@ }

};
WebglCharAtlas.prototype.getRasterizedGlyphCombinedChar = function (chars, attr, bg, fg) {
WebglCharAtlas.prototype.getRasterizedGlyphCombinedChar = function (chars, bg, fg) {
var rasterizedGlyphSet = this._cacheMapCombined[chars];

@@ -85,10 +89,17 @@ if (!rasterizedGlyphSet) {

}
var rasterizedGlyph = rasterizedGlyphSet[attr];
var rasterizedGlyph;
var rasterizedGlyphSetBg = rasterizedGlyphSet[bg];
if (rasterizedGlyphSetBg) {
rasterizedGlyph = rasterizedGlyphSetBg[fg];
}
if (!rasterizedGlyph) {
rasterizedGlyph = this._drawToCache(chars, attr, bg, fg);
rasterizedGlyphSet[attr] = rasterizedGlyph;
rasterizedGlyph = this._drawToCache(chars, bg, fg);
if (!rasterizedGlyphSet[bg]) {
rasterizedGlyphSet[bg] = {};
}
rasterizedGlyphSet[bg][fg] = rasterizedGlyph;
}
return rasterizedGlyph;
};
WebglCharAtlas.prototype.getRasterizedGlyph = function (code, attr, bg, fg) {
WebglCharAtlas.prototype.getRasterizedGlyph = function (code, bg, fg) {
var rasterizedGlyphSet = this._cacheMap[code];

@@ -99,6 +110,13 @@ if (!rasterizedGlyphSet) {

}
var rasterizedGlyph = rasterizedGlyphSet[attr];
var rasterizedGlyph;
var rasterizedGlyphSetBg = rasterizedGlyphSet[bg];
if (rasterizedGlyphSetBg) {
rasterizedGlyph = rasterizedGlyphSetBg[fg];
}
if (!rasterizedGlyph) {
rasterizedGlyph = this._drawToCache(code, attr, bg, fg);
rasterizedGlyphSet[attr] = rasterizedGlyph;
rasterizedGlyph = this._drawToCache(code, bg, fg);
if (!rasterizedGlyphSet[bg]) {
rasterizedGlyphSet[bg] = {};
}
rasterizedGlyphSet[bg][fg] = rasterizedGlyph;
}

@@ -113,32 +131,122 @@ return rasterizedGlyph;

};
WebglCharAtlas.prototype._getBackgroundColor = function (bg) {
WebglCharAtlas.prototype._getBackgroundColor = function (bgColorMode, bgColor, inverse) {
if (this._config.allowTransparency) {
return TRANSPARENT_COLOR;
}
else if (bg === Constants_1.INVERTED_DEFAULT_COLOR) {
return this._config.colors.foreground;
switch (bgColorMode) {
case 16777216:
case 33554432:
return this._getColorFromAnsiIndex(bgColor);
case 50331648:
var arr = AttributeData_1.AttributeData.toColorRGB(bgColor);
return {
rgba: bgColor << 8,
css: "#" + toPaddedHex(arr[0]) + toPaddedHex(arr[1]) + toPaddedHex(arr[2])
};
case 0:
default:
if (inverse) {
return this._config.colors.foreground;
}
return this._config.colors.background;
}
else if (CharAtlasUtils_1.is256Color(bg)) {
return this._getColorFromAnsiIndex(bg);
};
WebglCharAtlas.prototype._getForegroundCss = function (bg, bgColorMode, bgColor, fg, fgColorMode, fgColor, inverse, bold) {
var minimumContrastCss = this._getMinimumContrastCss(bg, bgColorMode, bgColor, fg, fgColorMode, fgColor, inverse, bold);
if (minimumContrastCss) {
return minimumContrastCss;
}
return this._config.colors.background;
switch (fgColorMode) {
case 16777216:
case 33554432:
if (this._config.drawBoldTextInBrightColors && bold && fgColor < 8) {
fgColor += 8;
}
return this._getColorFromAnsiIndex(fgColor).css;
case 50331648:
var arr = AttributeData_1.AttributeData.toColorRGB(fgColor);
return Color_1.toCss(arr[0], arr[1], arr[2]);
case 0:
default:
if (inverse) {
return this._config.colors.background.css;
}
return this._config.colors.foreground.css;
}
};
WebglCharAtlas.prototype._getForegroundColor = function (fg) {
if (fg === Constants_1.INVERTED_DEFAULT_COLOR) {
return this._config.colors.background;
WebglCharAtlas.prototype._resolveBackgroundRgba = function (bgColorMode, bgColor, inverse) {
switch (bgColorMode) {
case 16777216:
case 33554432:
return this._getColorFromAnsiIndex(bgColor).rgba;
case 50331648:
return bgColor << 8;
case 0:
default:
if (inverse) {
return this._config.colors.foreground.rgba;
}
return this._config.colors.background.rgba;
}
else if (CharAtlasUtils_1.is256Color(fg)) {
return this._getColorFromAnsiIndex(fg);
};
WebglCharAtlas.prototype._resolveForegroundRgba = function (fgColorMode, fgColor, inverse, bold) {
switch (fgColorMode) {
case 16777216:
case 33554432:
if (this._config.drawBoldTextInBrightColors && bold && fgColor < 8) {
fgColor += 8;
}
return this._getColorFromAnsiIndex(fgColor).rgba;
case 50331648:
return fgColor << 8;
case 0:
default:
if (inverse) {
return this._config.colors.background.rgba;
}
return this._config.colors.foreground.rgba;
}
return this._config.colors.foreground;
};
WebglCharAtlas.prototype._drawToCache = function (codeOrChars, attr, bg, fg) {
WebglCharAtlas.prototype._getMinimumContrastCss = function (bg, bgColorMode, bgColor, fg, fgColorMode, fgColor, inverse, bold) {
if (this._config.minimumContrastRatio === 1) {
return undefined;
}
var adjustedColor = this._config.colors.contrastCache.getCss(bg, fg);
if (adjustedColor !== undefined) {
return adjustedColor || undefined;
}
var bgRgba = this._resolveBackgroundRgba(bgColorMode, bgColor, inverse);
var fgRgba = this._resolveForegroundRgba(fgColorMode, fgColor, inverse, bold);
var result = Color_1.ensureContrastRatioRgba(bgRgba, fgRgba, this._config.minimumContrastRatio);
if (!result) {
this._config.colors.contrastCache.setCss(bg, fg, null);
return undefined;
}
var css = Color_1.toCss((result >> 24) & 0xFF, (result >> 16) & 0xFF, (result >> 8) & 0xFF);
this._config.colors.contrastCache.setCss(bg, fg, css);
return css;
};
WebglCharAtlas.prototype._drawToCache = function (codeOrChars, bg, fg) {
var chars = typeof codeOrChars === 'number' ? String.fromCharCode(codeOrChars) : codeOrChars;
this.hasCanvasChanged = true;
var flags = attr >> 18;
var bold = !!(flags & 1);
var dim = !!(flags & 32);
var italic = !!(flags & 64);
this._tmpCtx.save();
var backgroundColor = this._getBackgroundColor(bg);
this._workAttributeData.fg = fg;
this._workAttributeData.bg = bg;
var bold = !!this._workAttributeData.isBold();
var inverse = !!this._workAttributeData.isInverse();
var dim = !!this._workAttributeData.isDim();
var italic = !!this._workAttributeData.isItalic();
var fgColor = this._workAttributeData.getFgColor();
var fgColorMode = this._workAttributeData.getFgColorMode();
var bgColor = this._workAttributeData.getBgColor();
var bgColorMode = this._workAttributeData.getBgColorMode();
if (inverse) {
var temp = fgColor;
fgColor = bgColor;
bgColor = temp;
var temp2 = fgColorMode;
fgColorMode = bgColorMode;
bgColorMode = temp2;
}
var backgroundColor = this._getBackgroundColor(bgColorMode, bgColor, inverse);
this._tmpCtx.globalCompositeOperation = 'copy';

@@ -153,3 +261,3 @@ this._tmpCtx.fillStyle = backgroundColor.css;

this._tmpCtx.textBaseline = 'top';
this._tmpCtx.fillStyle = this._getForegroundColor(fg).css;
this._tmpCtx.fillStyle = this._getForegroundCss(bg, bgColorMode, bgColor, fg, fgColorMode, fgColor, inverse, bold);
if (dim) {

@@ -295,2 +403,22 @@ this._tmpCtx.globalAlpha = Constants_1.DIM_OPACITY;

}
function toPaddedHex(c) {
var s = c.toString(16);
return s.length < 2 ? '0' + s : s;
}
function getFgColor(fg) {
switch (fg & 50331648) {
case 16777216:
case 33554432: return fg & 255;
case 50331648: return fg & 16777215;
default: return -1;
}
}
function getBgColor(bg) {
switch (bg & 50331648) {
case 16777216:
case 33554432: return bg & 255;
case 50331648: return bg & 16777215;
default: return -1;
}
}
//# sourceMappingURL=WebglCharAtlas.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var WebglUtils_1 = require("./WebglUtils");
var WebglRenderer_1 = require("./WebglRenderer");
var RenderModel_1 = require("./RenderModel");

@@ -9,3 +8,2 @@ var TypedArrayUtils_1 = require("common/TypedArrayUtils");

var Constants_1 = require("common/buffer/Constants");
var ColorUtils_1 = require("./ColorUtils");
var vertexShaderSource = "#version 300 es\nlayout (location = " + 0 + ") in vec2 a_unitquad;\nlayout (location = " + 1 + ") in vec2 a_cellpos;\nlayout (location = " + 2 + ") in vec2 a_offset;\nlayout (location = " + 3 + ") in vec2 a_size;\nlayout (location = " + 4 + ") in vec2 a_texcoord;\nlayout (location = " + 5 + ") in vec2 a_texsize;\n\nuniform mat4 u_projection;\nuniform vec2 u_resolution;\n\nout vec2 v_texcoord;\n\nvoid main() {\n vec2 zeroToOne = (a_offset / u_resolution) + a_cellpos + (a_unitquad * a_size);\n gl_Position = u_projection * vec4(zeroToOne, 0.0, 1.0);\n v_texcoord = a_texcoord + a_unitquad * a_texsize;\n}";

@@ -79,6 +77,6 @@ var fragmentShaderSource = "#version 300 es\nprecision lowp float;\n\nin vec2 v_texcoord;\n\nuniform sampler2D u_texture;\n\nout vec4 outColor;\n\nvoid main() {\n outColor = texture(u_texture, v_texcoord);\n}";

};
GlyphRenderer.prototype.updateCell = function (x, y, code, attr, bg, fg, chars) {
this._updateCell(this._vertices.attributes, x, y, code, attr, bg, fg, chars);
GlyphRenderer.prototype.updateCell = function (x, y, code, bg, fg, chars) {
this._updateCell(this._vertices.attributes, x, y, code, bg, fg, chars);
};
GlyphRenderer.prototype._updateCell = function (array, x, y, code, attr, bg, fg, chars) {
GlyphRenderer.prototype._updateCell = function (array, x, y, code, bg, fg, chars) {
var terminal = this._terminal;

@@ -95,6 +93,6 @@ var i = (y * terminal.cols + x) * INDICES_PER_CELL;

if (chars && chars.length > 1) {
rasterizedGlyph = this._atlas.getRasterizedGlyphCombinedChar(chars, attr, bg, fg);
rasterizedGlyph = this._atlas.getRasterizedGlyphCombinedChar(chars, bg, fg);
}
else {
rasterizedGlyph = this._atlas.getRasterizedGlyph(code, attr, bg, fg);
rasterizedGlyph = this._atlas.getRasterizedGlyph(code, bg, fg);
}

@@ -117,5 +115,3 @@ if (!rasterizedGlyph) {

this._vertices.selectionAttributes = TypedArray_1.slice(this._vertices.attributes, 0);
var lumi = ColorUtils_1.getLuminance(this._colors.background);
var fg = lumi > 0.5 ? 7 : 0;
var bg = lumi > 0.5 ? 0 : 7;
var bg = (this._colors.selectionOpaque.rgba >>> 8) | 50331648;
if (columnSelectMode) {

@@ -126,3 +122,3 @@ var startCol = model.selection.startCol;

for (var y = model.selection.viewportCappedStartRow; y < model.selection.viewportCappedStartRow + height; y++) {
this._updateSelectionRange(startCol, startCol + width, y, model, bg, fg);
this._updateSelectionRange(startCol, startCol + width, y, model, bg);
}

@@ -133,14 +129,14 @@ }

var startRowEndCol = model.selection.viewportCappedStartRow === model.selection.viewportCappedEndRow ? model.selection.endCol : terminal.cols;
this._updateSelectionRange(startCol, startRowEndCol, model.selection.viewportCappedStartRow, model, bg, fg);
this._updateSelectionRange(startCol, startRowEndCol, model.selection.viewportCappedStartRow, model, bg);
var middleRowsCount = Math.max(model.selection.viewportCappedEndRow - model.selection.viewportCappedStartRow - 1, 0);
for (var y = model.selection.viewportCappedStartRow + 1; y <= model.selection.viewportCappedStartRow + middleRowsCount; y++) {
this._updateSelectionRange(0, startRowEndCol, y, model, bg, fg);
this._updateSelectionRange(0, startRowEndCol, y, model, bg);
}
if (model.selection.viewportCappedStartRow !== model.selection.viewportCappedEndRow) {
var endCol = model.selection.viewportEndRow === model.selection.viewportCappedEndRow ? model.selection.endCol : terminal.cols;
this._updateSelectionRange(0, endCol, model.selection.viewportCappedEndRow, model, bg, fg);
this._updateSelectionRange(0, endCol, model.selection.viewportCappedEndRow, model, bg);
}
}
};
GlyphRenderer.prototype._updateSelectionRange = function (startCol, endCol, y, model, bg, fg) {
GlyphRenderer.prototype._updateSelectionRange = function (startCol, endCol, y, model, bg) {
var terminal = this._terminal;

@@ -150,5 +146,3 @@ var row = y + terminal.buffer.viewportY;

for (var x = startCol; x < endCol; x++) {
var offset = (y * this._terminal.cols + x) * WebglRenderer_1.INDICIES_PER_CELL;
var attr = model.cells[offset + 1];
attr = attr & ~0x3ffff | bg << 9 | fg;
var offset = (y * this._terminal.cols + x) * RenderModel_1.RENDER_MODEL_INDICIES_PER_CELL;
var code = model.cells[offset];

@@ -160,6 +154,6 @@ if (code & RenderModel_1.COMBINED_CHAR_BIT_MASK) {

var chars = line.getCell(x).char;
this._updateCell(this._vertices.selectionAttributes, x, y, model.cells[offset], attr, bg, fg, chars);
this._updateCell(this._vertices.selectionAttributes, x, y, model.cells[offset], bg, model.cells[offset + RenderModel_1.RENDER_MODEL_FG_OFFSET], chars);
}
else {
this._updateCell(this._vertices.selectionAttributes, x, y, model.cells[offset], attr, bg, fg);
this._updateCell(this._vertices.selectionAttributes, x, y, model.cells[offset], bg, model.cells[offset + RenderModel_1.RENDER_MODEL_FG_OFFSET]);
}

@@ -166,0 +160,0 @@ }

@@ -5,5 +5,3 @@ "use strict";

var TypedArrayUtils_1 = require("common/TypedArrayUtils");
var Constants_1 = require("browser/renderer/atlas/Constants");
var CharAtlasUtils_1 = require("./atlas/CharAtlasUtils");
var Constants_2 = require("common/buffer/Constants");
var RenderModel_1 = require("./RenderModel");
var vertexShaderSource = "#version 300 es\nlayout (location = " + 0 + ") in vec2 a_position;\nlayout (location = " + 1 + ") in vec2 a_size;\nlayout (location = " + 2 + ") in vec3 a_color;\nlayout (location = " + 3 + ") in vec2 a_unitquad;\n\nuniform mat4 u_projection;\nuniform vec2 u_resolution;\n\nout vec3 v_color;\n\nvoid main() {\n vec2 zeroToOne = (a_position + (a_unitquad * a_size)) / u_resolution;\n gl_Position = u_projection * vec4(zeroToOne, 0.0, 1.0);\n v_color = a_color;\n}";

@@ -76,3 +74,3 @@ var fragmentShaderSource = "#version 300 es\nprecision lowp float;\n\nin vec3 v_color;\n\nout vec4 outColor;\n\nvoid main() {\n outColor = vec4(v_color, 1);\n}";

this._bgFloat = this._colorToFloat32Array(this._colors.background);
this._selectionFloat = this._colorToFloat32Array(this._colors.selection);
this._selectionFloat = this._colorToFloat32Array(this._colors.selectionOpaque);
};

@@ -116,18 +114,24 @@ RectangleRenderer.prototype._updateViewportRectangle = function () {

var currentStartX = -1;
var currentBg = Constants_2.DEFAULT_COLOR;
var currentBg = 0;
var currentFg = 0;
var currentInverse = false;
for (var x = 0; x < terminal.cols; x++) {
var modelIndex = ((y * terminal.cols) + x) * 4;
var bg = model.cells[modelIndex + 2];
if (bg !== currentBg) {
if (currentBg !== Constants_2.DEFAULT_COLOR) {
var modelIndex = ((y * terminal.cols) + x) * RenderModel_1.RENDER_MODEL_INDICIES_PER_CELL;
var bg = model.cells[modelIndex + RenderModel_1.RENDER_MODEL_BG_OFFSET];
var fg = model.cells[modelIndex + RenderModel_1.RENDER_MODEL_FG_OFFSET];
var inverse = !!(fg & 67108864);
if (bg !== currentBg || (fg !== currentFg && (currentInverse || inverse))) {
if (currentBg !== 0 || (currentInverse && currentFg !== 0)) {
var offset = rectangleCount++ * INDICES_PER_RECTANGLE;
this._updateRectangle(vertices, offset, currentBg, currentStartX, x, y);
this._updateRectangle(vertices, offset, currentFg, currentBg, currentStartX, x, y);
}
currentStartX = x;
currentBg = bg;
currentFg = fg;
currentInverse = inverse;
}
}
if (currentBg !== Constants_2.DEFAULT_COLOR) {
if (currentBg !== 0 || (currentInverse && currentFg !== 0)) {
var offset = rectangleCount++ * INDICES_PER_RECTANGLE;
this._updateRectangle(vertices, offset, currentBg, currentStartX, terminal.cols, y);
this._updateRectangle(vertices, offset, currentFg, currentBg, currentStartX, terminal.cols, y);
}

@@ -137,12 +141,31 @@ }

};
RectangleRenderer.prototype._updateRectangle = function (vertices, offset, bg, startX, endX, y) {
var color = null;
if (bg === Constants_1.INVERTED_DEFAULT_COLOR) {
color = this._colors.foreground;
RectangleRenderer.prototype._updateRectangle = function (vertices, offset, fg, bg, startX, endX, y) {
var rgba;
if (fg & 67108864) {
switch (fg & 50331648) {
case 16777216:
case 33554432:
rgba = this._colors.ansi[fg & 255].rgba;
break;
case 50331648:
rgba = (fg & 16777215) << 8;
break;
case 0:
default:
rgba = this._colors.foreground.rgba;
}
}
else if (CharAtlasUtils_1.is256Color(bg)) {
color = this._colors.ansi[bg];
}
else {
color = this._colors.foreground;
switch (bg & 50331648) {
case 16777216:
case 33554432:
rgba = this._colors.ansi[bg & 255].rgba;
break;
case 50331648:
rgba = (bg & 16777215) << 8;
break;
case 0:
default:
rgba = this._colors.background.rgba;
}
}

@@ -154,5 +177,5 @@ if (vertices.attributes.length < offset + 4) {

var y1 = y * this._dimensions.scaledCellHeight;
var r = ((color.rgba >> 24) & 0xFF) / 255;
var g = ((color.rgba >> 16) & 0xFF) / 255;
var b = ((color.rgba >> 8) & 0xFF) / 255;
var r = ((rgba >> 24) & 0xFF) / 255;
var g = ((rgba >> 16) & 0xFF) / 255;
var b = ((rgba >> 8) & 0xFF) / 255;
this._addRectangle(vertices.attributes, offset, x1, y1, (endX - startX) * this._dimensions.scaledCellWidth, this._dimensions.scaledCellHeight, r, g, b, 1);

@@ -159,0 +182,0 @@ };

@@ -16,11 +16,2 @@ "use strict";

this._scaledCharTop = 0;
this._currentGlyphIdentifier = {
chars: '',
code: 0,
bg: 0,
fg: 0,
bold: false,
dim: false,
italic: false
};
this._canvas = document.createElement('canvas');

@@ -27,0 +18,0 @@ this._canvas.classList.add("xterm-" + id + "-layer");

@@ -21,4 +21,5 @@ "use strict";

__extends(CursorRenderLayer, _super);
function CursorRenderLayer(container, zIndex, colors) {
function CursorRenderLayer(container, zIndex, colors, _onRequestRefreshRowsEvent) {
var _this = _super.call(this, container, 'cursor', zIndex, true, colors) || this;
_this._onRequestRefreshRowsEvent = _onRequestRefreshRowsEvent;
_this._cell = new CellData_1.CellData();

@@ -60,3 +61,3 @@ _this._state = {

}
terminal.refresh(terminal.buffer.cursorY, terminal.buffer.cursorY);
this._onRequestRefreshRowsEvent.fire({ start: terminal.buffer.cursorY, end: terminal.buffer.cursorY });
};

@@ -68,3 +69,3 @@ CursorRenderLayer.prototype.onFocus = function (terminal) {

else {
terminal.refresh(terminal.buffer.cursorY, terminal.buffer.cursorY);
this._onRequestRefreshRowsEvent.fire({ start: terminal.buffer.cursorY, end: terminal.buffer.cursorY });
}

@@ -74,2 +75,3 @@ };

var _this = this;
var _a;
if (terminal.getOption('cursorBlink')) {

@@ -83,7 +85,6 @@ if (!this._cursorBlinkStateManager) {

else {
if (this._cursorBlinkStateManager) {
this._cursorBlinkStateManager.dispose();
}
(_a = this._cursorBlinkStateManager) === null || _a === void 0 ? void 0 : _a.dispose();
this._cursorBlinkStateManager = undefined;
}
terminal.refresh(terminal.buffer.cursorY, terminal.buffer.cursorY);
this._onRequestRefreshRowsEvent.fire({ start: terminal.buffer.cursorY, end: terminal.buffer.cursorY });
};

@@ -104,3 +105,3 @@ CursorRenderLayer.prototype.onCursorMove = function (terminal) {

CursorRenderLayer.prototype._render = function (terminal, triggeredByAnimationFrame) {
if (!terminal._core.cursorState || terminal._core.cursorHidden) {
if (!terminal._core._coreService.isCursorInitialized || terminal._core._coreService.isCursorHidden) {
this._clearCursor();

@@ -107,0 +108,0 @@ return;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var TypedArrayUtils_1 = require("common/TypedArrayUtils");
exports.RENDER_MODEL_INDICIES_PER_CELL = 4;
exports.RENDER_MODEL_INDICIES_PER_CELL = 3;
exports.RENDER_MODEL_BG_OFFSET = 1;
exports.RENDER_MODEL_FG_OFFSET = 2;
exports.COMBINED_CHAR_BIT_MASK = 0x80000000;

@@ -6,0 +8,0 @@ var RenderModel = (function () {

@@ -10,4 +10,5 @@ "use strict";

if (!terminal.element) {
throw new Error('Cannot activate WebglRendererAddon before Terminal.open');
throw new Error('Cannot activate WebglAddon before Terminal.open');
}
this._terminal = terminal;
var renderService = terminal._core._renderService;

@@ -18,3 +19,8 @@ var colors = terminal._core._colorManager.colors;

WebglAddon.prototype.dispose = function () {
throw new Error('WebglRendererAddon.dispose Not yet implemented');
if (!this._terminal) {
throw new Error('Cannot dispose WebglAddon because it is activated');
}
var renderService = this._terminal._core._renderService;
renderService.setRenderer(this._terminal._core._createRenderer());
renderService.onResize(this._terminal.cols, this._terminal.rows);
};

@@ -21,0 +27,0 @@ return WebglAddon;

@@ -21,9 +21,7 @@ "use strict";

var RectangleRenderer_1 = require("./RectangleRenderer");
var Constants_1 = require("browser/renderer/atlas/Constants");
var RenderModel_1 = require("./RenderModel");
var Lifecycle_1 = require("common/Lifecycle");
var Constants_2 = require("common/buffer/Constants");
var ColorUtils_1 = require("./ColorUtils");
var CharDataCompat_1 = require("./CharDataCompat");
exports.INDICIES_PER_CELL = 4;
var Constants_1 = require("common/buffer/Constants");
var EventEmitter_1 = require("common/EventEmitter");
var CellData_1 = require("common/buffer/CellData");
var WebglRenderer = (function (_super) {

@@ -36,7 +34,8 @@ __extends(WebglRenderer, _super);

_this._model = new RenderModel_1.RenderModel();
_this._workCell = new CellData_1.CellData();
_this._onRequestRefreshRows = new EventEmitter_1.EventEmitter();
_this._core = _this._terminal._core;
_this._applyBgLuminanceBasedSelection();
_this._renderLayers = [
new LinkRenderLayer_1.LinkRenderLayer(_this._core.screenElement, 2, _this._colors, _this._core),
new CursorRenderLayer_1.CursorRenderLayer(_this._core.screenElement, 3, _this._colors)
new CursorRenderLayer_1.CursorRenderLayer(_this._core.screenElement, 3, _this._colors, _this._onRequestRefreshRows)
];

@@ -73,4 +72,10 @@ _this.dimensions = {

_this.onCharSizeChanged();
_this._isAttached = document.body.contains(_this._core.screenElement);
return _this;
}
Object.defineProperty(WebglRenderer.prototype, "onRequestRefreshRows", {
get: function () { return this._onRequestRefreshRows.event; },
enumerable: true,
configurable: true
});
WebglRenderer.prototype.dispose = function () {

@@ -81,14 +86,5 @@ this._renderLayers.forEach(function (l) { return l.dispose(); });

};
WebglRenderer.prototype._applyBgLuminanceBasedSelection = function () {
if (ColorUtils_1.getLuminance(this._colors.background) > 0.5) {
this._colors.selection = { css: '#000', rgba: 255 };
}
else {
this._colors.selection = { css: '#fff', rgba: 4294967295 };
}
};
WebglRenderer.prototype.setColors = function (colors) {
var _this = this;
this._colors = colors;
this._applyBgLuminanceBasedSelection();
this._renderLayers.forEach(function (l) {

@@ -143,3 +139,3 @@ l.setColors(_this._terminal, _this._colors);

this._glyphRenderer.updateSelection(this._model, columnSelectMode);
this._core.refresh(0, this._terminal.rows - 1);
this._onRequestRefreshRows.fire({ start: 0, end: this._terminal.rows - 1 });
};

@@ -158,2 +154,3 @@ WebglRenderer.prototype.onCursorMove = function () {

if (this.dimensions.scaledCharWidth <= 0 && this.dimensions.scaledCharHeight <= 0) {
this._isAttached = false;
return;

@@ -181,2 +178,12 @@ }

var _this = this;
if (!this._isAttached) {
if (document.body.contains(this._core.screenElement) && this._core._charSizeService.width && this._core._charSizeService.height) {
this._updateDimensions();
this._refreshCharAtlas();
this._isAttached = true;
}
else {
return;
}
}
this._renderLayers.forEach(function (l) { return l.onGridChanged(_this._terminal, start, end); });

@@ -197,29 +204,14 @@ if (this._glyphRenderer.beginFrame()) {

for (var x = 0; x < terminal.cols; x++) {
var charData = line.get(x);
var chars = charData[Constants_2.CHAR_DATA_CHAR_INDEX];
var code = charData[Constants_2.CHAR_DATA_CODE_INDEX];
var attr = CharDataCompat_1.getCompatAttr(line, x);
var i = ((y * terminal.cols) + x) * exports.INDICIES_PER_CELL;
if (code !== Constants_2.NULL_CELL_CODE) {
line.loadCell(x, this._workCell);
var chars = this._workCell.getChars();
var code = this._workCell.getCode();
var i = ((y * terminal.cols) + x) * RenderModel_1.RENDER_MODEL_INDICIES_PER_CELL;
if (code !== Constants_1.NULL_CELL_CODE) {
this._model.lineLengths[y] = x + 1;
}
if (this._model.cells[i] === code && this._model.cells[i + 1] === attr) {
if (this._model.cells[i] === code &&
this._model.cells[i + RenderModel_1.RENDER_MODEL_BG_OFFSET] === this._workCell.bg &&
this._model.cells[i + RenderModel_1.RENDER_MODEL_FG_OFFSET] === this._workCell.fg) {
continue;
}
var flags = attr >> 18;
var bg = attr & 0x1ff;
var fg = (attr >> 9) & 0x1ff;
if (flags & 8) {
var temp = bg;
bg = fg;
fg = temp;
if (fg === Constants_2.DEFAULT_COLOR) {
fg = Constants_1.INVERTED_DEFAULT_COLOR;
}
if (bg === Constants_2.DEFAULT_COLOR) {
bg = Constants_1.INVERTED_DEFAULT_COLOR;
}
}
var drawInBrightColor = terminal.options.drawBoldTextInBrightColors && !!(flags & 1) && fg < 8 && fg !== Constants_1.INVERTED_DEFAULT_COLOR;
fg += drawInBrightColor ? 8 : 0;
if (chars.length > 1) {

@@ -229,6 +221,5 @@ code = code | RenderModel_1.COMBINED_CHAR_BIT_MASK;

this._model.cells[i] = code;
this._model.cells[i + 1] = attr;
this._model.cells[i + 2] = bg;
this._model.cells[i + 3] = fg;
this._glyphRenderer.updateCell(x, y, code, attr, bg, fg, chars);
this._model.cells[i + RenderModel_1.RENDER_MODEL_BG_OFFSET] = this._workCell.bg;
this._model.cells[i + RenderModel_1.RENDER_MODEL_FG_OFFSET] = this._workCell.fg;
this._glyphRenderer.updateCell(x, y, code, this._workCell.bg, this._workCell.fg, chars);
}

@@ -235,0 +226,0 @@ }

{
"name": "xterm-addon-webgl",
"version": "0.3.0",
"version": "0.4.0-beta.10",
"author": {

@@ -5,0 +5,0 @@ "name": "The xterm.js authors",

@@ -7,3 +7,3 @@ /**

import { ICharAtlasConfig } from './Types';
import { DEFAULT_COLOR } from 'common/buffer/Constants';
import { Attributes } from 'common/buffer/Constants';
import { Terminal, FontWeight } from 'xterm';

@@ -25,5 +25,7 @@ import { IColorSet, IColor } from 'browser/Types';

selection: NULL_COLOR,
selectionOpaque: NULL_COLOR,
// For the static char atlas, we only use the first 16 colors, but we need all 256 for the
// dynamic character atlas.
ansi: colors.ansi.slice()
ansi: colors.ansi.slice(),
contrastCache: colors.contrastCache
};

@@ -39,2 +41,4 @@ return {

allowTransparency: terminal.getOption('allowTransparency'),
drawBoldTextInBrightColors: terminal.getOption('drawBoldTextInBrightColors'),
minimumContrastRatio: terminal.getOption('minimumContrastRatio'),
colors: clonedColors

@@ -58,2 +62,4 @@ };

a.scaledCharHeight === b.scaledCharHeight &&
a.drawBoldTextInBrightColors === b.drawBoldTextInBrightColors &&
a.minimumContrastRatio === b.minimumContrastRatio &&
a.colors.foreground === b.colors.foreground &&

@@ -64,3 +70,3 @@ a.colors.background === b.colors.background;

export function is256Color(colorCode: number): boolean {
return colorCode < DEFAULT_COLOR;
return (colorCode & Attributes.CM_MASK) === Attributes.CM_P16 || (colorCode & Attributes.CM_MASK) === Attributes.CM_P256;
}

@@ -28,3 +28,5 @@ /**

allowTransparency: boolean;
drawBoldTextInBrightColors: boolean;
minimumContrastRatio: number;
colors: IColorSet;
}

@@ -7,10 +7,10 @@ /**

import { ICharAtlasConfig } from './Types';
import { DIM_OPACITY, INVERTED_DEFAULT_COLOR } from 'browser/renderer/atlas/Constants';
import { DIM_OPACITY } from 'browser/renderer/atlas/Constants';
import { IRasterizedGlyph, IBoundingBox, IRasterizedGlyphSet } from '../Types';
import { DEFAULT_COLOR, DEFAULT_ATTR } from 'common/buffer/Constants';
import { is256Color } from './CharAtlasUtils';
import { DEFAULT_COLOR, FgFlags, Attributes, BgFlags } from 'common/buffer/Constants';
import { throwIfFalsy } from '../WebglUtils';
import { IColor } from 'browser/Types';
import { FLAGS } from '../Constants';
import { IDisposable } from 'xterm';
import { AttributeData } from 'common/buffer/AttributeData';
import { toCss, ensureContrastRatioRgba } from 'browser/Color';

@@ -72,4 +72,8 @@ // In practice we're probably never going to exhaust a texture this large. For debugging purposes,

private _workBoundingBox: IBoundingBox = { top: 0, left: 0, bottom: 0, right: 0 };
private _workAttributeData: AttributeData = new AttributeData();
constructor(document: Document, private _config: ICharAtlasConfig) {
constructor(
document: Document,
private _config: ICharAtlasConfig
) {
this.cacheCanvas = document.createElement('canvas');

@@ -108,5 +112,7 @@ this.cacheCanvas.width = TEXTURE_WIDTH;

for (let i = 33; i < 126; i++) {
const rasterizedGlyph = this._drawToCache(i, DEFAULT_ATTR, DEFAULT_COLOR, DEFAULT_COLOR);
const rasterizedGlyph = this._drawToCache(i, DEFAULT_COLOR, DEFAULT_COLOR);
this._cacheMap[i] = {
[DEFAULT_ATTR]: rasterizedGlyph
[DEFAULT_COLOR]: {
[DEFAULT_COLOR]: rasterizedGlyph
}
};

@@ -129,3 +135,3 @@ }

public getRasterizedGlyphCombinedChar(chars: string, attr: number, bg: number, fg: number): IRasterizedGlyph {
public getRasterizedGlyphCombinedChar(chars: string, bg: number, fg: number): IRasterizedGlyph {
let rasterizedGlyphSet = this._cacheMapCombined[chars];

@@ -136,6 +142,13 @@ if (!rasterizedGlyphSet) {

}
let rasterizedGlyph = rasterizedGlyphSet[attr];
let rasterizedGlyph: IRasterizedGlyph | undefined;
const rasterizedGlyphSetBg = rasterizedGlyphSet[bg];
if (rasterizedGlyphSetBg) {
rasterizedGlyph = rasterizedGlyphSetBg[fg];
}
if (!rasterizedGlyph) {
rasterizedGlyph = this._drawToCache(chars, attr, bg, fg);
rasterizedGlyphSet[attr] = rasterizedGlyph;
rasterizedGlyph = this._drawToCache(chars, bg, fg);
if (!rasterizedGlyphSet[bg]) {
rasterizedGlyphSet[bg] = {};
}
rasterizedGlyphSet[bg]![fg] = rasterizedGlyph;
}

@@ -148,3 +161,3 @@ return rasterizedGlyph;

*/
public getRasterizedGlyph(code: number, attr: number, bg: number, fg: number): IRasterizedGlyph {
public getRasterizedGlyph(code: number, bg: number, fg: number): IRasterizedGlyph {
let rasterizedGlyphSet = this._cacheMap[code];

@@ -155,6 +168,13 @@ if (!rasterizedGlyphSet) {

}
let rasterizedGlyph = rasterizedGlyphSet[attr];
let rasterizedGlyph: IRasterizedGlyph | undefined;
const rasterizedGlyphSetBg = rasterizedGlyphSet[bg];
if (rasterizedGlyphSetBg) {
rasterizedGlyph = rasterizedGlyphSetBg[fg];
}
if (!rasterizedGlyph) {
rasterizedGlyph = this._drawToCache(code, attr, bg, fg);
rasterizedGlyphSet[attr] = rasterizedGlyph;
rasterizedGlyph = this._drawToCache(code, bg, fg);
if (!rasterizedGlyphSet[bg]) {
rasterizedGlyphSet[bg] = {};
}
rasterizedGlyphSet[bg]![fg] = rasterizedGlyph;
}

@@ -171,3 +191,3 @@ return rasterizedGlyph;

private _getBackgroundColor(bg: number): IColor {
private _getBackgroundColor(bgColorMode: number, bgColor: number, inverse: boolean): IColor {
if (this._config.allowTransparency) {

@@ -178,24 +198,117 @@ // The background color might have some transparency, so we need to render it as fully

return TRANSPARENT_COLOR;
} else if (bg === INVERTED_DEFAULT_COLOR) {
return this._config.colors.foreground;
} else if (is256Color(bg)) {
return this._getColorFromAnsiIndex(bg);
}
// TODO: Support true color
return this._config.colors.background;
switch (bgColorMode) {
case Attributes.CM_P16:
case Attributes.CM_P256:
return this._getColorFromAnsiIndex(bgColor);
case Attributes.CM_RGB:
const arr = AttributeData.toColorRGB(bgColor);
// TODO: This object creation is slow
return {
rgba: bgColor << 8,
css: `#${toPaddedHex(arr[0])}${toPaddedHex(arr[1])}${toPaddedHex(arr[2])}`
};
case Attributes.CM_DEFAULT:
default:
if (inverse) {
return this._config.colors.foreground;
}
return this._config.colors.background;
}
}
private _getForegroundColor(fg: number): IColor {
if (fg === INVERTED_DEFAULT_COLOR) {
return this._config.colors.background;
} else if (is256Color(fg)) {
return this._getColorFromAnsiIndex(fg);
private _getForegroundCss(bg: number, bgColorMode: number, bgColor: number, fg: number, fgColorMode: number, fgColor: number, inverse: boolean, bold: boolean): string {
const minimumContrastCss = this._getMinimumContrastCss(bg, bgColorMode, bgColor, fg, fgColorMode, fgColor, inverse, bold);
if (minimumContrastCss) {
return minimumContrastCss;
}
// TODO: Support true color
return this._config.colors.foreground;
switch (fgColorMode) {
case Attributes.CM_P16:
case Attributes.CM_P256:
if (this._config.drawBoldTextInBrightColors && bold && fgColor < 8) {
fgColor += 8;
}
return this._getColorFromAnsiIndex(fgColor).css;
case Attributes.CM_RGB:
const arr = AttributeData.toColorRGB(fgColor);
return toCss(arr[0], arr[1], arr[2]);
case Attributes.CM_DEFAULT:
default:
if (inverse) {
return this._config.colors.background.css;
}
return this._config.colors.foreground.css;
}
}
private _drawToCache(code: number, attr: number, bg: number, fg: number): IRasterizedGlyph;
private _drawToCache(chars: string, attr: number, bg: number, fg: number): IRasterizedGlyph;
private _drawToCache(codeOrChars: number | string, attr: number, bg: number, fg: number): IRasterizedGlyph {
private _resolveBackgroundRgba(bgColorMode: number, bgColor: number, inverse: boolean): number {
switch (bgColorMode) {
case Attributes.CM_P16:
case Attributes.CM_P256:
return this._getColorFromAnsiIndex(bgColor).rgba;
case Attributes.CM_RGB:
return bgColor << 8;
case Attributes.CM_DEFAULT:
default:
if (inverse) {
return this._config.colors.foreground.rgba;
}
return this._config.colors.background.rgba;
}
}
private _resolveForegroundRgba(fgColorMode: number, fgColor: number, inverse: boolean, bold: boolean): number {
switch (fgColorMode) {
case Attributes.CM_P16:
case Attributes.CM_P256:
if (this._config.drawBoldTextInBrightColors && bold && fgColor < 8) {
fgColor += 8;
}
return this._getColorFromAnsiIndex(fgColor).rgba;
case Attributes.CM_RGB:
return fgColor << 8;
case Attributes.CM_DEFAULT:
default:
if (inverse) {
return this._config.colors.background.rgba;
}
return this._config.colors.foreground.rgba;
}
}
private _getMinimumContrastCss(bg: number, bgColorMode: number, bgColor: number, fg: number, fgColorMode: number, fgColor: number, inverse: boolean, bold: boolean): string | undefined {
if (this._config.minimumContrastRatio === 1) {
return undefined;
}
// Try get from cache first
const adjustedColor = this._config.colors.contrastCache.getCss(bg, fg);
if (adjustedColor !== undefined) {
return adjustedColor || undefined;
}
const bgRgba = this._resolveBackgroundRgba(bgColorMode, bgColor, inverse);
const fgRgba = this._resolveForegroundRgba(fgColorMode, fgColor, inverse, bold);
const result = ensureContrastRatioRgba(bgRgba, fgRgba, this._config.minimumContrastRatio);
if (!result) {
this._config.colors.contrastCache.setCss(bg, fg, null);
return undefined;
}
const css = toCss(
(result >> 24) & 0xFF,
(result >> 16) & 0xFF,
(result >> 8) & 0xFF
);
this._config.colors.contrastCache.setCss(bg, fg, css);
return css;
}
private _drawToCache(code: number, bg: number, fg: number): IRasterizedGlyph;
private _drawToCache(chars: string, bg: number, fg: number): IRasterizedGlyph;
private _drawToCache(codeOrChars: number | string, bg: number, fg: number): IRasterizedGlyph {
const chars = typeof codeOrChars === 'number' ? String.fromCharCode(codeOrChars) : codeOrChars;

@@ -205,12 +318,26 @@

const flags = attr >> 18;
this._tmpCtx.save();
const bold = !!(flags & FLAGS.BOLD);
const dim = !!(flags & FLAGS.DIM);
const italic = !!(flags & FLAGS.ITALIC);
this._workAttributeData.fg = fg;
this._workAttributeData.bg = bg;
this._tmpCtx.save();
const bold = !!this._workAttributeData.isBold();
const inverse = !!this._workAttributeData.isInverse();
const dim = !!this._workAttributeData.isDim();
const italic = !!this._workAttributeData.isItalic();
let fgColor = this._workAttributeData.getFgColor();
let fgColorMode = this._workAttributeData.getFgColorMode();
let bgColor = this._workAttributeData.getBgColor();
let bgColorMode = this._workAttributeData.getBgColorMode();
if (inverse) {
const temp = fgColor;
fgColor = bgColor;
bgColor = temp;
const temp2 = fgColorMode;
fgColorMode = bgColorMode;
bgColorMode = temp2;
}
// draw the background
const backgroundColor = this._getBackgroundColor(bg);
const backgroundColor = this._getBackgroundColor(bgColorMode, bgColor, inverse);
// Use a 'copy' composite operation to clear any existing glyph out of _tmpCtxWithAlpha, regardless of

@@ -230,3 +357,3 @@ // transparency in backgroundColor

this._tmpCtx.fillStyle = this._getForegroundColor(fg).css;
this._tmpCtx.fillStyle = this._getForegroundCss(bg, bgColorMode, bgColor, fg, fgColorMode, fgColor, inverse, bold);

@@ -412,1 +539,23 @@ // Apply alpha to dim the character

}
function toPaddedHex(c: number): string {
const s = c.toString(16);
return s.length < 2 ? '0' + s : s;
}
function getFgColor(fg: number): number {
switch (fg & Attributes.CM_MASK) {
case Attributes.CM_P16:
case Attributes.CM_P256: return fg & Attributes.PCOLOR_MASK;
case Attributes.CM_RGB: return fg & Attributes.RGB_MASK;
default: return -1; // CM_DEFAULT defaults to -1
}
}
function getBgColor(bg: number): number {
switch (bg & Attributes.CM_MASK) {
case Attributes.CM_P16:
case Attributes.CM_P256: return bg & Attributes.PCOLOR_MASK;
case Attributes.CM_RGB: return bg & Attributes.RGB_MASK;
default: return -1; // CM_DEFAULT defaults to -1
}
}

@@ -9,8 +9,6 @@ /**

import { IWebGL2RenderingContext, IWebGLVertexArrayObject, IRenderModel, IRasterizedGlyph } from './Types';
import { INDICIES_PER_CELL } from './WebglRenderer';
import { COMBINED_CHAR_BIT_MASK } from './RenderModel';
import { COMBINED_CHAR_BIT_MASK, RENDER_MODEL_INDICIES_PER_CELL, RENDER_MODEL_FG_OFFSET } from './RenderModel';
import { fill } from 'common/TypedArrayUtils';
import { slice } from './TypedArray';
import { NULL_CELL_CODE, WHITESPACE_CELL_CODE } from 'common/buffer/Constants';
import { getLuminance } from './ColorUtils';
import { NULL_CELL_CODE, WHITESPACE_CELL_CODE, Attributes } from 'common/buffer/Constants';
import { Terminal, IBufferLine } from 'xterm';

@@ -173,7 +171,7 @@ import { IColorSet } from 'browser/Types';

public updateCell(x: number, y: number, code: number, attr: number, bg: number, fg: number, chars: string): void {
this._updateCell(this._vertices.attributes, x, y, code, attr, bg, fg, chars);
public updateCell(x: number, y: number, code: number, bg: number, fg: number, chars: string): void {
this._updateCell(this._vertices.attributes, x, y, code, bg, fg, chars);
}
private _updateCell(array: Float32Array, x: number, y: number, code: number | undefined, attr: number, bg: number, fg: number, chars?: string): void {
private _updateCell(array: Float32Array, x: number, y: number, code: number | undefined, bg: number, fg: number, chars?: string): void {
const terminal = this._terminal;

@@ -194,5 +192,5 @@

if (chars && chars.length > 1) {
rasterizedGlyph = this._atlas.getRasterizedGlyphCombinedChar(chars, attr, bg, fg);
rasterizedGlyph = this._atlas.getRasterizedGlyphCombinedChar(chars, bg, fg);
} else {
rasterizedGlyph = this._atlas.getRasterizedGlyph(code, attr, bg, fg);
rasterizedGlyph = this._atlas.getRasterizedGlyph(code, bg, fg);
}

@@ -226,7 +224,3 @@

// TODO: Make fg and bg configurable, currently since the buffer doesn't
// support truecolor the char atlas cannot store it.
const lumi = getLuminance(this._colors.background);
const fg = lumi > 0.5 ? 7 : 0;
const bg = lumi > 0.5 ? 0 : 7;
const bg = (this._colors.selectionOpaque.rgba >>> 8) | Attributes.CM_RGB;

@@ -238,3 +232,3 @@ if (columnSelectMode) {

for (let y = model.selection.viewportCappedStartRow; y < model.selection.viewportCappedStartRow + height; y++) {
this._updateSelectionRange(startCol, startCol + width, y, model, bg, fg);
this._updateSelectionRange(startCol, startCol + width, y, model, bg);
}

@@ -245,3 +239,3 @@ } else {

const startRowEndCol = model.selection.viewportCappedStartRow === model.selection.viewportCappedEndRow ? model.selection.endCol : terminal.cols;
this._updateSelectionRange(startCol, startRowEndCol, model.selection.viewportCappedStartRow, model, bg, fg);
this._updateSelectionRange(startCol, startRowEndCol, model.selection.viewportCappedStartRow, model, bg);

@@ -251,3 +245,3 @@ // Draw middle rows

for (let y = model.selection.viewportCappedStartRow + 1; y <= model.selection.viewportCappedStartRow + middleRowsCount; y++) {
this._updateSelectionRange(0, startRowEndCol, y, model, bg, fg);
this._updateSelectionRange(0, startRowEndCol, y, model, bg);
}

@@ -259,3 +253,3 @@

const endCol = model.selection.viewportEndRow === model.selection.viewportCappedEndRow ? model.selection.endCol : terminal.cols;
this._updateSelectionRange(0, endCol, model.selection.viewportCappedEndRow, model, bg, fg);
this._updateSelectionRange(0, endCol, model.selection.viewportCappedEndRow, model, bg);
}

@@ -265,3 +259,3 @@ }

private _updateSelectionRange(startCol: number, endCol: number, y: number, model: IRenderModel, bg: number, fg: number): void {
private _updateSelectionRange(startCol: number, endCol: number, y: number, model: IRenderModel, bg: number): void {
const terminal = this._terminal;

@@ -271,6 +265,3 @@ const row = y + terminal.buffer.viewportY;

for (let x = startCol; x < endCol; x++) {
const offset = (y * this._terminal.cols + x) * INDICIES_PER_CELL;
// Because the cache uses attr as a lookup key it needs to contain the selection colors as well
let attr = model.cells[offset + 1];
attr = attr & ~0x3ffff | bg << 9 | fg;
const offset = (y * this._terminal.cols + x) * RENDER_MODEL_INDICIES_PER_CELL;
const code = model.cells[offset];

@@ -282,5 +273,5 @@ if (code & COMBINED_CHAR_BIT_MASK) {

const chars = line!.getCell(x)!.char;
this._updateCell(this._vertices.selectionAttributes, x, y, model.cells[offset], attr, bg, fg, chars);
this._updateCell(this._vertices.selectionAttributes, x, y, model.cells[offset], bg, model.cells[offset + RENDER_MODEL_FG_OFFSET], chars);
} else {
this._updateCell(this._vertices.selectionAttributes, x, y, model.cells[offset], attr, bg, fg);
this._updateCell(this._vertices.selectionAttributes, x, y, model.cells[offset], bg, model.cells[offset + RENDER_MODEL_FG_OFFSET]);
}

@@ -287,0 +278,0 @@ }

@@ -9,8 +9,7 @@ /**

import { fill } from 'common/TypedArrayUtils';
import { INVERTED_DEFAULT_COLOR } from 'browser/renderer/atlas/Constants';
import { is256Color } from './atlas/CharAtlasUtils';
import { DEFAULT_COLOR } from 'common/buffer/Constants';
import { Attributes, FgFlags } from 'common/buffer/Constants';
import { Terminal } from 'xterm';
import { IColorSet, IColor } from 'browser/Types';
import { IRenderDimensions } from 'browser/renderer/Types';
import { RENDER_MODEL_BG_OFFSET, RENDER_MODEL_FG_OFFSET, RENDER_MODEL_INDICIES_PER_CELL } from './RenderModel';

@@ -160,3 +159,3 @@ const enum VertexAttribLocations {

this._bgFloat = this._colorToFloat32Array(this._colors.background);
this._selectionFloat = this._colorToFloat32Array(this._colors.selection);
this._selectionFloat = this._colorToFloat32Array(this._colors.selectionOpaque);
}

@@ -252,20 +251,26 @@

let currentStartX = -1;
let currentBg = DEFAULT_COLOR;
let currentBg = 0;
let currentFg = 0;
let currentInverse = false;
for (let x = 0; x < terminal.cols; x++) {
const modelIndex = ((y * terminal.cols) + x) * 4;
const bg = model.cells[modelIndex + 2];
if (bg !== currentBg) {
const modelIndex = ((y * terminal.cols) + x) * RENDER_MODEL_INDICIES_PER_CELL;
const bg = model.cells[modelIndex + RENDER_MODEL_BG_OFFSET];
const fg = model.cells[modelIndex + RENDER_MODEL_FG_OFFSET];
const inverse = !!(fg & FgFlags.INVERSE);
if (bg !== currentBg || (fg !== currentFg && (currentInverse || inverse))) {
// A rectangle needs to be drawn if going from non-default to another color
if (currentBg !== DEFAULT_COLOR) {
if (currentBg !== 0 || (currentInverse && currentFg !== 0)) {
const offset = rectangleCount++ * INDICES_PER_RECTANGLE;
this._updateRectangle(vertices, offset, currentBg, currentStartX, x, y);
this._updateRectangle(vertices, offset, currentFg, currentBg, currentStartX, x, y);
}
currentStartX = x;
currentBg = bg;
currentFg = fg;
currentInverse = inverse;
}
}
// Finish rectangle if it's still going
if (currentBg !== DEFAULT_COLOR) {
if (currentBg !== 0 || (currentInverse && currentFg !== 0)) {
const offset = rectangleCount++ * INDICES_PER_RECTANGLE;
this._updateRectangle(vertices, offset, currentBg, currentStartX, terminal.cols, y);
this._updateRectangle(vertices, offset, currentFg, currentBg, currentStartX, terminal.cols, y);
}

@@ -276,12 +281,32 @@ }

private _updateRectangle(vertices: IVertices, offset: number, bg: number, startX: number, endX: number, y: number): void {
let color: IColor | null = null;
if (bg === INVERTED_DEFAULT_COLOR) {
color = this._colors.foreground;
} else if (is256Color(bg)) {
color = this._colors.ansi[bg];
private _updateRectangle(vertices: IVertices, offset: number, fg: number, bg: number, startX: number, endX: number, y: number): void {
let rgba: number | undefined;
if (fg & FgFlags.INVERSE) {
switch (fg & Attributes.CM_MASK) {
case Attributes.CM_P16:
case Attributes.CM_P256:
rgba = this._colors.ansi[fg & Attributes.PCOLOR_MASK].rgba;
break;
case Attributes.CM_RGB:
rgba = (fg & Attributes.RGB_MASK) << 8;
break;
case Attributes.CM_DEFAULT:
default:
rgba = this._colors.foreground.rgba;
}
} else {
// TODO: Add support for true color
color = this._colors.foreground;
switch (bg & Attributes.CM_MASK) {
case Attributes.CM_P16:
case Attributes.CM_P256:
rgba = this._colors.ansi[bg & Attributes.PCOLOR_MASK].rgba;
break;
case Attributes.CM_RGB:
rgba = (bg & Attributes.RGB_MASK) << 8;
break;
case Attributes.CM_DEFAULT:
default:
rgba = this._colors.background.rgba;
}
}
if (vertices.attributes.length < offset + 4) {

@@ -292,5 +317,5 @@ vertices.attributes = expandFloat32Array(vertices.attributes, this._terminal.rows * this._terminal.cols * INDICES_PER_RECTANGLE);

const y1 = y * this._dimensions.scaledCellHeight;
const r = ((color.rgba >> 24) & 0xFF) / 255;
const g = ((color.rgba >> 16) & 0xFF) / 255;
const b = ((color.rgba >> 8 ) & 0xFF) / 255;
const r = ((rgba >> 24) & 0xFF) / 255;
const g = ((rgba >> 16) & 0xFF) / 255;
const b = ((rgba >> 8 ) & 0xFF) / 255;

@@ -297,0 +322,0 @@ this._addRectangle(vertices.attributes, offset, x1, y1, (endX - startX) * this._dimensions.scaledCellWidth, this._dimensions.scaledCellHeight, r, g, b, 1);

@@ -7,3 +7,2 @@ /**

import { IRenderLayer } from './Types';
import { IGlyphIdentifier } from '../atlas/Types';
import { acquireCharAtlas } from '../atlas/CharAtlasCache';

@@ -29,15 +28,2 @@ import { Terminal } from 'xterm';

/**
* An object that's reused when drawing glyphs in order to reduce GC.
*/
private _currentGlyphIdentifier: IGlyphIdentifier = {
chars: '',
code: 0,
bg: 0,
fg: 0,
bold: false,
dim: false,
italic: false
};
constructor(

@@ -44,0 +30,0 @@ private _container: HTMLElement,

@@ -11,3 +11,4 @@ /**

import { IColorSet } from 'browser/Types';
import { IRenderDimensions } from 'browser/renderer/Types';
import { IRenderDimensions, IRequestRefreshRowsEvent } from 'browser/renderer/Types';
import { IEventEmitter } from 'common/EventEmitter';

@@ -33,3 +34,8 @@ interface ICursorState {

constructor(container: HTMLElement, zIndex: number, colors: IColorSet) {
constructor(
container: HTMLElement,
zIndex: number,
colors: IColorSet,
private _onRequestRefreshRowsEvent: IEventEmitter<IRequestRefreshRowsEvent>
) {
super(container, 'cursor', zIndex, true, colors);

@@ -75,3 +81,3 @@ this._state = {

}
terminal.refresh(terminal.buffer.cursorY, terminal.buffer.cursorY);
this._onRequestRefreshRowsEvent.fire({ start: terminal.buffer.cursorY, end: terminal.buffer.cursorY });
}

@@ -83,3 +89,3 @@

} else {
terminal.refresh(terminal.buffer.cursorY, terminal.buffer.cursorY);
this._onRequestRefreshRowsEvent.fire({ start: terminal.buffer.cursorY, end: terminal.buffer.cursorY });
}

@@ -96,9 +102,8 @@ }

} else {
if (this._cursorBlinkStateManager) {
this._cursorBlinkStateManager.dispose();
}
this._cursorBlinkStateManager?.dispose();
this._cursorBlinkStateManager = undefined;
}
// Request a refresh from the terminal as management of rendering is being
// moved back to the terminal
terminal.refresh(terminal.buffer.cursorY, terminal.buffer.cursorY);
this._onRequestRefreshRowsEvent.fire({ start: terminal.buffer.cursorY, end: terminal.buffer.cursorY });
}

@@ -123,3 +128,3 @@

// TODO: Need to expose API for this
if (!(terminal as any)._core.cursorState || (terminal as any)._core.cursorHidden) {
if (!(terminal as any)._core._coreService.isCursorInitialized || (terminal as any)._core._coreService.isCursorHidden) {
this._clearCursor();

@@ -126,0 +131,0 @@ return;

@@ -9,3 +9,5 @@ /**

export const RENDER_MODEL_INDICIES_PER_CELL = 4;
export const RENDER_MODEL_INDICIES_PER_CELL = 3;
export const RENDER_MODEL_BG_OFFSET = 1;
export const RENDER_MODEL_FG_OFFSET = 2;

@@ -12,0 +14,0 @@ export const COMBINED_CHAR_BIT_MASK = 0x80000000;

@@ -7,3 +7,3 @@ /**

export interface IRasterizedGlyphSet {
[flags: number]: IRasterizedGlyph;
[bg: number]: { [fg: number]: IRasterizedGlyph } | undefined;
}

@@ -10,0 +10,0 @@

@@ -12,2 +12,4 @@ /**

export class WebglAddon implements ITerminalAddon {
private _terminal?: Terminal;
constructor(

@@ -19,4 +21,5 @@ private _preserveDrawingBuffer?: boolean

if (!terminal.element) {
throw new Error('Cannot activate WebglRendererAddon before Terminal.open');
throw new Error('Cannot activate WebglAddon before Terminal.open');
}
this._terminal = terminal;
const renderService: IRenderService = (<any>terminal)._core._renderService;

@@ -28,4 +31,9 @@ const colors: IColorSet = (<any>terminal)._core._colorManager.colors;

public dispose(): void {
throw new Error('WebglRendererAddon.dispose Not yet implemented');
if (!this._terminal) {
throw new Error('Cannot dispose WebglAddon because it is activated');
}
const renderService: IRenderService = (<any>this._terminal)._core._renderService;
renderService.setRenderer((<any>this._terminal)._core._createRenderer());
renderService.onResize(this._terminal.cols, this._terminal.rows);
}
}

@@ -14,16 +14,12 @@ /**

import { IWebGL2RenderingContext } from './Types';
import { INVERTED_DEFAULT_COLOR } from 'browser/renderer/atlas/Constants';
import { RenderModel, COMBINED_CHAR_BIT_MASK } from './RenderModel';
import { RenderModel, COMBINED_CHAR_BIT_MASK, RENDER_MODEL_BG_OFFSET, RENDER_MODEL_FG_OFFSET, RENDER_MODEL_INDICIES_PER_CELL } from './RenderModel';
import { Disposable } from 'common/Lifecycle';
import { DEFAULT_COLOR, CHAR_DATA_CHAR_INDEX, CHAR_DATA_CODE_INDEX, NULL_CELL_CODE } from 'common/buffer/Constants';
import { Terminal } from 'xterm';
import { getLuminance } from './ColorUtils';
import { NULL_CELL_CODE } from 'common/buffer/Constants';
import { Terminal, IEvent } from 'xterm';
import { IRenderLayer } from './renderLayer/Types';
import { IRenderDimensions, IRenderer } from 'browser/renderer/Types';
import { IRenderDimensions, IRenderer, IRequestRefreshRowsEvent } from 'browser/renderer/Types';
import { IColorSet } from 'browser/Types';
import { FLAGS } from './Constants';
import { getCompatAttr } from './CharDataCompat';
import { EventEmitter } from 'common/EventEmitter';
import { CellData } from 'common/buffer/CellData';
export const INDICIES_PER_CELL = 4;
export class WebglRenderer extends Disposable implements IRenderer {

@@ -35,2 +31,3 @@ private _renderLayers: IRenderLayer[];

private _model: RenderModel = new RenderModel();
private _workCell: CellData = new CellData();

@@ -45,3 +42,7 @@ private _canvas: HTMLCanvasElement;

private _core: ITerminal;
private _isAttached: boolean;
private _onRequestRefreshRows = new EventEmitter<IRequestRefreshRowsEvent>();
public get onRequestRefreshRows(): IEvent<IRequestRefreshRowsEvent> { return this._onRequestRefreshRows.event; }
constructor(

@@ -56,7 +57,5 @@ private _terminal: Terminal,

this._applyBgLuminanceBasedSelection();
this._renderLayers = [
new LinkRenderLayer(this._core.screenElement, 2, this._colors, this._core),
new CursorRenderLayer(this._core.screenElement, 3, this._colors)
new CursorRenderLayer(this._core.screenElement, 3, this._colors, this._onRequestRefreshRows)
];

@@ -98,2 +97,4 @@ this.dimensions = {

this.onCharSizeChanged();
this._isAttached = document.body.contains(this._core.screenElement);
}

@@ -107,16 +108,4 @@

private _applyBgLuminanceBasedSelection(): void {
// HACK: This is needed until webgl renderer adds support for selection colors
if (getLuminance(this._colors.background) > 0.5) {
this._colors.selection = { css: '#000', rgba: 255 };
} else {
this._colors.selection = { css: '#fff', rgba: 4294967295 };
}
}
public setColors(colors: IColorSet): void {
this._colors = colors;
this._applyBgLuminanceBasedSelection();
// Clear layers and force a full render

@@ -194,4 +183,3 @@ this._renderLayers.forEach(l => {

// TODO: #2102 Should this move to RenderCoordinator?
this._core.refresh(0, this._terminal.rows - 1);
this._onRequestRefreshRows.fire({ start: 0, end: this._terminal.rows - 1 });
}

@@ -216,2 +204,4 @@

if (this.dimensions.scaledCharWidth <= 0 && this.dimensions.scaledCharHeight <= 0) {
// Mark as not attached so char atlas gets refreshed on next render
this._isAttached = false;
return;

@@ -242,2 +232,12 @@ }

public renderRows(start: number, end: number): void {
if (!this._isAttached) {
if (document.body.contains(this._core.screenElement) && (<any>this._core)._charSizeService.width && (<any>this._core)._charSizeService.height) {
this._updateDimensions();
this._refreshCharAtlas();
this._isAttached = true;
} else {
return;
}
}
// Update render layers

@@ -267,8 +267,8 @@ this._renderLayers.forEach(l => l.onGridChanged(this._terminal, start, end));

for (let x = 0; x < terminal.cols; x++) {
const charData = line.get(x);
const chars = charData[CHAR_DATA_CHAR_INDEX];
let code = charData[CHAR_DATA_CODE_INDEX];
const attr = getCompatAttr(line, x); // charData[CHAR_DATA_ATTR_INDEX];
const i = ((y * terminal.cols) + x) * INDICIES_PER_CELL;
line.loadCell(x, this._workCell);
const chars = this._workCell.getChars();
let code = this._workCell.getCode();
const i = ((y * terminal.cols) + x) * RENDER_MODEL_INDICIES_PER_CELL;
if (code !== NULL_CELL_CODE) {

@@ -279,26 +279,8 @@ this._model.lineLengths[y] = x + 1;

// Nothing has changed, no updates needed
if (this._model.cells[i] === code && this._model.cells[i + 1] === attr) {
if (this._model.cells[i] === code &&
this._model.cells[i + RENDER_MODEL_BG_OFFSET] === this._workCell.bg &&
this._model.cells[i + RENDER_MODEL_FG_OFFSET] === this._workCell.fg) {
continue;
}
// Resolve bg and fg and cache in the model
const flags = attr >> 18;
let bg = attr & 0x1ff;
let fg = (attr >> 9) & 0x1ff;
// If inverse flag is on, the foreground should become the background.
if (flags & FLAGS.INVERSE) {
const temp = bg;
bg = fg;
fg = temp;
if (fg === DEFAULT_COLOR) {
fg = INVERTED_DEFAULT_COLOR;
}
if (bg === DEFAULT_COLOR) {
bg = INVERTED_DEFAULT_COLOR;
}
}
const drawInBrightColor = terminal.options.drawBoldTextInBrightColors && !!(flags & FLAGS.BOLD) && fg < 8 && fg !== INVERTED_DEFAULT_COLOR;
fg += drawInBrightColor ? 8 : 0;
// Flag combined chars with a bit mask so they're easily identifiable

@@ -309,8 +291,8 @@ if (chars.length > 1) {

this._model.cells[i ] = code;
this._model.cells[i + 1] = attr;
this._model.cells[i + 2] = bg;
this._model.cells[i + 3] = fg;
// Cache the results in the model
this._model.cells[i] = code;
this._model.cells[i + RENDER_MODEL_BG_OFFSET] = this._workCell.bg;
this._model.cells[i + RENDER_MODEL_FG_OFFSET] = this._workCell.fg;
this._glyphRenderer.updateCell(x, y, code, attr, bg, fg, chars);
this._glyphRenderer.updateCell(x, y, code, this._workCell.bg, this._workCell.fg, chars);
}

@@ -317,0 +299,0 @@ }

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc