http://git-wip-us.apache.org/repos/asf/hadoop/blob/154449fb/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/resources/TERMINAL/xterm/dist/xterm.js ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/resources/TERMINAL/xterm/dist/xterm.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/resources/TERMINAL/xterm/dist/xterm.js new file mode 100644 index 0000000..eb44f54 --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/resources/TERMINAL/xterm/dist/xterm.js @@ -0,0 +1,8907 @@ +(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.Terminal = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var Strings = require("./Strings"); +var Browser_1 = require("./shared/utils/Browser"); +var RenderDebouncer_1 = require("./ui/RenderDebouncer"); +var Lifecycle_1 = require("./ui/Lifecycle"); +var Lifecycle_2 = require("./common/Lifecycle"); +var MAX_ROWS_TO_READ = 20; +var AccessibilityManager = (function (_super) { + __extends(AccessibilityManager, _super); + function AccessibilityManager(_terminal) { + var _this = _super.call(this) || this; + _this._terminal = _terminal; + _this._liveRegionLineCount = 0; + _this._charsToConsume = []; + _this._accessibilityTreeRoot = document.createElement('div'); + _this._accessibilityTreeRoot.classList.add('xterm-accessibility'); + _this._rowContainer = document.createElement('div'); + _this._rowContainer.classList.add('xterm-accessibility-tree'); + _this._rowElements = []; + for (var i = 0; i < _this._terminal.rows; i++) { + _this._rowElements[i] = _this._createAccessibilityTreeNode(); + _this._rowContainer.appendChild(_this._rowElements[i]); + } + _this._topBoundaryFocusListener = function (e) { return _this._onBoundaryFocus(e, 0); }; + _this._bottomBoundaryFocusListener = function (e) { return _this._onBoundaryFocus(e, 1); }; + _this._rowElements[0].addEventListener('focus', _this._topBoundaryFocusListener); + _this._rowElements[_this._rowElements.length - 1].addEventListener('focus', _this._bottomBoundaryFocusListener); + _this._refreshRowsDimensions(); + _this._accessibilityTreeRoot.appendChild(_this._rowContainer); + _this._renderRowsDebouncer = new RenderDebouncer_1.RenderDebouncer(_this._terminal, _this._renderRows.bind(_this)); + _this._refreshRows(); + _this._liveRegion = document.createElement('div'); + _this._liveRegion.classList.add('live-region'); + _this._liveRegion.setAttribute('aria-live', 'assertive'); + _this._accessibilityTreeRoot.appendChild(_this._liveRegion); + _this._terminal.element.insertAdjacentElement('afterbegin', _this._accessibilityTreeRoot); + _this.register(_this._renderRowsDebouncer); + _this.register(_this._terminal.addDisposableListener('resize', function (data) { return _this._onResize(data.rows); })); + _this.register(_this._terminal.addDisposableListener('refresh', function (data) { return _this._refreshRows(data.start, data.end); })); + _this.register(_this._terminal.addDisposableListener('scroll', function (data) { return _this._refreshRows(); })); + _this.register(_this._terminal.addDisposableListener('a11y.char', function (char) { return _this._onChar(char); })); + _this.register(_this._terminal.addDisposableListener('linefeed', function () { return _this._onChar('\n'); })); + _this.register(_this._terminal.addDisposableListener('a11y.tab', function (spaceCount) { return _this._onTab(spaceCount); })); + _this.register(_this._terminal.addDisposableListener('key', function (keyChar) { return _this._onKey(keyChar); })); + _this.register(_this._terminal.addDisposableListener('blur', function () { return _this._clearLiveRegion(); })); + _this.register(_this._terminal.addDisposableListener('dprchange', function () { return _this._refreshRowsDimensions(); })); + _this.register(_this._terminal.renderer.addDisposableListener('resize', function () { return _this._refreshRowsDimensions(); })); + _this.register(Lifecycle_1.addDisposableDomListener(window, 'resize', function () { return _this._refreshRowsDimensions(); })); + return _this; + } + AccessibilityManager.prototype.dispose = function () { + _super.prototype.dispose.call(this); + this._terminal.element.removeChild(this._accessibilityTreeRoot); + this._rowElements.length = 0; + }; + AccessibilityManager.prototype._onBoundaryFocus = function (e, position) { + var boundaryElement = e.target; + var beforeBoundaryElement = this._rowElements[position === 0 ? 1 : this._rowElements.length - 2]; + var posInSet = boundaryElement.getAttribute('aria-posinset'); + var lastRowPos = position === 0 ? '1' : "" + this._terminal.buffer.lines.length; + if (posInSet === lastRowPos) { + return; + } + if (e.relatedTarget !== beforeBoundaryElement) { + return; + } + var topBoundaryElement; + var bottomBoundaryElement; + if (position === 0) { + topBoundaryElement = boundaryElement; + bottomBoundaryElement = this._rowElements.pop(); + this._rowContainer.removeChild(bottomBoundaryElement); + } + else { + topBoundaryElement = this._rowElements.shift(); + bottomBoundaryElement = boundaryElement; + this._rowContainer.removeChild(topBoundaryElement); + } + topBoundaryElement.removeEventListener('focus', this._topBoundaryFocusListener); + bottomBoundaryElement.removeEventListener('focus', this._bottomBoundaryFocusListener); + if (position === 0) { + var newElement = this._createAccessibilityTreeNode(); + this._rowElements.unshift(newElement); + this._rowContainer.insertAdjacentElement('afterbegin', newElement); + } + else { + var newElement = this._createAccessibilityTreeNode(); + this._rowElements.push(newElement); + this._rowContainer.appendChild(newElement); + } + this._rowElements[0].addEventListener('focus', this._topBoundaryFocusListener); + this._rowElements[this._rowElements.length - 1].addEventListener('focus', this._bottomBoundaryFocusListener); + this._terminal.scrollLines(position === 0 ? -1 : 1); + this._rowElements[position === 0 ? 1 : this._rowElements.length - 2].focus(); + e.preventDefault(); + e.stopImmediatePropagation(); + }; + AccessibilityManager.prototype._onResize = function (rows) { + this._rowElements[this._rowElements.length - 1].removeEventListener('focus', this._bottomBoundaryFocusListener); + for (var i = this._rowContainer.children.length; i < this._terminal.rows; i++) { + this._rowElements[i] = this._createAccessibilityTreeNode(); + this._rowContainer.appendChild(this._rowElements[i]); + } + while (this._rowElements.length > rows) { + this._rowContainer.removeChild(this._rowElements.pop()); + } + this._rowElements[this._rowElements.length - 1].addEventListener('focus', this._bottomBoundaryFocusListener); + this._refreshRowsDimensions(); + }; + AccessibilityManager.prototype._createAccessibilityTreeNode = function () { + var element = document.createElement('div'); + element.setAttribute('role', 'listitem'); + element.tabIndex = -1; + this._refreshRowDimensions(element); + return element; + }; + AccessibilityManager.prototype._onTab = function (spaceCount) { + for (var i = 0; i < spaceCount; i++) { + this._onChar(' '); + } + }; + AccessibilityManager.prototype._onChar = function (char) { + var _this = this; + if (this._liveRegionLineCount < MAX_ROWS_TO_READ + 1) { + if (this._charsToConsume.length > 0) { + var shiftedChar = this._charsToConsume.shift(); + if (shiftedChar !== char) { + this._announceCharacter(char); + } + } + else { + this._announceCharacter(char); + } + if (char === '\n') { + this._liveRegionLineCount++; + if (this._liveRegionLineCount === MAX_ROWS_TO_READ + 1) { + this._liveRegion.textContent += Strings.tooMuchOutput; + } + } + if (Browser_1.isMac) { + if (this._liveRegion.textContent && this._liveRegion.textContent.length > 0 && !this._liveRegion.parentNode) { + setTimeout(function () { + _this._accessibilityTreeRoot.appendChild(_this._liveRegion); + }, 0); + } + } + } + }; + AccessibilityManager.prototype._clearLiveRegion = function () { + this._liveRegion.textContent = ''; + this._liveRegionLineCount = 0; + if (Browser_1.isMac) { + if (this._liveRegion.parentNode) { + this._accessibilityTreeRoot.removeChild(this._liveRegion); + } + } + }; + AccessibilityManager.prototype._onKey = function (keyChar) { + this._clearLiveRegion(); + this._charsToConsume.push(keyChar); + }; + AccessibilityManager.prototype._refreshRows = function (start, end) { + this._renderRowsDebouncer.refresh(start, end); + }; + AccessibilityManager.prototype._renderRows = function (start, end) { + var buffer = this._terminal.buffer; + var setSize = buffer.lines.length.toString(); + for (var i = start; i <= end; i++) { + var lineData = buffer.translateBufferLineToString(buffer.ydisp + i, true); + var posInSet = (buffer.ydisp + i + 1).toString(); + var element = this._rowElements[i]; + element.textContent = lineData.length === 0 ? Strings.blankLine : lineData; + element.setAttribute('aria-posinset', posInSet); + element.setAttribute('aria-setsize', setSize); + } + }; + AccessibilityManager.prototype._refreshRowsDimensions = function () { + if (!this._terminal.renderer.dimensions.actualCellHeight) { + return; + } + if (this._rowElements.length !== this._terminal.rows) { + this._onResize(this._terminal.rows); + } + for (var i = 0; i < this._terminal.rows; i++) { + this._refreshRowDimensions(this._rowElements[i]); + } + }; + AccessibilityManager.prototype._refreshRowDimensions = function (element) { + element.style.height = this._terminal.renderer.dimensions.actualCellHeight + "px"; + }; + AccessibilityManager.prototype._announceCharacter = function (char) { + if (char === ' ') { + this._liveRegion.innerHTML += ' '; + } + else { + this._liveRegion.textContent += char; + } + }; + return AccessibilityManager; +}(Lifecycle_2.Disposable)); +exports.AccessibilityManager = AccessibilityManager; + +},{"./Strings":13,"./common/Lifecycle":18,"./shared/utils/Browser":46,"./ui/Lifecycle":48,"./ui/RenderDebouncer":50}],2:[function(require,module,exports){ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var CircularList_1 = require("./common/CircularList"); +var EventEmitter_1 = require("./common/EventEmitter"); +var BufferLine_1 = require("./BufferLine"); +exports.DEFAULT_ATTR = (0 << 18) | (257 << 9) | (256 << 0); +exports.CHAR_DATA_ATTR_INDEX = 0; +exports.CHAR_DATA_CHAR_INDEX = 1; +exports.CHAR_DATA_WIDTH_INDEX = 2; +exports.CHAR_DATA_CODE_INDEX = 3; +exports.MAX_BUFFER_SIZE = 4294967295; +exports.NULL_CELL_CHAR = ' '; +exports.NULL_CELL_WIDTH = 1; +exports.NULL_CELL_CODE = 32; +var Buffer = (function () { + function Buffer(_terminal, _hasScrollback) { + this._terminal = _terminal; + this._hasScrollback = _hasScrollback; + this.markers = []; + this.clear(); + } + Object.defineProperty(Buffer.prototype, "hasScrollback", { + get: function () { + return this._hasScrollback && this.lines.maxLength > this._terminal.rows; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Buffer.prototype, "isCursorInViewport", { + get: function () { + var absoluteY = this.ybase + this.y; + var relativeY = absoluteY - this.ydisp; + return (relativeY >= 0 && relativeY < this._terminal.rows); + }, + enumerable: true, + configurable: true + }); + Buffer.prototype._getCorrectBufferLength = function (rows) { + if (!this._hasScrollback) { + return rows; + } + var correctBufferLength = rows + this._terminal.options.scrollback; + return correctBufferLength > exports.MAX_BUFFER_SIZE ? exports.MAX_BUFFER_SIZE : correctBufferLength; + }; + Buffer.prototype.fillViewportRows = function () { + if (this.lines.length === 0) { + var i = this._terminal.rows; + while (i--) { + this.lines.push(BufferLine_1.BufferLine.blankLine(this._terminal.cols, exports.DEFAULT_ATTR)); + } + } + }; + Buffer.prototype.clear = function () { + this.ydisp = 0; + this.ybase = 0; + this.y = 0; + this.x = 0; + this.lines = new CircularList_1.CircularList(this._getCorrectBufferLength(this._terminal.rows)); + this.scrollTop = 0; + this.scrollBottom = this._terminal.rows - 1; + this.setupTabStops(); + }; + Buffer.prototype.resize = function (newCols, newRows) { + var newMaxLength = this._getCorrectBufferLength(newRows); + if (newMaxLength > this.lines.maxLength) { + this.lines.maxLength = newMaxLength; + } + if (this.lines.length > 0) { + if (this._terminal.cols < newCols) { + var ch = [exports.DEFAULT_ATTR, exports.NULL_CELL_CHAR, exports.NULL_CELL_WIDTH, exports.NULL_CELL_CODE]; + for (var i = 0; i < this.lines.length; i++) { + while (this.lines.get(i).length < newCols) { + this.lines.get(i).push(ch); + } + } + } + var addToY = 0; + if (this._terminal.rows < newRows) { + for (var y = this._terminal.rows; y < newRows; y++) { + if (this.lines.length < newRows + this.ybase) { + if (this.ybase > 0 && this.lines.length <= this.ybase + this.y + addToY + 1) { + this.ybase--; + addToY++; + if (this.ydisp > 0) { + this.ydisp--; + } + } + else { + this.lines.push(BufferLine_1.BufferLine.blankLine(newCols, exports.DEFAULT_ATTR)); + } + } + } + } + else { + for (var y = this._terminal.rows; y > newRows; y--) { + if (this.lines.length > newRows + this.ybase) { + if (this.lines.length > this.ybase + this.y + 1) { + this.lines.pop(); + } + else { + this.ybase++; + this.ydisp++; + } + } + } + } + if (newMaxLength < this.lines.maxLength) { + var amountToTrim = this.lines.length - newMaxLength; + if (amountToTrim > 0) { + this.lines.trimStart(amountToTrim); + this.ybase = Math.max(this.ybase - amountToTrim, 0); + this.ydisp = Math.max(this.ydisp - amountToTrim, 0); + } + this.lines.maxLength = newMaxLength; + } + this.x = Math.min(this.x, newCols - 1); + this.y = Math.min(this.y, newRows - 1); + if (addToY) { + this.y += addToY; + } + this.savedY = Math.min(this.savedY, newRows - 1); + this.savedX = Math.min(this.savedX, newCols - 1); + this.scrollTop = 0; + } + this.scrollBottom = newRows - 1; + }; + Buffer.prototype.stringIndexToBufferIndex = function (lineIndex, stringIndex) { + while (stringIndex) { + var line = this.lines.get(lineIndex); + if (!line) { + [-1, -1]; + } + for (var i = 0; i < line.length; ++i) { + stringIndex -= line.get(i)[exports.CHAR_DATA_CHAR_INDEX].length; + if (stringIndex < 0) { + return [lineIndex, i]; + } + } + lineIndex++; + } + return [lineIndex, 0]; + }; + Buffer.prototype.translateBufferLineToString = function (lineIndex, trimRight, startCol, endCol) { + if (startCol === void 0) { startCol = 0; } + if (endCol === void 0) { endCol = null; } + var lineString = ''; + var line = this.lines.get(lineIndex); + if (!line) { + return ''; + } + var startIndex = startCol; + if (endCol === null) { + endCol = line.length; + } + var endIndex = endCol; + for (var i = 0; i < line.length; i++) { + var char = line.get(i); + lineString += char[exports.CHAR_DATA_CHAR_INDEX]; + if (char[exports.CHAR_DATA_WIDTH_INDEX] === 0) { + if (startCol >= i) { + startIndex--; + } + if (endCol > i) { + endIndex--; + } + } + else { + if (char[exports.CHAR_DATA_CHAR_INDEX].length > 1) { + if (startCol > i) { + startIndex += char[exports.CHAR_DATA_CHAR_INDEX].length - 1; + } + if (endCol > i) { + endIndex += char[exports.CHAR_DATA_CHAR_INDEX].length - 1; + } + } + } + } + if (trimRight) { + var rightWhitespaceIndex = lineString.search(/\s+$/); + if (rightWhitespaceIndex !== -1) { + endIndex = Math.min(endIndex, rightWhitespaceIndex); + } + if (endIndex <= startIndex) { + return ''; + } + } + return lineString.substring(startIndex, endIndex); + }; + Buffer.prototype.getWrappedRangeForLine = function (y) { + var first = y; + var last = y; + while (first > 0 && this.lines.get(first).isWrapped) { + first--; + } + while (last + 1 < this.lines.length && this.lines.get(last + 1).isWrapped) { + last++; + } + return { first: first, last: last }; + }; + Buffer.prototype.setupTabStops = function (i) { + if (i !== null && i !== undefined) { + if (!this.tabs[i]) { + i = this.prevStop(i); + } + } + else { + this.tabs = {}; + i = 0; + } + for (; i < this._terminal.cols; i += this._terminal.options.tabStopWidth) { + this.tabs[i] = true; + } + }; + Buffer.prototype.prevStop = function (x) { + if (x === null || x === undefined) { + x = this.x; + } + while (!this.tabs[--x] && x > 0) + ; + return x >= this._terminal.cols ? this._terminal.cols - 1 : x < 0 ? 0 : x; + }; + Buffer.prototype.nextStop = function (x) { + if (x === null || x === undefined) { + x = this.x; + } + while (!this.tabs[++x] && x < this._terminal.cols) + ; + return x >= this._terminal.cols ? this._terminal.cols - 1 : x < 0 ? 0 : x; + }; + Buffer.prototype.addMarker = function (y) { + var _this = this; + var marker = new Marker(y); + this.markers.push(marker); + marker.register(this.lines.addDisposableListener('trim', function (amount) { + marker.line -= amount; + if (marker.line < 0) { + marker.dispose(); + } + })); + marker.register(marker.addDisposableListener('dispose', function () { return _this._removeMarker(marker); })); + return marker; + }; + Buffer.prototype._removeMarker = function (marker) { + this.markers.splice(this.markers.indexOf(marker), 1); + }; + Buffer.prototype.iterator = function (trimRight, startIndex, endIndex, startOverscan, endOverscan) { + return new BufferStringIterator(this, trimRight, startIndex, endIndex, startOverscan, endOverscan); + }; + return Buffer; +}()); +exports.Buffer = Buffer; +var Marker = (function (_super) { + __extends(Marker, _super); + function Marker(line) { + var _this = _super.call(this) || this; + _this.line = line; + _this._id = Marker._nextId++; + _this.isDisposed = false; + return _this; + } + Object.defineProperty(Marker.prototype, "id", { + get: function () { return this._id; }, + enumerable: true, + configurable: true + }); + Marker.prototype.dispose = function () { + if (this.isDisposed) { + return; + } + this.isDisposed = true; + this.emit('dispose'); + _super.prototype.dispose.call(this); + }; + Marker._nextId = 1; + return Marker; +}(EventEmitter_1.EventEmitter)); +exports.Marker = Marker; +var BufferStringIterator = (function () { + function BufferStringIterator(_buffer, _trimRight, _startIndex, _endIndex, _startOverscan, _endOverscan) { + if (_startIndex === void 0) { _startIndex = 0; } + if (_endIndex === void 0) { _endIndex = _buffer.lines.length; } + if (_startOverscan === void 0) { _startOverscan = 0; } + if (_endOverscan === void 0) { _endOverscan = 0; } + this._buffer = _buffer; + this._trimRight = _trimRight; + this._startIndex = _startIndex; + this._endIndex = _endIndex; + this._startOverscan = _startOverscan; + this._endOverscan = _endOverscan; + if (this._startIndex < 0) { + this._startIndex = 0; + } + if (this._endIndex > this._buffer.lines.length) { + this._endIndex = this._buffer.lines.length; + } + this._current = this._startIndex; + } + BufferStringIterator.prototype.hasNext = function () { + return this._current < this._endIndex; + }; + BufferStringIterator.prototype.next = function () { + var range = this._buffer.getWrappedRangeForLine(this._current); + if (range.first < this._startIndex - this._startOverscan) { + range.first = this._startIndex - this._startOverscan; + } + if (range.last > this._endIndex + this._endOverscan) { + range.last = this._endIndex + this._endOverscan; + } + range.first = Math.max(range.first, 0); + range.last = Math.min(range.last, this._buffer.lines.length); + var result = ''; + for (var i = range.first; i <= range.last; ++i) { + result += this._buffer.translateBufferLineToString(i, (this._trimRight) ? i === range.last : false); + } + this._current = range.last + 1; + return { range: range, content: result }; + }; + return BufferStringIterator; +}()); +exports.BufferStringIterator = BufferStringIterator; + +},{"./BufferLine":3,"./common/CircularList":16,"./common/EventEmitter":17}],3:[function(require,module,exports){ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var Buffer_1 = require("./Buffer"); +var BufferLine = (function () { + function BufferLine(cols, ch, isWrapped) { + this.isWrapped = false; + this._data = []; + this.length = this._data.length; + if (cols) { + if (!ch) { + ch = [0, Buffer_1.NULL_CELL_CHAR, Buffer_1.NULL_CELL_WIDTH, Buffer_1.NULL_CELL_CODE]; + } + for (var i = 0; i < cols; i++) { + this.push(ch); + } + } + if (isWrapped) { + this.isWrapped = true; + } + } + BufferLine.blankLine = function (cols, attr, isWrapped) { + var ch = [attr, Buffer_1.NULL_CELL_CHAR, Buffer_1.NULL_CELL_WIDTH, Buffer_1.NULL_CELL_CODE]; + return new BufferLine(cols, ch, isWrapped); + }; + BufferLine.prototype.get = function (index) { + return this._data[index]; + }; + BufferLine.prototype.set = function (index, data) { + this._data[index] = data; + }; + BufferLine.prototype.pop = function () { + var data = this._data.pop(); + this.length = this._data.length; + return data; + }; + BufferLine.prototype.push = function (data) { + this._data.push(data); + this.length = this._data.length; + }; + BufferLine.prototype.splice = function (start, deleteCount) { + var items = []; + for (var _i = 2; _i < arguments.length; _i++) { + items[_i - 2] = arguments[_i]; + } + var _a; + var removed = (_a = this._data).splice.apply(_a, [start, deleteCount].concat(items)); + this.length = this._data.length; + return removed; + }; + BufferLine.prototype.insertCells = function (pos, n, ch) { + while (n--) { + this.splice(pos, 0, ch); + this.pop(); + } + }; + BufferLine.prototype.deleteCells = function (pos, n, fill) { + while (n--) { + this.splice(pos, 1); + this.push(fill); + } + }; + BufferLine.prototype.replaceCells = function (start, end, fill) { + while (start < end && start < this.length) { + this.set(start++, fill); + } + }; + return BufferLine; +}()); +exports.BufferLine = BufferLine; + +},{"./Buffer":2}],4:[function(require,module,exports){ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var Buffer_1 = require("./Buffer"); +var EventEmitter_1 = require("./common/EventEmitter"); +var BufferSet = (function (_super) { + __extends(BufferSet, _super); + function BufferSet(_terminal) { + var _this = _super.call(this) || this; + _this._terminal = _terminal; + _this._normal = new Buffer_1.Buffer(_this._terminal, true); + _this._normal.fillViewportRows(); + _this._alt = new Buffer_1.Buffer(_this._terminal, false); + _this._activeBuffer = _this._normal; + _this.setupTabStops(); + return _this; + } + Object.defineProperty(BufferSet.prototype, "alt", { + get: function () { + return this._alt; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(BufferSet.prototype, "active", { + get: function () { + return this._activeBuffer; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(BufferSet.prototype, "normal", { + get: function () { + return this._normal; + }, + enumerable: true, + configurable: true + }); + BufferSet.prototype.activateNormalBuffer = function () { + if (this._activeBuffer === this._normal) { + return; + } + this._alt.clear(); + this._activeBuffer = this._normal; + this.emit('activate', { + activeBuffer: this._normal, + inactiveBuffer: this._alt + }); + }; + BufferSet.prototype.activateAltBuffer = function () { + if (this._activeBuffer === this._alt) { + return; + } + this._alt.fillViewportRows(); + this._activeBuffer = this._alt; + this.emit('activate', { + activeBuffer: this._alt, + inactiveBuffer: this._normal + }); + }; + BufferSet.prototype.resize = function (newCols, newRows) { + this._normal.resize(newCols, newRows); + this._alt.resize(newCols, newRows); + }; + BufferSet.prototype.setupTabStops = function (i) { + this._normal.setupTabStops(i); + this._alt.setupTabStops(i); + }; + return BufferSet; +}(EventEmitter_1.EventEmitter)); +exports.BufferSet = BufferSet; + +},{"./Buffer":2,"./common/EventEmitter":17}],5:[function(require,module,exports){ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.wcwidth = (function (opts) { + var COMBINING_BMP = [ + [0x0300, 0x036F], [0x0483, 0x0486], [0x0488, 0x0489], + [0x0591, 0x05BD], [0x05BF, 0x05BF], [0x05C1, 0x05C2], + [0x05C4, 0x05C5], [0x05C7, 0x05C7], [0x0600, 0x0603], + [0x0610, 0x0615], [0x064B, 0x065E], [0x0670, 0x0670], + [0x06D6, 0x06E4], [0x06E7, 0x06E8], [0x06EA, 0x06ED], + [0x070F, 0x070F], [0x0711, 0x0711], [0x0730, 0x074A], + [0x07A6, 0x07B0], [0x07EB, 0x07F3], [0x0901, 0x0902], + [0x093C, 0x093C], [0x0941, 0x0948], [0x094D, 0x094D], + [0x0951, 0x0954], [0x0962, 0x0963], [0x0981, 0x0981], + [0x09BC, 0x09BC], [0x09C1, 0x09C4], [0x09CD, 0x09CD], + [0x09E2, 0x09E3], [0x0A01, 0x0A02], [0x0A3C, 0x0A3C], + [0x0A41, 0x0A42], [0x0A47, 0x0A48], [0x0A4B, 0x0A4D], + [0x0A70, 0x0A71], [0x0A81, 0x0A82], [0x0ABC, 0x0ABC], + [0x0AC1, 0x0AC5], [0x0AC7, 0x0AC8], [0x0ACD, 0x0ACD], + [0x0AE2, 0x0AE3], [0x0B01, 0x0B01], [0x0B3C, 0x0B3C], + [0x0B3F, 0x0B3F], [0x0B41, 0x0B43], [0x0B4D, 0x0B4D], + [0x0B56, 0x0B56], [0x0B82, 0x0B82], [0x0BC0, 0x0BC0], + [0x0BCD, 0x0BCD], [0x0C3E, 0x0C40], [0x0C46, 0x0C48], + [0x0C4A, 0x0C4D], [0x0C55, 0x0C56], [0x0CBC, 0x0CBC], + [0x0CBF, 0x0CBF], [0x0CC6, 0x0CC6], [0x0CCC, 0x0CCD], + [0x0CE2, 0x0CE3], [0x0D41, 0x0D43], [0x0D4D, 0x0D4D], + [0x0DCA, 0x0DCA], [0x0DD2, 0x0DD4], [0x0DD6, 0x0DD6], + [0x0E31, 0x0E31], [0x0E34, 0x0E3A], [0x0E47, 0x0E4E], + [0x0EB1, 0x0EB1], [0x0EB4, 0x0EB9], [0x0EBB, 0x0EBC], + [0x0EC8, 0x0ECD], [0x0F18, 0x0F19], [0x0F35, 0x0F35], + [0x0F37, 0x0F37], [0x0F39, 0x0F39], [0x0F71, 0x0F7E], + [0x0F80, 0x0F84], [0x0F86, 0x0F87], [0x0F90, 0x0F97], + [0x0F99, 0x0FBC], [0x0FC6, 0x0FC6], [0x102D, 0x1030], + [0x1032, 0x1032], [0x1036, 0x1037], [0x1039, 0x1039], + [0x1058, 0x1059], [0x1160, 0x11FF], [0x135F, 0x135F], + [0x1712, 0x1714], [0x1732, 0x1734], [0x1752, 0x1753], + [0x1772, 0x1773], [0x17B4, 0x17B5], [0x17B7, 0x17BD], + [0x17C6, 0x17C6], [0x17C9, 0x17D3], [0x17DD, 0x17DD], + [0x180B, 0x180D], [0x18A9, 0x18A9], [0x1920, 0x1922], + [0x1927, 0x1928], [0x1932, 0x1932], [0x1939, 0x193B], + [0x1A17, 0x1A18], [0x1B00, 0x1B03], [0x1B34, 0x1B34], + [0x1B36, 0x1B3A], [0x1B3C, 0x1B3C], [0x1B42, 0x1B42], + [0x1B6B, 0x1B73], [0x1DC0, 0x1DCA], [0x1DFE, 0x1DFF], + [0x200B, 0x200F], [0x202A, 0x202E], [0x2060, 0x2063], + [0x206A, 0x206F], [0x20D0, 0x20EF], [0x302A, 0x302F], + [0x3099, 0x309A], [0xA806, 0xA806], [0xA80B, 0xA80B], + [0xA825, 0xA826], [0xFB1E, 0xFB1E], [0xFE00, 0xFE0F], + [0xFE20, 0xFE23], [0xFEFF, 0xFEFF], [0xFFF9, 0xFFFB] + ]; + var COMBINING_HIGH = [ + [0x10A01, 0x10A03], [0x10A05, 0x10A06], [0x10A0C, 0x10A0F], + [0x10A38, 0x10A3A], [0x10A3F, 0x10A3F], [0x1D167, 0x1D169], + [0x1D173, 0x1D182], [0x1D185, 0x1D18B], [0x1D1AA, 0x1D1AD], + [0x1D242, 0x1D244], [0xE0001, 0xE0001], [0xE0020, 0xE007F], + [0xE0100, 0xE01EF] + ]; + function bisearch(ucs, data) { + var min = 0; + var max = data.length - 1; + var mid; + if (ucs < data[0][0] || ucs > data[max][1]) { + return false; + } + while (max >= min) { + mid = (min + max) >> 1; + if (ucs > data[mid][1]) { + min = mid + 1; + } + else if (ucs < data[mid][0]) { + max = mid - 1; + } + else { + return true; + } + } + return false; + } + function wcwidthBMP(ucs) { + if (ucs === 0) { + return opts.nul; + } + if (ucs < 32 || (ucs >= 0x7f && ucs < 0xa0)) { + return opts.control; + } + if (bisearch(ucs, COMBINING_BMP)) { + return 0; + } + if (isWideBMP(ucs)) { + return 2; + } + return 1; + } + function isWideBMP(ucs) { + return (ucs >= 0x1100 && (ucs <= 0x115f || + ucs === 0x2329 || + ucs === 0x232a || + (ucs >= 0x2e80 && ucs <= 0xa4cf && ucs !== 0x303f) || + (ucs >= 0xac00 && ucs <= 0xd7a3) || + (ucs >= 0xf900 && ucs <= 0xfaff) || + (ucs >= 0xfe10 && ucs <= 0xfe19) || + (ucs >= 0xfe30 && ucs <= 0xfe6f) || + (ucs >= 0xff00 && ucs <= 0xff60) || + (ucs >= 0xffe0 && ucs <= 0xffe6))); + } + function wcwidthHigh(ucs) { + if (bisearch(ucs, COMBINING_HIGH)) { + return 0; + } + if ((ucs >= 0x20000 && ucs <= 0x2fffd) || (ucs >= 0x30000 && ucs <= 0x3fffd)) { + return 2; + } + return 1; + } + var control = opts.control | 0; + var table = null; + function initTable() { + var CODEPOINTS = 65536; + var BITWIDTH = 2; + var ITEMSIZE = 32; + var CONTAINERSIZE = CODEPOINTS * BITWIDTH / ITEMSIZE; + var CODEPOINTS_PER_ITEM = ITEMSIZE / BITWIDTH; + table = (typeof Uint32Array === 'undefined') + ? new Array(CONTAINERSIZE) + : new Uint32Array(CONTAINERSIZE); + for (var i = 0; i < CONTAINERSIZE; ++i) { + var num = 0; + var pos = CODEPOINTS_PER_ITEM; + while (pos--) { + num = (num << 2) | wcwidthBMP(CODEPOINTS_PER_ITEM * i + pos); + } + table[i] = num; + } + return table; + } + return function (num) { + num = num | 0; + if (num < 32) { + return control | 0; + } + if (num < 127) { + return 1; + } + var t = table || initTable(); + if (num < 65536) { + return t[num >> 4] >> ((num & 15) << 1) & 3; + } + return wcwidthHigh(num); + }; +})({ nul: 0, control: 0 }); +function getStringCellWidth(s) { + var result = 0; + for (var i = 0; i < s.length; ++i) { + var code = s.charCodeAt(i); + if (0xD800 <= code && code <= 0xDBFF) { + var low = s.charCodeAt(i + 1); + if (isNaN(low)) { + return result; + } + code = ((code - 0xD800) * 0x400) + (low - 0xDC00) + 0x10000; + } + if (0xDC00 <= code && code <= 0xDFFF) { + continue; + } + result += exports.wcwidth(code); + } + return result; +} +exports.getStringCellWidth = getStringCellWidth; + +},{}],6:[function(require,module,exports){ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var CompositionHelper = (function () { + function CompositionHelper(_textarea, _compositionView, _terminal) { + this._textarea = _textarea; + this._compositionView = _compositionView; + this._terminal = _terminal; + this._isComposing = false; + this._isSendingComposition = false; + this._compositionPosition = { start: null, end: null }; + } + CompositionHelper.prototype.compositionstart = function () { + this._isComposing = true; + this._compositionPosition.start = this._textarea.value.length; + this._compositionView.textContent = ''; + this._compositionView.classList.add('active'); + }; + CompositionHelper.prototype.compositionupdate = function (ev) { + var _this = this; + this._compositionView.textContent = ev.data; + this.updateCompositionElements(); + setTimeout(function () { + _this._compositionPosition.end = _this._textarea.value.length; + }, 0); + }; + CompositionHelper.prototype.compositionend = function () { + this._finalizeComposition(true); + }; + CompositionHelper.prototype.keydown = function (ev) { + if (this._isComposing || this._isSendingComposition) { + if (ev.keyCode === 229) { + return false; + } + else if (ev.keyCode === 16 || ev.keyCode === 17 || ev.keyCode === 18) { + return false; + } + this._finalizeComposition(false); + } + if (ev.keyCode === 229) { + this._handleAnyTextareaChanges(); + return false; + } + return true; + }; + CompositionHelper.prototype._finalizeComposition = function (waitForPropogation) { + var _this = this; + this._compositionView.classList.remove('active'); + this._isComposing = false; + this._clearTextareaPosition(); + if (!waitForPropogation) { + this._isSendingComposition = false; + var input = this._textarea.value.substring(this._compositionPosition.start, this._compositionPosition.end); + this._terminal.handler(input); + } + else { + var currentCompositionPosition_1 = { + start: this._compositionPosition.start, + end: this._compositionPosition.end + }; + this._isSendingComposition = true; + setTimeout(function () { + if (_this._isSendingComposition) { + _this._isSendingComposition = false; + var input = void 0; + if (_this._isComposing) { + input = _this._textarea.value.substring(currentCompositionPosition_1.start, currentCompositionPosition_1.end); + } + else { + input = _this._textarea.value.substring(currentCompositionPosition_1.start); + } + _this._terminal.handler(input); + } + }, 0); + } + }; + CompositionHelper.prototype._handleAnyTextareaChanges = function () { + var _this = this; + var oldValue = this._textarea.value; + setTimeout(function () { + if (!_this._isComposing) { + var newValue = _this._textarea.value; + var diff = newValue.replace(oldValue, ''); + if (diff.length > 0) { + _this._terminal.handler(diff); + } + } + }, 0); + }; + CompositionHelper.prototype.updateCompositionElements = function (dontRecurse) { + var _this = this; + if (!this._isComposing) { + return; + } + if (this._terminal.buffer.isCursorInViewport) { + var cellHeight = Math.ceil(this._terminal.charMeasure.height * this._terminal.options.lineHeight); + var cursorTop = this._terminal.buffer.y * cellHeight; + var cursorLeft = this._terminal.buffer.x * this._terminal.charMeasure.width; + this._compositionView.style.left = cursorLeft + 'px'; + this._compositionView.style.top = cursorTop + 'px'; + this._compositionView.style.height = cellHeight + 'px'; + this._compositionView.style.lineHeight = cellHeight + 'px'; + var compositionViewBounds = this._compositionView.getBoundingClientRect(); + this._textarea.style.left = cursorLeft + 'px'; + this._textarea.style.top = cursorTop + 'px'; + this._textarea.style.width = compositionViewBounds.width + 'px'; + this._textarea.style.height = compositionViewBounds.height + 'px'; + this._textarea.style.lineHeight = compositionViewBounds.height + 'px'; + } + if (!dontRecurse) { + setTimeout(function () { return _this.updateCompositionElements(true); }, 0); + } + }; + CompositionHelper.prototype._clearTextareaPosition = function () { + this._textarea.style.left = ''; + this._textarea.style.top = ''; + }; + return CompositionHelper; +}()); +exports.CompositionHelper = CompositionHelper; + +},{}],7:[function(require,module,exports){ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var Lifecycle_1 = require("./common/Lifecycle"); +function r(low, high) { + var c = high - low; + var arr = new Array(c); + while (c--) { + arr[c] = --high; + } + return arr; +} +var TransitionTable = (function () { + function TransitionTable(length) { + this.table = (typeof Uint8Array === 'undefined') + ? new Array(length) + : new Uint8Array(length); + } + TransitionTable.prototype.add = function (code, state, action, next) { + this.table[state << 8 | code] = ((action | 0) << 4) | ((next === undefined) ? state : next); + }; + TransitionTable.prototype.addMany = function (codes, state, action, next) { + for (var i = 0; i < codes.length; i++) { + this.add(codes[i], state, action, next); + } + }; + return TransitionTable; +}()); +exports.TransitionTable = TransitionTable; +var PRINTABLES = r(0x20, 0x7f); +var EXECUTABLES = r(0x00, 0x18); +EXECUTABLES.push(0x19); +EXECUTABLES.concat(r(0x1c, 0x20)); +var DEFAULT_TRANSITION = 1 << 4 | 0; +exports.VT500_TRANSITION_TABLE = (function () { + var table = new TransitionTable(4095); + var states = r(0, 13 + 1); + var state; + for (state in states) { + for (var code = 0; code < 160; ++code) { + table.add(code, state, 1, 0); + } + } + table.addMany(PRINTABLES, 0, 2, 0); + for (state in states) { + table.addMany([0x18, 0x1a, 0x99, 0x9a], state, 3, 0); + table.addMany(r(0x80, 0x90), state, 3, 0); + table.addMany(r(0x90, 0x98), state, 3, 0); + table.add(0x9c, state, 0, 0); + table.add(0x1b, state, 11, 1); + table.add(0x9d, state, 4, 8); + table.addMany([0x98, 0x9e, 0x9f], state, 0, 7); + table.add(0x9b, state, 11, 3); + table.add(0x90, state, 11, 9); + } + table.addMany(EXECUTABLES, 0, 3, 0); + table.addMany(EXECUTABLES, 1, 3, 1); + table.add(0x7f, 1, 0, 1); + table.addMany(EXECUTABLES, 8, 0, 8); + table.addMany(EXECUTABLES, 3, 3, 3); + table.add(0x7f, 3, 0, 3); + table.addMany(EXECUTABLES, 4, 3, 4); + table.add(0x7f, 4, 0, 4); + table.addMany(EXECUTABLES, 6, 3, 6); + table.addMany(EXECUTABLES, 5, 3, 5); + table.add(0x7f, 5, 0, 5); + table.addMany(EXECUTABLES, 2, 3, 2); + table.add(0x7f, 2, 0, 2); + table.add(0x5d, 1, 4, 8); + table.addMany(PRINTABLES, 8, 5, 8); + table.add(0x7f, 8, 5, 8); + table.addMany([0x9c, 0x1b, 0x18, 0x1a, 0x07], 8, 6, 0); + table.addMany(r(0x1c, 0x20), 8, 0, 8); + table.addMany([0x58, 0x5e, 0x5f], 1, 0, 7); + table.addMany(PRINTABLES, 7, 0, 7); + table.addMany(EXECUTABLES, 7, 0, 7); + table.add(0x9c, 7, 0, 0); + table.add(0x5b, 1, 11, 3); + table.addMany(r(0x40, 0x7f), 3, 7, 0); + table.addMany(r(0x30, 0x3a), 3, 8, 4); + table.add(0x3b, 3, 8, 4); + table.addMany([0x3c, 0x3d, 0x3e, 0x3f], 3, 9, 4); + table.addMany(r(0x30, 0x3a), 4, 8, 4); + table.add(0x3b, 4, 8, 4); + table.addMany(r(0x40, 0x7f), 4, 7, 0); + table.addMany([0x3a, 0x3c, 0x3d, 0x3e, 0x3f], 4, 0, 6); + table.addMany(r(0x20, 0x40), 6, 0, 6); + table.add(0x7f, 6, 0, 6); + table.addMany(r(0x40, 0x7f), 6, 0, 0); + table.add(0x3a, 3, 0, 6); + table.addMany(r(0x20, 0x30), 3, 9, 5); + table.addMany(r(0x20, 0x30), 5, 9, 5); + table.addMany(r(0x30, 0x40), 5, 0, 6); + table.addMany(r(0x40, 0x7f), 5, 7, 0); + table.addMany(r(0x20, 0x30), 4, 9, 5); + table.addMany(r(0x20, 0x30), 1, 9, 2); + table.addMany(r(0x20, 0x30), 2, 9, 2); + table.addMany(r(0x30, 0x7f), 2, 10, 0); + table.addMany(r(0x30, 0x50), 1, 10, 0); + table.addMany(r(0x51, 0x58), 1, 10, 0); + table.addMany([0x59, 0x5a, 0x5c], 1, 10, 0); + table.addMany(r(0x60, 0x7f), 1, 10, 0); + table.add(0x50, 1, 11, 9); + table.addMany(EXECUTABLES, 9, 0, 9); + table.add(0x7f, 9, 0, 9); + table.addMany(r(0x1c, 0x20), 9, 0, 9); + table.addMany(r(0x20, 0x30), 9, 9, 12); + table.add(0x3a, 9, 0, 11); + table.addMany(r(0x30, 0x3a), 9, 8, 10); + table.add(0x3b, 9, 8, 10); + table.addMany([0x3c, 0x3d, 0x3e, 0x3f], 9, 9, 10); + table.addMany(EXECUTABLES, 11, 0, 11); + table.addMany(r(0x20, 0x80), 11, 0, 11); + table.addMany(r(0x1c, 0x20), 11, 0, 11); + table.addMany(EXECUTABLES, 10, 0, 10); + table.add(0x7f, 10, 0, 10); + table.addMany(r(0x1c, 0x20), 10, 0, 10); + table.addMany(r(0x30, 0x3a), 10, 8, 10); + table.add(0x3b, 10, 8, 10); + table.addMany([0x3a, 0x3c, 0x3d, 0x3e, 0x3f], 10, 0, 11); + table.addMany(r(0x20, 0x30), 10, 9, 12); + table.addMany(EXECUTABLES, 12, 0, 12); + table.add(0x7f, 12, 0, 12); + table.addMany(r(0x1c, 0x20), 12, 0, 12); + table.addMany(r(0x20, 0x30), 12, 9, 12); + table.addMany(r(0x30, 0x40), 12, 0, 11); + table.addMany(r(0x40, 0x7f), 12, 12, 13); + table.addMany(r(0x40, 0x7f), 10, 12, 13); + table.addMany(r(0x40, 0x7f), 9, 12, 13); + table.addMany(EXECUTABLES, 13, 13, 13); + table.addMany(PRINTABLES, 13, 13, 13); + table.add(0x7f, 13, 0, 13); + table.addMany([0x1b, 0x9c], 13, 14, 0); + return table; +})(); +var DcsDummy = (function () { + function DcsDummy() { + } + DcsDummy.prototype.hook = function (collect, params, flag) { }; + DcsDummy.prototype.put = function (data, start, end) { }; + DcsDummy.prototype.unhook = function () { }; + return DcsDummy; +}()); +var EscapeSequenceParser = (function (_super) { + __extends(EscapeSequenceParser, _super); + function EscapeSequenceParser(TRANSITIONS) { + if (TRANSITIONS === void 0) { TRANSITIONS = exports.VT500_TRANSITION_TABLE; } + var _this = _super.call(this) || this; + _this.TRANSITIONS = TRANSITIONS; + _this.initialState = 0; + _this.currentState = _this.initialState; + _this._osc = ''; + _this._params = [0]; + _this._collect = ''; + _this._printHandlerFb = function (data, start, end) { }; + _this._executeHandlerFb = function (code) { }; + _this._csiHandlerFb = function (collect, params, flag) { }; + _this._escHandlerFb = function (collect, flag) { }; + _this._oscHandlerFb = function (identifier, data) { }; + _this._dcsHandlerFb = new DcsDummy(); + _this._errorHandlerFb = function (state) { return state; }; + _this._printHandler = _this._printHandlerFb; + _this._executeHandlers = Object.create(null); + _this._csiHandlers = Object.create(null); + _this._escHandlers = Object.create(null); + _this._oscHandlers = Object.create(null); + _this._dcsHandlers = Object.create(null); + _this._activeDcsHandler = null; + _this._errorHandler = _this._errorHandlerFb; + return _this; + } + EscapeSequenceParser.prototype.dispose = function () { + this._printHandlerFb = null; + this._executeHandlerFb = null; + this._csiHandlerFb = null; + this._escHandlerFb = null; + this._oscHandlerFb = null; + this._dcsHandlerFb = null; + this._errorHandlerFb = null; + this._printHandler = null; + this._executeHandlers = null; + this._csiHandlers = null; + this._escHandlers = null; + this._oscHandlers = null; + this._dcsHandlers = null; + this._activeDcsHandler = null; + this._errorHandler = null; + }; + EscapeSequenceParser.prototype.setPrintHandler = function (callback) { + this._printHandler = callback; + }; + EscapeSequenceParser.prototype.clearPrintHandler = function () { + this._printHandler = this._printHandlerFb; + }; + EscapeSequenceParser.prototype.setExecuteHandler = function (flag, callback) { + this._executeHandlers[flag.charCodeAt(0)] = callback; + }; + EscapeSequenceParser.prototype.clearExecuteHandler = function (flag) { + if (this._executeHandlers[flag.charCodeAt(0)]) + delete this._executeHandlers[flag.charCodeAt(0)]; + }; + EscapeSequenceParser.prototype.setExecuteHandlerFallback = function (callback) { + this._executeHandlerFb = callback; + }; + EscapeSequenceParser.prototype.setCsiHandler = function (flag, callback) { + this._csiHandlers[flag.charCodeAt(0)] = callback; + }; + EscapeSequenceParser.prototype.clearCsiHandler = function (flag) { + if (this._csiHandlers[flag.charCodeAt(0)]) + delete this._csiHandlers[flag.charCodeAt(0)]; + }; + EscapeSequenceParser.prototype.setCsiHandlerFallback = function (callback) { + this._csiHandlerFb = callback; + }; + EscapeSequenceParser.prototype.setEscHandler = function (collectAndFlag, callback) { + this._escHandlers[collectAndFlag] = callback; + }; + EscapeSequenceParser.prototype.clearEscHandler = function (collectAndFlag) { + if (this._escHandlers[collectAndFlag]) + delete this._escHandlers[collectAndFlag]; + }; + EscapeSequenceParser.prototype.setEscHandlerFallback = function (callback) { + this._escHandlerFb = callback; + }; + EscapeSequenceParser.prototype.setOscHandler = function (ident, callback) { + this._oscHandlers[ident] = callback; + }; + EscapeSequenceParser.prototype.clearOscHandler = function (ident) { + if (this._oscHandlers[ident]) + delete this._oscHandlers[ident]; + }; + EscapeSequenceParser.prototype.setOscHandlerFallback = function (callback) { + this._oscHandlerFb = callback; + }; + EscapeSequenceParser.prototype.setDcsHandler = function (collectAndFlag, handler) { + this._dcsHandlers[collectAndFlag] = handler; + }; + EscapeSequenceParser.prototype.clearDcsHandler = function (collectAndFlag) { + if (this._dcsHandlers[collectAndFlag]) + delete this._dcsHandlers[collectAndFlag]; + }; + EscapeSequenceParser.prototype.setDcsHandlerFallback = function (handler) { + this._dcsHandlerFb = handler; + }; + EscapeSequenceParser.prototype.setErrorHandler = function (callback) { + this._errorHandler = callback; + }; + EscapeSequenceParser.prototype.clearErrorHandler = function () { + this._errorHandler = this._errorHandlerFb; + }; + EscapeSequenceParser.prototype.reset = function () { + this.currentState = this.initialState; + this._osc = ''; + this._params = [0]; + this._collect = ''; + this._activeDcsHandler = null; + }; + EscapeSequenceParser.prototype.parse = function (data) { + var code = 0; + var transition = 0; + var error = false; + var currentState = this.currentState; + var print = -1; + var dcs = -1; + var osc = this._osc; + var collect = this._collect; + var params = this._params; + var table = this.TRANSITIONS.table; + var dcsHandler = this._activeDcsHandler; + var callback = null; + var l = data.length; + for (var i = 0; i < l; ++i) { + code = data.charCodeAt(i); + if (currentState === 0 && code > 0x1f && code < 0x80) { + print = (~print) ? print : i; + do + i++; + while (i < l && data.charCodeAt(i) > 0x1f && data.charCodeAt(i) < 0x80); + i--; + continue; + } + if (currentState === 4 && (code > 0x2f && code < 0x39)) { + params[params.length - 1] = params[params.length - 1] * 10 + code - 48; + continue; + } + transition = (code < 0xa0) ? (table[currentState << 8 | code]) : DEFAULT_TRANSITION; + switch (transition >> 4) { + case 2: + print = (~print) ? print : i; + break; + case 3: + if (~print) { + this._printHandler(data, print, i); + print = -1; + } + callback = this._executeHandlers[code]; + if (callback) + callback(); + else + this._executeHandlerFb(code); + break; + case 0: + if (~print) { + this._printHandler(data, print, i); + print = -1; + } + else if (~dcs) { + dcsHandler.put(data, dcs, i); + dcs = -1; + } + break; + case 1: + if (code > 0x9f) { + switch (currentState) { + case 0: + print = (~print) ? print : i; + break; + case 8: + osc += String.fromCharCode(code); + transition |= 8; + break; + case 6: + transition |= 6; + break; + case 11: + transition |= 11; + break; + case 13: + dcs = (~dcs) ? dcs : i; + transition |= 13; + break; + default: + error = true; + } + } + else { + error = true; + } + if (error) { + var inject = this._errorHandler({ + position: i, + code: code, + currentState: currentState, + print: print, + dcs: dcs, + osc: osc, + collect: collect, + params: params, + abort: false + }); + if (inject.abort) + return; + error = false; + } + break; + case 7: + callback = this._csiHandlers[code]; + if (callback) + callback(params, collect); + else + this._csiHandlerFb(collect, params, code); + break; + case 8: + if (code === 0x3b) + params.push(0); + else + params[params.length - 1] = params[params.length - 1] * 10 + code - 48; + break; + case 9: + collect += String.fromCharCode(code); + break; + case 10: + callback = this._escHandlers[collect + String.fromCharCode(code)]; + if (callback) + callback(collect, code); + else + this._escHandlerFb(collect, code); + break; + case 11: + if (~print) { + this._printHandler(data, print, i); + print = -1; + } + osc = ''; + params = [0]; + collect = ''; + dcs = -1; + break; + case 12: + dcsHandler = this._dcsHandlers[collect + String.fromCharCode(code)]; + if (!dcsHandler) + dcsHandler = this._dcsHandlerFb; + dcsHandler.hook(collect, params, code); + break; + case 13: + dcs = (~dcs) ? dcs : i; + break; + case 14: + if (dcsHandler) { + if (~dcs) + dcsHandler.put(data, dcs, i); + dcsHandler.unhook(); + dcsHandler = null; + } + if (code === 0x1b) + transition |= 1; + osc = ''; + params = [0]; + collect = ''; + dcs = -1; + break; + case 4: + if (~print) { + this._printHandler(data, print, i); + print = -1; + } + osc = ''; + break; + case 5: + osc += data.charAt(i); + break; + case 6: + if (osc && code !== 0x18 && code !== 0x1a) { + var idx = osc.indexOf(';'); + if (idx === -1) { + this._oscHandlerFb(-1, osc); + } + else { + var identifier = parseInt(osc.substring(0, idx)); + var content = osc.substring(idx + 1); + callback = this._oscHandlers[identifier]; + if (callback) + callback(content); + else + this._oscHandlerFb(identifier, content); + } + } + if (code === 0x1b) + transition |= 1; + osc = ''; + params = [0]; + collect = ''; + dcs = -1; + break; + } + currentState = transition & 15; + } + if (currentState === 0 && ~print) { + this._printHandler(data, print, data.length); + } + else if (currentState === 13 && ~dcs && dcsHandler) { + dcsHandler.put(data, dcs, data.length); + } + this._osc = osc; + this._collect = collect; + this._params = params; + this._activeDcsHandler = dcsHandler; + this.currentState = currentState; + }; + return EscapeSequenceParser; +}(Lifecycle_1.Disposable)); +exports.EscapeSequenceParser = EscapeSequenceParser; + +},{"./common/Lifecycle":18}],8:[function(require,module,exports){ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var EscapeSequences_1 = require("./common/data/EscapeSequences"); +var Charsets_1 = require("./core/data/Charsets"); +var Buffer_1 = require("./Buffer"); +var CharWidth_1 = require("./CharWidth"); +var EscapeSequenceParser_1 = require("./EscapeSequenceParser"); +var Lifecycle_1 = require("./common/Lifecycle"); +var BufferLine_1 = require("./BufferLine"); +var GLEVEL = { '(': 0, ')': 1, '*': 2, '+': 3, '-': 1, '.': 2 }; +var RequestTerminfo = (function () { + function RequestTerminfo(_terminal) { + this._terminal = _terminal; + } + RequestTerminfo.prototype.hook = function (collect, params, flag) { + this._data = ''; + }; + RequestTerminfo.prototype.put = function (data, start, end) { + this._data += data.substring(start, end); + }; + RequestTerminfo.prototype.unhook = function () { + this._terminal.handler(EscapeSequences_1.C0.ESC + "P0+r" + this._data + EscapeSequences_1.C0.ESC + "\\"); + }; + return RequestTerminfo; +}()); +var DECRQSS = (function () { + function DECRQSS(_terminal) { + this._terminal = _terminal; + } + DECRQSS.prototype.hook = function (collect, params, flag) { + this._data = ''; + }; + DECRQSS.prototype.put = function (data, start, end) { + this._data += data.substring(start, end); + }; + DECRQSS.prototype.unhook = function () { + switch (this._data) { + case '"q': + return this._terminal.handler(EscapeSequences_1.C0.ESC + "P1$r0\"q" + EscapeSequences_1.C0.ESC + "\\"); + case '"p': + return this._terminal.handler(EscapeSequences_1.C0.ESC + "P1$r61\"p" + EscapeSequences_1.C0.ESC + "\\"); + case 'r': + var pt = '' + (this._terminal.buffer.scrollTop + 1) + + ';' + (this._terminal.buffer.scrollBottom + 1) + 'r'; + return this._terminal.handler(EscapeSequences_1.C0.ESC + "P1$r" + pt + EscapeSequences_1.C0.ESC + "\\"); + case 'm': + return this._terminal.handler(EscapeSequences_1.C0.ESC + "P1$r0m" + EscapeSequences_1.C0.ESC + "\\"); + case ' q': + var STYLES = { 'block': 2, 'underline': 4, 'bar': 6 }; + var style = STYLES[this._terminal.getOption('cursorStyle')]; + style -= this._terminal.getOption('cursorBlink'); + return this._terminal.handler(EscapeSequences_1.C0.ESC + "P1$r" + style + " q" + EscapeSequences_1.C0.ESC + "\\"); + default: + this._terminal.error('Unknown DCS $q %s', this._data); + this._terminal.handler(EscapeSequences_1.C0.ESC + "P0$r" + this._data + EscapeSequences_1.C0.ESC + "\\"); + } + }; + return DECRQSS; +}()); +var InputHandler = (function (_super) { + __extends(InputHandler, _super); + function InputHandler(_terminal, _parser) { + if (_parser === void 0) { _parser = new EscapeSequenceParser_1.EscapeSequenceParser(); } + var _this = _super.call(this) || this; + _this._terminal = _terminal; + _this._parser = _parser; + _this.register(_this._parser); + _this._surrogateHigh = ''; + _this._parser.setCsiHandlerFallback(function (collect, params, flag) { + _this._terminal.error('Unknown CSI code: ', { collect: collect, params: params, flag: String.fromCharCode(flag) }); + }); + _this._parser.setEscHandlerFallback(function (collect, flag) { + _this._terminal.error('Unknown ESC code: ', { collect: collect, flag: String.fromCharCode(flag) }); + }); + _this._parser.setExecuteHandlerFallback(function (code) { + _this._terminal.error('Unknown EXECUTE code: ', { code: code }); + }); + _this._parser.setOscHandlerFallback(function (identifier, data) { + _this._terminal.error('Unknown OSC code: ', { identifier: identifier, data: data }); + }); + _this._parser.setPrintHandler(function (data, start, end) { return _this.print(data, start, end); }); + _this._parser.setCsiHandler('@', function (params, collect) { return _this.insertChars(params); }); + _this._parser.setCsiHandler('A', function (params, collect) { return _this.cursorUp(params); }); + _this._parser.setCsiHandler('B', function (params, collect) { return _this.cursorDown(params); }); + _this._parser.setCsiHandler('C', function (params, collect) { return _this.cursorForward(params); }); + _this._parser.setCsiHandler('D', function (params, collect) { return _this.cursorBackward(params); }); + _this._parser.setCsiHandler('E', function (params, collect) { return _this.cursorNextLine(params); }); + _this._parser.setCsiHandler('F', function (params, collect) { return _this.cursorPrecedingLine(params); }); + _this._parser.setCsiHandler('G', function (params, collect) { return _this.cursorCharAbsolute(params); }); + _this._parser.setCsiHandler('H', function (params, collect) { return _this.cursorPosition(params); }); + _this._parser.setCsiHandler('I', function (params, collect) { return _this.cursorForwardTab(params); }); + _this._parser.setCsiHandler('J', function (params, collect) { return _this.eraseInDisplay(params); }); + _this._parser.setCsiHandler('K', function (params, collect) { return _this.eraseInLine(params); }); + _this._parser.setCsiHandler('L', function (params, collect) { return _this.insertLines(params); }); + _this._parser.setCsiHandler('M', function (params, collect) { return _this.deleteLines(params); }); + _this._parser.setCsiHandler('P', function (params, collect) { return _this.deleteChars(params); }); + _this._parser.setCsiHandler('S', function (params, collect) { return _this.scrollUp(params); }); + _this._parser.setCsiHandler('T', function (params, collect) { return _this.scrollDown(params, collect); }); + _this._parser.setCsiHandler('X', function (params, collect) { return _this.eraseChars(params); }); + _this._parser.setCsiHandler('Z', function (params, collect) { return _this.cursorBackwardTab(params); }); + _this._parser.setCsiHandler('`', function (params, collect) { return _this.charPosAbsolute(params); }); + _this._parser.setCsiHandler('a', function (params, collect) { return _this.hPositionRelative(params); }); + _this._parser.setCsiHandler('b', function (params, collect) { return _this.repeatPrecedingCharacter(params); }); + _this._parser.setCsiHandler('c', function (params, collect) { return _this.sendDeviceAttributes(params, collect); }); + _this._parser.setCsiHandler('d', function (params, collect) { return _this.linePosAbsolute(params); }); + _this._parser.setCsiHandler('e', function (params, collect) { return _this.vPositionRelative(params); }); + _this._parser.setCsiHandler('f', function (params, collect) { return _this.hVPosition(params); }); + _this._parser.setCsiHandler('g', function (params, collect) { return _this.tabClear(params); }); + _this._parser.setCsiHandler('h', function (params, collect) { return _this.setMode(params, collect); }); + _this._parser.setCsiHandler('l', function (params, collect) { return _this.resetMode(params, collect); }); + _this._parser.setCsiHandler('m', function (params, collect) { return _this.charAttributes(params); }); + _this._parser.setCsiHandler('n', function (params, collect) { return _this.deviceStatus(params, collect); }); + _this._parser.setCsiHandler('p', function (params, collect) { return _this.softReset(params, collect); }); + _this._parser.setCsiHandler('q', function (params, collect) { return _this.setCursorStyle(params, collect); }); + _this._parser.setCsiHandler('r', function (params, collect) { return _this.setScrollRegion(params, collect); }); + _this._parser.setCsiHandler('s', function (params, collect) { return _this.saveCursor(params); }); + _this._parser.setCsiHandler('u', function (params, collect) { return _this.restoreCursor(params); }); + _this._parser.setExecuteHandler(EscapeSequences_1.C0.BEL, function () { return _this.bell(); }); + _this._parser.setExecuteHandler(EscapeSequences_1.C0.LF, function () { return _this.lineFeed(); }); + _this._parser.setExecuteHandler(EscapeSequences_1.C0.VT, function () { return _this.lineFeed(); }); + _this._parser.setExecuteHandler(EscapeSequences_1.C0.FF, function () { return _this.lineFeed(); }); + _this._parser.setExecuteHandler(EscapeSequences_1.C0.CR, function () { return _this.carriageReturn(); }); + _this._parser.setExecuteHandler(EscapeSequences_1.C0.BS, function () { return _this.backspace(); }); + _this._parser.setExecuteHandler(EscapeSequences_1.C0.HT, function () { return _this.tab(); }); + _this._parser.setExecuteHandler(EscapeSequences_1.C0.SO, function () { return _this.shiftOut(); }); + _this._parser.setExecuteHandler(EscapeSequences_1.C0.SI, function () { return _this.shiftIn(); }); + _this._parser.setExecuteHandler(EscapeSequences_1.C1.IND, function () { return _this.index(); }); + _this._parser.setExecuteHandler(EscapeSequences_1.C1.NEL, function () { return _this.nextLine(); }); + _this._parser.setExecuteHandler(EscapeSequences_1.C1.HTS, function () { return _this.tabSet(); }); + _this._parser.setOscHandler(0, function (data) { return _this.setTitle(data); }); + _this._parser.setOscHandler(2, function (data) { return _this.setTitle(data); }); + _this._parser.setEscHandler('7', function () { return _this.saveCursor([]); }); + _this._parser.setEscHandler('8', function () { return _this.restoreCursor([]); }); + _this._parser.setEscHandler('D', function () { return _this.index(); }); + _this._parser.setEscHandler('E', function () { return _this.nextLine(); }); + _this._parser.setEscHandler('H', function () { return _this.tabSet(); }); + _this._parser.setEscHandler('M', function () { return _this.reverseIndex(); }); + _this._parser.setEscHandler('=', function () { return _this.keypadApplicationMode(); }); + _this._parser.setEscHandler('>', function () { return _this.keypadNumericMode(); }); + _this._parser.setEscHandler('c', function () { return _this.reset(); }); + _this._parser.setEscHandler('n', function () { return _this.setgLevel(2); }); + _this._parser.setEscHandler('o', function () { return _this.setgLevel(3); }); + _this._parser.setEscHandler('|', function () { return _this.setgLevel(3); }); + _this._parser.setEscHandler('}', function () { return _this.setgLevel(2); }); + _this._parser.setEscHandler('~', function () { return _this.setgLevel(1); }); + _this._parser.setEscHandler('%@', function () { return _this.selectDefaultCharset(); }); + _this._parser.setEscHandler('%G', function () { return _this.selectDefaultCharset(); }); + var _loop_1 = function (flag) { + this_1._parser.setEscHandler('(' + flag, function () { return _this.selectCharset('(' + flag); }); + this_1._parser.setEscHandler(')' + flag, function () { return _this.selectCharset(')' + flag); }); + this_1._parser.setEscHandler('*' + flag, function () { return _this.selectCharset('*' + flag); }); + this_1._parser.setEscHandler('+' + flag, function () { return _this.selectCharset('+' + flag); }); + this_1._parser.setEscHandler('-' + flag, function () { return _this.selectCharset('-' + flag); }); + this_1._parser.setEscHandler('.' + flag, function () { return _this.selectCharset('.' + flag); }); + this_1._parser.setEscHandler('/' + flag, function () { return _this.selectCharset('/' + flag); }); + }; + var this_1 = this; + for (var flag in Charsets_1.CHARSETS) { + _loop_1(flag); + } + _this._parser.setErrorHandler(function (state) { + _this._terminal.error('Parsing error: ', state); + return state; + }); + _this._parser.setDcsHandler('$q', new DECRQSS(_this._terminal)); + _this._parser.setDcsHandler('+q', new RequestTerminfo(_this._terminal)); + return _this; + } + InputHandler.prototype.dispose = function () { + _super.prototype.dispose.call(this); + this._terminal = null; + }; + InputHandler.prototype.parse = function (data) { + if (!this._terminal) { + return; + } + var buffer = this._terminal.buffer; + var cursorStartX = buffer.x; + var cursorStartY = buffer.y; + if (this._terminal.debug) { + this._terminal.log('data: ' + data); + } + if (this._surrogateHigh) { + data = this._surrogateHigh + data; + this._surrogateHigh = ''; + } + this._parser.parse(data); + buffer = this._terminal.buffer; + if (buffer.x !== cursorStartX || buffer.y !== cursorStartY) { + this._terminal.emit('cursormove'); + } + }; + InputHandler.prototype.print = function (data, start, end) { + var char; + var code; + var low; + var chWidth; + var buffer = this._terminal.buffer; + var charset = this._terminal.charset; + var screenReaderMode = this._terminal.options.screenReaderMode; + var cols = this._terminal.cols; + var wraparoundMode = this._terminal.wraparoundMode; + var insertMode = this._terminal.insertMode; + var curAttr = this._terminal.curAttr; + var bufferRow = buffer.lines.get(buffer.y + buffer.ybase); + this._terminal.updateRange(buffer.y); + for (var stringPosition = start; stringPosition < end; ++stringPosition) { + char = data.charAt(stringPosition); + code = data.charCodeAt(stringPosition); + if (0xD800 <= code && code <= 0xDBFF) { + low = data.charCodeAt(stringPosition + 1); + if (isNaN(low)) { + this._surrogateHigh = char; + continue; + } + code = ((code - 0xD800) * 0x400) + (low - 0xDC00) + 0x10000; + char += data.charAt(stringPosition + 1); + } + if (0xDC00 <= code && code <= 0xDFFF) { + continue; + } + chWidth = CharWidth_1.wcwidth(code); + if (charset) { + char = charset[char] || char; + code = char.charCodeAt(0); + } + if (screenReaderMode) { + this._terminal.emit('a11y.char', char); + } + if (!chWidth && buffer.x) { + var chMinusOne = bufferRow.get(buffer.x - 1); + if (chMinusOne) { + if (!chMinusOne[Buffer_1.CHAR_DATA_WIDTH_INDEX]) { + var chMinusTwo = bufferRow.get(buffer.x - 2); + if (chMinusTwo) { + chMinusTwo[Buffer_1.CHAR_DATA_CHAR_INDEX] += char; + chMinusTwo[Buffer_1.CHAR_DATA_CODE_INDEX] = code; + } + } + else { + chMinusOne[Buffer_1.CHAR_DATA_CHAR_INDEX] += char; + chMinusOne[Buffer_1.CHAR_DATA_CODE_INDEX] = code; + } + } + continue; + } + if (buffer.x + chWidth - 1 >= cols) { + if (wraparoundMode) { + buffer.x = 0; + buffer.y++; + if (buffer.y > buffer.scrollBottom) { + buffer.y--; + this._terminal.scroll(true); + } + else { + buffer.lines.get(buffer.y).isWrapped = true; + } + bufferRow = buffer.lines.get(buffer.y + buffer.ybase); + } + else { + if (chWidth === 2) { + continue; + } + } + } + if (insertMode) { + for (var moves = 0; moves < chWidth; ++moves) { + var removed = bufferRow.pop(); + var chMinusTwo = bufferRow.get(buffer.x - 2); + if (removed[Buffer_1.CHAR_DATA_WIDTH_INDEX] === 0 + && chMinusTwo + && chMinusTwo[Buffer_1.CHAR_DATA_WIDTH_INDEX] === 2) { + bufferRow.set(this._terminal.cols - 2, [curAttr, Buffer_1.NULL_CELL_CHAR, Buffer_1.NULL_CELL_WIDTH, Buffer_1.NULL_CELL_CODE]); + } + bufferRow.splice(buffer.x, 0, [curAttr, Buffer_1.NULL_CELL_CHAR, Buffer_1.NULL_CELL_WIDTH, Buffer_1.NULL_CELL_CODE]); + } + } + bufferRow.set(buffer.x++, [curAttr, char, chWidth, code]); + if (chWidth === 2) { + bufferRow.set(buffer.x++, [curAttr, '', 0, undefined]); + } + } + this._terminal.updateRange(buffer.y); + }; + InputHandler.prototype.bell = function () { + this._terminal.bell(); + }; + InputHandler.prototype.lineFeed = function () { + var buffer = this._terminal.buffer; + if (this._terminal.options.convertEol) { + buffer.x = 0; + } + buffer.y++; + if (buffer.y > buffer.scrollBottom) { + buffer.y--; + this._terminal.scroll(); + } + if (buffer.x >= this._terminal.cols) { + buffer.x--; + } + this._terminal.emit('linefeed'); + }; + InputHandler.prototype.carriageReturn = function () { + this._terminal.buffer.x = 0; + }; + InputHandler.prototype.backspace = function () { + if (this._terminal.buffer.x > 0) { + this._terminal.buffer.x--; + } + }; + InputHandler.prototype.tab = function () { + var originalX = this._terminal.buffer.x; + this._terminal.buffer.x = this._terminal.buffer.nextStop(); + if (this._terminal.options.screenReaderMode) { + this._terminal.emit('a11y.tab', this._terminal.buffer.x - originalX); + } + }; + InputHandler.prototype.shiftOut = function () { + this._terminal.setgLevel(1); + }; + InputHandler.prototype.shiftIn = function () { + this._terminal.setgLevel(0); + }; + InputHandler.prototype.insertChars = function (params) { + this._terminal.buffer.lines.get(this._terminal.buffer.y + this._terminal.buffer.ybase).insertCells(this._terminal.buffer.x, params[0] || 1, [this._terminal.eraseAttr(), Buffer_1.NULL_CELL_CHAR, Buffer_1.NULL_CELL_WIDTH, Buffer_1.NULL_CELL_CODE]); + this._terminal.updateRange(this._terminal.buffer.y); + }; + InputHandler.prototype.cursorUp = function (params) { + var param = params[0]; + if (param < 1) { + param = 1; + } + this._terminal.buffer.y -= param; + if (this._terminal.buffer.y < 0) { + this._terminal.buffer.y = 0; + } + }; + InputHandler.prototype.cursorDown = function (params) { + var param = params[0]; + if (param < 1) { + param = 1; + } + this._terminal.buffer.y += param; + if (this._terminal.buffer.y >= this._terminal.rows) { + this._terminal.buffer.y = this._terminal.rows - 1; + } + if (this._terminal.buffer.x >= this._terminal.cols) { + this._terminal.buffer.x--; + } + }; + InputHandler.prototype.cursorForward = function (params) { + var param = params[0]; + if (param < 1) { + param = 1; + } + this._terminal.buffer.x += param; + if (this._terminal.buffer.x >= this._terminal.cols) { + this._terminal.buffer.x = this._terminal.cols - 1; + } + }; + InputHandler.prototype.cursorBackward = function (params) { + var param = params[0]; + if (param < 1) { + param = 1; + } + if (this._terminal.buffer.x >= this._terminal.cols) { + this._terminal.buffer.x--; + } + this._terminal.buffer.x -= param; + if (this._terminal.buffer.x < 0) { + this._terminal.buffer.x = 0; + } + }; + InputHandler.prototype.cursorNextLine = function (params) { + var param = params[0]; + if (param < 1) { + param = 1; + } + this._terminal.buffer.y += param; + if (this._terminal.buffer.y >= this._terminal.rows) { + this._terminal.buffer.y = this._terminal.rows - 1; + } + this._terminal.buffer.x = 0; + }; + InputHandler.prototype.cursorPrecedingLine = function (params) { + var param = params[0]; + if (param < 1) { + param = 1; + } + this._terminal.buffer.y -= param; + if (this._terminal.buffer.y < 0) { + this._terminal.buffer.y = 0; + } + this._terminal.buffer.x = 0; + }; + InputHandler.prototype.cursorCharAbsolute = function (params) { + var param = params[0]; + if (param < 1) { + param = 1; + } + this._terminal.buffer.x = param - 1; + }; + InputHandler.prototype.cursorPosition = function (params) { + var col; + var row = params[0] - 1; + if (params.length >= 2) { + col = params[1] - 1; + } + else { + col = 0; + } + if (row < 0) { + row = 0; + } + else if (row >= this._terminal.rows) { + row = this._terminal.rows - 1; + } + if (col < 0) { + col = 0; + } + else if (col >= this._terminal.cols) { + col = this._terminal.cols - 1; + } + this._terminal.buffer.x = col; + this._terminal.buffer.y = row; + }; + InputHandler.prototype.cursorForwardTab = function (params) { + var param = params[0] || 1; + while (param--) { + this._terminal.buffer.x = this._terminal.buffer.nextStop(); + } + }; + InputHandler.prototype._eraseInBufferLine = function (y, start, end) { + this._terminal.buffer.lines.get(this._terminal.buffer.ybase + y).replaceCells(start, end, [this._terminal.eraseAttr(), Buffer_1.NULL_CELL_CHAR, Buffer_1.NULL_CELL_WIDTH, Buffer_1.NULL_CELL_CODE]); + }; + InputHandler.prototype.eraseInDisplay = function (params) { + var j; + switch (params[0]) { + case 0: + j = this._terminal.buffer.y; + this._terminal.updateRange(j); + this._eraseInBufferLine(j++, this._terminal.buffer.x, this._terminal.cols); + for (; j < this._terminal.rows; j++) { + this._eraseInBufferLine(j, 0, this._terminal.cols); + } + this._terminal.updateRange(j); + break; + case 1: + j = this._terminal.buffer.y; + this._terminal.updateRange(j); + this._eraseInBufferLine(j, 0, this._terminal.buffer.x + 1); + while (j--) { + this._eraseInBufferLine(j, 0, this._terminal.cols); + } + this._terminal.updateRange(0); + break; + case 2: + j = this._terminal.rows; + this._terminal.updateRange(j - 1); + while (j--) { + this._eraseInBufferLine(j, 0, this._terminal.cols); + } + this._terminal.updateRange(0); + break; + case 3: + var scrollBackSize = this._terminal.buffer.lines.length - this._terminal.rows; + if (scrollBackSize > 0) { + this._terminal.buffer.lines.trimStart(scrollBackSize); + this._terminal.buffer.ybase = Math.max(this._terminal.buffer.ybase - scrollBackSize, 0); + this._terminal.buffer.ydisp = Math.max(this._terminal.buffer.ydisp - scrollBackSize, 0); + this._terminal.emit('scroll', 0); + } + break; + } + }; + InputHandler.prototype.eraseInLine = function (params) { + switch (params[0]) { + case 0: + this._eraseInBufferLine(this._terminal.buffer.y, this._terminal.buffer.x, this._terminal.cols); + break; + case 1: + this._eraseInBufferLine(this._terminal.buffer.y, 0, this._terminal.buffer.x + 1); + break; + case 2: + this._eraseInBufferLine(this._terminal.buffer.y, 0, this._terminal.cols); + break; + } + this._terminal.updateRange(this._terminal.buffer.y); + }; + InputHandler.prototype.insertLines = function (params) { + var param = params[0]; + if (param < 1) { + param = 1; + } + var buffer = this._terminal.buffer; + var row = buffer.y + buffer.ybase; + var scrollBottomRowsOffset = this._terminal.rows - 1 - buffer.scrollBottom; + var scrollBottomAbsolute = this._terminal.rows - 1 + buffer.ybase - scrollBottomRowsOffset + 1; + while (param--) { + buffer.lines.splice(scrollBottomAbsolute - 1, 1); + buffer.lines.splice(row, 0, BufferLine_1.BufferLine.blankLine(this._terminal.cols, this._terminal.eraseAttr())); + } + th
<TRUNCATED> --------------------------------------------------------------------- To unsubscribe, e-mail: common-commits-unsubscr...@hadoop.apache.org For additional commands, e-mail: common-commits-h...@hadoop.apache.org