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

xterm

Package Overview
Dependencies
Maintainers
2
Versions
1092
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

xterm - npm Package Compare versions

Comparing version 3.8.0 to 3.9.0

lib/common/TypedArrayUtils.js

6

lib/AccessibilityManager.js

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

var Strings = require("./Strings");
var Browser_1 = require("./shared/utils/Browser");
var Platform_1 = require("./core/Platform");
var RenderDebouncer_1 = require("./ui/RenderDebouncer");

@@ -155,3 +155,3 @@ var Lifecycle_1 = require("./ui/Lifecycle");

}
if (Browser_1.isMac) {
if (Platform_1.isMac) {
if (this._liveRegion.textContent && this._liveRegion.textContent.length > 0 && !this._liveRegion.parentNode) {

@@ -168,3 +168,3 @@ setTimeout(function () {

this._liveRegionLineCount = 0;
if (Browser_1.isMac) {
if (Platform_1.isMac) {
if (this._liveRegion.parentNode) {

@@ -171,0 +171,0 @@ this._accessibilityTreeRoot.removeChild(this._liveRegion);

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

/// <reference types="../.." />
import { Terminal } from 'xterm';

@@ -2,0 +3,0 @@ export interface IGeometry {

@@ -0,3 +1,4 @@

/// <reference types="../.." />
import { Terminal } from 'xterm';
export declare function toggleFullScreen(term: Terminal, fullscreen: boolean): void;
export declare function apply(terminalConstructor: typeof Terminal): void;

@@ -6,11 +6,12 @@ "use strict";

if (typeof fullscreen === 'undefined') {
fn = (term.element.classList.contains('fullscreen')) ? 'remove' : 'add';
fn = (term.element.classList.contains('fullscreen')) ?
term.element.classList.remove : term.element.classList.add;
}
else if (!fullscreen) {
fn = 'remove';
fn = term.element.classList.remove;
}
else {
fn = 'add';
fn = term.element.classList.add;
}
term.element.classList[fn]('fullscreen');
fn('fullscreen');
}

@@ -17,0 +18,0 @@ exports.toggleFullScreen = toggleFullScreen;

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

/// <reference types="../.." />
import { Terminal } from 'xterm';

@@ -2,0 +3,0 @@ export interface ITerminalCore {

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

/// <reference types="../.." />
import { Terminal } from 'xterm';

@@ -2,0 +3,0 @@ import { ISearchOptions } from './Interfaces';

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var nonWordCharacters = ' ~!@#$%^&*()_+`-=[]{}|\;:"\',./<>?';
var nonWordCharacters = ' ~!@#$%^&*()+`-=[]{}|\;:"\',./<>?';
var SearchHelper = (function () {

@@ -15,3 +15,5 @@ function SearchHelper(_terminal) {

if (this._terminal._core.selectionManager.selectionEnd) {
startRow = this._terminal._core.selectionManager.selectionEnd[1];
if (this._terminal.getSelection().length !== 0) {
startRow = this._terminal._core.selectionManager.selectionEnd[1];
}
}

@@ -41,3 +43,5 @@ for (var y = startRow + 1; y < this._terminal._core.buffer.ybase + this._terminal.rows; y++) {

if (this._terminal._core.selectionManager.selectionStart) {
startRow = this._terminal._core.selectionManager.selectionStart[1];
if (this._terminal.getSelection().length !== 0) {
startRow = this._terminal._core.selectionManager.selectionStart[1];
}
}

@@ -117,3 +121,3 @@ for (var y = startRow - 1; y >= 0; y--) {

lineWrapsToNext = nextLine ? nextLine.isWrapped : false;
lineString += this._terminal._core.buffer.translateBufferLineToString(lineIndex, !lineWrapsToNext && trimRight);
lineString += this._terminal._core.buffer.translateBufferLineToString(lineIndex, !lineWrapsToNext && trimRight).substring(0, this._terminal.cols);
lineIndex++;

@@ -125,2 +129,3 @@ } while (lineWrapsToNext);

if (!result) {
this._terminal.clearSelection();
return false;

@@ -127,0 +132,0 @@ }

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

/// <reference types="../.." />
import { Terminal } from 'xterm';

@@ -2,0 +3,0 @@ export interface ITerminadoAddonTerminal extends Terminal {

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

/// <reference types="../.." />
import { Terminal } from 'xterm';

@@ -2,0 +3,0 @@ export declare function terminadoAttach(term: Terminal, socket: WebSocket, bidirectional: boolean, buffered: boolean): void;

@@ -0,3 +1,4 @@

/// <reference types="../.." />
import { Terminal, ILinkMatcherOptions } from 'xterm';
export declare function webLinksInit(term: Terminal, handler?: (event: MouseEvent, uri: string) => void, options?: ILinkMatcherOptions): void;
export declare function apply(terminalConstructor: typeof Terminal): void;

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

var hostClause = '((' + domainBodyClause + '\\.' + tldClause + ')|' + ipClause + '|' + localHostClause + ')' + portClause + '?';
var pathClause = '(\\/[\\/\\w\\.\\-%~]*)*';
var pathClause = '(\\/[\\/\\w\\.\\-%~:]*)*([^:\\s])';
var queryStringHashFragmentCharacterSet = '[0-9\\w\\[\\]\\(\\)\\/\\?\\!#@$%&\'*+,:;~\\=\\.\\-]*';

@@ -15,0 +15,0 @@ var queryStringClause = '(\\?' + queryStringHashFragmentCharacterSet + ')?';

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

/// <reference types="../.." />
import { Terminal } from 'xterm';

@@ -2,0 +3,0 @@ export interface ITerminalCore {

@@ -0,3 +1,4 @@

/// <reference types="../.." />
import { Terminal } from 'xterm';
export declare function winptyCompatInit(terminal: Terminal): void;
export declare function apply(terminalConstructor: typeof Terminal): void;

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

/// <reference types="../.." />
import { Terminal } from 'xterm';

@@ -2,0 +3,0 @@ export interface IZmodemOptions {

@@ -19,3 +19,4 @@ "use strict";

var BufferLine_1 = require("./BufferLine");
exports.DEFAULT_ATTR = (0 << 18) | (257 << 9) | (256 << 0);
var Types_1 = require("./renderer/atlas/Types");
exports.DEFAULT_ATTR = (0 << 18) | (Types_1.DEFAULT_COLOR << 9) | (256 << 0);
exports.CHAR_DATA_ATTR_INDEX = 0;

@@ -36,2 +37,32 @@ exports.CHAR_DATA_CHAR_INDEX = 1;

}
Buffer.prototype.setBufferLineFactory = function (type) {
if (type === 'JsArray') {
if (this._bufferLineConstructor !== BufferLine_1.BufferLineJSArray) {
this._bufferLineConstructor = BufferLine_1.BufferLineJSArray;
this._recreateLines();
}
}
else {
if (this._bufferLineConstructor !== BufferLine_1.BufferLine) {
this._bufferLineConstructor = BufferLine_1.BufferLine;
this._recreateLines();
}
}
};
Buffer.prototype._recreateLines = function () {
if (!this.lines)
return;
for (var i = 0; i < this.lines.length; ++i) {
var oldLine = this.lines.get(i);
var newLine = new this._bufferLineConstructor(oldLine.length);
for (var j = 0; j < oldLine.length; ++j) {
newLine.set(j, oldLine.get(j));
}
this.lines.set(i, newLine);
}
};
Buffer.prototype.getBlankLine = function (attr, isWrapped) {
var fillCharData = [attr, exports.NULL_CELL_CHAR, exports.NULL_CELL_WIDTH, exports.NULL_CELL_CODE];
return new this._bufferLineConstructor(this._terminal.cols, fillCharData, isWrapped);
};
Object.defineProperty(Buffer.prototype, "hasScrollback", {

@@ -60,7 +91,10 @@ get: function () {

};
Buffer.prototype.fillViewportRows = function () {
Buffer.prototype.fillViewportRows = function (fillAttr) {
if (this.lines.length === 0) {
if (fillAttr === undefined) {
fillAttr = exports.DEFAULT_ATTR;
}
var i = this._terminal.rows;
while (i--) {
this.lines.push(BufferLine_1.BufferLine.blankLine(this._terminal.cols, exports.DEFAULT_ATTR));
this.lines.push(this.getBlankLine(fillAttr));
}

@@ -70,2 +104,3 @@ }

Buffer.prototype.clear = function () {
this.setBufferLineFactory(this._terminal.options.experimentalBufferLineImpl);
this.ydisp = 0;

@@ -89,5 +124,3 @@ this.ybase = 0;

for (var i = 0; i < this.lines.length; i++) {
while (this.lines.get(i).length < newCols) {
this.lines.get(i).push(ch);
}
this.lines.get(i).resize(newCols, ch);
}

@@ -107,3 +140,4 @@ }

else {
this.lines.push(BufferLine_1.BufferLine.blankLine(newCols, exports.DEFAULT_ATTR));
var fillCharData = [exports.DEFAULT_ATTR, exports.NULL_CELL_CHAR, exports.NULL_CELL_WIDTH, exports.NULL_CELL_CODE];
this.lines.push(new this._bufferLineConstructor(newCols, fillCharData));
}

@@ -110,0 +144,0 @@ }

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Buffer_1 = require("./Buffer");
var BufferLine = (function () {
function BufferLine(cols, ch, isWrapped) {
var BufferLineJSArray = (function () {
function BufferLineJSArray(cols, fillCharData, 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 (!fillCharData) {
fillCharData = [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(fillCharData);
}
if (isWrapped) {
this.isWrapped = true;
}
this.length = this._data.length;
}
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 () {
BufferLineJSArray.prototype._pop = function () {
var data = this._data.pop();

@@ -36,7 +24,7 @@ this.length = this._data.length;

};
BufferLine.prototype.push = function (data) {
BufferLineJSArray.prototype._push = function (data) {
this._data.push(data);
this.length = this._data.length;
};
BufferLine.prototype.splice = function (start, deleteCount) {
BufferLineJSArray.prototype._splice = function (start, deleteCount) {
var items = [];

@@ -51,19 +39,196 @@ for (var _i = 2; _i < arguments.length; _i++) {

};
BufferLine.prototype.insertCells = function (pos, n, ch) {
BufferLineJSArray.prototype.get = function (index) {
return this._data[index];
};
BufferLineJSArray.prototype.set = function (index, data) {
this._data[index] = data;
};
BufferLineJSArray.prototype.insertCells = function (pos, n, ch) {
while (n--) {
this.splice(pos, 0, ch);
this.pop();
this._splice(pos, 0, ch);
this._pop();
}
};
BufferLine.prototype.deleteCells = function (pos, n, fill) {
BufferLineJSArray.prototype.deleteCells = function (pos, n, fillCharData) {
while (n--) {
this.splice(pos, 1);
this.push(fill);
this._splice(pos, 1);
this._push(fillCharData);
}
};
BufferLine.prototype.replaceCells = function (start, end, fill) {
BufferLineJSArray.prototype.replaceCells = function (start, end, fillCharData) {
while (start < end && start < this.length) {
this.set(start++, fill);
this.set(start++, fillCharData);
}
};
BufferLineJSArray.prototype.resize = function (cols, fillCharData, shrink) {
if (shrink === void 0) { shrink = false; }
while (this._data.length < cols) {
this._data.push(fillCharData);
}
if (shrink) {
while (this._data.length > cols) {
this._data.pop();
}
}
this.length = this._data.length;
};
BufferLineJSArray.prototype.fill = function (fillCharData) {
for (var i = 0; i < this.length; ++i) {
this.set(i, fillCharData);
}
};
BufferLineJSArray.prototype.copyFrom = function (line) {
this._data = line._data.slice(0);
this.length = line.length;
this.isWrapped = line.isWrapped;
};
BufferLineJSArray.prototype.clone = function () {
var newLine = new BufferLineJSArray(0);
newLine.copyFrom(this);
return newLine;
};
return BufferLineJSArray;
}());
exports.BufferLineJSArray = BufferLineJSArray;
var CELL_SIZE = 3;
var BufferLine = (function () {
function BufferLine(cols, fillCharData, isWrapped) {
if (isWrapped === void 0) { isWrapped = false; }
this.isWrapped = isWrapped;
this._data = null;
this._combined = {};
if (!fillCharData) {
fillCharData = [0, Buffer_1.NULL_CELL_CHAR, Buffer_1.NULL_CELL_WIDTH, Buffer_1.NULL_CELL_CODE];
}
if (cols) {
this._data = new Uint32Array(cols * CELL_SIZE);
for (var i = 0; i < cols; ++i) {
this.set(i, fillCharData);
}
}
this.length = cols;
}
BufferLine.prototype.get = function (index) {
var stringData = this._data[index * CELL_SIZE + 1];
return [
this._data[index * CELL_SIZE + 0],
(stringData & 0x80000000)
? this._combined[index]
: (stringData) ? String.fromCharCode(stringData) : '',
this._data[index * CELL_SIZE + 2],
(stringData & 0x80000000)
? this._combined[index].charCodeAt(this._combined[index].length - 1)
: stringData
];
};
BufferLine.prototype.set = function (index, value) {
this._data[index * CELL_SIZE + 0] = value[0];
if (value[1].length > 1) {
this._combined[index] = value[1];
this._data[index * CELL_SIZE + 1] = index | 0x80000000;
}
else {
this._data[index * CELL_SIZE + 1] = value[1].charCodeAt(0);
}
this._data[index * CELL_SIZE + 2] = value[2];
};
BufferLine.prototype.insertCells = function (pos, n, fillCharData) {
pos %= this.length;
if (n < this.length - pos) {
for (var i = this.length - pos - n - 1; i >= 0; --i) {
this.set(pos + n + i, this.get(pos + i));
}
for (var i = 0; i < n; ++i) {
this.set(pos + i, fillCharData);
}
}
else {
for (var i = pos; i < this.length; ++i) {
this.set(i, fillCharData);
}
}
};
BufferLine.prototype.deleteCells = function (pos, n, fillCharData) {
pos %= this.length;
if (n < this.length - pos) {
for (var i = 0; i < this.length - pos - n; ++i) {
this.set(pos + i, this.get(pos + n + i));
}
for (var i = this.length - n; i < this.length; ++i) {
this.set(i, fillCharData);
}
}
else {
for (var i = pos; i < this.length; ++i) {
this.set(i, fillCharData);
}
}
};
BufferLine.prototype.replaceCells = function (start, end, fillCharData) {
while (start < end && start < this.length) {
this.set(start++, fillCharData);
}
};
BufferLine.prototype.resize = function (cols, fillCharData, shrink) {
if (shrink === void 0) { shrink = false; }
if (cols === this.length || (!shrink && cols < this.length)) {
return;
}
if (cols > this.length) {
var data = new Uint32Array(cols * CELL_SIZE);
if (this.length) {
if (cols * CELL_SIZE < this._data.length) {
data.set(this._data.subarray(0, cols * CELL_SIZE));
}
else {
data.set(this._data);
}
}
this._data = data;
for (var i = this.length; i < cols; ++i) {
this.set(i, fillCharData);
}
}
else if (shrink) {
if (cols) {
var data = new Uint32Array(cols * CELL_SIZE);
data.set(this._data.subarray(0, cols * CELL_SIZE));
this._data = data;
}
else {
this._data = null;
}
}
this.length = cols;
};
BufferLine.prototype.fill = function (fillCharData) {
this._combined = {};
for (var i = 0; i < this.length; ++i) {
this.set(i, fillCharData);
}
};
BufferLine.prototype.copyFrom = function (line) {
if (this.length !== line.length) {
this._data = new Uint32Array(line._data);
}
else {
this._data.set(line._data);
}
this.length = line.length;
this._combined = {};
for (var el in line._combined) {
this._combined[el] = line._combined[el];
}
this.isWrapped = line.isWrapped;
};
BufferLine.prototype.clone = function () {
var newLine = new BufferLine(0);
newLine._data = new Uint32Array(this._data);
newLine.length = this.length;
for (var el in this._combined) {
newLine._combined[el] = this._combined[el];
}
newLine.isWrapped = this.isWrapped;
return newLine;
};
return BufferLine;

@@ -70,0 +235,0 @@ }());

@@ -55,2 +55,4 @@ "use strict";

}
this._normal.x = this._alt.x;
this._normal.y = this._alt.y;
this._alt.clear();

@@ -63,7 +65,9 @@ this._activeBuffer = this._normal;

};
BufferSet.prototype.activateAltBuffer = function () {
BufferSet.prototype.activateAltBuffer = function (fillAttr) {
if (this._activeBuffer === this._alt) {
return;
}
this._alt.fillViewportRows();
this._alt.fillViewportRows(fillAttr);
this._alt.x = this._normal.x;
this._alt.y = this._normal.y;
this._activeBuffer = this._alt;

@@ -70,0 +74,0 @@ this.emit('activate', {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var TypedArrayUtils_1 = require("./common/TypedArrayUtils");
exports.wcwidth = (function (opts) {

@@ -77,29 +78,2 @@ var COMBINING_BMP = [

}
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) {

@@ -115,24 +89,22 @@ if (bisearch(ucs, COMBINING_HIGH)) {

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;
var table = new Uint8Array(65536);
TypedArrayUtils_1.fill(table, 1);
table[0] = opts.nul;
TypedArrayUtils_1.fill(table, opts.control, 1, 32);
TypedArrayUtils_1.fill(table, opts.control, 0x7f, 0xa0);
TypedArrayUtils_1.fill(table, 2, 0x1100, 0x1160);
table[0x2329] = 2;
table[0x232a] = 2;
TypedArrayUtils_1.fill(table, 2, 0x2e80, 0xa4d0);
table[0x303f] = 1;
TypedArrayUtils_1.fill(table, 2, 0xac00, 0xd7a4);
TypedArrayUtils_1.fill(table, 2, 0xf900, 0xfb00);
TypedArrayUtils_1.fill(table, 2, 0xfe10, 0xfe1a);
TypedArrayUtils_1.fill(table, 2, 0xfe30, 0xfe70);
TypedArrayUtils_1.fill(table, 2, 0xff00, 0xff61);
TypedArrayUtils_1.fill(table, 2, 0xffe0, 0xffe7);
for (var r = 0; r < COMBINING_BMP.length; ++r) {
TypedArrayUtils_1.fill(table, 0, COMBINING_BMP[r][0], COMBINING_BMP[r][1] + 1);
}
return function (num) {
num = num | 0;
if (num < 32) {

@@ -144,5 +116,4 @@ return control | 0;

}
var t = table || initTable();
if (num < 65536) {
return t[num >> 4] >> ((num & 15) << 1) & 3;
return table[num];
}

@@ -154,14 +125,17 @@ return wcwidthHigh(num);

var result = 0;
for (var i = 0; i < s.length; ++i) {
var length = s.length;
for (var i = 0; i < length; ++i) {
var code = s.charCodeAt(i);
if (0xD800 <= code && code <= 0xDBFF) {
var low = s.charCodeAt(i + 1);
if (isNaN(low)) {
return result;
if (++i >= length) {
return result + exports.wcwidth(code);
}
code = ((code - 0xD800) * 0x400) + (low - 0xDC00) + 0x10000;
var second = s.charCodeAt(i);
if (0xDC00 <= second && second <= 0xDFFF) {
code = (code - 0xD800) * 0x400 + second - 0xDC00 + 0x10000;
}
else {
result += exports.wcwidth(second);
}
}
if (0xDC00 <= code && code <= 0xDFFF) {
continue;
}
result += exports.wcwidth(code);

@@ -168,0 +142,0 @@ }

@@ -70,6 +70,3 @@ "use strict";

if (this._length === this._maxLength) {
this._startIndex++;
if (this._startIndex === this._maxLength) {
this._startIndex = 0;
}
this._startIndex = ++this._startIndex % this._maxLength;
this.emit('trim', 1);

@@ -81,2 +78,17 @@ }

};
CircularList.prototype.recycle = function () {
if (this._length !== this._maxLength) {
throw new Error('Can only recycle when the buffer is full');
}
this._startIndex = ++this._startIndex % this._maxLength;
this.emit('trim', 1);
return this._array[this._getCyclicIndex(this._length - 1)];
};
Object.defineProperty(CircularList.prototype, "isFull", {
get: function () {
return this._length === this._maxLength;
},
enumerable: true,
configurable: true
});
CircularList.prototype.pop = function () {

@@ -103,6 +115,6 @@ return this._array[this._getCyclicIndex(this._length-- - 1)];

}
if (this._length + items.length > this.maxLength) {
var countToTrim = (this._length + items.length) - this.maxLength;
if (this._length + items.length > this._maxLength) {
var countToTrim = (this._length + items.length) - this._maxLength;
this._startIndex += countToTrim;
this._length = this.maxLength;
this._length = this._maxLength;
this.emit('trim', countToTrim);

@@ -140,3 +152,3 @@ }

this._length += expandListBy;
while (this._length > this.maxLength) {
while (this._length > this._maxLength) {
this._length--;

@@ -155,3 +167,3 @@ this._startIndex++;

CircularList.prototype._getCyclicIndex = function (index) {
return (this._startIndex + index) % this.maxLength;
return (this._startIndex + index) % this._maxLength;
};

@@ -158,0 +170,0 @@ return CircularList;

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

EXECUTABLES.push(0x19);
EXECUTABLES.concat(r(0x1c, 0x20));
EXECUTABLES.push.apply(EXECUTABLES, r(0x1c, 0x20));
var DEFAULT_TRANSITION = 1 << 4 | 0;

@@ -183,2 +183,3 @@ exports.VT500_TRANSITION_TABLE = (function () {

_this._errorHandler = _this._errorHandlerFb;
_this.setEscHandler('\\', function () { });
return _this;

@@ -185,0 +186,0 @@ }

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

this._startRow = this._terminal.buffer.y;
var coordinates = this._terminal.mouseHelper.getCoords(this._mouseEvent, this._terminal.element, this._terminal.charMeasure, this._terminal.options.lineHeight, this._terminal.cols, this._terminal.rows, false);
var coordinates = this._terminal.mouseHelper.getCoords(this._mouseEvent, this._terminal.element, this._terminal.charMeasure, this._terminal.cols, this._terminal.rows, false);
if (coordinates) {

@@ -15,0 +15,0 @@ _a = coordinates.map(function (coordinate) {

@@ -22,3 +22,2 @@ "use strict";

var Lifecycle_1 = require("./common/Lifecycle");
var BufferLine_1 = require("./BufferLine");
var GLEVEL = { '(': 0, ')': 1, '*': 2, '+': 3, '-': 1, '.': 2 };

@@ -82,3 +81,3 @@ var RequestTerminfo = (function () {

_this.register(_this._parser);
_this._surrogateHigh = '';
_this._surrogateFirst = '';
_this._parser.setCsiHandlerFallback(function (collect, params, flag) {

@@ -198,5 +197,5 @@ _this._terminal.error('Unknown CSI code: ', { collect: collect, params: params, flag: String.fromCharCode(flag) });

}
if (this._surrogateHigh) {
data = this._surrogateHigh + data;
this._surrogateHigh = '';
if (this._surrogateFirst) {
data = this._surrogateFirst + data;
this._surrogateFirst = '';
}

@@ -212,3 +211,2 @@ this._parser.parse(data);

var code;
var low;
var chWidth;

@@ -228,13 +226,15 @@ var buffer = this._terminal.buffer;

if (0xD800 <= code && code <= 0xDBFF) {
low = data.charCodeAt(stringPosition + 1);
if (isNaN(low)) {
this._surrogateHigh = char;
if (++stringPosition >= end) {
this._surrogateFirst = char;
continue;
}
code = ((code - 0xD800) * 0x400) + (low - 0xDC00) + 0x10000;
char += data.charAt(stringPosition + 1);
var second = data.charCodeAt(stringPosition);
if (0xDC00 <= second && second <= 0xDFFF) {
code = (code - 0xD800) * 0x400 + second - 0xDC00 + 0x10000;
char += data.charAt(stringPosition);
}
else {
stringPosition--;
}
}
if (0xDC00 <= code && code <= 0xDFFF) {
continue;
}
chWidth = CharWidth_1.wcwidth(code);

@@ -256,2 +256,3 @@ if (charset) {

chMinusTwo[Buffer_1.CHAR_DATA_CODE_INDEX] = code;
bufferRow.set(buffer.x - 2, chMinusTwo);
}

@@ -262,2 +263,3 @@ }

chMinusOne[Buffer_1.CHAR_DATA_CODE_INDEX] = code;
bufferRow.set(buffer.x - 1, chMinusOne);
}

@@ -287,16 +289,13 @@ }

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.insertCells(buffer.x, chWidth, [curAttr, Buffer_1.NULL_CELL_CHAR, Buffer_1.NULL_CELL_WIDTH, Buffer_1.NULL_CELL_CODE]);
var lastCell = bufferRow.get(cols - 1);
if (lastCell[Buffer_1.CHAR_DATA_WIDTH_INDEX] === 2) {
bufferRow.set(cols - 1, [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]);
if (chWidth > 0) {
while (--chWidth) {
bufferRow.set(buffer.x++, [curAttr, '', 0, undefined]);
}
}

@@ -454,5 +453,13 @@ }

};
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._eraseInBufferLine = function (y, start, end, clearWrap) {
if (clearWrap === void 0) { clearWrap = false; }
var line = this._terminal.buffer.lines.get(this._terminal.buffer.ybase + y);
line.replaceCells(start, end, [this._terminal.eraseAttr(), Buffer_1.NULL_CELL_CHAR, Buffer_1.NULL_CELL_WIDTH, Buffer_1.NULL_CELL_CODE]);
if (clearWrap) {
line.isWrapped = false;
}
};
InputHandler.prototype._resetBufferLine = function (y) {
this._eraseInBufferLine(y, 0, this._terminal.cols, true);
};
InputHandler.prototype.eraseInDisplay = function (params) {

@@ -464,5 +471,5 @@ var j;

this._terminal.updateRange(j);
this._eraseInBufferLine(j++, this._terminal.buffer.x, this._terminal.cols);
this._eraseInBufferLine(j++, this._terminal.buffer.x, this._terminal.cols, this._terminal.buffer.x === 0);
for (; j < this._terminal.rows; j++) {
this._eraseInBufferLine(j, 0, this._terminal.cols);
this._resetBufferLine(j);
}

@@ -474,5 +481,8 @@ this._terminal.updateRange(j);

this._terminal.updateRange(j);
this._eraseInBufferLine(j, 0, this._terminal.buffer.x + 1);
this._eraseInBufferLine(j, 0, this._terminal.buffer.x + 1, true);
if (this._terminal.buffer.x + 1 >= this._terminal.cols) {
this._terminal.buffer.lines.get(j + 1).isWrapped = false;
}
while (j--) {
this._eraseInBufferLine(j, 0, this._terminal.cols);
this._resetBufferLine(j);
}

@@ -485,3 +495,3 @@ this._terminal.updateRange(0);

while (j--) {
this._eraseInBufferLine(j, 0, this._terminal.cols);
this._resetBufferLine(j);
}

@@ -526,3 +536,3 @@ this._terminal.updateRange(0);

buffer.lines.splice(scrollBottomAbsolute - 1, 1);
buffer.lines.splice(row, 0, BufferLine_1.BufferLine.blankLine(this._terminal.cols, this._terminal.eraseAttr()));
buffer.lines.splice(row, 0, buffer.getBlankLine(this._terminal.eraseAttr()));
}

@@ -544,3 +554,3 @@ this._terminal.updateRange(buffer.y);

buffer.lines.splice(row, 1);
buffer.lines.splice(j, 0, BufferLine_1.BufferLine.blankLine(this._terminal.cols, this._terminal.eraseAttr()));
buffer.lines.splice(j, 0, buffer.getBlankLine(this._terminal.eraseAttr()));
}

@@ -559,3 +569,3 @@ this._terminal.updateRange(buffer.y);

buffer.lines.splice(buffer.ybase + buffer.scrollTop, 1);
buffer.lines.splice(buffer.ybase + buffer.scrollBottom, 0, BufferLine_1.BufferLine.blankLine(this._terminal.cols, Buffer_1.DEFAULT_ATTR));
buffer.lines.splice(buffer.ybase + buffer.scrollBottom, 0, buffer.getBlankLine(Buffer_1.DEFAULT_ATTR));
}

@@ -571,3 +581,3 @@ this._terminal.updateRange(buffer.scrollTop);

buffer.lines.splice(buffer.ybase + buffer.scrollBottom, 1);
buffer.lines.splice(buffer.ybase + buffer.scrollBottom, 0, BufferLine_1.BufferLine.blankLine(this._terminal.cols, Buffer_1.DEFAULT_ATTR));
buffer.lines.splice(buffer.ybase + buffer.scrollBottom, 0, buffer.getBlankLine(Buffer_1.DEFAULT_ATTR));
}

@@ -728,3 +738,5 @@ this._terminal.updateRange(buffer.scrollTop);

this._terminal.applicationKeypad = true;
this._terminal.viewport.syncScrollArea();
if (this._terminal.viewport) {
this._terminal.viewport.syncScrollArea();
}
break;

@@ -758,7 +770,14 @@ case 9:

break;
case 1048:
this.saveCursor(params);
break;
case 1049:
this.saveCursor(params);
case 47:
case 1047:
this._terminal.buffers.activateAltBuffer();
this._terminal.viewport.syncScrollArea();
this._terminal.buffers.activateAltBuffer(this._terminal.eraseAttr());
this._terminal.refresh(0, this._terminal.rows - 1);
if (this._terminal.viewport) {
this._terminal.viewport.syncScrollArea();
}
this._terminal.showCursor();

@@ -810,3 +829,5 @@ break;

this._terminal.applicationKeypad = false;
this._terminal.viewport.syncScrollArea();
if (this._terminal.viewport) {
this._terminal.viewport.syncScrollArea();
}
break;

@@ -839,2 +860,5 @@ case 9:

break;
case 1048:
this.restoreCursor(params);
break;
case 1049:

@@ -844,4 +868,9 @@ case 47:

this._terminal.buffers.activateNormalBuffer();
if (params[0] === 1049) {
this.restoreCursor(params);
}
this._terminal.refresh(0, this._terminal.rows - 1);
this._terminal.viewport.syncScrollArea();
if (this._terminal.viewport) {
this._terminal.viewport.syncScrollArea();
}
this._terminal.showCursor();

@@ -1008,3 +1037,5 @@ break;

this._terminal.applicationKeypad = false;
this._terminal.viewport.syncScrollArea();
if (this._terminal.viewport) {
this._terminal.viewport.syncScrollArea();
}
this._terminal.applicationCursor = false;

@@ -1052,3 +1083,3 @@ this._terminal.buffer.scrollTop = 0;

this._terminal.buffer.savedY = this._terminal.buffer.y;
this._terminal.savedCurAttr = this._terminal.curAttr;
this._terminal.buffer.savedCurAttr = this._terminal.curAttr;
};

@@ -1058,3 +1089,3 @@ InputHandler.prototype.restoreCursor = function (params) {

this._terminal.buffer.y = this._terminal.buffer.savedY || 0;
this._terminal.curAttr = this._terminal.savedCurAttr || Buffer_1.DEFAULT_ATTR;
this._terminal.curAttr = this._terminal.buffer.savedCurAttr || Buffer_1.DEFAULT_ATTR;
};

@@ -1061,0 +1092,0 @@ InputHandler.prototype.setTitle = function (data) {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Types_1 = require("./Types");
function generateConfig(scaledCharWidth, scaledCharHeight, terminal, colors) {

@@ -45,2 +46,6 @@ var clonedColors = {

exports.configEquals = configEquals;
function is256Color(colorCode) {
return colorCode < Types_1.DEFAULT_COLOR;
}
exports.is256Color = is256Color;
//# sourceMappingURL=CharAtlasUtils.js.map

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

var ColorManager_1 = require("../ColorManager");
var CharAtlasGenerator_1 = require("../../shared/atlas/CharAtlasGenerator");
var CharAtlasGenerator_1 = require("./CharAtlasGenerator");
var LRUMap_1 = require("./LRUMap");
var Browser_1 = require("../../shared/utils/Browser");
var Platform_1 = require("../../core/Platform");
var TEXTURE_WIDTH = 1024;

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

}
exports.getGlyphCacheKey = getGlyphCacheKey;
var DynamicCharAtlas = (function (_super) {

@@ -72,2 +73,5 @@ __extends(DynamicCharAtlas, _super);

}
if (!this._canCache(glyph)) {
return false;
}
var glyphKey = getGlyphCacheKey(glyph);

@@ -79,3 +83,3 @@ var cacheValue = this._cacheMap.get(glyphKey);

}
else if (this._canCache(glyph) && this._drawToCacheCount < FRAME_CACHE_DRAW_LIMIT) {
else if (this._drawToCacheCount < FRAME_CACHE_DRAW_LIMIT) {
var index = void 0;

@@ -176,3 +180,3 @@ if (this._cacheMap.size < this._cacheMap.capacity) {

var _this = this;
if (!('createImageBitmap' in window) || Browser_1.isFirefox || Browser_1.isSafari) {
if (!('createImageBitmap' in window) || Platform_1.isFirefox || Platform_1.isSafari) {
return;

@@ -179,0 +183,0 @@ }

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

var Types_1 = require("./Types");
var Types_2 = require("../../shared/atlas/Types");
var CharAtlasGenerator_1 = require("../../shared/atlas/CharAtlasGenerator");
var CharAtlasGenerator_1 = require("./CharAtlasGenerator");
var BaseCharAtlas_1 = require("./BaseCharAtlas");
var CharAtlasUtils_1 = require("./CharAtlasUtils");
var StaticCharAtlas = (function (_super) {

@@ -50,4 +50,4 @@ __extends(StaticCharAtlas, _super);

var isBasicColor = glyph.fg < 16;
var isDefaultColor = glyph.fg >= 256;
var isDefaultBackground = glyph.bg >= 256;
var isDefaultColor = glyph.fg === Types_1.DEFAULT_COLOR;
var isDefaultBackground = glyph.bg === Types_1.DEFAULT_COLOR;
return isAscii && (isBasicColor || isDefaultColor) && isDefaultBackground && !glyph.italic;

@@ -60,6 +60,6 @@ };

var colorIndex = 0;
if (glyph.fg < 256) {
if (CharAtlasUtils_1.is256Color(glyph.fg)) {
colorIndex = 2 + glyph.fg + (glyph.bold ? 16 : 0);
}
else {
else if (glyph.fg === Types_1.DEFAULT_COLOR) {
if (glyph.bold) {

@@ -73,4 +73,4 @@ colorIndex = 1;

ctx.save();
var charAtlasCellWidth = this._config.scaledCharWidth + Types_2.CHAR_ATLAS_CELL_SPACING;
var charAtlasCellHeight = this._config.scaledCharHeight + Types_2.CHAR_ATLAS_CELL_SPACING;
var charAtlasCellWidth = this._config.scaledCharWidth + Types_1.CHAR_ATLAS_CELL_SPACING;
var charAtlasCellHeight = this._config.scaledCharHeight + Types_1.CHAR_ATLAS_CELL_SPACING;
if (glyph.dim) {

@@ -77,0 +77,0 @@ ctx.globalAlpha = Types_1.DIM_OPACITY;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.INVERTED_DEFAULT_COLOR = -1;
exports.DEFAULT_COLOR = 256;
exports.INVERTED_DEFAULT_COLOR = 257;
exports.DIM_OPACITY = 0.5;
exports.CHAR_ATLAS_CELL_SPACING = 1;
//# sourceMappingURL=Types.js.map

@@ -6,2 +6,3 @@ "use strict";

var Buffer_1 = require("../Buffer");
var CharAtlasUtils_1 = require("./atlas/CharAtlasUtils");
var BaseRenderLayer = (function () {

@@ -151,3 +152,3 @@ function BaseRenderLayer(_container, id, zIndex, _alpha, _colors) {

}
else if (fg < 256) {
else if (CharAtlasUtils_1.is256Color(fg)) {
this._ctx.fillStyle = this._colors.ansi[fg].css;

@@ -154,0 +155,0 @@ }

@@ -20,2 +20,3 @@ "use strict";

var DomRendererRowFactory_1 = require("./DomRendererRowFactory");
var Types_1 = require("../atlas/Types");
var TERMINAL_CLASS_PREFIX = 'xterm-dom-renderer-owner-';

@@ -80,6 +81,6 @@ var ROW_CONTAINER_CLASS = 'xterm-rows';

var _this = this;
this.dimensions.scaledCharWidth = this._terminal.charMeasure.width * window.devicePixelRatio;
this.dimensions.scaledCharHeight = this._terminal.charMeasure.height * window.devicePixelRatio;
this.dimensions.scaledCellWidth = this.dimensions.scaledCharWidth;
this.dimensions.scaledCellHeight = this.dimensions.scaledCharHeight;
this.dimensions.scaledCharWidth = Math.floor(this._terminal.charMeasure.width * window.devicePixelRatio);
this.dimensions.scaledCharHeight = Math.ceil(this._terminal.charMeasure.height * window.devicePixelRatio);
this.dimensions.scaledCellWidth = this.dimensions.scaledCharWidth + Math.round(this._terminal.options.letterSpacing);
this.dimensions.scaledCellHeight = Math.floor(this.dimensions.scaledCharHeight * this._terminal.options.lineHeight);
this.dimensions.scaledCharLeft = 0;

@@ -89,9 +90,11 @@ this.dimensions.scaledCharTop = 0;

this.dimensions.scaledCanvasHeight = this.dimensions.scaledCellHeight * this._terminal.rows;
this.dimensions.canvasWidth = this._terminal.charMeasure.width * this._terminal.cols;
this.dimensions.canvasHeight = this._terminal.charMeasure.height * this._terminal.rows;
this.dimensions.actualCellWidth = this._terminal.charMeasure.width;
this.dimensions.actualCellHeight = this._terminal.charMeasure.height;
this.dimensions.canvasWidth = Math.round(this.dimensions.scaledCanvasWidth / window.devicePixelRatio);
this.dimensions.canvasHeight = Math.round(this.dimensions.scaledCanvasHeight / window.devicePixelRatio);
this.dimensions.actualCellWidth = this.dimensions.canvasWidth / this._terminal.cols;
this.dimensions.actualCellHeight = this.dimensions.canvasHeight / this._terminal.rows;
this._rowElements.forEach(function (element) {
element.style.width = _this.dimensions.canvasWidth + "px";
element.style.height = _this._terminal.charMeasure.height + "px";
element.style.height = _this.dimensions.actualCellHeight + "px";
element.style.lineHeight = _this.dimensions.actualCellHeight + "px";
element.style.overflow = 'hidden';
});

@@ -106,8 +109,8 @@ if (!this._dimensionsStyleElement) {

" vertical-align: top;" +
(" width: " + this._terminal.charMeasure.width + "px") +
(" width: " + this.dimensions.actualCellWidth + "px") +
"}";
this._dimensionsStyleElement.innerHTML = styles;
this._selectionContainer.style.height = this._terminal._viewportElement.style.height;
this._rowContainer.style.width = this.dimensions.canvasWidth + "px";
this._rowContainer.style.height = this.dimensions.canvasHeight + "px";
this._terminal.screenElement.style.width = this.dimensions.canvasWidth + "px";
this._terminal.screenElement.style.height = this.dimensions.canvasHeight + "px";
};

@@ -171,2 +174,5 @@ DomRenderer.prototype.setTheme = function (theme) {

});
styles +=
this._terminalSelector + " ." + FG_CLASS_PREFIX + Types_1.INVERTED_DEFAULT_COLOR + " { color: " + this.colorManager.colors.background.css + "; }" +
(this._terminalSelector + " ." + BG_CLASS_PREFIX + Types_1.INVERTED_DEFAULT_COLOR + " { background-color: " + this.colorManager.colors.foreground.css + "; }");
this._themeStyleElement.innerHTML = styles;

@@ -235,6 +241,6 @@ return this.colorManager.colors;

var element = document.createElement('div');
element.style.height = rowCount * this._terminal.charMeasure.height + "px";
element.style.top = row * this._terminal.charMeasure.height + "px";
element.style.left = colStart * this._terminal.charMeasure.width + "px";
element.style.width = this._terminal.charMeasure.width * (colEnd - colStart) + "px";
element.style.height = rowCount * this.dimensions.actualCellHeight + "px";
element.style.top = row * this.dimensions.actualCellHeight + "px";
element.style.left = colStart * this.dimensions.actualCellWidth + "px";
element.style.width = this.dimensions.actualCellWidth * (colEnd - colStart) + "px";
return element;

@@ -265,3 +271,3 @@ };

var cursorStyle = terminal.options.cursorStyle;
rowElement.appendChild(this._rowFactory.createRow(lineData, row === cursorAbsoluteY, cursorStyle, cursorX, terminal.charMeasure.width, terminal.cols));
rowElement.appendChild(this._rowFactory.createRow(lineData, row === cursorAbsoluteY, cursorStyle, cursorX, this.dimensions.actualCellWidth, terminal.cols));
}

@@ -287,3 +293,7 @@ this._terminal.emit('refresh', { start: start, end: end });

while (x !== x2 || y !== y2) {
var span = this._rowElements[y].children[x];
var row = this._rowElements[y];
if (!row) {
return;
}
var span = row.children[x];
span.style.textDecoration = enabled ? 'underline' : 'none';

@@ -290,0 +300,0 @@ x = (x + 1) % cols;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Buffer_1 = require("../../Buffer");
var Types_1 = require("../atlas/Types");
exports.BOLD_CLASS = 'xterm-bold';

@@ -16,7 +17,12 @@ exports.ITALIC_CLASS = 'xterm-italic';

var fragment = this._document.createDocumentFragment();
var colCount = 0;
for (var x = 0; x < lineData.length; x++) {
if (colCount >= cols) {
continue;
var lineLength = 0;
for (var x = Math.min(lineData.length, cols) - 1; x >= 0; x--) {
var charData = lineData.get(x);
var code = charData[Buffer_1.CHAR_DATA_CODE_INDEX];
if (code !== Buffer_1.NULL_CELL_CODE || (isCursorRow && x === cursorX)) {
lineLength = x + 1;
break;
}
}
for (var x = 0; x < lineLength; x++) {
var charData = lineData.get(x);

@@ -54,7 +60,7 @@ var char = charData[Buffer_1.CHAR_DATA_CHAR_INDEX];

fg = temp;
if (fg === 256) {
fg = 0;
if (fg === Types_1.DEFAULT_COLOR) {
fg = Types_1.INVERTED_DEFAULT_COLOR;
}
if (bg === 257) {
bg = 15;
if (bg === Types_1.DEFAULT_COLOR) {
bg = Types_1.INVERTED_DEFAULT_COLOR;
}

@@ -72,10 +78,9 @@ }

charElement.textContent = char;
if (fg !== 257) {
if (fg !== Types_1.DEFAULT_COLOR) {
charElement.classList.add("xterm-fg-" + fg);
}
if (bg !== 256) {
if (bg !== Types_1.DEFAULT_COLOR) {
charElement.classList.add("xterm-bg-" + bg);
}
fragment.appendChild(charElement);
colCount += width;
}

@@ -82,0 +87,0 @@ return fragment;

@@ -18,2 +18,3 @@ "use strict";

var Types_1 = require("./atlas/Types");
var CharAtlasUtils_1 = require("./atlas/CharAtlasUtils");
var LinkRenderLayer = (function (_super) {

@@ -50,3 +51,3 @@ __extends(LinkRenderLayer, _super);

}
else if (e.fg < 256) {
else if (CharAtlasUtils_1.is256Color(e.fg)) {
this._ctx.fillStyle = this._colors.ansi[e.fg].css;

@@ -53,0 +54,0 @@ }

@@ -20,2 +20,3 @@ "use strict";

var BaseRenderLayer_1 = require("./BaseRenderLayer");
var CharAtlasUtils_1 = require("./atlas/CharAtlasUtils");
var TextRenderLayer = (function (_super) {

@@ -81,6 +82,6 @@ __extends(TextRenderLayer, _super);

fg = temp;
if (fg === 256) {
if (fg === Types_1.DEFAULT_COLOR) {
fg = Types_1.INVERTED_DEFAULT_COLOR;
}
if (bg === 257) {
if (bg === Types_1.DEFAULT_COLOR) {
bg = Types_1.INVERTED_DEFAULT_COLOR;

@@ -107,3 +108,3 @@ }

}
else if (bg < 256) {
else if (CharAtlasUtils_1.is256Color(bg)) {
nextFillStyle = _this._colors.ansi[bg].css;

@@ -146,3 +147,3 @@ }

}
else if (fg < 256) {
else if (CharAtlasUtils_1.is256Color(fg)) {
_this._ctx.fillStyle = _this._colors.ansi[fg].css;

@@ -149,0 +150,0 @@ }

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

var MouseHelper_1 = require("./utils/MouseHelper");
var Browser = require("./shared/utils/Browser");
var Browser = require("./core/Platform");
var EventEmitter_1 = require("./common/EventEmitter");

@@ -176,5 +176,9 @@ var SelectionModel_1 = require("./SelectionModel");

}
return this._areCoordsInSelection(coords, start, end);
};
SelectionManager.prototype._areCoordsInSelection = function (coords, start, end) {
return (coords[1] > start[1] && coords[1] < end[1]) ||
(start[1] === end[1] && coords[1] === start[1] && coords[0] > start[0] && coords[0] < end[0]) ||
(start[1] < end[1] && coords[1] === end[1] && coords[0] < end[0]);
(start[1] === end[1] && coords[1] === start[1] && coords[0] >= start[0] && coords[0] < end[0]) ||
(start[1] < end[1] && coords[1] === end[1] && coords[0] < end[0]) ||
(start[1] < end[1] && coords[1] === start[1] && coords[0] >= start[0]);
};

@@ -210,3 +214,3 @@ SelectionManager.prototype.selectWordAtCursor = function (event) {

SelectionManager.prototype._getMouseBufferCoords = function (event) {
var coords = this._terminal.mouseHelper.getCoords(event, this._terminal.screenElement, this._charMeasure, this._terminal.options.lineHeight, this._terminal.cols, this._terminal.rows, true);
var coords = this._terminal.mouseHelper.getCoords(event, this._terminal.screenElement, this._charMeasure, this._terminal.cols, this._terminal.rows, true);
if (!coords) {

@@ -213,0 +217,0 @@ return null;

@@ -8,19 +8,28 @@ "use strict";

}
Object.defineProperty(SoundManager, "audioContext", {
get: function () {
if (!SoundManager._audioContext) {
var audioContextCtor = window.AudioContext || window.webkitAudioContext;
if (!audioContextCtor) {
console.warn('Web Audio API is not supported by this browser. Consider upgrading to the latest version');
return null;
}
SoundManager._audioContext = new audioContextCtor();
}
return SoundManager._audioContext;
},
enumerable: true,
configurable: true
});
SoundManager.prototype.playBellSound = function () {
var audioContextCtor = window.AudioContext || window.webkitAudioContext;
if (!this._audioContext && audioContextCtor) {
this._audioContext = new audioContextCtor();
var ctx = SoundManager.audioContext;
if (!ctx) {
return;
}
if (this._audioContext) {
var bellAudioSource_1 = this._audioContext.createBufferSource();
var context_1 = this._audioContext;
this._audioContext.decodeAudioData(this._base64ToArrayBuffer(this._removeMimeType(this._terminal.options.bellSound)), function (buffer) {
bellAudioSource_1.buffer = buffer;
bellAudioSource_1.connect(context_1.destination);
bellAudioSource_1.start(0);
});
}
else {
console.warn('Sorry, but the Web Audio API is not supported by your browser. Please, consider upgrading to the latest version');
}
var bellAudioSource = ctx.createBufferSource();
ctx.decodeAudioData(this._base64ToArrayBuffer(this._removeMimeType(this._terminal.options.bellSound)), function (buffer) {
bellAudioSource.buffer = buffer;
bellAudioSource.connect(ctx.destination);
bellAudioSource.start(0);
});
};

@@ -27,0 +36,0 @@ SoundManager.prototype._base64ToArrayBuffer = function (base64) {

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

var Viewport_1 = require("./Viewport");
var Clipboard_1 = require("./handlers/Clipboard");
var Clipboard_1 = require("./ui/Clipboard");
var EscapeSequences_1 = require("./common/data/EscapeSequences");

@@ -29,3 +29,3 @@ var InputHandler_1 = require("./InputHandler");

var CharMeasure_1 = require("./ui/CharMeasure");
var Browser = require("./shared/utils/Browser");
var Browser = require("./core/Platform");
var Lifecycle_1 = require("./ui/Lifecycle");

@@ -43,3 +43,2 @@ var Strings = require("./Strings");

var Keyboard_1 = require("./core/input/Keyboard");
var BufferLine_1 = require("./BufferLine");
var document = (typeof window !== 'undefined') ? window.document : null;

@@ -80,3 +79,4 @@ var WRITE_BUFFER_PAUSE_THRESHOLD = 5;

rightClickSelectsWord: Browser.isMac,
rendererType: 'canvas'
rendererType: 'canvas',
experimentalBufferLineImpl: 'TypedArray'
};

@@ -89,2 +89,3 @@ var Terminal = (function (_super) {

_this.browser = Browser;
_this._blankLine = null;
_this.options = Clone_1.clone(options);

@@ -170,3 +171,3 @@ _this._setup();

get: function () {
return document.activeElement === this.textarea;
return document.activeElement === this.textarea && document.hasFocus();
},

@@ -288,2 +289,3 @@ enumerable: true,

}
this.mouseHelper.setRenderer(this.renderer);
break;

@@ -312,2 +314,7 @@ case 'scrollback':

break;
case 'experimentalBufferLineImpl':
this.buffers.normal.setBufferLineFactory(value);
this.buffers.alt.setBufferLineFactory(value);
this._blankLine = null;
break;
}

@@ -515,3 +522,3 @@ if (this.renderer) {

button = getButton(ev);
pos = self.mouseHelper.getRawByteCoords(ev, self.screenElement, self.charMeasure, self.options.lineHeight, self.cols, self.rows);
pos = self.mouseHelper.getRawByteCoords(ev, self.screenElement, self.charMeasure, self.cols, self.rows);
if (!pos)

@@ -533,3 +540,3 @@ return;

var button = pressed;
var pos = self.mouseHelper.getRawByteCoords(ev, self.screenElement, self.charMeasure, self.options.lineHeight, self.cols, self.rows);
var pos = self.mouseHelper.getRawByteCoords(ev, self.screenElement, self.charMeasure, self.cols, self.rows);
if (!pos)

@@ -663,3 +670,3 @@ return;

case 'wheel':
button = ev.wheelDeltaY > 0
button = ev.deltaY < 0
? 64

@@ -770,6 +777,6 @@ : 65;

if (this.selectionManager && this.selectionManager.shouldColumnSelect(ev)) {
this.element.classList.add('xterm-cursor-crosshair');
this.element.classList.add('column-select');
}
else {
this.element.classList.remove('xterm-cursor-crosshair');
this.element.classList.remove('column-select');
}

@@ -784,12 +791,35 @@ };

Terminal.prototype.scroll = function (isWrapped) {
var newLine = BufferLine_1.BufferLine.blankLine(this.cols, Buffer_1.DEFAULT_ATTR, isWrapped);
if (isWrapped === void 0) { isWrapped = false; }
var newLine;
var useRecycling = this.options.experimentalBufferLineImpl !== 'JsArray';
if (useRecycling) {
newLine = this._blankLine;
if (!newLine || newLine.length !== this.cols || newLine.get(0)[Buffer_1.CHAR_DATA_ATTR_INDEX] !== this.eraseAttr()) {
newLine = this.buffer.getBlankLine(this.eraseAttr(), isWrapped);
this._blankLine = newLine;
}
newLine.isWrapped = isWrapped;
}
else {
newLine = this.buffer.getBlankLine(this.eraseAttr(), isWrapped);
}
var topRow = this.buffer.ybase + this.buffer.scrollTop;
var bottomRow = this.buffer.ybase + this.buffer.scrollBottom;
if (this.buffer.scrollTop === 0) {
var willBufferBeTrimmed = this.buffer.lines.length === this.buffer.lines.maxLength;
var willBufferBeTrimmed = this.buffer.lines.isFull;
if (bottomRow === this.buffer.lines.length - 1) {
this.buffer.lines.push(newLine);
if (useRecycling) {
if (willBufferBeTrimmed) {
this.buffer.lines.recycle().copyFrom(newLine);
}
else {
this.buffer.lines.push(newLine.clone());
}
}
else {
this.buffer.lines.push(newLine);
}
}
else {
this.buffer.lines.splice(bottomRow + 1, 0, newLine);
this.buffer.lines.splice(bottomRow + 1, 0, (useRecycling) ? newLine.clone() : newLine);
}

@@ -811,3 +841,3 @@ if (!willBufferBeTrimmed) {

this.buffer.lines.shiftElements(topRow + 1, scrollRegionHeight - 1, -1);
this.buffer.lines.set(bottomRow, newLine);
this.buffer.lines.set(bottomRow, (useRecycling) ? newLine.clone() : newLine);
}

@@ -1117,3 +1147,3 @@ if (!this._userScrolling) {

for (var i = 1; i < this.rows; i++) {
this.buffer.lines.push(BufferLine_1.BufferLine.blankLine(this.cols, Buffer_1.DEFAULT_ATTR));
this.buffer.lines.push(this.buffer.getBlankLine(Buffer_1.DEFAULT_ATTR));
}

@@ -1161,3 +1191,3 @@ this.refresh(0, this.rows - 1);

this.buffer.lines.shiftElements(this.buffer.y + this.buffer.ybase, scrollRegionHeight, 1);
this.buffer.lines.set(this.buffer.y + this.buffer.ybase, BufferLine_1.BufferLine.blankLine(this.cols, this.eraseAttr()));
this.buffer.lines.set(this.buffer.y + this.buffer.ybase, this.buffer.getBlankLine(this.eraseAttr()));
this.updateRange(this.buffer.scrollTop);

@@ -1164,0 +1194,0 @@ this.updateRange(this.buffer.scrollBottom);

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

MouseZoneManager.prototype._findZoneEventAt = function (e) {
var coords = this._terminal.mouseHelper.getCoords(e, this._terminal.screenElement, this._terminal.charMeasure, this._terminal.options.lineHeight, this._terminal.cols, this._terminal.rows);
var coords = this._terminal.mouseHelper.getCoords(e, this._terminal.screenElement, this._terminal.charMeasure, this._terminal.cols, this._terminal.rows);
if (!coords) {

@@ -141,0 +141,0 @@ return null;

@@ -7,2 +7,5 @@ "use strict";

}
MouseHelper.prototype.setRenderer = function (renderer) {
this._renderer = renderer;
};
MouseHelper.getCoordsRelativeToElement = function (event, element) {

@@ -28,3 +31,3 @@ if (event.pageX === null || event.pageX === undefined) {

};
MouseHelper.prototype.getCoords = function (event, element, charMeasure, lineHeight, colCount, rowCount, isSelection) {
MouseHelper.prototype.getCoords = function (event, element, charMeasure, colCount, rowCount, isSelection) {
if (!charMeasure.width || !charMeasure.height) {

@@ -43,4 +46,4 @@ return null;

};
MouseHelper.prototype.getRawByteCoords = function (event, element, charMeasure, lineHeight, colCount, rowCount) {
var coords = this.getCoords(event, element, charMeasure, lineHeight, colCount, rowCount);
MouseHelper.prototype.getRawByteCoords = function (event, element, charMeasure, colCount, rowCount) {
var coords = this.getCoords(event, element, charMeasure, colCount, rowCount);
var x = coords[0];

@@ -47,0 +50,0 @@ var y = coords[1];

{
"name": "xterm",
"description": "Full xterm terminal, in your browser",
"version": "3.8.0",
"version": "3.9.0",
"main": "lib/public/Terminal.js",

@@ -42,3 +42,3 @@ "types": "typings/xterm.d.ts",

"tslint-consistent-codestyle": "^1.13.0",
"typescript": "3.0",
"typescript": "3.1",
"vinyl-buffer": "^1.0.0",

@@ -54,2 +54,3 @@ "vinyl-source-stream": "^1.1.0",

"lint": "tslint 'src/**/*.ts' './demo/**/*.ts'",
"pretest": "npm run layering",
"test": "npm run mocha",

@@ -67,6 +68,6 @@ "posttest": "npm run lint",

"coveralls": "nyc report --reporter=text-lcov | coveralls",
"webpack": "gulp webpack",
"watch": "concurrently --kill-others-on-fail --names \"lib,css\" \"tsc -w\" \"gulp watch-css\"",
"watch-addons": "concurrently --kill-others-on-fail --names \"attach,fit,fullscreen,search,terminado,webLinks,winptyCompat,zmodem\" \"tsc -w -p ./src/addons/attach\" \"tsc -w -p ./src/addons/fit\" \"tsc -w -p ./src/addons/fullscreen\" \"tsc -w -p ./src/addons/search\" \"tsc -w -p ./src/addons/terminado\" \"tsc -w -p ./src/addons/webLinks\" \"tsc -w -p ./src/addons/winptyCompat\" \"tsc -w -p ./src/addons/zmodem\""
"watch-addons": "concurrently --kill-others-on-fail --names \"attach,fit,fullscreen,search,terminado,webLinks,winptyCompat,zmodem\" \"tsc -w -p ./src/addons/attach\" \"tsc -w -p ./src/addons/fit\" \"tsc -w -p ./src/addons/fullscreen\" \"tsc -w -p ./src/addons/search\" \"tsc -w -p ./src/addons/terminado\" \"tsc -w -p ./src/addons/webLinks\" \"tsc -w -p ./src/addons/winptyCompat\" \"tsc -w -p ./src/addons/zmodem\"",
"layering": "concurrently --kill-others-on-fail --names \"common,core\" \"tsc -p ./src/common\" \"tsc -p ./src/core\""
}
}

@@ -162,3 +162,3 @@ # [![xterm.js logo](logo-full.png)](https://xtermjs.org)

- [**abstruse**](https://github.com/bleenco/abstruse): Abstruse CI is a continuous integration platform based on Node.JS and Docker.
- [**Microsoft SQL Operations Studio**](https://github.com/Microsoft/sqlopsstudio): A data management tool that enables working with SQL Server, Azure SQL DB and SQL DW from Windows, macOS and Linux
- [**Azure Data Studio**](https://github.com/Microsoft/azuredatastudio): A data management tool that enables working with SQL Server, Azure SQL DB and SQL DW from Windows, macOS and Linux.
- [**FreeMAN**](https://github.com/matthew-matvei/freeman): A free, cross-platform file manager for power users

@@ -175,2 +175,4 @@ - [**Fluent Terminal**](https://github.com/felixse/FluentTerminal): A terminal emulator based on UWP and web technologies.

- [**Juno**](http://junolab.org/): A flexible Julia IDE, based on Atom.
- [**webssh**](https://github.com/huashengdun/webssh): Web based ssh client.
- [**info-beamer hosted**](https://info-beamer.com): Uses Xterm.js to manage digital signage devices from the web dashboard.

@@ -177,0 +179,0 @@ [And much more...](https://github.com/xtermjs/xterm.js/network/dependents)

@@ -8,3 +8,3 @@ /**

import { ITerminal, IBuffer } from './Types';
import { isMac } from './shared/utils/Browser';
import { isMac } from './core/Platform';
import { RenderDebouncer } from './ui/RenderDebouncer';

@@ -11,0 +11,0 @@ import { addDisposableDomListener } from './ui/Lifecycle';

@@ -7,3 +7,3 @@ {

"dom",
"es6",
"es5"
],

@@ -15,8 +15,11 @@ "rootDir": ".",

"declaration": true,
"preserveWatchOutput": true
"preserveWatchOutput": true,
"types": [
"../../node_modules/@types/mocha",
"../.."
]
},
"include": [
"**/*.ts",
"../../../typings/xterm.d.ts"
"**/*.ts"
]
}

@@ -14,13 +14,14 @@ /**

export function toggleFullScreen(term: Terminal, fullscreen: boolean): void {
let fn: string;
let fn: (...tokens: string[]) => void;
if (typeof fullscreen === 'undefined') {
fn = (term.element.classList.contains('fullscreen')) ? 'remove' : 'add';
fn = (term.element.classList.contains('fullscreen')) ?
term.element.classList.remove : term.element.classList.add;
} else if (!fullscreen) {
fn = 'remove';
fn = term.element.classList.remove;
} else {
fn = 'add';
fn = term.element.classList.add;
}
term.element.classList[fn]('fullscreen');
fn('fullscreen');
}

@@ -27,0 +28,0 @@

@@ -7,3 +7,3 @@ {

"dom",
"es6",
"es5"
],

@@ -15,8 +15,11 @@ "rootDir": ".",

"declaration": true,
"preserveWatchOutput": true
"preserveWatchOutput": true,
"types": [
"../../node_modules/@types/mocha",
"../.."
]
},
"include": [
"**/*.ts",
"../../../typings/xterm.d.ts"
"**/*.ts"
]
}

@@ -13,3 +13,3 @@ /**

* doesn't exist, do nothing.
* @param term Tne search term.
* @param term The search term.
* @param searchOptions Search options

@@ -29,3 +29,3 @@ * @return Whether a result was found.

* doesn't exist, do nothing.
* @param term Tne search term.
* @param term The search term.
* @param searchOptions Search options

@@ -32,0 +32,0 @@ * @return Whether a result was found.

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

import { ISearchHelper, ISearchAddonTerminal, ISearchOptions, ISearchResult } from './Interfaces';
const nonWordCharacters = ' ~!@#$%^&*()_+`-=[]{}|\;:"\',./<>?';
const nonWordCharacters = ' ~!@#$%^&*()+`-=[]{}|\;:"\',./<>?';

@@ -23,3 +23,3 @@ /**

* doesn't exist, do nothing.
* @param term Tne search term.
* @param term The search term.
* @param searchOptions Search options.

@@ -38,3 +38,5 @@ * @return Whether a result was found.

// Start from the selection end if there is a selection
startRow = this._terminal._core.selectionManager.selectionEnd[1];
if (this._terminal.getSelection().length !== 0) {
startRow = this._terminal._core.selectionManager.selectionEnd[1];
}
}

@@ -67,3 +69,3 @@

* doesn't exist, do nothing.
* @param term Tne search term.
* @param term The search term.
* @param searchOptions Search options.

@@ -82,3 +84,5 @@ * @return Whether a result was found.

// Start from the selection end if there is a selection
startRow = this._terminal._core.selectionManager.selectionStart[1];
if (this._terminal.getSelection().length !== 0) {
startRow = this._terminal._core.selectionManager.selectionStart[1];
}
}

@@ -116,3 +120,3 @@

return (((searchIndex === 0) || (nonWordCharacters.indexOf(line[searchIndex - 1]) !== -1)) &&
(((searchIndex + term.length) === line.length) || (nonWordCharacters.indexOf(line[searchIndex + term.length]) !== -1)));
(((searchIndex + term.length) === line.length) || (nonWordCharacters.indexOf(line[searchIndex + term.length]) !== -1)));
}

@@ -125,3 +129,3 @@

* text starts on is searched.
* @param term Tne search term.
* @param term The search term.
* @param y The line to search.

@@ -201,3 +205,3 @@ * @param searchOptions Search options.

lineWrapsToNext = nextLine ? nextLine.isWrapped : false;
lineString += this._terminal._core.buffer.translateBufferLineToString(lineIndex, !lineWrapsToNext && trimRight);
lineString += this._terminal._core.buffer.translateBufferLineToString(lineIndex, !lineWrapsToNext && trimRight).substring(0, this._terminal.cols);
lineIndex++;

@@ -216,2 +220,3 @@ } while (lineWrapsToNext);

if (!result) {
this._terminal.clearSelection();
return false;

@@ -218,0 +223,0 @@ }

@@ -6,4 +6,3 @@ {

"lib": [
"dom",
"es6",
"es5"
],

@@ -15,8 +14,11 @@ "rootDir": ".",

"declaration": true,
"preserveWatchOutput": true
"preserveWatchOutput": true,
"types": [
"../../node_modules/@types/mocha",
"../.."
]
},
"include": [
"**/*.ts",
"../../../typings/xterm.d.ts"
"**/*.ts"
]
}

@@ -6,4 +6,3 @@ {

"lib": [
"dom",
"es6",
"es5"
],

@@ -15,8 +14,11 @@ "rootDir": ".",

"declaration": true,
"preserveWatchOutput": true
"preserveWatchOutput": true,
"types": [
"../../node_modules/@types/mocha",
"../.."
]
},
"include": [
"**/*.ts",
"../../../typings/xterm.d.ts"
"**/*.ts"
]
}

@@ -7,3 +7,3 @@ {

"dom",
"es6",
"es5",
],

@@ -15,8 +15,11 @@ "rootDir": ".",

"declaration": true,
"preserveWatchOutput": true
"preserveWatchOutput": true,
"types": [
"../../node_modules/@types/mocha",
"../.."
]
},
"include": [
"**/*.ts",
"../../../typings/xterm.d.ts"
"**/*.ts"
]
}

@@ -17,3 +17,3 @@ /**

const hostClause = '((' + domainBodyClause + '\\.' + tldClause + ')|' + ipClause + '|' + localHostClause + ')' + portClause + '?';
const pathClause = '(\\/[\\/\\w\\.\\-%~]*)*';
const pathClause = '(\\/[\\/\\w\\.\\-%~:]*)*([^:\\s])';
const queryStringHashFragmentCharacterSet = '[0-9\\w\\[\\]\\(\\)\\/\\?\\!#@$%&\'*+,:;~\\=\\.\\-]*';

@@ -20,0 +20,0 @@ const queryStringClause = '(\\?' + queryStringHashFragmentCharacterSet + ')?';

@@ -6,4 +6,3 @@ {

"lib": [
"dom",
"es6",
"es5"
],

@@ -15,8 +14,11 @@ "rootDir": ".",

"declaration": true,
"preserveWatchOutput": true
"preserveWatchOutput": true,
"types": [
"../../node_modules/@types/mocha",
"../.."
]
},
"include": [
"**/*.ts",
"../../../typings/xterm.d.ts"
"**/*.ts"
]
}

@@ -6,4 +6,3 @@ {

"lib": [
"dom",
"es6",
"es5"
],

@@ -15,8 +14,11 @@ "rootDir": ".",

"declaration": true,
"preserveWatchOutput": true
"preserveWatchOutput": true,
"types": [
"../../node_modules/@types/mocha",
"../.."
]
},
"include": [
"**/*.ts",
"../../../typings/xterm.d.ts"
"**/*.ts"
]
}

@@ -37,3 +37,3 @@ /**

let zmodem;
let zmodem: any;

@@ -48,3 +48,3 @@ export interface IZmodemOptions {

let zsentry;
let zsentry: any;

@@ -51,0 +51,0 @@ function shouldWrite(): boolean {

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

import { CircularList } from './common/CircularList';
import { CharData, ITerminal, IBuffer, IBufferLine, BufferIndex, IBufferStringIterator, IBufferStringIteratorResult } from './Types';
import { CharData, ITerminal, IBuffer, IBufferLine, BufferIndex, IBufferStringIterator, IBufferStringIteratorResult, IBufferLineConstructor } from './Types';
import { EventEmitter } from './common/EventEmitter';
import { IMarker } from 'xterm';
import { BufferLine } from './BufferLine';
import { BufferLine, BufferLineJSArray } from './BufferLine';
import { DEFAULT_COLOR } from './renderer/atlas/Types';
export const DEFAULT_ATTR = (0 << 18) | (257 << 9) | (256 << 0);
export const DEFAULT_ATTR = (0 << 18) | (DEFAULT_COLOR << 9) | (256 << 0);
export const CHAR_DATA_ATTR_INDEX = 0;

@@ -42,3 +43,5 @@ export const CHAR_DATA_CHAR_INDEX = 1;

public savedX: number;
public savedCurAttr: number;
public markers: Marker[] = [];
private _bufferLineConstructor: IBufferLineConstructor;

@@ -58,2 +61,33 @@ /**

public setBufferLineFactory(type: string): void {
if (type === 'JsArray') {
if (this._bufferLineConstructor !== BufferLineJSArray) {
this._bufferLineConstructor = BufferLineJSArray;
this._recreateLines();
}
} else {
if (this._bufferLineConstructor !== BufferLine) {
this._bufferLineConstructor = BufferLine;
this._recreateLines();
}
}
}
private _recreateLines(): void {
if (!this.lines) return;
for (let i = 0; i < this.lines.length; ++i) {
const oldLine = this.lines.get(i);
const newLine = new this._bufferLineConstructor(oldLine.length);
for (let j = 0; j < oldLine.length; ++j) {
newLine.set(j, oldLine.get(j));
}
this.lines.set(i, newLine);
}
}
public getBlankLine(attr: number, isWrapped?: boolean): IBufferLine {
const fillCharData: CharData = [attr, NULL_CELL_CHAR, NULL_CELL_WIDTH, NULL_CELL_CODE];
return new this._bufferLineConstructor(this._terminal.cols, fillCharData, isWrapped);
}
public get hasScrollback(): boolean {

@@ -87,7 +121,10 @@ return this._hasScrollback && this.lines.maxLength > this._terminal.rows;

*/
public fillViewportRows(): void {
public fillViewportRows(fillAttr?: number): void {
if (this.lines.length === 0) {
if (fillAttr === undefined) {
fillAttr = DEFAULT_ATTR;
}
let i = this._terminal.rows;
while (i--) {
this.lines.push(BufferLine.blankLine(this._terminal.cols, DEFAULT_ATTR));
this.lines.push(this.getBlankLine(fillAttr));
}

@@ -101,2 +138,3 @@ }

public clear(): void {
this.setBufferLineFactory(this._terminal.options.experimentalBufferLineImpl);
this.ydisp = 0;

@@ -132,5 +170,3 @@ this.ybase = 0;

for (let i = 0; i < this.lines.length; i++) {
while (this.lines.get(i).length < newCols) {
this.lines.get(i).push(ch);
}
this.lines.get(i).resize(newCols, ch);
}

@@ -156,3 +192,4 @@ }

// are blank lines after the cursor
this.lines.push(BufferLine.blankLine(newCols, DEFAULT_ATTR));
const fillCharData: CharData = [DEFAULT_ATTR, NULL_CELL_CHAR, NULL_CELL_WIDTH, NULL_CELL_CODE];
this.lines.push(new this._bufferLineConstructor(newCols, fillCharData));
}

@@ -159,0 +196,0 @@ }

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

* Class representing a terminal line.
*
* @deprecated to be removed with one of the next releases
*/
export class BufferLine implements IBufferLine {
static blankLine(cols: number, attr: number, isWrapped?: boolean): IBufferLine {
const ch: CharData = [attr, NULL_CELL_CHAR, NULL_CELL_WIDTH, NULL_CELL_CODE];
return new BufferLine(cols, ch, isWrapped);
}
export class BufferLineJSArray implements IBufferLine {
protected _data: CharData[];

@@ -21,27 +19,17 @@ public isWrapped = false;

constructor(cols?: number, ch?: CharData, isWrapped?: boolean) {
constructor(cols: number, fillCharData?: CharData, isWrapped?: boolean) {
this._data = [];
this.length = this._data.length;
if (cols) {
if (!ch) {
ch = [0, NULL_CELL_CHAR, NULL_CELL_WIDTH, NULL_CELL_CODE];
}
for (let i = 0; i < cols; i++) {
this.push(ch); // Note: the ctor ch is not cloned (resembles old behavior)
}
if (!fillCharData) {
fillCharData = [0, NULL_CELL_CHAR, NULL_CELL_WIDTH, NULL_CELL_CODE];
}
for (let i = 0; i < cols; i++) {
this._push(fillCharData); // Note: the ctor ch is not cloned (resembles old behavior)
}
if (isWrapped) {
this.isWrapped = true;
}
this.length = this._data.length;
}
public get(index: number): CharData {
return this._data[index];
}
public set(index: number, data: CharData): void {
this._data[index] = data;
}
public pop(): CharData | undefined {
private _pop(): CharData | undefined {
const data = this._data.pop();

@@ -52,3 +40,3 @@ this.length = this._data.length;

public push(data: CharData): void {
private _push(data: CharData): void {
this._data.push(data);

@@ -58,3 +46,3 @@ this.length = this._data.length;

public splice(start: number, deleteCount: number, ...items: CharData[]): CharData[] {
private _splice(start: number, deleteCount: number, ...items: CharData[]): CharData[] {
const removed = this._data.splice(start, deleteCount, ...items);

@@ -65,7 +53,15 @@ this.length = this._data.length;

public get(index: number): CharData {
return this._data[index];
}
public set(index: number, data: CharData): void {
this._data[index] = data;
}
/** insert n cells ch at pos, right cells are lost (stable length) */
public insertCells(pos: number, n: number, ch: CharData): void {
while (n--) {
this.splice(pos, 0, ch);
this.pop();
this._splice(pos, 0, ch);
this._pop();
}

@@ -75,6 +71,6 @@ }

/** delete n cells at pos, right side is filled with fill (stable length) */
public deleteCells(pos: number, n: number, fill: CharData): void {
public deleteCells(pos: number, n: number, fillCharData: CharData): void {
while (n--) {
this.splice(pos, 1);
this.push(fill);
this._splice(pos, 1);
this._push(fillCharData);
}

@@ -84,7 +80,200 @@ }

/** replace cells from pos to pos + n - 1 with fill */
public replaceCells(start: number, end: number, fill: CharData): void {
public replaceCells(start: number, end: number, fillCharData: CharData): void {
while (start < end && start < this.length) {
this.set(start++, fill); // Note: fill is not cloned (resembles old behavior)
this.set(start++, fillCharData); // Note: fill is not cloned (resembles old behavior)
}
}
/** resize line to cols filling new cells with fill */
public resize(cols: number, fillCharData: CharData, shrink: boolean = false): void {
while (this._data.length < cols) {
this._data.push(fillCharData);
}
if (shrink) {
while (this._data.length > cols) {
this._data.pop();
}
}
this.length = this._data.length;
}
public fill(fillCharData: CharData): void {
for (let i = 0; i < this.length; ++i) {
this.set(i, fillCharData);
}
}
public copyFrom(line: BufferLineJSArray): void {
this._data = line._data.slice(0);
this.length = line.length;
this.isWrapped = line.isWrapped;
}
public clone(): IBufferLine {
const newLine = new BufferLineJSArray(0);
newLine.copyFrom(this);
return newLine;
}
}
/** typed array slots taken by one cell */
const CELL_SIZE = 3;
/** cell member indices */
const enum Cell {
FLAGS = 0,
STRING = 1,
WIDTH = 2
}
/**
* Typed array based bufferline implementation.
*/
export class BufferLine implements IBufferLine {
protected _data: Uint32Array | null = null;
protected _combined: {[index: number]: string} = {};
public length: number;
constructor(cols: number, fillCharData?: CharData, public isWrapped: boolean = false) {
if (!fillCharData) {
fillCharData = [0, NULL_CELL_CHAR, NULL_CELL_WIDTH, NULL_CELL_CODE];
}
if (cols) {
this._data = new Uint32Array(cols * CELL_SIZE);
for (let i = 0; i < cols; ++i) {
this.set(i, fillCharData);
}
}
this.length = cols;
}
public get(index: number): CharData {
const stringData = this._data[index * CELL_SIZE + Cell.STRING];
return [
this._data[index * CELL_SIZE + Cell.FLAGS],
(stringData & 0x80000000)
? this._combined[index]
: (stringData) ? String.fromCharCode(stringData) : '',
this._data[index * CELL_SIZE + Cell.WIDTH],
(stringData & 0x80000000)
? this._combined[index].charCodeAt(this._combined[index].length - 1)
: stringData
];
}
public set(index: number, value: CharData): void {
this._data[index * CELL_SIZE + Cell.FLAGS] = value[0];
if (value[1].length > 1) {
this._combined[index] = value[1];
this._data[index * CELL_SIZE + Cell.STRING] = index | 0x80000000;
} else {
this._data[index * CELL_SIZE + Cell.STRING] = value[1].charCodeAt(0);
}
this._data[index * CELL_SIZE + Cell.WIDTH] = value[2];
}
public insertCells(pos: number, n: number, fillCharData: CharData): void {
pos %= this.length;
if (n < this.length - pos) {
for (let i = this.length - pos - n - 1; i >= 0; --i) {
this.set(pos + n + i, this.get(pos + i));
}
for (let i = 0; i < n; ++i) {
this.set(pos + i, fillCharData);
}
} else {
for (let i = pos; i < this.length; ++i) {
this.set(i, fillCharData);
}
}
}
public deleteCells(pos: number, n: number, fillCharData: CharData): void {
pos %= this.length;
if (n < this.length - pos) {
for (let i = 0; i < this.length - pos - n; ++i) {
this.set(pos + i, this.get(pos + n + i));
}
for (let i = this.length - n; i < this.length; ++i) {
this.set(i, fillCharData);
}
} else {
for (let i = pos; i < this.length; ++i) {
this.set(i, fillCharData);
}
}
}
public replaceCells(start: number, end: number, fillCharData: CharData): void {
while (start < end && start < this.length) {
this.set(start++, fillCharData);
}
}
public resize(cols: number, fillCharData: CharData, shrink: boolean = false): void {
if (cols === this.length || (!shrink && cols < this.length)) {
return;
}
if (cols > this.length) {
const data = new Uint32Array(cols * CELL_SIZE);
if (this.length) {
if (cols * CELL_SIZE < this._data.length) {
data.set(this._data.subarray(0, cols * CELL_SIZE));
} else {
data.set(this._data);
}
}
this._data = data;
for (let i = this.length; i < cols; ++i) {
this.set(i, fillCharData);
}
} else if (shrink) {
if (cols) {
const data = new Uint32Array(cols * CELL_SIZE);
data.set(this._data.subarray(0, cols * CELL_SIZE));
this._data = data;
} else {
this._data = null;
}
}
this.length = cols;
}
/** fill a line with fillCharData */
public fill(fillCharData: CharData): void {
this._combined = {};
for (let i = 0; i < this.length; ++i) {
this.set(i, fillCharData);
}
}
/** alter to a full copy of line */
public copyFrom(line: BufferLine): void {
if (this.length !== line.length) {
this._data = new Uint32Array(line._data);
} else {
// use high speed copy if lengths are equal
this._data.set(line._data);
}
this.length = line.length;
this._combined = {};
for (const el in line._combined) {
this._combined[el] = line._combined[el];
}
this.isWrapped = line.isWrapped;
}
/** create a new clone */
public clone(): IBufferLine {
const newLine = new BufferLine(0);
// creation of new typed array from another is actually pretty slow :(
// still faster than copying values one by one
newLine._data = new Uint32Array(this._data);
newLine.length = this.length;
for (const el in this._combined) {
newLine._combined[el] = this._combined[el];
}
newLine.isWrapped = this.isWrapped;
return newLine;
}
}

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

}
this._normal.x = this._alt.x;
this._normal.y = this._alt.y;
// The alt buffer should always be cleared when we switch to the normal

@@ -79,3 +81,3 @@ // buffer. This frees up memory since the alt buffer should always be new

*/
public activateAltBuffer(): void {
public activateAltBuffer(fillAttr?: number): void {
if (this._activeBuffer === this._alt) {

@@ -86,3 +88,5 @@ return;

// activated, we want to fill it when switching to it.
this._alt.fillViewportRows();
this._alt.fillViewportRows(fillAttr);
this._alt.x = this._normal.x;
this._alt.y = this._normal.y;
this._activeBuffer = this._alt;

@@ -89,0 +93,0 @@ this.emit('activate', {

@@ -6,167 +6,135 @@ /**

import { fill } from './common/TypedArrayUtils';
export const wcwidth = (function(opts: {nul: number, control: number}): (ucs: number) => number {
// extracted from https://www.cl.cam.ac.uk/%7Emgk25/ucs/wcwidth.c
// combining characters
const 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]
];
const 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]
];
// binary search
function bisearch(ucs: number, data: number[][]): boolean {
let min = 0;
let max = data.length - 1;
let 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;
}
}
// extracted from https://www.cl.cam.ac.uk/%7Emgk25/ucs/wcwidth.c
// combining characters
const 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]
];
const 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]
];
// binary search
function bisearch(ucs: number, data: number[][]): boolean {
let min = 0;
let max = data.length - 1;
let mid;
if (ucs < data[0][0] || ucs > data[max][1]) {
return false;
}
function wcwidthBMP(ucs: number): number {
// test for 8-bit control characters
if (ucs === 0) {
return opts.nul;
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;
}
if (ucs < 32 || (ucs >= 0x7f && ucs < 0xa0)) {
return opts.control;
}
// binary search in table of non-spacing characters
if (bisearch(ucs, COMBINING_BMP)) {
return 0;
}
// if we arrive here, ucs is not a combining or C0/C1 control character
if (isWideBMP(ucs)) {
return 2;
}
return 1;
}
function isWideBMP(ucs: number): boolean {
return (
ucs >= 0x1100 && (
ucs <= 0x115f || // Hangul Jamo init. consonants
ucs === 0x2329 ||
ucs === 0x232a ||
(ucs >= 0x2e80 && ucs <= 0xa4cf && ucs !== 0x303f) || // CJK..Yi
(ucs >= 0xac00 && ucs <= 0xd7a3) || // Hangul Syllables
(ucs >= 0xf900 && ucs <= 0xfaff) || // CJK Compat Ideographs
(ucs >= 0xfe10 && ucs <= 0xfe19) || // Vertical forms
(ucs >= 0xfe30 && ucs <= 0xfe6f) || // CJK Compat Forms
(ucs >= 0xff00 && ucs <= 0xff60) || // Fullwidth Forms
(ucs >= 0xffe0 && ucs <= 0xffe6)));
return false;
}
function wcwidthHigh(ucs: number): 0 | 1 | 2 {
if (bisearch(ucs, COMBINING_HIGH)) {
return 0;
}
function wcwidthHigh(ucs: number): 0 | 1 | 2 {
if (bisearch(ucs, COMBINING_HIGH)) {
return 0;
}
if ((ucs >= 0x20000 && ucs <= 0x2fffd) || (ucs >= 0x30000 && ucs <= 0x3fffd)) {
return 2;
}
if ((ucs >= 0x20000 && ucs <= 0x2fffd) || (ucs >= 0x30000 && ucs <= 0x3fffd)) {
return 2;
}
return 1;
}
const control = opts.control | 0;
// create lookup table for BMP plane
const table = new Uint8Array(65536);
fill(table, 1);
table[0] = opts.nul;
// control chars
fill(table, opts.control, 1, 32);
fill(table, opts.control, 0x7f, 0xa0);
// apply wide char rules first
// wide chars
fill(table, 2, 0x1100, 0x1160);
table[0x2329] = 2;
table[0x232a] = 2;
fill(table, 2, 0x2e80, 0xa4d0);
table[0x303f] = 1; // wrongly in last line
fill(table, 2, 0xac00, 0xd7a4);
fill(table, 2, 0xf900, 0xfb00);
fill(table, 2, 0xfe10, 0xfe1a);
fill(table, 2, 0xfe30, 0xfe70);
fill(table, 2, 0xff00, 0xff61);
fill(table, 2, 0xffe0, 0xffe7);
// apply combining last to ensure we overwrite
// wrongly wide set chars:
// the original algo evals combining first and falls
// through to wide check so we simply do here the opposite
// combining 0
for (let r = 0; r < COMBINING_BMP.length; ++r) {
fill(table, 0, COMBINING_BMP[r][0], COMBINING_BMP[r][1] + 1);
}
return function (num: number): number {
if (num < 32) {
return control | 0;
}
if (num < 127) {
return 1;
}
const control = opts.control | 0;
let table: number[] | Uint32Array = null;
function initTable(): number[] | Uint32Array {
// lookup table for BMP
const CODEPOINTS = 65536; // BMP holds 65536 codepoints
const BITWIDTH = 2; // a codepoint can have a width of 0, 1 or 2
const ITEMSIZE = 32; // using uint32_t
const CONTAINERSIZE = CODEPOINTS * BITWIDTH / ITEMSIZE;
const CODEPOINTS_PER_ITEM = ITEMSIZE / BITWIDTH;
table = (typeof Uint32Array === 'undefined')
? new Array(CONTAINERSIZE)
: new Uint32Array(CONTAINERSIZE);
for (let i = 0; i < CONTAINERSIZE; ++i) {
let num = 0;
let pos = CODEPOINTS_PER_ITEM;
while (pos--) {
num = (num << 2) | wcwidthBMP(CODEPOINTS_PER_ITEM * i + pos);
}
table[i] = num;
}
return table;
if (num < 65536) {
return table[num];
}
// get width from lookup table
// position in container : num / CODEPOINTS_PER_ITEM
// ==> n = table[Math.floor(num / 16)]
// ==> n = table[num >> 4]
// 16 codepoints per number: FFEEDDCCBBAA99887766554433221100
// position in number : (num % CODEPOINTS_PER_ITEM) * BITWIDTH
// ==> m = (n % 16) * 2
// ==> m = (num & 15) << 1
// right shift to position m
// ==> n = n >> m e.g. m=12 000000000000FFEEDDCCBBAA99887766
// we are only interested in 2 LSBs, cut off higher bits
// ==> n = n & 3 e.g. 000000000000000000000000000000XX
return function (num: number): number {
num = num | 0; // get asm.js like optimization under V8
if (num < 32) {
return control | 0;
}
if (num < 127) {
return 1;
}
const t = table || initTable();
if (num < 65536) {
return t[num >> 4] >> ((num & 15) << 1) & 3;
}
// do a full search for high codepoints
return wcwidthHigh(num);
};
// do a full search for high codepoints
return wcwidthHigh(num);
};
})({nul: 0, control: 0}); // configurable options

@@ -179,14 +147,24 @@

let result = 0;
for (let i = 0; i < s.length; ++i) {
const length = s.length;
for (let i = 0; i < length; ++i) {
let code = s.charCodeAt(i);
// surrogate pair first
if (0xD800 <= code && code <= 0xDBFF) {
const low = s.charCodeAt(i + 1);
if (isNaN(low)) {
return result;
if (++i >= length) {
// this should not happen with strings retrieved from
// Buffer.translateToString as it converts from UTF-32
// and therefore always should contain the second part
// for any other string we still have to handle it somehow:
// simply treat the lonely surrogate first as a single char (UCS-2 behavior)
return result + wcwidth(code);
}
code = ((code - 0xD800) * 0x400) + (low - 0xDC00) + 0x10000;
const second = s.charCodeAt(i);
// convert surrogate pair to high codepoint only for valid second part (UTF-16)
// otherwise treat them independently (UCS-2 behavior)
if (0xDC00 <= second && second <= 0xDFFF) {
code = (code - 0xD800) * 0x400 + second - 0xDC00 + 0x10000;
} else {
result += wcwidth(second);
}
}
if (0xDC00 <= code && code <= 0xDFFF) {
continue;
}
result += wcwidth(code);

@@ -193,0 +171,0 @@ }

@@ -93,6 +93,3 @@ /**

if (this._length === this._maxLength) {
this._startIndex++;
if (this._startIndex === this._maxLength) {
this._startIndex = 0;
}
this._startIndex = ++this._startIndex % this._maxLength;
this.emit('trim', 1);

@@ -105,2 +102,23 @@ } else {

/**
* Advance ringbuffer index and return current element for recycling.
* Note: The buffer must be full for this method to work.
* @throws When the buffer is not full.
*/
public recycle(): T {
if (this._length !== this._maxLength) {
throw new Error('Can only recycle when the buffer is full');
}
this._startIndex = ++this._startIndex % this._maxLength;
this.emit('trim', 1);
return this._array[this._getCyclicIndex(this._length - 1)]!;
}
/**
* Ringbuffer is at max length.
*/
public get isFull(): boolean {
return this._length === this._maxLength;
}
/**
* Removes and returns the last value on the list.

@@ -141,6 +159,6 @@ * @return The popped value.

// Adjust length as needed
if (this._length + items.length > this.maxLength) {
const countToTrim = (this._length + items.length) - this.maxLength;
if (this._length + items.length > this._maxLength) {
const countToTrim = (this._length + items.length) - this._maxLength;
this._startIndex += countToTrim;
this._length = this.maxLength;
this._length = this._maxLength;
this.emit('trim', countToTrim);

@@ -184,3 +202,3 @@ } else {

this._length += expandListBy;
while (this._length > this.maxLength) {
while (this._length > this._maxLength) {
this._length--;

@@ -205,4 +223,4 @@ this._startIndex++;

private _getCyclicIndex(index: number): number {
return (this._startIndex + index) % this.maxLength;
return (this._startIndex + index) % this._maxLength;
}
}

@@ -17,3 +17,3 @@ /**

// constructor is called multiple times on the same object (terminal reset).
this._events = this._events || {};
this._events = (<any>this)._events || {};
}

@@ -20,0 +20,0 @@

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

maxLength: number;
isFull: boolean;

@@ -32,2 +33,3 @@ get(index: number): T | undefined;

push(value: T): void;
recycle(): T | undefined;
pop(): T | undefined;

@@ -34,0 +36,0 @@ splice(start: number, deleteCount: number, ...items: T[]): void;

@@ -13,3 +13,3 @@ /**

*/
export const CHARSETS: { [key: string]: ICharset } = {};
export const CHARSETS: { [key: string]: ICharset | null } = {};

@@ -19,3 +19,3 @@ /**

*/
export const DEFAULT_CHARSET: ICharset = CHARSETS['B'];
export const DEFAULT_CHARSET: ICharset | null = CHARSETS['B'];

@@ -22,0 +22,0 @@ /**

@@ -69,3 +69,3 @@ /**

EXECUTABLES.push(0x19);
EXECUTABLES.concat(r(0x1c, 0x20));
EXECUTABLES.push.apply(EXECUTABLES, r(0x1c, 0x20));
const DEFAULT_TRANSITION = ParserAction.ERROR << 4 | ParserState.GROUND;

@@ -265,2 +265,5 @@

this._errorHandler = this._errorHandlerFb;
// swallow 7bit ST (ESC+\)
this.setEscHandler('\\', () => {});
}

@@ -267,0 +270,0 @@

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

this._terminal.charMeasure,
this._terminal.options.lineHeight,
this._terminal.cols,

@@ -39,0 +38,0 @@ this._terminal.rows,

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

import { IColorSet } from '../Types';
import { ICharAtlasConfig } from '../../shared/atlas/Types';
import { generateConfig, configEquals } from './CharAtlasUtils';

@@ -15,2 +14,3 @@ import BaseCharAtlas from './BaseCharAtlas';

import StaticCharAtlas from './StaticCharAtlas';
import { ICharAtlasConfig } from './Types';

@@ -17,0 +17,0 @@ const charAtlasImplementations = {

@@ -8,3 +8,3 @@ /**

import { IColorSet } from '../Types';
import { ICharAtlasConfig } from '../../shared/atlas/Types';
import { DEFAULT_COLOR, ICharAtlasConfig } from './Types';

@@ -55,1 +55,5 @@ export function generateConfig(scaledCharWidth: number, scaledCharHeight: number, terminal: ITerminal, colors: IColorSet): ICharAtlasConfig {

}
export function is256Color(colorCode: number): boolean {
return colorCode < DEFAULT_COLOR;
}

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

import { DIM_OPACITY, IGlyphIdentifier, INVERTED_DEFAULT_COLOR } from './Types';
import { ICharAtlasConfig } from '../../shared/atlas/Types';
import { IColor } from '../../shared/Types';
import { DIM_OPACITY, IGlyphIdentifier, INVERTED_DEFAULT_COLOR, ICharAtlasConfig } from './Types';
import BaseCharAtlas from './BaseCharAtlas';
import { DEFAULT_ANSI_COLORS } from '../ColorManager';
import { clearColor } from '../../shared/atlas/CharAtlasGenerator';
import { clearColor } from './CharAtlasGenerator';
import LRUMap from './LRUMap';
import { isFirefox, isSafari } from '../../shared/utils/Browser';
import { isFirefox, isSafari } from '../../core/Platform';
import { IColor } from '../Types';

@@ -46,3 +45,3 @@ // In practice we're probably never going to exhaust a texture this large. For debugging purposes,

function getGlyphCacheKey(glyph: IGlyphIdentifier): number {
export function getGlyphCacheKey(glyph: IGlyphIdentifier): number {
// Note that this only returns a valid key when code < 256

@@ -134,2 +133,7 @@ // Layout:

// Exit early for uncachable glyphs
if (!this._canCache(glyph)) {
return false;
}
const glyphKey = getGlyphCacheKey(glyph);

@@ -140,3 +144,3 @@ const cacheValue = this._cacheMap.get(glyphKey);

return true;
} else if (this._canCache(glyph) && this._drawToCacheCount < FRAME_CACHE_DRAW_LIMIT) {
} else if (this._drawToCacheCount < FRAME_CACHE_DRAW_LIMIT) {
let index;

@@ -143,0 +147,0 @@ if (this._cacheMap.size < this._cacheMap.capacity) {

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

import { IGlyphIdentifier } from './Types';
import { ICharAtlasConfig } from '../../shared/atlas/Types';
import { IGlyphIdentifier, ICharAtlasConfig } from './Types';
import BaseCharAtlas from './BaseCharAtlas';

@@ -12,0 +11,0 @@

@@ -6,6 +6,6 @@ /**

import { DIM_OPACITY, IGlyphIdentifier } from './Types';
import { CHAR_ATLAS_CELL_SPACING, ICharAtlasConfig } from '../../shared/atlas/Types';
import { generateStaticCharAtlasTexture } from '../../shared/atlas/CharAtlasGenerator';
import { DIM_OPACITY, IGlyphIdentifier, DEFAULT_COLOR, ICharAtlasConfig, CHAR_ATLAS_CELL_SPACING } from './Types';
import { generateStaticCharAtlasTexture } from './CharAtlasGenerator';
import BaseCharAtlas from './BaseCharAtlas';
import { is256Color } from './CharAtlasUtils';

@@ -45,4 +45,4 @@ export default class StaticCharAtlas extends BaseCharAtlas {

const isBasicColor = glyph.fg < 16;
const isDefaultColor = glyph.fg >= 256;
const isDefaultBackground = glyph.bg >= 256;
const isDefaultColor = glyph.fg === DEFAULT_COLOR;
const isDefaultBackground = glyph.bg === DEFAULT_COLOR;
return isAscii && (isBasicColor || isDefaultColor) && isDefaultBackground && !glyph.italic;

@@ -63,5 +63,5 @@ }

let colorIndex = 0;
if (glyph.fg < 256) {
if (is256Color(glyph.fg)) {
colorIndex = 2 + glyph.fg + (glyph.bold ? 16 : 0);
} else {
} else if (glyph.fg === DEFAULT_COLOR) {
// If default color and bold

@@ -68,0 +68,0 @@ if (glyph.bold) {

@@ -6,5 +6,11 @@ /**

export const INVERTED_DEFAULT_COLOR = -1;
import { FontWeight } from 'xterm';
import { IColorSet } from '../Types';
export const DEFAULT_COLOR = 256;
export const INVERTED_DEFAULT_COLOR = 257;
export const DIM_OPACITY = 0.5;
export const CHAR_ATLAS_CELL_SPACING = 1;
export interface IGlyphIdentifier {

@@ -19,1 +25,14 @@ chars: string;

}
export interface ICharAtlasConfig {
type: 'none' | 'static' | 'dynamic';
devicePixelRatio: number;
fontSize: number;
fontFamily: string;
fontWeight: FontWeight;
fontWeightBold: FontWeight;
scaledCharWidth: number;
scaledCharHeight: number;
allowTransparency: boolean;
colors: IColorSet;
}

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

import { CHAR_DATA_CHAR_INDEX } from '../Buffer';
import { is256Color } from './atlas/CharAtlasUtils';

@@ -302,3 +303,3 @@ export abstract class BaseRenderLayer implements IRenderLayer {

this._ctx.fillStyle = this._colors.background.css;
} else if (fg < 256) {
} else if (is256Color(fg)) {
// 256 color support

@@ -305,0 +306,0 @@ this._ctx.fillStyle = this._colors.ansi[fg].css;

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

import { IColorManager } from './Types';
import { IColor, IColorSet } from '../shared/Types';
import { IColorManager, IColor, IColorSet } from './Types';
import { ITheme } from 'xterm';

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

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

import { BOLD_CLASS, ITALIC_CLASS, CURSOR_CLASS, CURSOR_STYLE_BLOCK_CLASS, CURSOR_STYLE_BAR_CLASS, CURSOR_STYLE_UNDERLINE_CLASS, DomRendererRowFactory } from './DomRendererRowFactory';
import { INVERTED_DEFAULT_COLOR } from '../atlas/Types';

@@ -98,6 +99,6 @@ const TERMINAL_CLASS_PREFIX = 'xterm-dom-renderer-owner-';

private _updateDimensions(): void {
this.dimensions.scaledCharWidth = this._terminal.charMeasure.width * window.devicePixelRatio;
this.dimensions.scaledCharHeight = this._terminal.charMeasure.height * window.devicePixelRatio;
this.dimensions.scaledCellWidth = this.dimensions.scaledCharWidth;
this.dimensions.scaledCellHeight = this.dimensions.scaledCharHeight;
this.dimensions.scaledCharWidth = Math.floor(this._terminal.charMeasure.width * window.devicePixelRatio);
this.dimensions.scaledCharHeight = Math.ceil(this._terminal.charMeasure.height * window.devicePixelRatio);
this.dimensions.scaledCellWidth = this.dimensions.scaledCharWidth + Math.round(this._terminal.options.letterSpacing);
this.dimensions.scaledCellHeight = Math.floor(this.dimensions.scaledCharHeight * this._terminal.options.lineHeight);
this.dimensions.scaledCharLeft = 0;

@@ -107,10 +108,13 @@ this.dimensions.scaledCharTop = 0;

this.dimensions.scaledCanvasHeight = this.dimensions.scaledCellHeight * this._terminal.rows;
this.dimensions.canvasWidth = this._terminal.charMeasure.width * this._terminal.cols;
this.dimensions.canvasHeight = this._terminal.charMeasure.height * this._terminal.rows;
this.dimensions.actualCellWidth = this._terminal.charMeasure.width;
this.dimensions.actualCellHeight = this._terminal.charMeasure.height;
this.dimensions.canvasWidth = Math.round(this.dimensions.scaledCanvasWidth / window.devicePixelRatio);
this.dimensions.canvasHeight = Math.round(this.dimensions.scaledCanvasHeight / window.devicePixelRatio);
this.dimensions.actualCellWidth = this.dimensions.canvasWidth / this._terminal.cols;
this.dimensions.actualCellHeight = this.dimensions.canvasHeight / this._terminal.rows;
this._rowElements.forEach(element => {
element.style.width = `${this.dimensions.canvasWidth}px`;
element.style.height = `${this._terminal.charMeasure.height}px`;
element.style.height = `${this.dimensions.actualCellHeight}px`;
element.style.lineHeight = `${this.dimensions.actualCellHeight}px`;
// Make sure rows don't overflow onto following row
element.style.overflow = 'hidden';
});

@@ -128,3 +132,3 @@

` vertical-align: top;` +
` width: ${this._terminal.charMeasure.width}px` +
` width: ${this.dimensions.actualCellWidth}px` +
`}`;

@@ -135,4 +139,4 @@

this._selectionContainer.style.height = (<any>this._terminal)._viewportElement.style.height;
this._rowContainer.style.width = `${this.dimensions.canvasWidth}px`;
this._rowContainer.style.height = `${this.dimensions.canvasHeight}px`;
this._terminal.screenElement.style.width = `${this.dimensions.canvasWidth}px`;
this._terminal.screenElement.style.height = `${this.dimensions.canvasHeight}px`;
}

@@ -204,2 +208,5 @@

});
styles +=
`${this._terminalSelector} .${FG_CLASS_PREFIX}${INVERTED_DEFAULT_COLOR} { color: ${this.colorManager.colors.background.css}; }` +
`${this._terminalSelector} .${BG_CLASS_PREFIX}${INVERTED_DEFAULT_COLOR} { background-color: ${this.colorManager.colors.foreground.css}; }`;

@@ -299,6 +306,6 @@ this._themeStyleElement.innerHTML = styles;

const element = document.createElement('div');
element.style.height = `${rowCount * this._terminal.charMeasure.height}px`;
element.style.top = `${row * this._terminal.charMeasure.height}px`;
element.style.left = `${colStart * this._terminal.charMeasure.width}px`;
element.style.width = `${this._terminal.charMeasure.width * (colEnd - colStart)}px`;
element.style.height = `${rowCount * this.dimensions.actualCellHeight}px`;
element.style.top = `${row * this.dimensions.actualCellHeight}px`;
element.style.left = `${colStart * this.dimensions.actualCellWidth}px`;
element.style.width = `${this.dimensions.actualCellWidth * (colEnd - colStart)}px`;
return element;

@@ -339,3 +346,3 @@ }

const cursorStyle = terminal.options.cursorStyle;
rowElement.appendChild(this._rowFactory.createRow(lineData, row === cursorAbsoluteY, cursorStyle, cursorX, terminal.charMeasure.width, terminal.cols));
rowElement.appendChild(this._rowFactory.createRow(lineData, row === cursorAbsoluteY, cursorStyle, cursorX, this.dimensions.actualCellWidth, terminal.cols));
}

@@ -363,3 +370,7 @@

while (x !== x2 || y !== y2) {
const span = <HTMLElement>this._rowElements[y].children[x];
const row = this._rowElements[y];
if (!row) {
return;
}
const span = <HTMLElement>row.children[x];
span.style.textDecoration = enabled ? 'underline' : 'none';

@@ -366,0 +377,0 @@ x = (x + 1) % cols;

@@ -6,5 +6,6 @@ /**

import { CHAR_DATA_CHAR_INDEX, CHAR_DATA_ATTR_INDEX, CHAR_DATA_WIDTH_INDEX } from '../../Buffer';
import { CHAR_DATA_CHAR_INDEX, CHAR_DATA_ATTR_INDEX, CHAR_DATA_WIDTH_INDEX, CHAR_DATA_CODE_INDEX, NULL_CELL_CODE } from '../../Buffer';
import { FLAGS } from '../Types';
import { IBufferLine } from '../../Types';
import { DEFAULT_COLOR, INVERTED_DEFAULT_COLOR } from '../atlas/Types';

@@ -26,14 +27,23 @@ export const BOLD_CLASS = 'xterm-bold';

const fragment = this._document.createDocumentFragment();
let colCount = 0;
for (let x = 0; x < lineData.length; x++) {
// Don't allow any buffer to the right to be displayed
if (colCount >= cols) {
continue;
// Find the line length first, this prevents the need to output a bunch of
// empty cells at the end. This cannot easily be integrated into the main
// loop below because of the colCount feature (which can be removed after we
// properly support reflow and disallow data to go beyond the right-side of
// the viewport).
let lineLength = 0;
for (let x = Math.min(lineData.length, cols) - 1; x >= 0; x--) {
const charData = lineData.get(x);
const code = charData[CHAR_DATA_CODE_INDEX];
if (code !== NULL_CELL_CODE || (isCursorRow && x === cursorX)) {
lineLength = x + 1;
break;
}
}
for (let x = 0; x < lineLength; x++) {
const charData = lineData.get(x);
const char: string = charData[CHAR_DATA_CHAR_INDEX];
const attr: number = charData[CHAR_DATA_ATTR_INDEX];
const width: number = charData[CHAR_DATA_WIDTH_INDEX];
const char = charData[CHAR_DATA_CHAR_INDEX];
const attr = charData[CHAR_DATA_ATTR_INDEX];
const width = charData[CHAR_DATA_WIDTH_INDEX];

@@ -75,7 +85,7 @@ // The character to the left is a wide character, drawing is owned by the char at x-1

fg = temp;
if (fg === 256) {
fg = 0;
if (fg === DEFAULT_COLOR) {
fg = INVERTED_DEFAULT_COLOR;
}
if (bg === 257) {
bg = 15;
if (bg === DEFAULT_COLOR) {
bg = INVERTED_DEFAULT_COLOR;
}

@@ -85,3 +95,4 @@ }

if (flags & FLAGS.BOLD) {
// Convert the FG color to the bold variant
// Convert the FG color to the bold variant. This should not happen when
// the fg is the inverse default color as there is no bold variant.
if (fg < 8) {

@@ -98,10 +109,9 @@ fg += 8;

charElement.textContent = char;
if (fg !== 257) {
if (fg !== DEFAULT_COLOR) {
charElement.classList.add(`xterm-fg-${fg}`);
}
if (bg !== 256) {
if (bg !== DEFAULT_COLOR) {
charElement.classList.add(`xterm-bg-${bg}`);
}
fragment.appendChild(charElement);
colCount += width;
}

@@ -108,0 +118,0 @@ return fragment;

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

import { INVERTED_DEFAULT_COLOR } from './atlas/Types';
import { is256Color } from './atlas/CharAtlasUtils';

@@ -46,3 +47,3 @@ export class LinkRenderLayer extends BaseRenderLayer {

this._ctx.fillStyle = this._colors.background.css;
} else if (e.fg < 256) {
} else if (is256Color(e.fg)) {
// 256 color support

@@ -49,0 +50,0 @@ this._ctx.fillStyle = this._colors.ansi[e.fg].css;

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

import { CharData, ITerminal } from '../Types';
import { INVERTED_DEFAULT_COLOR } from './atlas/Types';
import { INVERTED_DEFAULT_COLOR, DEFAULT_COLOR } from './atlas/Types';
import { GridCache } from './GridCache';
import { BaseRenderLayer } from './BaseRenderLayer';
import { is256Color } from './atlas/CharAtlasUtils';

@@ -147,6 +148,6 @@ /**

fg = temp;
if (fg === 256) {
if (fg === DEFAULT_COLOR) {
fg = INVERTED_DEFAULT_COLOR;
}
if (bg === 257) {
if (bg === DEFAULT_COLOR) {
bg = INVERTED_DEFAULT_COLOR;

@@ -191,3 +192,3 @@ }

nextFillStyle = this._colors.foreground.css;
} else if (bg < 256) {
} else if (is256Color(bg)) {
nextFillStyle = this._colors.ansi[bg].css;

@@ -236,3 +237,3 @@ }

this._ctx.fillStyle = this._colors.background.css;
} else if (fg < 256) {
} else if (is256Color(fg)) {
// 256 color support

@@ -239,0 +240,0 @@ this._ctx.fillStyle = this._colors.ansi[fg].css;

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

import { IEventEmitter, ITheme, IDisposable } from 'xterm';
import { IColorSet } from '../shared/Types';

@@ -52,5 +51,2 @@ /**

// TODO: We should probably rewrite the imports for IColorSet, but there's a lot of them
export { IColorSet };
export interface IRenderDimensions {

@@ -139,1 +135,15 @@ scaledCharWidth: number;

}
export interface IColor {
css: string;
rgba: number; // 32-bit int with rgba in each byte
}
export interface IColorSet {
foreground: IColor;
background: IColor;
cursor: IColor;
cursorAccent: IColor;
selection: IColor;
ansi: IColor[];
}

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

import { MouseHelper } from './utils/MouseHelper';
import * as Browser from './shared/utils/Browser';
import * as Browser from './core/Platform';
import { CharMeasure } from './ui/CharMeasure';

@@ -293,5 +293,10 @@ import { EventEmitter } from './common/EventEmitter';

return this._areCoordsInSelection(coords, start, end);
}
protected _areCoordsInSelection(coords: [number, number], start: [number, number], end: [number, number]): boolean {
return (coords[1] > start[1] && coords[1] < end[1]) ||
(start[1] === end[1] && coords[1] === start[1] && coords[0] > start[0] && coords[0] < end[0]) ||
(start[1] < end[1] && coords[1] === end[1] && coords[0] < end[0]);
(start[1] === end[1] && coords[1] === start[1] && coords[0] >= start[0] && coords[0] < end[0]) ||
(start[1] < end[1] && coords[1] === end[1] && coords[0] < end[0]) ||
(start[1] < end[1] && coords[1] === start[1] && coords[0] >= start[0]);
}

@@ -347,3 +352,3 @@

private _getMouseBufferCoords(event: MouseEvent): [number, number] {
const coords = this._terminal.mouseHelper.getCoords(event, this._terminal.screenElement, this._charMeasure, this._terminal.options.lineHeight, this._terminal.cols, this._terminal.rows, true);
const coords = this._terminal.mouseHelper.getCoords(event, this._terminal.screenElement, this._charMeasure, this._terminal.cols, this._terminal.rows, true);
if (!coords) {

@@ -350,0 +355,0 @@ return null;

@@ -15,4 +15,16 @@ /**

export class SoundManager implements ISoundManager {
private _audioContext: AudioContext;
private static _audioContext: AudioContext;
static get audioContext(): AudioContext | null {
if (!SoundManager._audioContext) {
const audioContextCtor: typeof AudioContext = (<any>window).AudioContext || (<any>window).webkitAudioContext;
if (!audioContextCtor) {
console.warn('Web Audio API is not supported by this browser. Consider upgrading to the latest version');
return null;
}
SoundManager._audioContext = new audioContextCtor();
}
return SoundManager._audioContext;
}
constructor(

@@ -24,18 +36,12 @@ private _terminal: ITerminal

public playBellSound(): void {
const audioContextCtor: typeof AudioContext = (<any>window).AudioContext || (<any>window).webkitAudioContext;
if (!this._audioContext && audioContextCtor) {
this._audioContext = new audioContextCtor();
const ctx = SoundManager.audioContext;
if (!ctx) {
return;
}
if (this._audioContext) {
const bellAudioSource = this._audioContext.createBufferSource();
const context = this._audioContext;
this._audioContext.decodeAudioData(this._base64ToArrayBuffer(this._removeMimeType(this._terminal.options.bellSound)), (buffer) => {
bellAudioSource.buffer = buffer;
bellAudioSource.connect(context.destination);
bellAudioSource.start(0);
});
} else {
console.warn('Sorry, but the Web Audio API is not supported by your browser. Please, consider upgrading to the latest version');
}
const bellAudioSource = ctx.createBufferSource();
ctx.decodeAudioData(this._base64ToArrayBuffer(this._removeMimeType(this._terminal.options.bellSound)), (buffer) => {
bellAudioSource.buffer = buffer;
bellAudioSource.connect(ctx.destination);
bellAudioSource.start(0);
});
}

@@ -42,0 +48,0 @@

@@ -24,11 +24,11 @@ /**

import { IInputHandlingTerminal, IViewport, ICompositionHelper, ITerminalOptions, ITerminal, IBrowser, ILinkifier, ILinkMatcherOptions, CustomKeyEventHandler, LinkMatcherHandler, CharData, CharacterJoinerHandler } from './Types';
import { IInputHandlingTerminal, IViewport, ICompositionHelper, ITerminalOptions, ITerminal, IBrowser, ILinkifier, ILinkMatcherOptions, CustomKeyEventHandler, LinkMatcherHandler, CharData, CharacterJoinerHandler, IBufferLine } from './Types';
import { IMouseZoneManager } from './ui/Types';
import { IRenderer } from './renderer/Types';
import { BufferSet } from './BufferSet';
import { Buffer, MAX_BUFFER_SIZE, DEFAULT_ATTR, NULL_CELL_CODE, NULL_CELL_WIDTH, NULL_CELL_CHAR } from './Buffer';
import { Buffer, MAX_BUFFER_SIZE, DEFAULT_ATTR, NULL_CELL_CODE, NULL_CELL_WIDTH, NULL_CELL_CHAR, CHAR_DATA_ATTR_INDEX } from './Buffer';
import { CompositionHelper } from './CompositionHelper';
import { EventEmitter } from './common/EventEmitter';
import { Viewport } from './Viewport';
import { rightClickHandler, moveTextAreaUnderMouseCursor, pasteHandler, copyHandler } from './handlers/Clipboard';
import { rightClickHandler, moveTextAreaUnderMouseCursor, pasteHandler, copyHandler } from './ui/Clipboard';
import { C0 } from './common/data/EscapeSequences';

@@ -40,3 +40,3 @@ import { InputHandler } from './InputHandler';

import { CharMeasure } from './ui/CharMeasure';
import * as Browser from './shared/utils/Browser';
import * as Browser from './core/Platform';
import { addDisposableDomListener } from './ui/Lifecycle';

@@ -57,3 +57,2 @@ import * as Strings from './Strings';

import { KeyboardResultType, ICharset } from './core/Types';
import { BufferLine } from './BufferLine';

@@ -112,3 +111,4 @@ // Let it work inside Node.js for automated testing purposes.

rightClickSelectsWord: Browser.isMac,
rendererType: 'canvas'
rendererType: 'canvas',
experimentalBufferLineImpl: 'TypedArray'
};

@@ -177,3 +177,2 @@

public curAttr: number;
public savedCurAttr: number;

@@ -216,2 +215,5 @@ public params: (string | number)[];

// bufferline to clone/copy from for new blank lines
private _blankLine: IBufferLine = null;
public cols: number;

@@ -351,3 +353,3 @@ public rows: number;

public get isFocused(): boolean {
return document.activeElement === this.textarea;
return document.activeElement === this.textarea && document.hasFocus();
}

@@ -483,2 +485,3 @@

}
this.mouseHelper.setRenderer(this.renderer);
break;

@@ -504,2 +507,7 @@ case 'scrollback':

case 'tabStopWidth': this.buffers.setupTabStops(); break;
case 'experimentalBufferLineImpl':
this.buffers.normal.setBufferLineFactory(value);
this.buffers.alt.setBufferLineFactory(value);
this._blankLine = null;
break;
}

@@ -811,3 +819,3 @@ // Inform renderer of changes

// get mouse coordinates
pos = self.mouseHelper.getRawByteCoords(ev, self.screenElement, self.charMeasure, self.options.lineHeight, self.cols, self.rows);
pos = self.mouseHelper.getRawByteCoords(ev, self.screenElement, self.charMeasure, self.cols, self.rows);
if (!pos) return;

@@ -838,3 +846,3 @@

let button = pressed;
const pos = self.mouseHelper.getRawByteCoords(ev, self.screenElement, self.charMeasure, self.options.lineHeight, self.cols, self.rows);
const pos = self.mouseHelper.getRawByteCoords(ev, self.screenElement, self.charMeasure, self.cols, self.rows);
if (!pos) return;

@@ -994,3 +1002,3 @@

case 'wheel':
button = (<WheelEvent>ev).wheelDeltaY > 0
button = (<WheelEvent>ev).deltaY < 0
? 64

@@ -1164,5 +1172,5 @@ : 65;

if (this.selectionManager && this.selectionManager.shouldColumnSelect(ev)) {
this.element.classList.add('xterm-cursor-crosshair');
this.element.classList.add('column-select');
} else {
this.element.classList.remove('xterm-cursor-crosshair');
this.element.classList.remove('column-select');
}

@@ -1185,4 +1193,16 @@ }

*/
public scroll(isWrapped?: boolean): void {
const newLine = BufferLine.blankLine(this.cols, DEFAULT_ATTR, isWrapped);
public scroll(isWrapped: boolean = false): void {
let newLine: IBufferLine;
const useRecycling = this.options.experimentalBufferLineImpl !== 'JsArray';
if (useRecycling) {
newLine = this._blankLine;
if (!newLine || newLine.length !== this.cols || newLine.get(0)[CHAR_DATA_ATTR_INDEX] !== this.eraseAttr()) {
newLine = this.buffer.getBlankLine(this.eraseAttr(), isWrapped);
this._blankLine = newLine;
}
newLine.isWrapped = isWrapped;
} else {
newLine = this.buffer.getBlankLine(this.eraseAttr(), isWrapped);
}
const topRow = this.buffer.ybase + this.buffer.scrollTop;

@@ -1193,9 +1213,17 @@ const bottomRow = this.buffer.ybase + this.buffer.scrollBottom;

// Determine whether the buffer is going to be trimmed after insertion.
const willBufferBeTrimmed = this.buffer.lines.length === this.buffer.lines.maxLength;
const willBufferBeTrimmed = this.buffer.lines.isFull;
// Insert the line using the fastest method
if (bottomRow === this.buffer.lines.length - 1) {
this.buffer.lines.push(newLine);
if (useRecycling) {
if (willBufferBeTrimmed) {
this.buffer.lines.recycle().copyFrom(newLine);
} else {
this.buffer.lines.push(newLine.clone());
}
} else {
this.buffer.lines.push(newLine);
}
} else {
this.buffer.lines.splice(bottomRow + 1, 0, newLine);
this.buffer.lines.splice(bottomRow + 1, 0, (useRecycling) ? newLine.clone() : newLine);
}

@@ -1222,3 +1250,3 @@

this.buffer.lines.shiftElements(topRow + 1, scrollRegionHeight - 1, -1);
this.buffer.lines.set(bottomRow, newLine);
this.buffer.lines.set(bottomRow, (useRecycling) ? newLine.clone() : newLine);
}

@@ -1741,3 +1769,3 @@

for (let i = 1; i < this.rows; i++) {
this.buffer.lines.push(BufferLine.blankLine(this.cols, DEFAULT_ATTR));
this.buffer.lines.push(this.buffer.getBlankLine(DEFAULT_ATTR));
}

@@ -1834,3 +1862,3 @@ this.refresh(0, this.rows - 1);

this.buffer.lines.shiftElements(this.buffer.y + this.buffer.ybase, scrollRegionHeight, 1);
this.buffer.lines.set(this.buffer.y + this.buffer.ybase, BufferLine.blankLine(this.cols, this.eraseAttr()));
this.buffer.lines.set(this.buffer.y + this.buffer.ybase, this.buffer.getBlankLine(this.eraseAttr()));
this.updateRange(this.buffer.scrollTop);

@@ -1837,0 +1865,0 @@ this.updateRange(this.buffer.scrollBottom);

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

curAttr: number;
savedCurAttr: number;
savedCols: number;

@@ -250,4 +249,4 @@ x10Mouse: boolean;

export interface IMouseHelper {
getCoords(event: { pageX: number, pageY: number }, element: HTMLElement, charMeasure: ICharMeasure, lineHeight: number, colCount: number, rowCount: number, isSelection?: boolean): [number, number];
getRawByteCoords(event: MouseEvent, element: HTMLElement, charMeasure: ICharMeasure, lineHeight: number, colCount: number, rowCount: number): { x: number, y: number };
getCoords(event: { pageX: number, pageY: number }, element: HTMLElement, charMeasure: ICharMeasure, colCount: number, rowCount: number, isSelection?: boolean): [number, number];
getRawByteCoords(event: MouseEvent, element: HTMLElement, charMeasure: ICharMeasure, colCount: number, rowCount: number): { x: number, y: number };
}

@@ -295,2 +294,3 @@

savedX: number;
savedCurAttr: number;
isCursorInViewport: boolean;

@@ -301,2 +301,3 @@ translateBufferLineToString(lineIndex: number, trimRight: boolean, startCol?: number, endCol?: number): string;

prevStop(x?: number): number;
getBlankLine(attr: number, isWrapped?: boolean): IBufferLine;
stringIndexToBufferIndex(lineIndex: number, stringIndex: number): number[];

@@ -312,3 +313,3 @@ iterator(trimRight: boolean, startIndex?: number, endIndex?: number, startOverscan?: number, endOverscan?: number): IBufferStringIterator;

activateNormalBuffer(): void;
activateAltBuffer(): void;
activateAltBuffer(fillAttr?: number): void;
}

@@ -524,8 +525,13 @@

set(index: number, value: CharData): void;
pop(): CharData | undefined;
push(data: CharData): void;
splice(start: number, deleteCount: number, ...items: CharData[]): CharData[];
insertCells(pos: number, n: number, ch: CharData): void;
deleteCells(pos: number, n: number, fill: CharData): void;
replaceCells(start: number, end: number, fill: CharData): void;
resize(cols: number, fill: CharData, shrink?: boolean): void;
fill(fillCharData: CharData): void;
copyFrom(line: IBufferLine): void;
clone(): IBufferLine;
}
export interface IBufferLineConstructor {
new(cols: number, fillCharData?: CharData, isWrapped?: boolean): IBufferLine;
}

@@ -183,3 +183,3 @@ /**

private _findZoneEventAt(e: MouseEvent): IMouseZone {
const coords = this._terminal.mouseHelper.getCoords(e, this._terminal.screenElement, this._terminal.charMeasure, this._terminal.options.lineHeight, this._terminal.cols, this._terminal.rows);
const coords = this._terminal.mouseHelper.getCoords(e, this._terminal.screenElement, this._terminal.charMeasure, this._terminal.cols, this._terminal.rows);
if (!coords) {

@@ -186,0 +186,0 @@ return null;

@@ -22,3 +22,3 @@ /**

private _currentDevicePixelRatio: number;
private _outerListener: MediaQueryListListener;
private _outerListener: (this: MediaQueryList, ev: MediaQueryListEvent) => any;
private _listener: ScreenDprListener;

@@ -25,0 +25,0 @@ private _resolutionMediaMatchList: MediaQueryList;

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

public setRenderer(renderer: IRenderer): void {
this._renderer = renderer;
}
public static getCoordsRelativeToElement(event: {pageX: number, pageY: number}, element: HTMLElement): [number, number] {

@@ -52,3 +56,3 @@ // Ignore browsers that don't support MouseEvent.pageX

*/
public getCoords(event: {pageX: number, pageY: number}, element: HTMLElement, charMeasure: ICharMeasure, lineHeight: number, colCount: number, rowCount: number, isSelection?: boolean): [number, number] {
public getCoords(event: {pageX: number, pageY: number}, element: HTMLElement, charMeasure: ICharMeasure, colCount: number, rowCount: number, isSelection?: boolean): [number, number] {
// Coordinates cannot be measured if charMeasure has not been initialized

@@ -86,4 +90,4 @@ if (!charMeasure.width || !charMeasure.height) {

*/
public getRawByteCoords(event: MouseEvent, element: HTMLElement, charMeasure: ICharMeasure, lineHeight: number, colCount: number, rowCount: number): { x: number, y: number } {
const coords = this.getCoords(event, element, charMeasure, lineHeight, colCount, rowCount);
public getRawByteCoords(event: MouseEvent, element: HTMLElement, charMeasure: ICharMeasure, colCount: number, rowCount: number): { x: number, y: number } {
const coords = this.getCoords(event, element, charMeasure, colCount, rowCount);
let x = coords[0];

@@ -90,0 +94,0 @@ let y = coords[1];

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

/// <reference lib="dom"/>
declare module 'xterm' {

@@ -104,2 +106,13 @@ /**

/**
* (EXPERIMENTAL) Defines which implementation to use for buffer lines.
*
* - 'JsArray': The default/stable implementation.
* - 'TypedArray': The new experimental implementation based on TypedArrays that is expected to
* significantly boost performance and memory consumption. Use at your own risk.
*
* @deprecated This option will be removed in the future.
*/
experimentalBufferLineImpl?: 'JsArray' | 'TypedArray';
/**
* The font size used to render text.

@@ -153,3 +166,2 @@ */

*
* - Line height
* - Letter spacing

@@ -381,3 +393,3 @@ * - Cursor blink

*/
on(type: 'key', listener: (key?: string, event?: KeyboardEvent) => void): void;
on(type: 'key', listener: (key: string, event: KeyboardEvent) => void): void;
/**

@@ -388,3 +400,3 @@ * Registers an event listener.

*/
on(type: 'keypress' | 'keydown', listener: (event?: KeyboardEvent) => void): void;
on(type: 'keypress' | 'keydown', listener: (event: KeyboardEvent) => void): void;
/**

@@ -395,3 +407,3 @@ * Registers an event listener.

*/
on(type: 'refresh', listener: (data?: {start: number, end: number}) => void): void;
on(type: 'refresh', listener: (data: {start: number, end: number}) => void): void;
/**

@@ -402,3 +414,3 @@ * Registers an event listener.

*/
on(type: 'resize', listener: (data?: {cols: number, rows: number}) => void): void;
on(type: 'resize', listener: (data: {cols: number, rows: number}) => void): void;
/**

@@ -409,3 +421,3 @@ * Registers an event listener.

*/
on(type: 'scroll', listener: (ydisp?: number) => void): void;
on(type: 'scroll', listener: (ydisp: number) => void): void;
/**

@@ -416,3 +428,3 @@ * Registers an event listener.

*/
on(type: 'title', listener: (title?: string) => void): void;
on(type: 'title', listener: (title: string) => void): void;
/**

@@ -419,0 +431,0 @@ * Registers an event listener.

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

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

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

Sorry, the diff of this file is too big to display

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