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.2.0 to 3.3.0

lib/renderer/atlas/CharAtlas.js

32

dist/addons/attach/attach.js

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

(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.attach = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.attach = f()}})(function(){var define,module,exports;return (function(){function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}return e})()({1:[function(require,module,exports){
"use strict";

@@ -24,20 +24,34 @@ Object.defineProperty(exports, "__esModule", { value: true });

var str;
if (typeof ev.data === 'object') {
if (typeof ev.data == 'object') {
if (!myTextDecoder) {
myTextDecoder = new TextDecoder();
}
if (ev.data instanceof ArrayBuffer) {
if (!myTextDecoder) {
myTextDecoder = new TextDecoder();
}
str = myTextDecoder.decode(ev.data);
displayData(str);
}
else {
throw 'TODO: handle Blob?';
var fileReader = new FileReader();
fileReader.addEventListener('load', function () {
str = myTextDecoder.decode(this.result);
displayData(str);
});
fileReader.readAsArrayBuffer(ev.data);
}
}
else if (typeof ev.data == 'string') {
displayData(ev.data);
}
else {
throw Error("Cannot handle \"" + typeof ev.data + "\" websocket message.");
}
};
function displayData(str, data) {
if (buffered) {
addonTerminal.__pushToBuffer(str || ev.data);
addonTerminal.__pushToBuffer(str || data);
}
else {
addonTerminal.write(str || ev.data);
addonTerminal.write(str || data);
}
};
}
addonTerminal.__sendData = function (data) {

@@ -44,0 +58,0 @@ if (socket.readyState !== 1) {

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

(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.fit = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.fit = f()}})(function(){var define,module,exports;return (function(){function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}return e})()({1:[function(require,module,exports){
"use strict";

@@ -3,0 +3,0 @@ Object.defineProperty(exports, "__esModule", { value: true });

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

(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.fullscreen = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.fullscreen = f()}})(function(){var define,module,exports;return (function(){function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}return e})()({1:[function(require,module,exports){
"use strict";

@@ -3,0 +3,0 @@ Object.defineProperty(exports, "__esModule", { value: true });

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

(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.search = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.search = f()}})(function(){var define,module,exports;return (function(){function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}return e})()({1:[function(require,module,exports){
"use strict";

@@ -3,0 +3,0 @@ Object.defineProperty(exports, "__esModule", { value: true });

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

(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.terminado = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.terminado = f()}})(function(){var define,module,exports;return (function(){function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}return e})()({1:[function(require,module,exports){
"use strict";

@@ -3,0 +3,0 @@ Object.defineProperty(exports, "__esModule", { value: true });

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

(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.webLinks = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.webLinks = f()}})(function(){var define,module,exports;return (function(){function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}return e})()({1:[function(require,module,exports){
"use strict";

@@ -3,0 +3,0 @@ Object.defineProperty(exports, "__esModule", { value: true });

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

(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.winptyCompat = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.winptyCompat = f()}})(function(){var define,module,exports;return (function(){function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}return e})()({1:[function(require,module,exports){
"use strict";

@@ -3,0 +3,0 @@ Object.defineProperty(exports, "__esModule", { value: true });

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

(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.zmodem = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.zmodem = f()}})(function(){var define,module,exports;return (function(){function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}return e})()({1:[function(require,module,exports){
"use strict";

@@ -3,0 +3,0 @@ Object.defineProperty(exports, "__esModule", { value: true });

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

var MAX_ROWS_TO_READ = 20;
var ACTIVE_ITEM_ID_PREFIX = 'xterm-active-item-';
var BoundaryPosition;

@@ -19,3 +18,2 @@ (function (BoundaryPosition) {

this._terminal = _terminal;
this._rowElements = [];
this._liveRegionLineCount = 0;

@@ -28,2 +26,3 @@ this._disposables = [];

this._rowContainer.classList.add('xterm-accessibility-tree');
this._rowElements = [];
for (var i = 0; i < this._terminal.rows; i++) {

@@ -60,10 +59,6 @@ this._rowElements[i] = this._createAccessibilityTreeNode();

AccessibilityManager.prototype.dispose = function () {
this._disposables.forEach(function (d) { return d.dispose(); });
this._disposables.length = 0;
this._terminal.element.removeChild(this._accessibilityTreeRoot);
this._disposables.forEach(function (d) { return d.dispose(); });
this._disposables = null;
this._accessibilityTreeRoot = null;
this._rowContainer = null;
this._liveRegion = null;
this._rowContainer = null;
this._rowElements = null;
this._rowElements.length = 0;
};

@@ -155,3 +150,3 @@ AccessibilityManager.prototype._onBoundaryFocus = function (e, position) {

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

@@ -196,3 +191,2 @@ _this._accessibilityTreeRoot.appendChild(_this._liveRegion);

}
var buffer = this._terminal.buffer;
for (var i = 0; i < this._terminal.rows; i++) {

@@ -199,0 +193,0 @@ this._refreshRowDimensions(this._rowElements[i]);

@@ -23,20 +23,34 @@ "use strict";

var str;
if (typeof ev.data === 'object') {
if (typeof ev.data == 'object') {
if (!myTextDecoder) {
myTextDecoder = new TextDecoder();
}
if (ev.data instanceof ArrayBuffer) {
if (!myTextDecoder) {
myTextDecoder = new TextDecoder();
}
str = myTextDecoder.decode(ev.data);
displayData(str);
}
else {
throw 'TODO: handle Blob?';
var fileReader = new FileReader();
fileReader.addEventListener('load', function () {
str = myTextDecoder.decode(this.result);
displayData(str);
});
fileReader.readAsArrayBuffer(ev.data);
}
}
else if (typeof ev.data == 'string') {
displayData(ev.data);
}
else {
throw Error("Cannot handle \"" + typeof ev.data + "\" websocket message.");
}
};
function displayData(str, data) {
if (buffered) {
addonTerminal.__pushToBuffer(str || ev.data);
addonTerminal.__pushToBuffer(str || data);
}
else {
addonTerminal.write(str || ev.data);
addonTerminal.write(str || data);
}
};
}
addonTerminal.__sendData = function (data) {

@@ -43,0 +57,0 @@ if (socket.readyState !== 1) {

"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var CircularList_1 = require("./utils/CircularList");
var EventEmitter_1 = require("./EventEmitter");
exports.CHAR_DATA_ATTR_INDEX = 0;

@@ -13,2 +24,3 @@ exports.CHAR_DATA_CHAR_INDEX = 1;

this._hasScrollback = _hasScrollback;
this.markers = [];
this.clear();

@@ -204,6 +216,50 @@ }

};
Buffer.prototype.addMarker = function (y) {
var _this = this;
var marker = new Marker(y);
this.markers.push(marker);
marker.disposables.push(this._lines.addDisposableListener('trim', function (amount) {
marker.line -= amount;
if (marker.line < 0) {
marker.dispose();
}
}));
marker.on('dispose', function () { return _this._removeMarker(marker); });
return marker;
};
Buffer.prototype._removeMarker = function (marker) {
this.markers.splice(this.markers.indexOf(marker), 1);
};
return Buffer;
}());
exports.Buffer = Buffer;
var Marker = (function (_super) {
__extends(Marker, _super);
function Marker(line) {
var _this = _super.call(this) || this;
_this.line = line;
_this._id = Marker.NEXT_ID++;
_this.isDisposed = false;
_this.disposables = [];
return _this;
}
Object.defineProperty(Marker.prototype, "id", {
get: function () { return this._id; },
enumerable: true,
configurable: true
});
Marker.prototype.dispose = function () {
if (this.isDisposed) {
return;
}
this.isDisposed = true;
this.disposables.forEach(function (d) { return d.dispose(); });
this.disposables.length = 0;
this.emit('dispose');
};
Marker.NEXT_ID = 1;
return Marker;
}(EventEmitter_1.EventEmitter));
exports.Marker = Marker;
//# sourceMappingURL=Buffer.js.map

@@ -155,4 +155,27 @@ "use strict";

});
describe('addMarker', function () {
it('should adjust a marker line when the buffer is trimmed', function () {
terminal.options.scrollback = 0;
buffer = new Buffer_1.Buffer(terminal, true);
buffer.fillViewportRows();
var marker = buffer.addMarker(buffer.lines.length - 1);
chai_1.assert.equal(marker.line, buffer.lines.length - 1);
buffer.lines.emit('trim', 1);
chai_1.assert.equal(marker.line, buffer.lines.length - 2);
});
it('should dispose of a marker if it is trimmed off the buffer', function () {
terminal.options.scrollback = 0;
buffer = new Buffer_1.Buffer(terminal, true);
buffer.fillViewportRows();
chai_1.assert.equal(buffer.markers.length, 0);
var marker = buffer.addMarker(0);
chai_1.assert.equal(marker.isDisposed, false);
chai_1.assert.equal(buffer.markers.length, 1);
buffer.lines.emit('trim', 1);
chai_1.assert.equal(marker.isDisposed, true);
chai_1.assert.equal(buffer.markers.length, 0);
});
});
});
//# sourceMappingURL=Buffer.test.js.map

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

[0xA825, 0xA826], [0xFB1E, 0xFB1E], [0xFE00, 0xFE0F],
[0xFE20, 0xFE23], [0xFEFF, 0xFEFF], [0xFFF9, 0xFFFB],
[0xFE20, 0xFE23], [0xFEFF, 0xFEFF], [0xFFF9, 0xFFFB]
];

@@ -50,0 +50,0 @@ var COMBINING_HIGH = [

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var CompositionHelper = (function () {
function CompositionHelper(textarea, compositionView, terminal) {
this.textarea = textarea;
this.compositionView = compositionView;
this.terminal = terminal;
this.isComposing = false;
this.isSendingComposition = false;
this.compositionPosition = { start: null, end: null };
function CompositionHelper(_textarea, _compositionView, _terminal) {
this._textarea = _textarea;
this._compositionView = _compositionView;
this._terminal = _terminal;
this._isComposing = false;
this._isSendingComposition = false;
this._compositionPosition = { start: null, end: null };
}
CompositionHelper.prototype.compositionstart = function () {
this.isComposing = true;
this.compositionPosition.start = this.textarea.value.length;
this.compositionView.textContent = '';
this.compositionView.classList.add('active');
this._isComposing = true;
this._compositionPosition.start = this._textarea.value.length;
this._compositionView.textContent = '';
this._compositionView.classList.add('active');
};
CompositionHelper.prototype.compositionupdate = function (ev) {
var _this = this;
this.compositionView.textContent = ev.data;
this._compositionView.textContent = ev.data;
this.updateCompositionElements();
setTimeout(function () {
_this.compositionPosition.end = _this.textarea.value.length;
_this._compositionPosition.end = _this._textarea.value.length;
}, 0);
};
CompositionHelper.prototype.compositionend = function () {
this.finalizeComposition(true);
this._finalizeComposition(true);
};
CompositionHelper.prototype.keydown = function (ev) {
if (this.isComposing || this.isSendingComposition) {
if (this._isComposing || this._isSendingComposition) {
if (ev.keyCode === 229) {

@@ -38,7 +38,7 @@ return false;

else {
this.finalizeComposition(false);
this._finalizeComposition(false);
}
}
if (ev.keyCode === 229) {
this.handleAnyTextareaChanges();
this._handleAnyTextareaChanges();
return false;

@@ -48,29 +48,29 @@ }

};
CompositionHelper.prototype.finalizeComposition = function (waitForPropogation) {
CompositionHelper.prototype._finalizeComposition = function (waitForPropogation) {
var _this = this;
this.compositionView.classList.remove('active');
this.isComposing = false;
this.clearTextareaPosition();
this._compositionView.classList.remove('active');
this._isComposing = false;
this._clearTextareaPosition();
if (!waitForPropogation) {
this.isSendingComposition = false;
var input = this.textarea.value.substring(this.compositionPosition.start, this.compositionPosition.end);
this.terminal.handler(input);
this._isSendingComposition = false;
var input = this._textarea.value.substring(this._compositionPosition.start, this._compositionPosition.end);
this._terminal.handler(input);
}
else {
var currentCompositionPosition_1 = {
start: this.compositionPosition.start,
end: this.compositionPosition.end,
start: this._compositionPosition.start,
end: this._compositionPosition.end
};
this.isSendingComposition = true;
this._isSendingComposition = true;
setTimeout(function () {
if (_this.isSendingComposition) {
_this.isSendingComposition = false;
if (_this._isSendingComposition) {
_this._isSendingComposition = false;
var input = void 0;
if (_this.isComposing) {
input = _this.textarea.value.substring(currentCompositionPosition_1.start, currentCompositionPosition_1.end);
if (_this._isComposing) {
input = _this._textarea.value.substring(currentCompositionPosition_1.start, currentCompositionPosition_1.end);
}
else {
input = _this.textarea.value.substring(currentCompositionPosition_1.start);
input = _this._textarea.value.substring(currentCompositionPosition_1.start);
}
_this.terminal.handler(input);
_this._terminal.handler(input);
}

@@ -80,11 +80,11 @@ }, 0);

};
CompositionHelper.prototype.handleAnyTextareaChanges = function () {
CompositionHelper.prototype._handleAnyTextareaChanges = function () {
var _this = this;
var oldValue = this.textarea.value;
var oldValue = this._textarea.value;
setTimeout(function () {
if (!_this.isComposing) {
var newValue = _this.textarea.value;
if (!_this._isComposing) {
var newValue = _this._textarea.value;
var diff = newValue.replace(oldValue, '');
if (diff.length > 0) {
_this.terminal.handler(diff);
_this._terminal.handler(diff);
}

@@ -96,19 +96,19 @@ }

var _this = this;
if (!this.isComposing) {
if (!this._isComposing) {
return;
}
if (this.terminal.buffer.isCursorInViewport) {
var cellHeight = Math.ceil(this.terminal.charMeasure.height * this.terminal.options.lineHeight);
var cursorTop = this.terminal.buffer.y * cellHeight;
var cursorLeft = this.terminal.buffer.x * this.terminal.charMeasure.width;
this.compositionView.style.left = cursorLeft + 'px';
this.compositionView.style.top = cursorTop + 'px';
this.compositionView.style.height = cellHeight + 'px';
this.compositionView.style.lineHeight = cellHeight + 'px';
var compositionViewBounds = this.compositionView.getBoundingClientRect();
this.textarea.style.left = cursorLeft + 'px';
this.textarea.style.top = cursorTop + 'px';
this.textarea.style.width = compositionViewBounds.width + 'px';
this.textarea.style.height = compositionViewBounds.height + 'px';
this.textarea.style.lineHeight = compositionViewBounds.height + 'px';
if (this._terminal.buffer.isCursorInViewport) {
var cellHeight = Math.ceil(this._terminal.charMeasure.height * this._terminal.options.lineHeight);
var cursorTop = this._terminal.buffer.y * cellHeight;
var cursorLeft = this._terminal.buffer.x * this._terminal.charMeasure.width;
this._compositionView.style.left = cursorLeft + 'px';
this._compositionView.style.top = cursorTop + 'px';
this._compositionView.style.height = cellHeight + 'px';
this._compositionView.style.lineHeight = cellHeight + 'px';
var compositionViewBounds = this._compositionView.getBoundingClientRect();
this._textarea.style.left = cursorLeft + 'px';
this._textarea.style.top = cursorTop + 'px';
this._textarea.style.width = compositionViewBounds.width + 'px';
this._textarea.style.height = compositionViewBounds.height + 'px';
this._textarea.style.lineHeight = compositionViewBounds.height + 'px';
}

@@ -119,5 +119,5 @@ if (!dontRecurse) {

};
CompositionHelper.prototype.clearTextareaPosition = function () {
this.textarea.style.left = '';
this.textarea.style.top = '';
CompositionHelper.prototype._clearTextareaPosition = function () {
this._textarea.style.left = '';
this._textarea.style.top = '';
};

@@ -124,0 +124,0 @@ return CompositionHelper;

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

add: function () { },
remove: function () { },
remove: function () { }
},

@@ -18,0 +18,0 @@ getBoundingClientRect: function () {

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

AltClickHandler.prototype._resetStartingRow = function () {
var startRow = this._endRow - this._wrappedRowsForRow(this._endRow);
var endRow = this._endRow;
if (this._moveToRequestedRow().length === 0) {

@@ -39,0 +37,0 @@ return '';

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function prepareTextForTerminal(text, isMSWindows) {
if (isMSWindows) {
return text.replace(/\r?\n/g, '\r');
}
return text;
function prepareTextForTerminal(text) {
return text.replace(/\r?\n/g, '\r');
}

@@ -31,3 +28,3 @@ exports.prepareTextForTerminal = prepareTextForTerminal;

var dispatchPaste = function (text) {
text = prepareTextForTerminal(text, term.browser.isMSWindows);
text = prepareTextForTerminal(text);
text = bracketTextForPaste(text, term.bracketedPasteMode);

@@ -34,0 +31,0 @@ term.handler(text);

@@ -6,8 +6,13 @@ "use strict";

describe('evaluatePastedTextProcessing', function () {
it('should replace carriage return + line feed with line feed on windows', function () {
var pastedText = 'foo\r\nbar\r\n';
var processedText = Clipboard.prepareTextForTerminal(pastedText, false);
var windowsProcessedText = Clipboard.prepareTextForTerminal(pastedText, true);
chai_1.assert.equal(processedText, 'foo\r\nbar\r\n');
chai_1.assert.equal(windowsProcessedText, 'foo\rbar\r');
it('should replace carriage return and/or line feed with carriage return', function () {
var pastedText = {
unix: 'foo\nbar\n',
windows: 'foo\r\nbar\r\n'
};
var processedText = {
unix: Clipboard.prepareTextForTerminal(pastedText.unix),
windows: Clipboard.prepareTextForTerminal(pastedText.windows)
};
chai_1.assert.equal(processedText.unix, 'foo\rbar\r');
chai_1.assert.equal(processedText.windows, 'foo\rbar\r');
});

@@ -14,0 +19,0 @@ it('should bracket pasted text in bracketedPasteMode', function () {

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

var zone = this._zones[i];
if (zone.y > start && zone.y <= end + 1) {
if ((zone.y1 > start && zone.y1 <= end + 1) ||
(zone.y2 > start && zone.y2 <= end + 1) ||
(zone.y1 < start && zone.y2 > end + 1)) {
if (this._currentZone && this._currentZone === zone) {

@@ -120,7 +122,18 @@ this._currentZone.leaveCallback();

}
var x = coords[0];
var y = coords[1];
for (var i = 0; i < this._zones.length; i++) {
var zone = this._zones[i];
if (zone.y === coords[1] && zone.x1 <= coords[0] && zone.x2 > coords[0]) {
return zone;
if (zone.y1 === zone.y2) {
if (y === zone.y1 && x >= zone.x1 && x < zone.x2) {
return zone;
}
}
else {
if ((y === zone.y1 && x >= zone.x1) ||
(y === zone.y2 && x < zone.x2) ||
(y > zone.y1 && y < zone.y2)) {
return zone;
}
}
}

@@ -133,6 +146,7 @@ return null;

var MouseZone = (function () {
function MouseZone(x1, x2, y, clickCallback, hoverCallback, tooltipCallback, leaveCallback, willLinkActivate) {
function MouseZone(x1, y1, x2, y2, clickCallback, hoverCallback, tooltipCallback, leaveCallback, willLinkActivate) {
this.x1 = x1;
this.y1 = y1;
this.x2 = x2;
this.y = y;
this.y2 = y2;
this.clickCallback = clickCallback;

@@ -139,0 +153,0 @@ this.hoverCallback = hoverCallback;

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

}
if (this._terminal.buffer.lines.get(absoluteRowIndex).isWrapped) {
if (rowIndex !== 0) {
return;
}
do {
rowIndex--;
absoluteRowIndex--;
} while (this._terminal.buffer.lines.get(absoluteRowIndex).isWrapped);
}
var text = this._terminal.buffer.translateBufferLineToString(absoluteRowIndex, false);
var currentIndex = absoluteRowIndex + 1;
while (currentIndex < this._terminal.buffer.lines.length &&
this._terminal.buffer.lines.get(currentIndex).isWrapped) {
text += this._terminal.buffer.translateBufferLineToString(currentIndex++, false);
}
for (var i = 0; i < this._linkMatchers.length; i++) {

@@ -114,3 +128,2 @@ this._doLinkifyRow(rowIndex, text, this._linkMatchers[i]);

if (offset === void 0) { offset = 0; }
var result = [];
var match = text.match(matcher.regex);

@@ -143,3 +156,11 @@ if (!match || match.length === 0) {

var _this = this;
this._mouseZoneManager.add(new MouseZoneManager_1.MouseZone(x + 1, x + 1 + uri.length, y + 1, function (e) {
var x1 = x % this._terminal.cols;
var y1 = y + Math.floor(x / this._terminal.cols);
var x2 = (x1 + uri.length) % this._terminal.cols;
var y2 = y1 + Math.floor((x1 + uri.length) / this._terminal.cols);
if (x2 === 0) {
x2 = this._terminal.cols;
y2--;
}
this._mouseZoneManager.add(new MouseZoneManager_1.MouseZone(x1 + 1, y1 + 1, x2 + 1, y2 + 1, function (e) {
if (matcher.handler) {

@@ -150,6 +171,6 @@ return matcher.handler(e, uri);

}, function (e) {
_this.emit(Types_1.LinkHoverEventTypes.HOVER, { x: x, y: y, length: uri.length });
_this._terminal.element.style.cursor = 'pointer';
_this.emit(Types_1.LinkHoverEventTypes.HOVER, _this._createLinkHoverEvent(x1, y1, x2, y2));
_this._terminal.element.classList.add('xterm-cursor-pointer');
}, function (e) {
_this.emit(Types_1.LinkHoverEventTypes.TOOLTIP, { x: x, y: y, length: uri.length });
_this.emit(Types_1.LinkHoverEventTypes.TOOLTIP, _this._createLinkHoverEvent(x1, y1, x2, y2));
if (matcher.hoverTooltipCallback) {

@@ -159,4 +180,4 @@ matcher.hoverTooltipCallback(e, uri);

}, function () {
_this.emit(Types_1.LinkHoverEventTypes.LEAVE, { x: x, y: y, length: uri.length });
_this._terminal.element.style.cursor = '';
_this.emit(Types_1.LinkHoverEventTypes.LEAVE, _this._createLinkHoverEvent(x1, y1, x2, y2));
_this._terminal.element.classList.remove('xterm-cursor-pointer');
if (matcher.hoverLeaveCallback) {

@@ -172,2 +193,5 @@ matcher.hoverLeaveCallback();

};
Linkifier.prototype._createLinkHoverEvent = function (x1, y1, x2, y2) {
return { x1: x1, y1: y1, x2: x2, y2: y2, cols: this._terminal.cols };
};
Linkifier.TIME_BEFORE_LINKIFY = 200;

@@ -174,0 +198,0 @@ return Linkifier;

@@ -50,6 +50,5 @@ "use strict";

beforeEach(function () {
terminal = {
buffer: new TestUtils_test_1.MockBuffer(),
element: {}
};
terminal = new TestUtils_test_1.MockTerminal();
terminal.cols = 100;
terminal.buffer = new TestUtils_test_1.MockBuffer();
terminal.buffer.lines = new CircularList_1.CircularList(20);

@@ -70,13 +69,18 @@ terminal.buffer.ydisp = 0;

}
function assertLinkifiesEntireRow(uri, done) {
addRow(uri);
function assertLinkifiesRow(rowText, linkMatcherRegex, links, done) {
addRow(rowText);
linkifier.registerLinkMatcher(linkMatcherRegex, function () { });
linkifier.linkifyRows();
setTimeout(function () {
chai_1.assert.equal(mouseZoneManager.zones[0].x1, 1);
chai_1.assert.equal(mouseZoneManager.zones[0].x2, uri.length + 1);
chai_1.assert.equal(mouseZoneManager.zones[0].y, terminal.buffer.lines.length);
chai_1.assert.equal(mouseZoneManager.zones.length, links.length);
links.forEach(function (l, i) {
chai_1.assert.equal(mouseZoneManager.zones[i].x1, l.x + 1);
chai_1.assert.equal(mouseZoneManager.zones[i].x2, l.x + l.length + 1);
chai_1.assert.equal(mouseZoneManager.zones[i].y1, terminal.buffer.lines.length);
chai_1.assert.equal(mouseZoneManager.zones[i].y2, terminal.buffer.lines.length);
});
done();
}, 0);
}
function assertLinkifiesRow(rowText, linkMatcherRegex, links, done) {
function assertLinkifiesMultiLineLink(rowText, linkMatcherRegex, links, done) {
addRow(rowText);

@@ -88,5 +92,6 @@ linkifier.registerLinkMatcher(linkMatcherRegex, function () { });

links.forEach(function (l, i) {
chai_1.assert.equal(mouseZoneManager.zones[i].x1, l.x + 1);
chai_1.assert.equal(mouseZoneManager.zones[i].x2, l.x + l.length + 1);
chai_1.assert.equal(mouseZoneManager.zones[i].y, terminal.buffer.lines.length);
chai_1.assert.equal(mouseZoneManager.zones[i].x1, l.x1 + 1);
chai_1.assert.equal(mouseZoneManager.zones[i].x2, l.x2 + 1);
chai_1.assert.equal(mouseZoneManager.zones[i].y1, l.y1 + 1);
chai_1.assert.equal(mouseZoneManager.zones[i].y2, l.y2 + 1);
});

@@ -134,2 +139,20 @@ done();

});
describe('multi-line links', function () {
it('should match links that start on line 1/2 of a wrapped line and end on the last character of line 1/2', function (done) {
terminal.cols = 4;
assertLinkifiesMultiLineLink('12345', /1234/, [{ x1: 0, x2: 4, y1: 0, y2: 0 }], done);
});
it('should match links that start on line 1/2 of a wrapped line and wrap to line 2/2', function (done) {
terminal.cols = 4;
assertLinkifiesMultiLineLink('12345', /12345/, [{ x1: 0, x2: 1, y1: 0, y2: 1 }], done);
});
it('should match links that start and end on line 2/2 of a wrapped line', function (done) {
terminal.cols = 4;
assertLinkifiesMultiLineLink('12345678', /5678/, [{ x1: 0, x2: 4, y1: 1, y2: 1 }], done);
});
it('should match links that start on line 2/3 of a wrapped line and wrap to line 3/3', function (done) {
terminal.cols = 4;
assertLinkifiesMultiLineLink('123456789', /56789/, [{ x1: 0, x2: 1, y1: 1, y2: 2 }], done);
});
});
});

@@ -146,3 +169,4 @@ describe('validationCallback', function () {

chai_1.assert.equal(mouseZoneManager.zones[0].x2, 5);
chai_1.assert.equal(mouseZoneManager.zones[0].y, 1);
chai_1.assert.equal(mouseZoneManager.zones[0].y1, 1);
chai_1.assert.equal(mouseZoneManager.zones[0].y2, 1);
mouseZoneManager.zones[0].clickCallback({});

@@ -149,0 +173,0 @@ }

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

var l = data.length;
var j;
var cs;

@@ -155,0 +154,0 @@ var ch;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var CharAtlas_1 = require("./CharAtlas");
var Types_1 = require("./atlas/Types");
var Types_2 = require("../shared/atlas/Types");
var CharAtlas_1 = require("./atlas/CharAtlas");
var Buffer_1 = require("../Buffer");
exports.INVERTED_DEFAULT_COLOR = -1;
var DIM_OPACITY = 0.5;
var BaseRenderLayer = (function () {

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

};
BaseRenderLayer.prototype.resize = function (terminal, dim, charSizeChanged) {
BaseRenderLayer.prototype.resize = function (terminal, dim) {
this._scaledCellWidth = dim.scaledCellWidth;

@@ -80,5 +80,3 @@ this._scaledCellHeight = dim.scaledCellHeight;

}
if (charSizeChanged) {
this._refreshCharAtlas(terminal, this._colors);
}
this._refreshCharAtlas(terminal, this._colors);
};

@@ -104,3 +102,3 @@ BaseRenderLayer.prototype.fillCells = function (x, y, width, height) {

else {
this._ctx.fillStyle = this._colors.background;
this._ctx.fillStyle = this._colors.background.css;
this._ctx.fillRect(0, 0, this._canvas.width, this._canvas.height);

@@ -114,3 +112,3 @@ }

else {
this._ctx.fillStyle = this._colors.background;
this._ctx.fillStyle = this._colors.background.css;
this._ctx.fillRect(x * this._scaledCellWidth, y * this._scaledCellHeight, width * this._scaledCellWidth, height * this._scaledCellHeight);

@@ -140,6 +138,6 @@ }

if (this._charAtlas && isAscii && (isBasicColor || isDefaultColor) && isDefaultBackground) {
var charAtlasCellWidth = this._scaledCharWidth + CharAtlas_1.CHAR_ATLAS_CELL_SPACING;
var charAtlasCellHeight = this._scaledCharHeight + CharAtlas_1.CHAR_ATLAS_CELL_SPACING;
var charAtlasCellWidth = this._scaledCharWidth + Types_2.CHAR_ATLAS_CELL_SPACING;
var charAtlasCellHeight = this._scaledCharHeight + Types_2.CHAR_ATLAS_CELL_SPACING;
if (dim) {
this._ctx.globalAlpha = DIM_OPACITY;
this._ctx.globalAlpha = Types_1.DIM_OPACITY;
}

@@ -161,14 +159,14 @@ if (bold && !terminal.options.enableBold) {

this._ctx.textBaseline = 'top';
if (fg === exports.INVERTED_DEFAULT_COLOR) {
this._ctx.fillStyle = this._colors.background;
if (fg === Types_1.INVERTED_DEFAULT_COLOR) {
this._ctx.fillStyle = this._colors.background.css;
}
else if (fg < 256) {
this._ctx.fillStyle = this._colors.ansi[fg];
this._ctx.fillStyle = this._colors.ansi[fg].css;
}
else {
this._ctx.fillStyle = this._colors.foreground;
this._ctx.fillStyle = this._colors.foreground.css;
}
this._clipRow(terminal, y);
if (dim) {
this._ctx.globalAlpha = DIM_OPACITY;
this._ctx.globalAlpha = Types_1.DIM_OPACITY;
}

@@ -175,0 +173,0 @@ this._ctx.fillText(char, x * this._scaledCellWidth + this._scaledCharLeft, y * this._scaledCellHeight + this._scaledCharTop);

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var DEFAULT_FOREGROUND = '#ffffff';
var DEFAULT_BACKGROUND = '#000000';
var DEFAULT_CURSOR = '#ffffff';
var DEFAULT_CURSOR_ACCENT = '#000000';
var DEFAULT_SELECTION = 'rgba(255, 255, 255, 0.3)';
exports.DEFAULT_ANSI_COLORS = [
'#2e3436',
'#cc0000',
'#4e9a06',
'#c4a000',
'#3465a4',
'#75507b',
'#06989a',
'#d3d7cf',
'#555753',
'#ef2929',
'#8ae234',
'#fce94f',
'#729fcf',
'#ad7fa8',
'#34e2e2',
'#eeeeec'
];
function generate256Colors(first16Colors) {
var colors = first16Colors.slice();
var DEFAULT_FOREGROUND = fromHex('#ffffff');
var DEFAULT_BACKGROUND = fromHex('#000000');
var DEFAULT_CURSOR = fromHex('#ffffff');
var DEFAULT_CURSOR_ACCENT = fromHex('#000000');
var DEFAULT_SELECTION = {
css: 'rgba(255, 255, 255, 0.3)',
rgba: 0xFFFFFF77
};
exports.DEFAULT_ANSI_COLORS = (function () {
var colors = [
fromHex('#2e3436'),
fromHex('#cc0000'),
fromHex('#4e9a06'),
fromHex('#c4a000'),
fromHex('#3465a4'),
fromHex('#75507b'),
fromHex('#06989a'),
fromHex('#d3d7cf'),
fromHex('#555753'),
fromHex('#ef2929'),
fromHex('#8ae234'),
fromHex('#fce94f'),
fromHex('#729fcf'),
fromHex('#ad7fa8'),
fromHex('#34e2e2'),
fromHex('#eeeeec')
];
var v = [0x00, 0x5f, 0x87, 0xaf, 0xd7, 0xff];
for (var i = 0; i < 216; i++) {
var r = toPaddedHex(v[(i / 36) % 6 | 0]);
var g = toPaddedHex(v[(i / 6) % 6 | 0]);
var b = toPaddedHex(v[i % 6]);
colors.push("#" + r + g + b);
var r = v[(i / 36) % 6 | 0];
var g = v[(i / 6) % 6 | 0];
var b = v[i % 6];
colors.push({
css: "#" + toPaddedHex(r) + toPaddedHex(g) + toPaddedHex(b),
rgba: ((r << 24) | (g << 16) | (b << 8) | 0xFF) >>> 0
});
}
for (var i = 0; i < 24; i++) {
var c = toPaddedHex(8 + i * 10);
colors.push("#" + c + c + c);
var c = 8 + i * 10;
var ch = toPaddedHex(c);
colors.push({
css: "#" + ch + ch + ch,
rgba: ((c << 24) | (c << 16) | (c << 8) | 0xFF) >>> 0
});
}
return colors;
})();
function fromHex(css) {
return {
css: css,
rgba: parseInt(css.slice(1), 16) << 8 | 0xFF
};
}

@@ -46,3 +61,10 @@ function toPaddedHex(c) {

var ColorManager = (function () {
function ColorManager() {
function ColorManager(document, allowTransparency) {
this.allowTransparency = allowTransparency;
var canvas = document.createElement('canvas');
canvas.width = 1;
canvas.height = 1;
this._ctx = canvas.getContext('2d');
this._ctx.globalCompositeOperation = 'copy';
this._litmusColor = this._ctx.createLinearGradient(0, 0, 1, 1);
this.colors = {

@@ -54,28 +76,51 @@ foreground: DEFAULT_FOREGROUND,

selection: DEFAULT_SELECTION,
ansi: generate256Colors(exports.DEFAULT_ANSI_COLORS)
ansi: exports.DEFAULT_ANSI_COLORS.slice()
};
}
ColorManager.prototype.setTheme = function (theme) {
this.colors.foreground = theme.foreground || DEFAULT_FOREGROUND;
this.colors.background = theme.background || DEFAULT_BACKGROUND;
this.colors.cursor = theme.cursor || DEFAULT_CURSOR;
this.colors.cursorAccent = theme.cursorAccent || DEFAULT_CURSOR_ACCENT;
this.colors.selection = theme.selection || DEFAULT_SELECTION;
this.colors.ansi[0] = theme.black || exports.DEFAULT_ANSI_COLORS[0];
this.colors.ansi[1] = theme.red || exports.DEFAULT_ANSI_COLORS[1];
this.colors.ansi[2] = theme.green || exports.DEFAULT_ANSI_COLORS[2];
this.colors.ansi[3] = theme.yellow || exports.DEFAULT_ANSI_COLORS[3];
this.colors.ansi[4] = theme.blue || exports.DEFAULT_ANSI_COLORS[4];
this.colors.ansi[5] = theme.magenta || exports.DEFAULT_ANSI_COLORS[5];
this.colors.ansi[6] = theme.cyan || exports.DEFAULT_ANSI_COLORS[6];
this.colors.ansi[7] = theme.white || exports.DEFAULT_ANSI_COLORS[7];
this.colors.ansi[8] = theme.brightBlack || exports.DEFAULT_ANSI_COLORS[8];
this.colors.ansi[9] = theme.brightRed || exports.DEFAULT_ANSI_COLORS[9];
this.colors.ansi[10] = theme.brightGreen || exports.DEFAULT_ANSI_COLORS[10];
this.colors.ansi[11] = theme.brightYellow || exports.DEFAULT_ANSI_COLORS[11];
this.colors.ansi[12] = theme.brightBlue || exports.DEFAULT_ANSI_COLORS[12];
this.colors.ansi[13] = theme.brightMagenta || exports.DEFAULT_ANSI_COLORS[13];
this.colors.ansi[14] = theme.brightCyan || exports.DEFAULT_ANSI_COLORS[14];
this.colors.ansi[15] = theme.brightWhite || exports.DEFAULT_ANSI_COLORS[15];
this.colors.foreground = this._parseColor(theme.foreground, DEFAULT_FOREGROUND);
this.colors.background = this._parseColor(theme.background, DEFAULT_BACKGROUND);
this.colors.cursor = this._parseColor(theme.cursor, DEFAULT_CURSOR, true);
this.colors.cursorAccent = this._parseColor(theme.cursorAccent, DEFAULT_CURSOR_ACCENT, true);
this.colors.selection = this._parseColor(theme.selection, DEFAULT_SELECTION, true);
this.colors.ansi[0] = this._parseColor(theme.black, exports.DEFAULT_ANSI_COLORS[0]);
this.colors.ansi[1] = this._parseColor(theme.red, exports.DEFAULT_ANSI_COLORS[1]);
this.colors.ansi[2] = this._parseColor(theme.green, exports.DEFAULT_ANSI_COLORS[2]);
this.colors.ansi[3] = this._parseColor(theme.yellow, exports.DEFAULT_ANSI_COLORS[3]);
this.colors.ansi[4] = this._parseColor(theme.blue, exports.DEFAULT_ANSI_COLORS[4]);
this.colors.ansi[5] = this._parseColor(theme.magenta, exports.DEFAULT_ANSI_COLORS[5]);
this.colors.ansi[6] = this._parseColor(theme.cyan, exports.DEFAULT_ANSI_COLORS[6]);
this.colors.ansi[7] = this._parseColor(theme.white, exports.DEFAULT_ANSI_COLORS[7]);
this.colors.ansi[8] = this._parseColor(theme.brightBlack, exports.DEFAULT_ANSI_COLORS[8]);
this.colors.ansi[9] = this._parseColor(theme.brightRed, exports.DEFAULT_ANSI_COLORS[9]);
this.colors.ansi[10] = this._parseColor(theme.brightGreen, exports.DEFAULT_ANSI_COLORS[10]);
this.colors.ansi[11] = this._parseColor(theme.brightYellow, exports.DEFAULT_ANSI_COLORS[11]);
this.colors.ansi[12] = this._parseColor(theme.brightBlue, exports.DEFAULT_ANSI_COLORS[12]);
this.colors.ansi[13] = this._parseColor(theme.brightMagenta, exports.DEFAULT_ANSI_COLORS[13]);
this.colors.ansi[14] = this._parseColor(theme.brightCyan, exports.DEFAULT_ANSI_COLORS[14]);
this.colors.ansi[15] = this._parseColor(theme.brightWhite, exports.DEFAULT_ANSI_COLORS[15]);
};
ColorManager.prototype._parseColor = function (css, fallback, allowTransparency) {
if (allowTransparency === void 0) { allowTransparency = this.allowTransparency; }
if (!css) {
return fallback;
}
this._ctx.fillStyle = this._litmusColor;
this._ctx.fillStyle = css;
if (typeof this._ctx.fillStyle !== 'string') {
console.warn("Color: " + css + " is invalid using fallback " + fallback.css);
return fallback;
}
this._ctx.fillRect(0, 0, 1, 1);
var data = this._ctx.getImageData(0, 0, 1, 1).data;
if (!allowTransparency && data[3] !== 0xFF) {
console.warn("Color: " + css + " is using transparency, but allowTransparency is false. " +
("Using fallback " + fallback.css + "."));
return fallback;
}
return {
css: css,
rgba: (data[0] << 24 | data[1] << 16 | data[2] << 8 | data[3]) >>> 0
};
};
return ColorManager;

@@ -82,0 +127,0 @@ }());

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var jsdom = require("jsdom");
var chai_1 = require("chai");

@@ -7,10 +8,26 @@ var ColorManager_1 = require("./ColorManager");

var cm;
var dom;
var document;
var window;
beforeEach(function () {
cm = new ColorManager_1.ColorManager();
dom = new jsdom.JSDOM('');
window = dom.window;
document = window.document;
window.HTMLCanvasElement.prototype.getContext = function () { return ({
createLinearGradient: function () {
return null;
},
fillRect: function () { },
getImageData: function () {
return { data: [0, 0, 0, 0xFF] };
}
}); };
cm = new ColorManager_1.ColorManager(document, false);
});
describe('constructor', function () {
it('should fill all colors with values', function () {
for (var key in cm.colors) {
if (typeof key === 'string') {
chai_1.assert.ok(cm.colors[key].length >= 7);
for (var _i = 0, _a = Object.keys(cm.colors); _i < _a.length; _i++) {
var key = _a[_i];
if (key !== 'ansi') {
chai_1.assert.ok(cm.colors[key].css.length >= 7);
}

@@ -21,242 +38,242 @@ }

it('should fill 240 colors with expected values', function () {
chai_1.assert.equal(cm.colors.ansi[16], '#000000');
chai_1.assert.equal(cm.colors.ansi[17], '#00005f');
chai_1.assert.equal(cm.colors.ansi[18], '#000087');
chai_1.assert.equal(cm.colors.ansi[19], '#0000af');
chai_1.assert.equal(cm.colors.ansi[20], '#0000d7');
chai_1.assert.equal(cm.colors.ansi[21], '#0000ff');
chai_1.assert.equal(cm.colors.ansi[22], '#005f00');
chai_1.assert.equal(cm.colors.ansi[23], '#005f5f');
chai_1.assert.equal(cm.colors.ansi[24], '#005f87');
chai_1.assert.equal(cm.colors.ansi[25], '#005faf');
chai_1.assert.equal(cm.colors.ansi[26], '#005fd7');
chai_1.assert.equal(cm.colors.ansi[27], '#005fff');
chai_1.assert.equal(cm.colors.ansi[28], '#008700');
chai_1.assert.equal(cm.colors.ansi[29], '#00875f');
chai_1.assert.equal(cm.colors.ansi[30], '#008787');
chai_1.assert.equal(cm.colors.ansi[31], '#0087af');
chai_1.assert.equal(cm.colors.ansi[32], '#0087d7');
chai_1.assert.equal(cm.colors.ansi[33], '#0087ff');
chai_1.assert.equal(cm.colors.ansi[34], '#00af00');
chai_1.assert.equal(cm.colors.ansi[35], '#00af5f');
chai_1.assert.equal(cm.colors.ansi[36], '#00af87');
chai_1.assert.equal(cm.colors.ansi[37], '#00afaf');
chai_1.assert.equal(cm.colors.ansi[38], '#00afd7');
chai_1.assert.equal(cm.colors.ansi[39], '#00afff');
chai_1.assert.equal(cm.colors.ansi[40], '#00d700');
chai_1.assert.equal(cm.colors.ansi[41], '#00d75f');
chai_1.assert.equal(cm.colors.ansi[42], '#00d787');
chai_1.assert.equal(cm.colors.ansi[43], '#00d7af');
chai_1.assert.equal(cm.colors.ansi[44], '#00d7d7');
chai_1.assert.equal(cm.colors.ansi[45], '#00d7ff');
chai_1.assert.equal(cm.colors.ansi[46], '#00ff00');
chai_1.assert.equal(cm.colors.ansi[47], '#00ff5f');
chai_1.assert.equal(cm.colors.ansi[48], '#00ff87');
chai_1.assert.equal(cm.colors.ansi[49], '#00ffaf');
chai_1.assert.equal(cm.colors.ansi[50], '#00ffd7');
chai_1.assert.equal(cm.colors.ansi[51], '#00ffff');
chai_1.assert.equal(cm.colors.ansi[52], '#5f0000');
chai_1.assert.equal(cm.colors.ansi[53], '#5f005f');
chai_1.assert.equal(cm.colors.ansi[54], '#5f0087');
chai_1.assert.equal(cm.colors.ansi[55], '#5f00af');
chai_1.assert.equal(cm.colors.ansi[56], '#5f00d7');
chai_1.assert.equal(cm.colors.ansi[57], '#5f00ff');
chai_1.assert.equal(cm.colors.ansi[58], '#5f5f00');
chai_1.assert.equal(cm.colors.ansi[59], '#5f5f5f');
chai_1.assert.equal(cm.colors.ansi[60], '#5f5f87');
chai_1.assert.equal(cm.colors.ansi[61], '#5f5faf');
chai_1.assert.equal(cm.colors.ansi[62], '#5f5fd7');
chai_1.assert.equal(cm.colors.ansi[63], '#5f5fff');
chai_1.assert.equal(cm.colors.ansi[64], '#5f8700');
chai_1.assert.equal(cm.colors.ansi[65], '#5f875f');
chai_1.assert.equal(cm.colors.ansi[66], '#5f8787');
chai_1.assert.equal(cm.colors.ansi[67], '#5f87af');
chai_1.assert.equal(cm.colors.ansi[68], '#5f87d7');
chai_1.assert.equal(cm.colors.ansi[69], '#5f87ff');
chai_1.assert.equal(cm.colors.ansi[70], '#5faf00');
chai_1.assert.equal(cm.colors.ansi[71], '#5faf5f');
chai_1.assert.equal(cm.colors.ansi[72], '#5faf87');
chai_1.assert.equal(cm.colors.ansi[73], '#5fafaf');
chai_1.assert.equal(cm.colors.ansi[74], '#5fafd7');
chai_1.assert.equal(cm.colors.ansi[75], '#5fafff');
chai_1.assert.equal(cm.colors.ansi[76], '#5fd700');
chai_1.assert.equal(cm.colors.ansi[77], '#5fd75f');
chai_1.assert.equal(cm.colors.ansi[78], '#5fd787');
chai_1.assert.equal(cm.colors.ansi[79], '#5fd7af');
chai_1.assert.equal(cm.colors.ansi[80], '#5fd7d7');
chai_1.assert.equal(cm.colors.ansi[81], '#5fd7ff');
chai_1.assert.equal(cm.colors.ansi[82], '#5fff00');
chai_1.assert.equal(cm.colors.ansi[83], '#5fff5f');
chai_1.assert.equal(cm.colors.ansi[84], '#5fff87');
chai_1.assert.equal(cm.colors.ansi[85], '#5fffaf');
chai_1.assert.equal(cm.colors.ansi[86], '#5fffd7');
chai_1.assert.equal(cm.colors.ansi[87], '#5fffff');
chai_1.assert.equal(cm.colors.ansi[88], '#870000');
chai_1.assert.equal(cm.colors.ansi[89], '#87005f');
chai_1.assert.equal(cm.colors.ansi[90], '#870087');
chai_1.assert.equal(cm.colors.ansi[91], '#8700af');
chai_1.assert.equal(cm.colors.ansi[92], '#8700d7');
chai_1.assert.equal(cm.colors.ansi[93], '#8700ff');
chai_1.assert.equal(cm.colors.ansi[94], '#875f00');
chai_1.assert.equal(cm.colors.ansi[95], '#875f5f');
chai_1.assert.equal(cm.colors.ansi[96], '#875f87');
chai_1.assert.equal(cm.colors.ansi[97], '#875faf');
chai_1.assert.equal(cm.colors.ansi[98], '#875fd7');
chai_1.assert.equal(cm.colors.ansi[99], '#875fff');
chai_1.assert.equal(cm.colors.ansi[100], '#878700');
chai_1.assert.equal(cm.colors.ansi[101], '#87875f');
chai_1.assert.equal(cm.colors.ansi[102], '#878787');
chai_1.assert.equal(cm.colors.ansi[103], '#8787af');
chai_1.assert.equal(cm.colors.ansi[104], '#8787d7');
chai_1.assert.equal(cm.colors.ansi[105], '#8787ff');
chai_1.assert.equal(cm.colors.ansi[106], '#87af00');
chai_1.assert.equal(cm.colors.ansi[107], '#87af5f');
chai_1.assert.equal(cm.colors.ansi[108], '#87af87');
chai_1.assert.equal(cm.colors.ansi[109], '#87afaf');
chai_1.assert.equal(cm.colors.ansi[110], '#87afd7');
chai_1.assert.equal(cm.colors.ansi[111], '#87afff');
chai_1.assert.equal(cm.colors.ansi[112], '#87d700');
chai_1.assert.equal(cm.colors.ansi[113], '#87d75f');
chai_1.assert.equal(cm.colors.ansi[114], '#87d787');
chai_1.assert.equal(cm.colors.ansi[115], '#87d7af');
chai_1.assert.equal(cm.colors.ansi[116], '#87d7d7');
chai_1.assert.equal(cm.colors.ansi[117], '#87d7ff');
chai_1.assert.equal(cm.colors.ansi[118], '#87ff00');
chai_1.assert.equal(cm.colors.ansi[119], '#87ff5f');
chai_1.assert.equal(cm.colors.ansi[120], '#87ff87');
chai_1.assert.equal(cm.colors.ansi[121], '#87ffaf');
chai_1.assert.equal(cm.colors.ansi[122], '#87ffd7');
chai_1.assert.equal(cm.colors.ansi[123], '#87ffff');
chai_1.assert.equal(cm.colors.ansi[124], '#af0000');
chai_1.assert.equal(cm.colors.ansi[125], '#af005f');
chai_1.assert.equal(cm.colors.ansi[126], '#af0087');
chai_1.assert.equal(cm.colors.ansi[127], '#af00af');
chai_1.assert.equal(cm.colors.ansi[128], '#af00d7');
chai_1.assert.equal(cm.colors.ansi[129], '#af00ff');
chai_1.assert.equal(cm.colors.ansi[130], '#af5f00');
chai_1.assert.equal(cm.colors.ansi[131], '#af5f5f');
chai_1.assert.equal(cm.colors.ansi[132], '#af5f87');
chai_1.assert.equal(cm.colors.ansi[133], '#af5faf');
chai_1.assert.equal(cm.colors.ansi[134], '#af5fd7');
chai_1.assert.equal(cm.colors.ansi[135], '#af5fff');
chai_1.assert.equal(cm.colors.ansi[136], '#af8700');
chai_1.assert.equal(cm.colors.ansi[137], '#af875f');
chai_1.assert.equal(cm.colors.ansi[138], '#af8787');
chai_1.assert.equal(cm.colors.ansi[139], '#af87af');
chai_1.assert.equal(cm.colors.ansi[140], '#af87d7');
chai_1.assert.equal(cm.colors.ansi[141], '#af87ff');
chai_1.assert.equal(cm.colors.ansi[142], '#afaf00');
chai_1.assert.equal(cm.colors.ansi[143], '#afaf5f');
chai_1.assert.equal(cm.colors.ansi[144], '#afaf87');
chai_1.assert.equal(cm.colors.ansi[145], '#afafaf');
chai_1.assert.equal(cm.colors.ansi[146], '#afafd7');
chai_1.assert.equal(cm.colors.ansi[147], '#afafff');
chai_1.assert.equal(cm.colors.ansi[148], '#afd700');
chai_1.assert.equal(cm.colors.ansi[149], '#afd75f');
chai_1.assert.equal(cm.colors.ansi[150], '#afd787');
chai_1.assert.equal(cm.colors.ansi[151], '#afd7af');
chai_1.assert.equal(cm.colors.ansi[152], '#afd7d7');
chai_1.assert.equal(cm.colors.ansi[153], '#afd7ff');
chai_1.assert.equal(cm.colors.ansi[154], '#afff00');
chai_1.assert.equal(cm.colors.ansi[155], '#afff5f');
chai_1.assert.equal(cm.colors.ansi[156], '#afff87');
chai_1.assert.equal(cm.colors.ansi[157], '#afffaf');
chai_1.assert.equal(cm.colors.ansi[158], '#afffd7');
chai_1.assert.equal(cm.colors.ansi[159], '#afffff');
chai_1.assert.equal(cm.colors.ansi[160], '#d70000');
chai_1.assert.equal(cm.colors.ansi[161], '#d7005f');
chai_1.assert.equal(cm.colors.ansi[162], '#d70087');
chai_1.assert.equal(cm.colors.ansi[163], '#d700af');
chai_1.assert.equal(cm.colors.ansi[164], '#d700d7');
chai_1.assert.equal(cm.colors.ansi[165], '#d700ff');
chai_1.assert.equal(cm.colors.ansi[166], '#d75f00');
chai_1.assert.equal(cm.colors.ansi[167], '#d75f5f');
chai_1.assert.equal(cm.colors.ansi[168], '#d75f87');
chai_1.assert.equal(cm.colors.ansi[169], '#d75faf');
chai_1.assert.equal(cm.colors.ansi[170], '#d75fd7');
chai_1.assert.equal(cm.colors.ansi[171], '#d75fff');
chai_1.assert.equal(cm.colors.ansi[172], '#d78700');
chai_1.assert.equal(cm.colors.ansi[173], '#d7875f');
chai_1.assert.equal(cm.colors.ansi[174], '#d78787');
chai_1.assert.equal(cm.colors.ansi[175], '#d787af');
chai_1.assert.equal(cm.colors.ansi[176], '#d787d7');
chai_1.assert.equal(cm.colors.ansi[177], '#d787ff');
chai_1.assert.equal(cm.colors.ansi[178], '#d7af00');
chai_1.assert.equal(cm.colors.ansi[179], '#d7af5f');
chai_1.assert.equal(cm.colors.ansi[180], '#d7af87');
chai_1.assert.equal(cm.colors.ansi[181], '#d7afaf');
chai_1.assert.equal(cm.colors.ansi[182], '#d7afd7');
chai_1.assert.equal(cm.colors.ansi[183], '#d7afff');
chai_1.assert.equal(cm.colors.ansi[184], '#d7d700');
chai_1.assert.equal(cm.colors.ansi[185], '#d7d75f');
chai_1.assert.equal(cm.colors.ansi[186], '#d7d787');
chai_1.assert.equal(cm.colors.ansi[187], '#d7d7af');
chai_1.assert.equal(cm.colors.ansi[188], '#d7d7d7');
chai_1.assert.equal(cm.colors.ansi[189], '#d7d7ff');
chai_1.assert.equal(cm.colors.ansi[190], '#d7ff00');
chai_1.assert.equal(cm.colors.ansi[191], '#d7ff5f');
chai_1.assert.equal(cm.colors.ansi[192], '#d7ff87');
chai_1.assert.equal(cm.colors.ansi[193], '#d7ffaf');
chai_1.assert.equal(cm.colors.ansi[194], '#d7ffd7');
chai_1.assert.equal(cm.colors.ansi[195], '#d7ffff');
chai_1.assert.equal(cm.colors.ansi[196], '#ff0000');
chai_1.assert.equal(cm.colors.ansi[197], '#ff005f');
chai_1.assert.equal(cm.colors.ansi[198], '#ff0087');
chai_1.assert.equal(cm.colors.ansi[199], '#ff00af');
chai_1.assert.equal(cm.colors.ansi[200], '#ff00d7');
chai_1.assert.equal(cm.colors.ansi[201], '#ff00ff');
chai_1.assert.equal(cm.colors.ansi[202], '#ff5f00');
chai_1.assert.equal(cm.colors.ansi[203], '#ff5f5f');
chai_1.assert.equal(cm.colors.ansi[204], '#ff5f87');
chai_1.assert.equal(cm.colors.ansi[205], '#ff5faf');
chai_1.assert.equal(cm.colors.ansi[206], '#ff5fd7');
chai_1.assert.equal(cm.colors.ansi[207], '#ff5fff');
chai_1.assert.equal(cm.colors.ansi[208], '#ff8700');
chai_1.assert.equal(cm.colors.ansi[209], '#ff875f');
chai_1.assert.equal(cm.colors.ansi[210], '#ff8787');
chai_1.assert.equal(cm.colors.ansi[211], '#ff87af');
chai_1.assert.equal(cm.colors.ansi[212], '#ff87d7');
chai_1.assert.equal(cm.colors.ansi[213], '#ff87ff');
chai_1.assert.equal(cm.colors.ansi[214], '#ffaf00');
chai_1.assert.equal(cm.colors.ansi[215], '#ffaf5f');
chai_1.assert.equal(cm.colors.ansi[216], '#ffaf87');
chai_1.assert.equal(cm.colors.ansi[217], '#ffafaf');
chai_1.assert.equal(cm.colors.ansi[218], '#ffafd7');
chai_1.assert.equal(cm.colors.ansi[219], '#ffafff');
chai_1.assert.equal(cm.colors.ansi[220], '#ffd700');
chai_1.assert.equal(cm.colors.ansi[221], '#ffd75f');
chai_1.assert.equal(cm.colors.ansi[222], '#ffd787');
chai_1.assert.equal(cm.colors.ansi[223], '#ffd7af');
chai_1.assert.equal(cm.colors.ansi[224], '#ffd7d7');
chai_1.assert.equal(cm.colors.ansi[225], '#ffd7ff');
chai_1.assert.equal(cm.colors.ansi[226], '#ffff00');
chai_1.assert.equal(cm.colors.ansi[227], '#ffff5f');
chai_1.assert.equal(cm.colors.ansi[228], '#ffff87');
chai_1.assert.equal(cm.colors.ansi[229], '#ffffaf');
chai_1.assert.equal(cm.colors.ansi[230], '#ffffd7');
chai_1.assert.equal(cm.colors.ansi[231], '#ffffff');
chai_1.assert.equal(cm.colors.ansi[232], '#080808');
chai_1.assert.equal(cm.colors.ansi[233], '#121212');
chai_1.assert.equal(cm.colors.ansi[234], '#1c1c1c');
chai_1.assert.equal(cm.colors.ansi[235], '#262626');
chai_1.assert.equal(cm.colors.ansi[236], '#303030');
chai_1.assert.equal(cm.colors.ansi[237], '#3a3a3a');
chai_1.assert.equal(cm.colors.ansi[238], '#444444');
chai_1.assert.equal(cm.colors.ansi[239], '#4e4e4e');
chai_1.assert.equal(cm.colors.ansi[240], '#585858');
chai_1.assert.equal(cm.colors.ansi[241], '#626262');
chai_1.assert.equal(cm.colors.ansi[242], '#6c6c6c');
chai_1.assert.equal(cm.colors.ansi[243], '#767676');
chai_1.assert.equal(cm.colors.ansi[244], '#808080');
chai_1.assert.equal(cm.colors.ansi[245], '#8a8a8a');
chai_1.assert.equal(cm.colors.ansi[246], '#949494');
chai_1.assert.equal(cm.colors.ansi[247], '#9e9e9e');
chai_1.assert.equal(cm.colors.ansi[248], '#a8a8a8');
chai_1.assert.equal(cm.colors.ansi[249], '#b2b2b2');
chai_1.assert.equal(cm.colors.ansi[250], '#bcbcbc');
chai_1.assert.equal(cm.colors.ansi[251], '#c6c6c6');
chai_1.assert.equal(cm.colors.ansi[252], '#d0d0d0');
chai_1.assert.equal(cm.colors.ansi[253], '#dadada');
chai_1.assert.equal(cm.colors.ansi[254], '#e4e4e4');
chai_1.assert.equal(cm.colors.ansi[255], '#eeeeee');
chai_1.assert.equal(cm.colors.ansi[16].css, '#000000');
chai_1.assert.equal(cm.colors.ansi[17].css, '#00005f');
chai_1.assert.equal(cm.colors.ansi[18].css, '#000087');
chai_1.assert.equal(cm.colors.ansi[19].css, '#0000af');
chai_1.assert.equal(cm.colors.ansi[20].css, '#0000d7');
chai_1.assert.equal(cm.colors.ansi[21].css, '#0000ff');
chai_1.assert.equal(cm.colors.ansi[22].css, '#005f00');
chai_1.assert.equal(cm.colors.ansi[23].css, '#005f5f');
chai_1.assert.equal(cm.colors.ansi[24].css, '#005f87');
chai_1.assert.equal(cm.colors.ansi[25].css, '#005faf');
chai_1.assert.equal(cm.colors.ansi[26].css, '#005fd7');
chai_1.assert.equal(cm.colors.ansi[27].css, '#005fff');
chai_1.assert.equal(cm.colors.ansi[28].css, '#008700');
chai_1.assert.equal(cm.colors.ansi[29].css, '#00875f');
chai_1.assert.equal(cm.colors.ansi[30].css, '#008787');
chai_1.assert.equal(cm.colors.ansi[31].css, '#0087af');
chai_1.assert.equal(cm.colors.ansi[32].css, '#0087d7');
chai_1.assert.equal(cm.colors.ansi[33].css, '#0087ff');
chai_1.assert.equal(cm.colors.ansi[34].css, '#00af00');
chai_1.assert.equal(cm.colors.ansi[35].css, '#00af5f');
chai_1.assert.equal(cm.colors.ansi[36].css, '#00af87');
chai_1.assert.equal(cm.colors.ansi[37].css, '#00afaf');
chai_1.assert.equal(cm.colors.ansi[38].css, '#00afd7');
chai_1.assert.equal(cm.colors.ansi[39].css, '#00afff');
chai_1.assert.equal(cm.colors.ansi[40].css, '#00d700');
chai_1.assert.equal(cm.colors.ansi[41].css, '#00d75f');
chai_1.assert.equal(cm.colors.ansi[42].css, '#00d787');
chai_1.assert.equal(cm.colors.ansi[43].css, '#00d7af');
chai_1.assert.equal(cm.colors.ansi[44].css, '#00d7d7');
chai_1.assert.equal(cm.colors.ansi[45].css, '#00d7ff');
chai_1.assert.equal(cm.colors.ansi[46].css, '#00ff00');
chai_1.assert.equal(cm.colors.ansi[47].css, '#00ff5f');
chai_1.assert.equal(cm.colors.ansi[48].css, '#00ff87');
chai_1.assert.equal(cm.colors.ansi[49].css, '#00ffaf');
chai_1.assert.equal(cm.colors.ansi[50].css, '#00ffd7');
chai_1.assert.equal(cm.colors.ansi[51].css, '#00ffff');
chai_1.assert.equal(cm.colors.ansi[52].css, '#5f0000');
chai_1.assert.equal(cm.colors.ansi[53].css, '#5f005f');
chai_1.assert.equal(cm.colors.ansi[54].css, '#5f0087');
chai_1.assert.equal(cm.colors.ansi[55].css, '#5f00af');
chai_1.assert.equal(cm.colors.ansi[56].css, '#5f00d7');
chai_1.assert.equal(cm.colors.ansi[57].css, '#5f00ff');
chai_1.assert.equal(cm.colors.ansi[58].css, '#5f5f00');
chai_1.assert.equal(cm.colors.ansi[59].css, '#5f5f5f');
chai_1.assert.equal(cm.colors.ansi[60].css, '#5f5f87');
chai_1.assert.equal(cm.colors.ansi[61].css, '#5f5faf');
chai_1.assert.equal(cm.colors.ansi[62].css, '#5f5fd7');
chai_1.assert.equal(cm.colors.ansi[63].css, '#5f5fff');
chai_1.assert.equal(cm.colors.ansi[64].css, '#5f8700');
chai_1.assert.equal(cm.colors.ansi[65].css, '#5f875f');
chai_1.assert.equal(cm.colors.ansi[66].css, '#5f8787');
chai_1.assert.equal(cm.colors.ansi[67].css, '#5f87af');
chai_1.assert.equal(cm.colors.ansi[68].css, '#5f87d7');
chai_1.assert.equal(cm.colors.ansi[69].css, '#5f87ff');
chai_1.assert.equal(cm.colors.ansi[70].css, '#5faf00');
chai_1.assert.equal(cm.colors.ansi[71].css, '#5faf5f');
chai_1.assert.equal(cm.colors.ansi[72].css, '#5faf87');
chai_1.assert.equal(cm.colors.ansi[73].css, '#5fafaf');
chai_1.assert.equal(cm.colors.ansi[74].css, '#5fafd7');
chai_1.assert.equal(cm.colors.ansi[75].css, '#5fafff');
chai_1.assert.equal(cm.colors.ansi[76].css, '#5fd700');
chai_1.assert.equal(cm.colors.ansi[77].css, '#5fd75f');
chai_1.assert.equal(cm.colors.ansi[78].css, '#5fd787');
chai_1.assert.equal(cm.colors.ansi[79].css, '#5fd7af');
chai_1.assert.equal(cm.colors.ansi[80].css, '#5fd7d7');
chai_1.assert.equal(cm.colors.ansi[81].css, '#5fd7ff');
chai_1.assert.equal(cm.colors.ansi[82].css, '#5fff00');
chai_1.assert.equal(cm.colors.ansi[83].css, '#5fff5f');
chai_1.assert.equal(cm.colors.ansi[84].css, '#5fff87');
chai_1.assert.equal(cm.colors.ansi[85].css, '#5fffaf');
chai_1.assert.equal(cm.colors.ansi[86].css, '#5fffd7');
chai_1.assert.equal(cm.colors.ansi[87].css, '#5fffff');
chai_1.assert.equal(cm.colors.ansi[88].css, '#870000');
chai_1.assert.equal(cm.colors.ansi[89].css, '#87005f');
chai_1.assert.equal(cm.colors.ansi[90].css, '#870087');
chai_1.assert.equal(cm.colors.ansi[91].css, '#8700af');
chai_1.assert.equal(cm.colors.ansi[92].css, '#8700d7');
chai_1.assert.equal(cm.colors.ansi[93].css, '#8700ff');
chai_1.assert.equal(cm.colors.ansi[94].css, '#875f00');
chai_1.assert.equal(cm.colors.ansi[95].css, '#875f5f');
chai_1.assert.equal(cm.colors.ansi[96].css, '#875f87');
chai_1.assert.equal(cm.colors.ansi[97].css, '#875faf');
chai_1.assert.equal(cm.colors.ansi[98].css, '#875fd7');
chai_1.assert.equal(cm.colors.ansi[99].css, '#875fff');
chai_1.assert.equal(cm.colors.ansi[100].css, '#878700');
chai_1.assert.equal(cm.colors.ansi[101].css, '#87875f');
chai_1.assert.equal(cm.colors.ansi[102].css, '#878787');
chai_1.assert.equal(cm.colors.ansi[103].css, '#8787af');
chai_1.assert.equal(cm.colors.ansi[104].css, '#8787d7');
chai_1.assert.equal(cm.colors.ansi[105].css, '#8787ff');
chai_1.assert.equal(cm.colors.ansi[106].css, '#87af00');
chai_1.assert.equal(cm.colors.ansi[107].css, '#87af5f');
chai_1.assert.equal(cm.colors.ansi[108].css, '#87af87');
chai_1.assert.equal(cm.colors.ansi[109].css, '#87afaf');
chai_1.assert.equal(cm.colors.ansi[110].css, '#87afd7');
chai_1.assert.equal(cm.colors.ansi[111].css, '#87afff');
chai_1.assert.equal(cm.colors.ansi[112].css, '#87d700');
chai_1.assert.equal(cm.colors.ansi[113].css, '#87d75f');
chai_1.assert.equal(cm.colors.ansi[114].css, '#87d787');
chai_1.assert.equal(cm.colors.ansi[115].css, '#87d7af');
chai_1.assert.equal(cm.colors.ansi[116].css, '#87d7d7');
chai_1.assert.equal(cm.colors.ansi[117].css, '#87d7ff');
chai_1.assert.equal(cm.colors.ansi[118].css, '#87ff00');
chai_1.assert.equal(cm.colors.ansi[119].css, '#87ff5f');
chai_1.assert.equal(cm.colors.ansi[120].css, '#87ff87');
chai_1.assert.equal(cm.colors.ansi[121].css, '#87ffaf');
chai_1.assert.equal(cm.colors.ansi[122].css, '#87ffd7');
chai_1.assert.equal(cm.colors.ansi[123].css, '#87ffff');
chai_1.assert.equal(cm.colors.ansi[124].css, '#af0000');
chai_1.assert.equal(cm.colors.ansi[125].css, '#af005f');
chai_1.assert.equal(cm.colors.ansi[126].css, '#af0087');
chai_1.assert.equal(cm.colors.ansi[127].css, '#af00af');
chai_1.assert.equal(cm.colors.ansi[128].css, '#af00d7');
chai_1.assert.equal(cm.colors.ansi[129].css, '#af00ff');
chai_1.assert.equal(cm.colors.ansi[130].css, '#af5f00');
chai_1.assert.equal(cm.colors.ansi[131].css, '#af5f5f');
chai_1.assert.equal(cm.colors.ansi[132].css, '#af5f87');
chai_1.assert.equal(cm.colors.ansi[133].css, '#af5faf');
chai_1.assert.equal(cm.colors.ansi[134].css, '#af5fd7');
chai_1.assert.equal(cm.colors.ansi[135].css, '#af5fff');
chai_1.assert.equal(cm.colors.ansi[136].css, '#af8700');
chai_1.assert.equal(cm.colors.ansi[137].css, '#af875f');
chai_1.assert.equal(cm.colors.ansi[138].css, '#af8787');
chai_1.assert.equal(cm.colors.ansi[139].css, '#af87af');
chai_1.assert.equal(cm.colors.ansi[140].css, '#af87d7');
chai_1.assert.equal(cm.colors.ansi[141].css, '#af87ff');
chai_1.assert.equal(cm.colors.ansi[142].css, '#afaf00');
chai_1.assert.equal(cm.colors.ansi[143].css, '#afaf5f');
chai_1.assert.equal(cm.colors.ansi[144].css, '#afaf87');
chai_1.assert.equal(cm.colors.ansi[145].css, '#afafaf');
chai_1.assert.equal(cm.colors.ansi[146].css, '#afafd7');
chai_1.assert.equal(cm.colors.ansi[147].css, '#afafff');
chai_1.assert.equal(cm.colors.ansi[148].css, '#afd700');
chai_1.assert.equal(cm.colors.ansi[149].css, '#afd75f');
chai_1.assert.equal(cm.colors.ansi[150].css, '#afd787');
chai_1.assert.equal(cm.colors.ansi[151].css, '#afd7af');
chai_1.assert.equal(cm.colors.ansi[152].css, '#afd7d7');
chai_1.assert.equal(cm.colors.ansi[153].css, '#afd7ff');
chai_1.assert.equal(cm.colors.ansi[154].css, '#afff00');
chai_1.assert.equal(cm.colors.ansi[155].css, '#afff5f');
chai_1.assert.equal(cm.colors.ansi[156].css, '#afff87');
chai_1.assert.equal(cm.colors.ansi[157].css, '#afffaf');
chai_1.assert.equal(cm.colors.ansi[158].css, '#afffd7');
chai_1.assert.equal(cm.colors.ansi[159].css, '#afffff');
chai_1.assert.equal(cm.colors.ansi[160].css, '#d70000');
chai_1.assert.equal(cm.colors.ansi[161].css, '#d7005f');
chai_1.assert.equal(cm.colors.ansi[162].css, '#d70087');
chai_1.assert.equal(cm.colors.ansi[163].css, '#d700af');
chai_1.assert.equal(cm.colors.ansi[164].css, '#d700d7');
chai_1.assert.equal(cm.colors.ansi[165].css, '#d700ff');
chai_1.assert.equal(cm.colors.ansi[166].css, '#d75f00');
chai_1.assert.equal(cm.colors.ansi[167].css, '#d75f5f');
chai_1.assert.equal(cm.colors.ansi[168].css, '#d75f87');
chai_1.assert.equal(cm.colors.ansi[169].css, '#d75faf');
chai_1.assert.equal(cm.colors.ansi[170].css, '#d75fd7');
chai_1.assert.equal(cm.colors.ansi[171].css, '#d75fff');
chai_1.assert.equal(cm.colors.ansi[172].css, '#d78700');
chai_1.assert.equal(cm.colors.ansi[173].css, '#d7875f');
chai_1.assert.equal(cm.colors.ansi[174].css, '#d78787');
chai_1.assert.equal(cm.colors.ansi[175].css, '#d787af');
chai_1.assert.equal(cm.colors.ansi[176].css, '#d787d7');
chai_1.assert.equal(cm.colors.ansi[177].css, '#d787ff');
chai_1.assert.equal(cm.colors.ansi[178].css, '#d7af00');
chai_1.assert.equal(cm.colors.ansi[179].css, '#d7af5f');
chai_1.assert.equal(cm.colors.ansi[180].css, '#d7af87');
chai_1.assert.equal(cm.colors.ansi[181].css, '#d7afaf');
chai_1.assert.equal(cm.colors.ansi[182].css, '#d7afd7');
chai_1.assert.equal(cm.colors.ansi[183].css, '#d7afff');
chai_1.assert.equal(cm.colors.ansi[184].css, '#d7d700');
chai_1.assert.equal(cm.colors.ansi[185].css, '#d7d75f');
chai_1.assert.equal(cm.colors.ansi[186].css, '#d7d787');
chai_1.assert.equal(cm.colors.ansi[187].css, '#d7d7af');
chai_1.assert.equal(cm.colors.ansi[188].css, '#d7d7d7');
chai_1.assert.equal(cm.colors.ansi[189].css, '#d7d7ff');
chai_1.assert.equal(cm.colors.ansi[190].css, '#d7ff00');
chai_1.assert.equal(cm.colors.ansi[191].css, '#d7ff5f');
chai_1.assert.equal(cm.colors.ansi[192].css, '#d7ff87');
chai_1.assert.equal(cm.colors.ansi[193].css, '#d7ffaf');
chai_1.assert.equal(cm.colors.ansi[194].css, '#d7ffd7');
chai_1.assert.equal(cm.colors.ansi[195].css, '#d7ffff');
chai_1.assert.equal(cm.colors.ansi[196].css, '#ff0000');
chai_1.assert.equal(cm.colors.ansi[197].css, '#ff005f');
chai_1.assert.equal(cm.colors.ansi[198].css, '#ff0087');
chai_1.assert.equal(cm.colors.ansi[199].css, '#ff00af');
chai_1.assert.equal(cm.colors.ansi[200].css, '#ff00d7');
chai_1.assert.equal(cm.colors.ansi[201].css, '#ff00ff');
chai_1.assert.equal(cm.colors.ansi[202].css, '#ff5f00');
chai_1.assert.equal(cm.colors.ansi[203].css, '#ff5f5f');
chai_1.assert.equal(cm.colors.ansi[204].css, '#ff5f87');
chai_1.assert.equal(cm.colors.ansi[205].css, '#ff5faf');
chai_1.assert.equal(cm.colors.ansi[206].css, '#ff5fd7');
chai_1.assert.equal(cm.colors.ansi[207].css, '#ff5fff');
chai_1.assert.equal(cm.colors.ansi[208].css, '#ff8700');
chai_1.assert.equal(cm.colors.ansi[209].css, '#ff875f');
chai_1.assert.equal(cm.colors.ansi[210].css, '#ff8787');
chai_1.assert.equal(cm.colors.ansi[211].css, '#ff87af');
chai_1.assert.equal(cm.colors.ansi[212].css, '#ff87d7');
chai_1.assert.equal(cm.colors.ansi[213].css, '#ff87ff');
chai_1.assert.equal(cm.colors.ansi[214].css, '#ffaf00');
chai_1.assert.equal(cm.colors.ansi[215].css, '#ffaf5f');
chai_1.assert.equal(cm.colors.ansi[216].css, '#ffaf87');
chai_1.assert.equal(cm.colors.ansi[217].css, '#ffafaf');
chai_1.assert.equal(cm.colors.ansi[218].css, '#ffafd7');
chai_1.assert.equal(cm.colors.ansi[219].css, '#ffafff');
chai_1.assert.equal(cm.colors.ansi[220].css, '#ffd700');
chai_1.assert.equal(cm.colors.ansi[221].css, '#ffd75f');
chai_1.assert.equal(cm.colors.ansi[222].css, '#ffd787');
chai_1.assert.equal(cm.colors.ansi[223].css, '#ffd7af');
chai_1.assert.equal(cm.colors.ansi[224].css, '#ffd7d7');
chai_1.assert.equal(cm.colors.ansi[225].css, '#ffd7ff');
chai_1.assert.equal(cm.colors.ansi[226].css, '#ffff00');
chai_1.assert.equal(cm.colors.ansi[227].css, '#ffff5f');
chai_1.assert.equal(cm.colors.ansi[228].css, '#ffff87');
chai_1.assert.equal(cm.colors.ansi[229].css, '#ffffaf');
chai_1.assert.equal(cm.colors.ansi[230].css, '#ffffd7');
chai_1.assert.equal(cm.colors.ansi[231].css, '#ffffff');
chai_1.assert.equal(cm.colors.ansi[232].css, '#080808');
chai_1.assert.equal(cm.colors.ansi[233].css, '#121212');
chai_1.assert.equal(cm.colors.ansi[234].css, '#1c1c1c');
chai_1.assert.equal(cm.colors.ansi[235].css, '#262626');
chai_1.assert.equal(cm.colors.ansi[236].css, '#303030');
chai_1.assert.equal(cm.colors.ansi[237].css, '#3a3a3a');
chai_1.assert.equal(cm.colors.ansi[238].css, '#444444');
chai_1.assert.equal(cm.colors.ansi[239].css, '#4e4e4e');
chai_1.assert.equal(cm.colors.ansi[240].css, '#585858');
chai_1.assert.equal(cm.colors.ansi[241].css, '#626262');
chai_1.assert.equal(cm.colors.ansi[242].css, '#6c6c6c');
chai_1.assert.equal(cm.colors.ansi[243].css, '#767676');
chai_1.assert.equal(cm.colors.ansi[244].css, '#808080');
chai_1.assert.equal(cm.colors.ansi[245].css, '#8a8a8a');
chai_1.assert.equal(cm.colors.ansi[246].css, '#949494');
chai_1.assert.equal(cm.colors.ansi[247].css, '#9e9e9e');
chai_1.assert.equal(cm.colors.ansi[248].css, '#a8a8a8');
chai_1.assert.equal(cm.colors.ansi[249].css, '#b2b2b2');
chai_1.assert.equal(cm.colors.ansi[250].css, '#bcbcbc');
chai_1.assert.equal(cm.colors.ansi[251].css, '#c6c6c6');
chai_1.assert.equal(cm.colors.ansi[252].css, '#d0d0d0');
chai_1.assert.equal(cm.colors.ansi[253].css, '#dadada');
chai_1.assert.equal(cm.colors.ansi[254].css, '#e4e4e4');
chai_1.assert.equal(cm.colors.ansi[255].css, '#eeeeee');
});

@@ -271,4 +288,4 @@ });

it('should set a partial set of colors, using the default if not present', function () {
chai_1.assert.equal(cm.colors.background, '#000000');
chai_1.assert.equal(cm.colors.foreground, '#ffffff');
chai_1.assert.equal(cm.colors.background.css, '#000000');
chai_1.assert.equal(cm.colors.foreground.css, '#ffffff');
cm.setTheme({

@@ -278,9 +295,9 @@ background: '#FF0000',

});
chai_1.assert.equal(cm.colors.background, '#FF0000');
chai_1.assert.equal(cm.colors.foreground, '#00FF00');
chai_1.assert.equal(cm.colors.background.css, '#FF0000');
chai_1.assert.equal(cm.colors.foreground.css, '#00FF00');
cm.setTheme({
background: '#0000FF'
});
chai_1.assert.equal(cm.colors.background, '#0000FF');
chai_1.assert.equal(cm.colors.foreground, '#ffffff');
chai_1.assert.equal(cm.colors.background.css, '#0000FF');
chai_1.assert.equal(cm.colors.foreground.css, '#ffffff');
});

@@ -287,0 +304,0 @@ });

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

style: null,
width: null,
width: null
};

@@ -35,4 +35,4 @@ _this._cursorRenderers = {

}
CursorRenderLayer.prototype.resize = function (terminal, dim, charSizeChanged) {
_super.prototype.resize.call(this, terminal, dim, charSizeChanged);
CursorRenderLayer.prototype.resize = function (terminal, dim) {
_super.prototype.resize.call(this, terminal, dim);
this._state = {

@@ -43,3 +43,3 @@ x: null,

style: null,
width: null,
width: null
};

@@ -117,3 +117,3 @@ };

this._ctx.save();
this._ctx.fillStyle = this._colors.cursor;
this._ctx.fillStyle = this._colors.cursor.css;
this._renderBlurCursor(terminal, terminal.buffer.x, viewportRelativeCursorY, charData);

@@ -159,3 +159,3 @@ this._ctx.restore();

style: null,
width: null,
width: null
};

@@ -166,3 +166,3 @@ }

this._ctx.save();
this._ctx.fillStyle = this._colors.cursor;
this._ctx.fillStyle = this._colors.cursor.css;
this.fillLeftLineAtCell(x, y);

@@ -173,5 +173,5 @@ this._ctx.restore();

this._ctx.save();
this._ctx.fillStyle = this._colors.cursor;
this._ctx.fillStyle = this._colors.cursor.css;
this.fillCells(x, y, charData[Buffer_1.CHAR_DATA_WIDTH_INDEX], 1);
this._ctx.fillStyle = this._colors.cursorAccent;
this._ctx.fillStyle = this._colors.cursorAccent.css;
this.fillCharTrueColor(terminal, charData, x, y);

@@ -182,3 +182,3 @@ this._ctx.restore();

this._ctx.save();
this._ctx.fillStyle = this._colors.cursor;
this._ctx.fillStyle = this._colors.cursor.css;
this.fillBottomLineAtCells(x, y);

@@ -189,3 +189,3 @@ this._ctx.restore();

this._ctx.save();
this._ctx.strokeStyle = this._colors.cursor;
this._ctx.strokeStyle = this._colors.cursor.css;
this.strokeRectAtCell(x, y, charData[Buffer_1.CHAR_DATA_WIDTH_INDEX], 1);

@@ -198,4 +198,4 @@ this._ctx.restore();

var CursorBlinkStateManager = (function () {
function CursorBlinkStateManager(terminal, renderCallback) {
this.renderCallback = renderCallback;
function CursorBlinkStateManager(terminal, _renderCallback) {
this._renderCallback = _renderCallback;
this.isCursorVisible = true;

@@ -234,3 +234,3 @@ if (terminal.isFocused) {

this._animationFrame = window.requestAnimationFrame(function () {
_this.renderCallback();
_this._renderCallback();
_this._animationFrame = null;

@@ -257,3 +257,3 @@ });

_this._animationFrame = window.requestAnimationFrame(function () {
_this.renderCallback();
_this._renderCallback();
_this._animationFrame = null;

@@ -270,3 +270,3 @@ });

_this._animationFrame = window.requestAnimationFrame(function () {
_this.renderCallback();
_this._renderCallback();
_this._animationFrame = null;

@@ -273,0 +273,0 @@ });

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

}
LinkRenderLayer.prototype.resize = function (terminal, dim, charSizeChanged) {
_super.prototype.resize.call(this, terminal, dim, charSizeChanged);
LinkRenderLayer.prototype.resize = function (terminal, dim) {
_super.prototype.resize.call(this, terminal, dim);
this._state = null;

@@ -34,3 +34,8 @@ };

if (this._state) {
this.clearCells(this._state.x, this._state.y, this._state.length, 1);
this.clearCells(this._state.x1, this._state.y1, this._state.cols - this._state.x1, 1);
var middleRowCount = this._state.y2 - this._state.y1 - 1;
if (middleRowCount > 0) {
this.clearCells(0, this._state.y1 + 1, this._state.cols, middleRowCount);
}
this.clearCells(0, this._state.y2, this._state.x2, 1);
this._state = null;

@@ -40,4 +45,13 @@ }

LinkRenderLayer.prototype._onLinkHover = function (e) {
this._ctx.fillStyle = this._colors.foreground;
this.fillBottomLineAtCells(e.x, e.y, e.length);
this._ctx.fillStyle = this._colors.foreground.css;
if (e.y1 === e.y2) {
this.fillBottomLineAtCells(e.x1, e.y1, e.x2 - e.x1);
}
else {
this.fillBottomLineAtCells(e.x1, e.y1, e.cols - e.x1);
for (var y = e.y1 + 1; y < e.y2; y++) {
this.fillBottomLineAtCells(0, y, e.cols);
}
this.fillBottomLineAtCells(0, e.y2, e.x2);
}
this._state = e;

@@ -44,0 +58,0 @@ };

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

_this._needsFullRefresh = false;
_this.colorManager = new ColorManager_1.ColorManager();
var allowTransparency = _this._terminal.options.allowTransparency;
_this.colorManager = new ColorManager_1.ColorManager(document, allowTransparency);
if (theme) {

@@ -34,3 +35,3 @@ _this.colorManager.setTheme(theme);

_this._renderLayers = [
new TextRenderLayer_1.TextRenderLayer(_this._terminal.screenElement, 0, _this.colorManager.colors, _this._terminal.options.allowTransparency),
new TextRenderLayer_1.TextRenderLayer(_this._terminal.screenElement, 0, _this.colorManager.colors, allowTransparency),
new SelectionRenderLayer_1.SelectionRenderLayer(_this._terminal.screenElement, 1, _this.colorManager.colors),

@@ -75,3 +76,3 @@ new LinkRenderLayer_1.LinkRenderLayer(_this._terminal.screenElement, 2, _this.colorManager.colors, _this._terminal),

this._devicePixelRatio = devicePixelRatio;
this.onResize(this._terminal.cols, this._terminal.rows, true);
this.onResize(this._terminal.cols, this._terminal.rows);
}

@@ -94,6 +95,6 @@ };

};
Renderer.prototype.onResize = function (cols, rows, didCharSizeChange) {
Renderer.prototype.onResize = function (cols, rows) {
var _this = this;
this._updateDimensions();
this._renderLayers.forEach(function (l) { return l.resize(_this._terminal, _this.dimensions, didCharSizeChange); });
this._renderLayers.forEach(function (l) { return l.resize(_this._terminal, _this.dimensions); });
if (this._isPaused) {

@@ -113,3 +114,3 @@ this._needsFullRefresh = true;

Renderer.prototype.onCharSizeChanged = function () {
this.onResize(this._terminal.cols, this._terminal.rows, true);
this.onResize(this._terminal.cols, this._terminal.rows);
};

@@ -116,0 +117,0 @@ Renderer.prototype.onBlur = function () {

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

}
SelectionRenderLayer.prototype.resize = function (terminal, dim, charSizeChanged) {
_super.prototype.resize.call(this, terminal, dim, charSizeChanged);
SelectionRenderLayer.prototype.resize = function (terminal, dim) {
_super.prototype.resize.call(this, terminal, dim);
this._state = {

@@ -58,3 +58,3 @@ start: null,

var startRowEndCol = viewportCappedStartRow === viewportCappedEndRow ? end[0] : terminal.cols;
this._ctx.fillStyle = this._colors.selection;
this._ctx.fillStyle = this._colors.selection.css;
this.fillCells(startCol, viewportCappedStartRow, startRowEndCol - startCol, 1);

@@ -61,0 +61,0 @@ var middleRowsCount = Math.max(viewportCappedEndRow - viewportCappedStartRow - 1, 0);

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

var Types_1 = require("./Types");
var Types_2 = require("./atlas/Types");
var GridCache_1 = require("./GridCache");
var BaseRenderLayer_1 = require("./BaseRenderLayer");
var OVERLAP_OWNED_CHAR_DATA = [null, '', 0, -1];
var TextRenderLayer = (function (_super) {

@@ -27,4 +27,4 @@ __extends(TextRenderLayer, _super);

}
TextRenderLayer.prototype.resize = function (terminal, dim, charSizeChanged) {
_super.prototype.resize.call(this, terminal, dim, charSizeChanged);
TextRenderLayer.prototype.resize = function (terminal, dim) {
_super.prototype.resize.call(this, terminal, dim);
var terminalFont = this._getFont(terminal, false);

@@ -87,6 +87,6 @@ if (this._characterWidth !== dim.scaledCharWidth || this._characterFont !== terminalFont) {

if (fg === 256) {
fg = BaseRenderLayer_1.INVERTED_DEFAULT_COLOR;
fg = Types_2.INVERTED_DEFAULT_COLOR;
}
if (bg === 257) {
bg = BaseRenderLayer_1.INVERTED_DEFAULT_COLOR;
bg = Types_2.INVERTED_DEFAULT_COLOR;
}

@@ -98,3 +98,3 @@ }

this._ctx.save();
this._ctx.fillStyle = (bg === BaseRenderLayer_1.INVERTED_DEFAULT_COLOR ? this._colors.foreground : this._colors.ansi[bg]);
this._ctx.fillStyle = (bg === Types_2.INVERTED_DEFAULT_COLOR ? this._colors.foreground.css : this._colors.ansi[bg].css);
this.fillCells(x, y, width, 1);

@@ -111,10 +111,10 @@ this._ctx.restore();

if (flags & Types_1.FLAGS.UNDERLINE) {
if (fg === BaseRenderLayer_1.INVERTED_DEFAULT_COLOR) {
this._ctx.fillStyle = this._colors.background;
if (fg === Types_2.INVERTED_DEFAULT_COLOR) {
this._ctx.fillStyle = this._colors.background.css;
}
else if (fg < 256) {
this._ctx.fillStyle = this._colors.ansi[fg];
this._ctx.fillStyle = this._colors.ansi[fg].css;
}
else {
this._ctx.fillStyle = this._colors.foreground;
this._ctx.fillStyle = this._colors.foreground.css;
}

@@ -150,10 +150,2 @@ this.fillBottomLineAtCells(x, y);

};
TextRenderLayer.prototype._clearChar = function (x, y) {
var colsToClear = 1;
var state = this._state.cache[x][y];
if (state && state[Buffer_1.CHAR_DATA_WIDTH_INDEX] === 2) {
colsToClear = 2;
}
this.clearCells(x, y, colsToClear, 1);
};
return TextRenderLayer;

@@ -160,0 +152,0 @@ }(BaseRenderLayer_1.BaseRenderLayer));

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

};
SelectionManager.prototype.selectLines = function (start, end) {
this._model.clearSelection();
start = Math.max(start, 0);
end = Math.min(end, this._terminal.buffer.lines.length - 1);
this._model.selectionStart = [0, start];
this._model.selectionEnd = [this._terminal.cols, end];
this.refresh();
this._terminal.emit('selection');
};
SelectionManager.prototype._onTrim = function (amount) {

@@ -178,0 +187,0 @@ var needsRefresh = this._model.onTrim(amount);

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

Object.defineProperty(exports, "__esModule", { value: true });
var jsdom = require("jsdom");
var chai_1 = require("chai");

@@ -45,13 +44,6 @@ var SelectionManager_1 = require("./SelectionManager");

describe('SelectionManager', function () {
var dom;
var window;
var document;
var terminal;
var buffer;
var rowContainer;
var selectionManager;
beforeEach(function () {
dom = new jsdom.JSDOM('');
window = dom.window;
document = window.document;
terminal = new TestMockTerminal();

@@ -317,2 +309,40 @@ terminal.cols = 80;

});
describe('selectLines', function () {
it('should select a single line', function () {
buffer.lines.length = 3;
buffer.lines.set(0, stringToRow('1'));
buffer.lines.set(1, stringToRow('2'));
buffer.lines.set(2, stringToRow('3'));
selectionManager.selectLines(1, 1);
chai_1.assert.deepEqual(selectionManager.model.finalSelectionStart, [0, 1]);
chai_1.assert.deepEqual(selectionManager.model.finalSelectionEnd, [terminal.cols, 1]);
});
it('should select multiple lines', function () {
buffer.lines.length = 5;
buffer.lines.set(0, stringToRow('1'));
buffer.lines.set(1, stringToRow('2'));
buffer.lines.set(2, stringToRow('3'));
buffer.lines.set(3, stringToRow('4'));
buffer.lines.set(4, stringToRow('5'));
selectionManager.selectLines(1, 3);
chai_1.assert.deepEqual(selectionManager.model.finalSelectionStart, [0, 1]);
chai_1.assert.deepEqual(selectionManager.model.finalSelectionEnd, [terminal.cols, 3]);
});
it('should select the to the start when requesting a negative row', function () {
buffer.lines.length = 2;
buffer.lines.set(0, stringToRow('1'));
buffer.lines.set(1, stringToRow('2'));
selectionManager.selectLines(-1, 0);
chai_1.assert.deepEqual(selectionManager.model.finalSelectionStart, [0, 0]);
chai_1.assert.deepEqual(selectionManager.model.finalSelectionEnd, [terminal.cols, 0]);
});
it('should select the to the end when requesting beyond the final row', function () {
buffer.lines.length = 2;
buffer.lines.set(0, stringToRow('1'));
buffer.lines.set(1, stringToRow('2'));
selectionManager.selectLines(1, 2);
chai_1.assert.deepEqual(selectionManager.model.finalSelectionStart, [0, 1]);
chai_1.assert.deepEqual(selectionManager.model.finalSelectionEnd, [terminal.cols, 1]);
});
});
describe('hasSelection', function () {

@@ -319,0 +349,0 @@ it('should return whether there is a selection', function () {

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

describe('SelectionManager', function () {
var window;
var document;
var terminal;

@@ -29,0 +27,0 @@ var model;

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

var context_1 = this._audioContext;
this._audioContext.decodeAudioData(this.base64ToArrayBuffer(this.removeMimeType(this._terminal.options.bellSound)), function (buffer) {
this._audioContext.decodeAudioData(this._base64ToArrayBuffer(this._removeMimeType(this._terminal.options.bellSound)), function (buffer) {
bellAudioSource_1.buffer = buffer;

@@ -27,3 +27,3 @@ bellAudioSource_1.connect(context_1.destination);

};
SoundManager.prototype.base64ToArrayBuffer = function (base64) {
SoundManager.prototype._base64ToArrayBuffer = function (base64) {
var binaryString = window.atob(base64);

@@ -37,3 +37,3 @@ var len = binaryString.length;

};
SoundManager.prototype.removeMimeType = function (dataURI) {
SoundManager.prototype._removeMimeType = function (dataURI) {
var splitUri = dataURI.split(',');

@@ -40,0 +40,0 @@ return splitUri[1];

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

xterm.writeBuffer.push(fromPty);
xterm.innerWrite();
xterm._innerWrite();
var fromEmulator = terminalToString(xterm);

@@ -93,0 +93,0 @@ console.log = CONSOLE_LOG_1;

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

var MouseHelper_1 = require("./utils/MouseHelper");
var Clone_1 = require("./utils/Clone");
var SoundManager_1 = require("./SoundManager");

@@ -96,7 +97,7 @@ var ColorManager_1 = require("./renderer/ColorManager");

_this.browser = Browser;
_this.options = options;
_this.setup();
_this.options = Clone_1.clone(options);
_this._setup();
return _this;
}
Terminal.prototype.setup = function () {
Terminal.prototype._setup = function () {
var _this = this;

@@ -109,3 +110,3 @@ Object.keys(DEFAULT_OPTIONS).forEach(function (key) {

});
this.parent = document ? document.body : null;
this._parent = document ? document.body : null;
this.cols = this.options.cols;

@@ -118,4 +119,4 @@ this.rows = this.options.rows;

this.cursorHidden = false;
this.sendDataQueue = '';
this.customKeyEventHandler = null;
this._sendDataQueue = '';
this._customKeyEventHandler = null;
this.applicationKeypad = false;

@@ -131,4 +132,2 @@ this.applicationCursor = false;

this.charsets = [null];
this.readable = true;
this.writable = true;
this.defAttr = (0 << 18) | (257 << 9) | (256 << 0);

@@ -141,9 +140,7 @@ this.curAttr = (0 << 18) | (257 << 9) | (256 << 0);

this.writeBuffer = [];
this.writeInProgress = false;
this.xoffSentToCatchUp = false;
this.writeStopped = false;
this.surrogateHigh = '';
this.userScrolling = false;
this.inputHandler = new InputHandler_1.InputHandler(this);
this.parser = new Parser_1.Parser(this.inputHandler, this);
this._writeInProgress = false;
this._xoffSentToCatchUp = false;
this._userScrolling = false;
this._inputHandler = new InputHandler_1.InputHandler(this);
this._parser = new Parser_1.Parser(this._inputHandler, this);
this.renderer = this.renderer || null;

@@ -274,5 +271,4 @@ this.selectionManager = this.selectionManager || null;

case 'fontWeightBold':
var didCharSizeChange = (key === 'fontWeight' || key === 'fontWeightBold' || key === 'enableBold');
this.renderer.clear();
this.renderer.onResize(this.cols, this.rows, didCharSizeChange);
this.renderer.onResize(this.cols, this.rows);
this.refresh(0, this.rows - 1);

@@ -324,5 +320,5 @@ case 'scrollback':

};
Terminal.prototype.initGlobal = function () {
Terminal.prototype._initGlobal = function () {
var _this = this;
this.bindKeys();
this._bindKeys();
on(this.element, 'copy', function (event) {

@@ -357,3 +353,3 @@ if (!_this.hasSelection()) {

};
Terminal.prototype.bindKeys = function () {
Terminal.prototype._bindKeys = function () {
var _this = this;

@@ -380,38 +376,36 @@ var self = this;

on(this.textarea, 'keypress', function (ev) { return _this._keyPress(ev); }, true);
on(this.textarea, 'compositionstart', function () { return _this.compositionHelper.compositionstart(); });
on(this.textarea, 'compositionupdate', function (e) { return _this.compositionHelper.compositionupdate(e); });
on(this.textarea, 'compositionend', function () { return _this.compositionHelper.compositionend(); });
this.on('refresh', function () { return _this.compositionHelper.updateCompositionElements(); });
this.on('refresh', function (data) { return _this.queueLinkification(data.start, data.end); });
on(this.textarea, 'compositionstart', function () { return _this._compositionHelper.compositionstart(); });
on(this.textarea, 'compositionupdate', function (e) { return _this._compositionHelper.compositionupdate(e); });
on(this.textarea, 'compositionend', function () { return _this._compositionHelper.compositionend(); });
this.on('refresh', function () { return _this._compositionHelper.updateCompositionElements(); });
this.on('refresh', function (data) { return _this._queueLinkification(data.start, data.end); });
};
Terminal.prototype.open = function (parent) {
var _this = this;
var i = 0;
var div;
this.parent = parent || this.parent;
if (!this.parent) {
this._parent = parent || this._parent;
if (!this._parent) {
throw new Error('Terminal requires a parent element.');
}
this.context = this.parent.ownerDocument.defaultView;
this.document = this.parent.ownerDocument;
this.body = this.document.body;
this._context = this._parent.ownerDocument.defaultView;
this._document = this._parent.ownerDocument;
this._screenDprMonitor = new ScreenDprMonitor_1.ScreenDprMonitor();
this._screenDprMonitor.setListener(function () { return _this.emit('dprchange', window.devicePixelRatio); });
this.element = this.document.createElement('div');
this.element = this._document.createElement('div');
this.element.dir = 'ltr';
this.element.classList.add('terminal');
this.element.classList.add('xterm');
this.element.setAttribute('tabindex', '0');
this.parent.appendChild(this.element);
this._parent.appendChild(this.element);
var fragment = document.createDocumentFragment();
this.viewportElement = document.createElement('div');
this.viewportElement.classList.add('xterm-viewport');
fragment.appendChild(this.viewportElement);
this.viewportScrollArea = document.createElement('div');
this.viewportScrollArea.classList.add('xterm-scroll-area');
this.viewportElement.appendChild(this.viewportScrollArea);
this._viewportElement = document.createElement('div');
this._viewportElement.classList.add('xterm-viewport');
fragment.appendChild(this._viewportElement);
this._viewportScrollArea = document.createElement('div');
this._viewportScrollArea.classList.add('xterm-scroll-area');
this._viewportElement.appendChild(this._viewportScrollArea);
this.screenElement = document.createElement('div');
this.screenElement.classList.add('xterm-screen');
this.helperContainer = document.createElement('div');
this.helperContainer.classList.add('xterm-helpers');
this.screenElement.appendChild(this.helperContainer);
this._helperContainer = document.createElement('div');
this._helperContainer.classList.add('xterm-helpers');
this.screenElement.appendChild(this._helperContainer);
fragment.appendChild(this.screenElement);

@@ -431,17 +425,15 @@ this._mouseZoneManager = new MouseZoneManager_1.MouseZoneManager(this);

this.textarea.addEventListener('blur', function () { return _this._onTextAreaBlur(); });
this.helperContainer.appendChild(this.textarea);
this.compositionView = document.createElement('div');
this.compositionView.classList.add('composition-view');
this.compositionHelper = new CompositionHelper_1.CompositionHelper(this.textarea, this.compositionView, this);
this.helperContainer.appendChild(this.compositionView);
this.charSizeStyleElement = document.createElement('style');
this.helperContainer.appendChild(this.charSizeStyleElement);
this.charMeasure = new CharMeasure_1.CharMeasure(document, this.helperContainer);
this._helperContainer.appendChild(this.textarea);
this._compositionView = document.createElement('div');
this._compositionView.classList.add('composition-view');
this._compositionHelper = new CompositionHelper_1.CompositionHelper(this.textarea, this._compositionView, this);
this._helperContainer.appendChild(this._compositionView);
this.charMeasure = new CharMeasure_1.CharMeasure(document, this._helperContainer);
this.element.appendChild(fragment);
this.renderer = new Renderer_1.Renderer(this, this.options.theme);
this.options.theme = null;
this.viewport = new Viewport_1.Viewport(this, this.viewportElement, this.viewportScrollArea, this.charMeasure);
this.viewport = new Viewport_1.Viewport(this, this._viewportElement, this._viewportScrollArea, this.charMeasure);
this.viewport.onThemeChanged(this.renderer.colorManager.colors);
this.on('cursormove', function () { return _this.renderer.onCursorMove(); });
this.on('resize', function () { return _this.renderer.onResize(_this.cols, _this.rows, false); });
this.on('resize', function () { return _this.renderer.onResize(_this.cols, _this.rows); });
this.on('blur', function () { return _this.renderer.onBlur(); });

@@ -451,3 +443,3 @@ this.on('focus', function () { return _this.renderer.onFocus(); });

window.addEventListener('resize', function () { return _this.renderer.onWindowResize(window.devicePixelRatio); });
this.charMeasure.on('charsizechanged', function () { return _this.renderer.onResize(_this.cols, _this.rows, true); });
this.charMeasure.on('charsizechanged', function () { return _this.renderer.onResize(_this.cols, _this.rows); });
this.renderer.on('resize', function (dimensions) { return _this.viewport.syncScrollArea(); });

@@ -466,3 +458,3 @@ this.selectionManager = new SelectionManager_1.SelectionManager(this, this.charMeasure);

});
this.viewportElement.addEventListener('scroll', function () { return _this.selectionManager.refresh(); });
this._viewportElement.addEventListener('scroll', function () { return _this.selectionManager.refresh(); });
this.mouseHelper = new MouseHelper_1.MouseHelper(this.renderer);

@@ -474,3 +466,3 @@ if (this.options.screenReaderMode) {

this.refresh(0, this.rows - 1);
this.initGlobal();
this._initGlobal();
this.bindMouse();

@@ -546,3 +538,3 @@ };

function sendEvent(button, pos) {
if (self.vt300Mouse) {
if (self._vt300Mouse) {
button &= 3;

@@ -566,3 +558,3 @@ pos.x -= 32;

}
if (self.decLocator) {
if (self._decLocator) {
button &= 3;

@@ -675,3 +667,3 @@ pos.x -= 32;

if (_this.normalMouse)
on(_this.document, 'mousemove', sendMove);
on(_this._document, 'mousemove', sendMove);
if (!_this.x10Mouse) {

@@ -681,7 +673,7 @@ var handler_1 = function (ev) {

if (_this.normalMouse)
off(_this.document, 'mousemove', sendMove);
off(_this.document, 'mouseup', handler_1);
off(_this._document, 'mousemove', sendMove);
off(_this._document, 'mouseup', handler_1);
return _this.cancel(ev);
};
on(_this.document, 'mouseup', handler_1);
on(_this._document, 'mouseup', handler_1);
}

@@ -691,5 +683,18 @@ return _this.cancel(ev);

on(el, 'wheel', function (ev) {
if (!_this.mouseEvents)
if (!_this.mouseEvents) {
if (!_this.buffer.hasScrollback) {
var amount = _this.viewport.getLinesScrolled(ev);
if (amount === 0) {
return;
}
var sequence = EscapeSequences_1.C0.ESC + (_this.applicationCursor ? 'O' : '[') + (ev.deltaY < 0 ? 'A' : 'B');
var data = '';
for (var i = 0; i < Math.abs(amount); i++) {
data += sequence;
}
_this.send(data);
}
return;
if (_this.x10Mouse || _this.vt300Mouse || _this.decLocator)
}
if (_this.x10Mouse || _this._vt300Mouse || _this._decLocator)
return;

@@ -720,4 +725,2 @@ sendButton(ev);

_super.prototype.destroy.call(this);
this.readable = false;
this.writable = false;
this.handler = function () { };

@@ -734,3 +737,3 @@ this.write = function () { };

};
Terminal.prototype.queueLinkification = function (start, end) {
Terminal.prototype._queueLinkification = function (start, end) {
if (this.linkifier) {

@@ -760,3 +763,3 @@ this.linkifier.linkifyRows(start, end);

this.buffer.ybase++;
if (!this.userScrolling) {
if (!this._userScrolling) {
this.buffer.ydisp++;

@@ -766,3 +769,3 @@ }

else {
if (this.userScrolling) {
if (this._userScrolling) {
this.buffer.ydisp = Math.max(this.buffer.ydisp - 1, 0);

@@ -777,3 +780,3 @@ }

}
if (!this.userScrolling) {
if (!this._userScrolling) {
this.buffer.ydisp = this.buffer.ybase;

@@ -790,6 +793,6 @@ }

}
this.userScrolling = true;
this._userScrolling = true;
}
else if (disp + this.buffer.ydisp >= this.buffer.ybase) {
this.userScrolling = false;
this._userScrolling = false;
}

@@ -815,17 +818,26 @@ var oldYdisp = this.buffer.ydisp;

};
Terminal.prototype.scrollToLine = function (line) {
var scrollAmount = line - this.buffer.ydisp;
if (scrollAmount !== 0) {
this.scrollLines(scrollAmount);
}
};
Terminal.prototype.write = function (data) {
var _this = this;
if (!data) {
return;
}
this.writeBuffer.push(data);
if (this.options.useFlowControl && !this.xoffSentToCatchUp && this.writeBuffer.length >= WRITE_BUFFER_PAUSE_THRESHOLD) {
if (this.options.useFlowControl && !this._xoffSentToCatchUp && this.writeBuffer.length >= WRITE_BUFFER_PAUSE_THRESHOLD) {
this.send(EscapeSequences_1.C0.DC3);
this.xoffSentToCatchUp = true;
this._xoffSentToCatchUp = true;
}
if (!this.writeInProgress && this.writeBuffer.length > 0) {
this.writeInProgress = true;
if (!this._writeInProgress && this.writeBuffer.length > 0) {
this._writeInProgress = true;
setTimeout(function () {
_this.innerWrite();
_this._innerWrite();
});
}
};
Terminal.prototype.innerWrite = function () {
Terminal.prototype._innerWrite = function () {
var _this = this;

@@ -835,18 +847,18 @@ var writeBatch = this.writeBuffer.splice(0, WRITE_BATCH_SIZE);

var data = writeBatch.shift();
if (this.xoffSentToCatchUp && writeBatch.length === 0 && this.writeBuffer.length === 0) {
if (this._xoffSentToCatchUp && writeBatch.length === 0 && this.writeBuffer.length === 0) {
this.send(EscapeSequences_1.C0.DC1);
this.xoffSentToCatchUp = false;
this._xoffSentToCatchUp = false;
}
this.refreshStart = this.buffer.y;
this.refreshEnd = this.buffer.y;
var state = this.parser.parse(data);
this.parser.setState(state);
this._refreshStart = this.buffer.y;
this._refreshEnd = this.buffer.y;
var state = this._parser.parse(data);
this._parser.setState(state);
this.updateRange(this.buffer.y);
this.refresh(this.refreshStart, this.refreshEnd);
this.refresh(this._refreshStart, this._refreshEnd);
}
if (this.writeBuffer.length > 0) {
setTimeout(function () { return _this.innerWrite(); }, 0);
setTimeout(function () { return _this._innerWrite(); }, 0);
}
else {
this.writeInProgress = false;
this._writeInProgress = false;
}

@@ -858,3 +870,3 @@ };

Terminal.prototype.attachCustomKeyEventHandler = function (customKeyEventHandler) {
this.customKeyEventHandler = customKeyEventHandler;
this._customKeyEventHandler = customKeyEventHandler;
};

@@ -871,2 +883,15 @@ Terminal.prototype.registerLinkMatcher = function (regex, handler, options) {

};
Object.defineProperty(Terminal.prototype, "markers", {
get: function () {
return this.buffer.markers;
},
enumerable: true,
configurable: true
});
Terminal.prototype.addMarker = function (cursorYOffset) {
if (this.buffer !== this.buffers.normal) {
return;
}
return this.buffer.addMarker(this.buffer.ybase + this.buffer.y + cursorYOffset);
};
Terminal.prototype.hasSelection = function () {

@@ -888,7 +913,12 @@ return this.selectionManager ? this.selectionManager.hasSelection : false;

};
Terminal.prototype.selectLines = function (start, end) {
if (this.selectionManager) {
this.selectionManager.selectLines(start, end);
}
};
Terminal.prototype._keyDown = function (ev) {
if (this.customKeyEventHandler && this.customKeyEventHandler(ev) === false) {
if (this._customKeyEventHandler && this._customKeyEventHandler(ev) === false) {
return false;
}
if (!this.compositionHelper.keydown(ev)) {
if (!this._compositionHelper.keydown(ev)) {
if (this.buffer.ybase !== this.buffer.ydisp) {

@@ -900,8 +930,2 @@ this.scrollToBottom();

var result = this._evaluateKeyEscapeSequence(ev);
if (result.key === EscapeSequences_1.C0.DC3) {
this.writeStopped = true;
}
else if (result.key === EscapeSequences_1.C0.DC1) {
this.writeStopped = false;
}
if (result.scrollLines) {

@@ -1262,3 +1286,3 @@ this.scrollLines(result.scrollLines);

var key;
if (this.customKeyEventHandler && this.customKeyEventHandler(ev) === false) {
if (this._customKeyEventHandler && this._customKeyEventHandler(ev) === false) {
return false;

@@ -1291,9 +1315,9 @@ }

var _this = this;
if (!this.sendDataQueue) {
if (!this._sendDataQueue) {
setTimeout(function () {
_this.handler(_this.sendDataQueue);
_this.sendDataQueue = '';
_this.handler(_this._sendDataQueue);
_this._sendDataQueue = '';
}, 1);
}
this.sendDataQueue += data;
this._sendDataQueue += data;
};

@@ -1303,9 +1327,9 @@ Terminal.prototype.bell = function () {

this.emit('bell');
if (this.soundBell()) {
if (this._soundBell()) {
this.soundManager.playBellSound();
}
if (this.visualBell()) {
if (this._visualBell()) {
this.element.classList.add('visual-bell-active');
clearTimeout(this.visualBellTimer);
this.visualBellTimer = window.setTimeout(function () {
clearTimeout(this._visualBellTimer);
this._visualBellTimer = window.setTimeout(function () {
_this.element.classList.remove('visual-bell-active');

@@ -1318,5 +1342,5 @@ }, 200);

return;
if (!this.context.console || !this.context.console.log)
if (!this._context.console || !this._context.console.log)
return;
this.context.console.log(text, data);
this._context.console.log(text, data);
};

@@ -1326,5 +1350,5 @@ Terminal.prototype.error = function (text, data) {

return;
if (!this.context.console || !this.context.console.error)
if (!this._context.console || !this._context.console.error)
return;
this.context.console.error(text, data);
this._context.console.error(text, data);
};

@@ -1356,10 +1380,10 @@ Terminal.prototype.resize = function (x, y) {

Terminal.prototype.updateRange = function (y) {
if (y < this.refreshStart)
this.refreshStart = y;
if (y > this.refreshEnd)
this.refreshEnd = y;
if (y < this._refreshStart)
this._refreshStart = y;
if (y > this._refreshEnd)
this._refreshEnd = y;
};
Terminal.prototype.maxRange = function () {
this.refreshStart = 0;
this.refreshEnd = this.rows - 1;
this._refreshStart = 0;
this._refreshEnd = this.rows - 1;
};

@@ -1469,9 +1493,11 @@ Terminal.prototype.eraseRight = function (x, y) {

this.options.cols = this.cols;
var customKeyEventHandler = this.customKeyEventHandler;
var inputHandler = this.inputHandler;
this.setup();
this.customKeyEventHandler = customKeyEventHandler;
this.inputHandler = inputHandler;
var customKeyEventHandler = this._customKeyEventHandler;
var inputHandler = this._inputHandler;
this._setup();
this._customKeyEventHandler = customKeyEventHandler;
this._inputHandler = inputHandler;
this.refresh(0, this.rows - 1);
this.viewport.syncScrollArea();
if (this.viewport) {
this.viewport.syncScrollArea();
}
};

@@ -1492,6 +1518,6 @@ Terminal.prototype.tabSet = function () {

};
Terminal.prototype.visualBell = function () {
Terminal.prototype._visualBell = function () {
return false;
};
Terminal.prototype.soundBell = function () {
Terminal.prototype._soundBell = function () {
return this.options.bellStyle === 'sound';

@@ -1520,26 +1546,2 @@ };

}
var vcolors = (function () {
var result = ColorManager_1.DEFAULT_ANSI_COLORS.map(function (c) {
c = c.substring(1);
return [
parseInt(c.substring(0, 2), 16),
parseInt(c.substring(2, 4), 16),
parseInt(c.substring(4, 6), 16)
];
});
var r = [0x00, 0x5f, 0x87, 0xaf, 0xd7, 0xff];
for (var i = 0; i < 216; i++) {
result.push([
r[(i / 36) % 6 | 0],
r[(i / 6) % 6 | 0],
r[i % 6]
]);
}
var c;
for (var i = 0; i < 24; i++) {
c = 8 + i * 10;
result.push([c, c, c]);
}
return result;
})();
var matchColorCache = {};

@@ -1564,7 +1566,7 @@ function matchColorDistance(r1, g1, b1, r2, g2, b2) {

var diff;
for (; i < vcolors.length; i++) {
c = vcolors[i];
r2 = c[0];
g2 = c[1];
b2 = c[2];
for (; i < ColorManager_1.DEFAULT_ANSI_COLORS.length; i++) {
c = ColorManager_1.DEFAULT_ANSI_COLORS[i].rgba;
r2 = c >>> 24;
g2 = c >>> 16 & 0xFF;
b2 = c >>> 8 & 0xFF;
diff = matchColorDistance(r1, g1, b1, r2, g2, b2);

@@ -1571,0 +1573,0 @@ if (diff === 0) {

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

_this._measureElement = _this._document.createElement('span');
_this._measureElement.style.position = 'absolute';
_this._measureElement.style.top = '0';
_this._measureElement.style.left = '-9999em';
_this._measureElement.style.lineHeight = 'normal';
_this._measureElement.classList.add('xterm-char-measure-element');
_this._measureElement.textContent = 'W';

@@ -27,0 +24,0 @@ _this._measureElement.setAttribute('aria-hidden', 'true');

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

});
Object.defineProperty(CircularList.prototype, "forEach", {
get: function () {
var _this = this;
return function (callbackfn) {
var i = 0;
var length = _this.length;
for (var i_1 = 0; i_1 < length; i_1++) {
callbackfn(_this.get(i_1), i_1);
}
};
},
enumerable: true,
configurable: true
});
CircularList.prototype.get = function (index) {

@@ -74,0 +60,0 @@ return this._array[this._getCyclicIndex(index)];

"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var chai_1 = require("chai");
var CircularList_1 = require("./CircularList");
var TestCircularList = (function (_super) {
__extends(TestCircularList, _super);
function TestCircularList() {
return _super !== null && _super.apply(this, arguments) || this;
}
Object.defineProperty(TestCircularList.prototype, "array", {
get: function () { return this._array; },
enumerable: true,
configurable: true
});
return TestCircularList;
}(CircularList_1.CircularList));
describe('CircularList', function () {

@@ -28,0 +6,0 @@ describe('push', function () {

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

}
MockTerminal.prototype.addMarker = function (cursorYOffset) {
throw new Error('Method not implemented.');
};
MockTerminal.prototype.selectLines = function (start, end) {
throw new Error('Method not implemented.');
};
MockTerminal.prototype.scrollToLine = function (line) {
throw new Error('Method not implemented.');
};
MockTerminal.prototype.getOption = function (key) {

@@ -216,2 +225,5 @@ throw new Error('Method not implemented.');

};
MockInputHandlingTerminal.prototype.tabSet = function () {
throw new Error('Method not implemented.');
};
return MockInputHandlingTerminal;

@@ -251,3 +263,3 @@ }());

MockRenderer.prototype.setTheme = function (theme) { return {}; };
MockRenderer.prototype.onResize = function (cols, rows, didCharSizeChange) { };
MockRenderer.prototype.onResize = function (cols, rows) { };
MockRenderer.prototype.onCharSizeChanged = function () { };

@@ -282,2 +294,5 @@ MockRenderer.prototype.onBlur = function () { };

MockViewport.prototype.syncScrollArea = function () { };
MockViewport.prototype.getLinesScrolled = function (ev) {
throw new Error('Method not implemented.');
};
return MockViewport;

@@ -284,0 +299,0 @@ }());

@@ -5,28 +5,29 @@ "use strict";

var Viewport = (function () {
function Viewport(terminal, viewportElement, scrollArea, charMeasure) {
function Viewport(_terminal, _viewportElement, _scrollArea, _charMeasure) {
var _this = this;
this.terminal = terminal;
this.viewportElement = viewportElement;
this.scrollArea = scrollArea;
this.charMeasure = charMeasure;
this._terminal = _terminal;
this._viewportElement = _viewportElement;
this._scrollArea = _scrollArea;
this._charMeasure = _charMeasure;
this.scrollBarWidth = 0;
this.currentRowHeight = 0;
this.lastRecordedBufferLength = 0;
this.lastRecordedViewportHeight = 0;
this.lastRecordedBufferHeight = 0;
this.scrollBarWidth = (this.viewportElement.offsetWidth - this.scrollArea.offsetWidth) || FALLBACK_SCROLL_BAR_WIDTH;
this.viewportElement.addEventListener('scroll', this.onScroll.bind(this));
this._currentRowHeight = 0;
this._lastRecordedBufferLength = 0;
this._lastRecordedViewportHeight = 0;
this._lastRecordedBufferHeight = 0;
this._wheelPartialScroll = 0;
this.scrollBarWidth = (this._viewportElement.offsetWidth - this._scrollArea.offsetWidth) || FALLBACK_SCROLL_BAR_WIDTH;
this._viewportElement.addEventListener('scroll', this._onScroll.bind(this));
setTimeout(function () { return _this.syncScrollArea(); }, 0);
}
Viewport.prototype.onThemeChanged = function (colors) {
this.viewportElement.style.backgroundColor = colors.background;
this._viewportElement.style.backgroundColor = colors.background.css;
};
Viewport.prototype.refresh = function () {
if (this.charMeasure.height > 0) {
this.currentRowHeight = this.terminal.renderer.dimensions.scaledCellHeight / window.devicePixelRatio;
this.lastRecordedViewportHeight = this.viewportElement.offsetHeight;
var newBufferHeight = Math.round(this.currentRowHeight * this.lastRecordedBufferLength) + (this.lastRecordedViewportHeight - this.terminal.renderer.dimensions.canvasHeight);
if (this.lastRecordedBufferHeight !== newBufferHeight) {
this.lastRecordedBufferHeight = newBufferHeight;
this.scrollArea.style.height = this.lastRecordedBufferHeight + 'px';
Viewport.prototype._refresh = function () {
if (this._charMeasure.height > 0) {
this._currentRowHeight = this._terminal.renderer.dimensions.scaledCellHeight / window.devicePixelRatio;
this._lastRecordedViewportHeight = this._viewportElement.offsetHeight;
var newBufferHeight = Math.round(this._currentRowHeight * this._lastRecordedBufferLength) + (this._lastRecordedViewportHeight - this._terminal.renderer.dimensions.canvasHeight);
if (this._lastRecordedBufferHeight !== newBufferHeight) {
this._lastRecordedBufferHeight = newBufferHeight;
this._scrollArea.style.height = this._lastRecordedBufferHeight + 'px';
}

@@ -36,51 +37,74 @@ }

Viewport.prototype.syncScrollArea = function () {
if (this.lastRecordedBufferLength !== this.terminal.buffer.lines.length) {
this.lastRecordedBufferLength = this.terminal.buffer.lines.length;
this.refresh();
if (this._lastRecordedBufferLength !== this._terminal.buffer.lines.length) {
this._lastRecordedBufferLength = this._terminal.buffer.lines.length;
this._refresh();
}
else if (this.lastRecordedViewportHeight !== this.terminal.renderer.dimensions.canvasHeight) {
this.refresh();
else if (this._lastRecordedViewportHeight !== this._terminal.renderer.dimensions.canvasHeight) {
this._refresh();
}
else {
if (this.terminal.renderer.dimensions.scaledCellHeight / window.devicePixelRatio !== this.currentRowHeight) {
this.refresh();
if (this._terminal.renderer.dimensions.scaledCellHeight / window.devicePixelRatio !== this._currentRowHeight) {
this._refresh();
}
}
var scrollTop = this.terminal.buffer.ydisp * this.currentRowHeight;
if (this.viewportElement.scrollTop !== scrollTop) {
this.viewportElement.scrollTop = scrollTop;
var scrollTop = this._terminal.buffer.ydisp * this._currentRowHeight;
if (this._viewportElement.scrollTop !== scrollTop) {
this._viewportElement.scrollTop = scrollTop;
}
};
Viewport.prototype.onScroll = function (ev) {
if (!this.viewportElement.offsetParent) {
Viewport.prototype._onScroll = function (ev) {
if (!this._viewportElement.offsetParent) {
return;
}
var newRow = Math.round(this.viewportElement.scrollTop / this.currentRowHeight);
var diff = newRow - this.terminal.buffer.ydisp;
this.terminal.scrollLines(diff, true);
var newRow = Math.round(this._viewportElement.scrollTop / this._currentRowHeight);
var diff = newRow - this._terminal.buffer.ydisp;
this._terminal.scrollLines(diff, true);
};
Viewport.prototype.onWheel = function (ev) {
if (ev.deltaY === 0) {
var amount = this._getPixelsScrolled(ev);
if (amount === 0) {
return;
}
var multiplier = 1;
this._viewportElement.scrollTop += amount;
ev.preventDefault();
};
Viewport.prototype._getPixelsScrolled = function (ev) {
if (ev.deltaY === 0) {
return 0;
}
var amount = ev.deltaY;
if (ev.deltaMode === WheelEvent.DOM_DELTA_LINE) {
multiplier = this.currentRowHeight;
amount *= this._currentRowHeight;
}
else if (ev.deltaMode === WheelEvent.DOM_DELTA_PAGE) {
multiplier = this.currentRowHeight * this.terminal.rows;
amount *= this._currentRowHeight * this._terminal.rows;
}
this.viewportElement.scrollTop += ev.deltaY * multiplier;
ev.preventDefault();
return amount;
};
Viewport.prototype.getLinesScrolled = function (ev) {
if (ev.deltaY === 0) {
return 0;
}
var amount = ev.deltaY;
if (ev.deltaMode === WheelEvent.DOM_DELTA_PIXEL) {
amount /= this._currentRowHeight + 0.0;
this._wheelPartialScroll += amount;
amount = Math.floor(Math.abs(this._wheelPartialScroll)) * (this._wheelPartialScroll > 0 ? 1 : -1);
this._wheelPartialScroll %= 1;
}
else if (ev.deltaMode === WheelEvent.DOM_DELTA_PAGE) {
amount *= this._terminal.rows;
}
return amount;
};
Viewport.prototype.onTouchStart = function (ev) {
this.lastTouchY = ev.touches[0].pageY;
this._lastTouchY = ev.touches[0].pageY;
};
Viewport.prototype.onTouchMove = function (ev) {
var deltaY = this.lastTouchY - ev.touches[0].pageY;
this.lastTouchY = ev.touches[0].pageY;
var deltaY = this._lastTouchY - ev.touches[0].pageY;
this._lastTouchY = ev.touches[0].pageY;
if (deltaY === 0) {
return;
}
this.viewportElement.scrollTop += deltaY;
this._viewportElement.scrollTop += deltaY;
ev.preventDefault();

@@ -87,0 +111,0 @@ };

{
"name": "xterm",
"description": "Full xterm terminal, in your browser",
"version": "3.2.0",
"version": "3.3.0",
"ignore": [

@@ -6,0 +6,0 @@ "demo",

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

- [**FreeMAN**](https://github.com/matthew-matvei/freeman): A free, cross-platform file manager for power users
- [**Fluent Terminal**](https://github.com/felixse/FluentTerminal): A terminal emulator based on UWP and web technologies.

@@ -132,0 +133,0 @@ Do you use xterm.js in your application as well? Please [open a Pull Request](https://github.com/sourcelair/xterm.js/pulls) to include it here. We would love to have it in our list.

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

const MAX_ROWS_TO_READ = 20;
const ACTIVE_ITEM_ID_PREFIX = 'xterm-active-item-';

@@ -25,3 +24,3 @@ enum BoundaryPosition {

private _rowContainer: HTMLElement;
private _rowElements: HTMLElement[] = [];
private _rowElements: HTMLElement[];
private _liveRegion: HTMLElement;

@@ -54,2 +53,3 @@ private _liveRegionLineCount: number = 0;

this._rowContainer.classList.add('xterm-accessibility-tree');
this._rowElements = [];
for (let i = 0; i < this._terminal.rows; i++) {

@@ -99,10 +99,6 @@ this._rowElements[i] = this._createAccessibilityTreeNode();

public dispose(): void {
this._disposables.forEach(d => d.dispose());
this._disposables.length = 0;
this._terminal.element.removeChild(this._accessibilityTreeRoot);
this._disposables.forEach(d => d.dispose());
this._disposables = null;
this._accessibilityTreeRoot = null;
this._rowContainer = null;
this._liveRegion = null;
this._rowContainer = null;
this._rowElements = null;
this._rowElements.length = 0;
}

@@ -132,6 +128,6 @@

topBoundaryElement = boundaryElement;
bottomBoundaryElement = this._rowElements.pop();
bottomBoundaryElement = this._rowElements.pop()!;
this._rowContainer.removeChild(bottomBoundaryElement);
} else {
topBoundaryElement = this._rowElements.shift();
topBoundaryElement = this._rowElements.shift()!;
bottomBoundaryElement = boundaryElement;

@@ -182,3 +178,3 @@ this._rowContainer.removeChild(topBoundaryElement);

while (this._rowElements.length > rows) {
this._rowContainer.removeChild(this._rowElements.pop());
this._rowContainer.removeChild(this._rowElements.pop()!);
}

@@ -227,3 +223,3 @@

if (isMac) {
if (this._liveRegion.textContent.length > 0 && !this._liveRegion.parentNode) {
if (this._liveRegion.textContent && this._liveRegion.textContent.length > 0 && !this._liveRegion.parentNode) {
setTimeout(() => {

@@ -275,3 +271,2 @@ this._accessibilityTreeRoot.appendChild(this._liveRegion);

}
const buffer: IBuffer = this._terminal.buffer;
for (let i = 0; i < this._terminal.rows; i++) {

@@ -278,0 +273,0 @@ this._refreshRowDimensions(this._rowElements[i]);

@@ -45,20 +45,40 @@ /**

let str;
if (typeof ev.data === 'object') {
if (typeof ev.data == 'object') {
if (!myTextDecoder) {
myTextDecoder = new TextDecoder();
}
if (ev.data instanceof ArrayBuffer) {
if (!myTextDecoder) {
myTextDecoder = new TextDecoder();
}
str = myTextDecoder.decode(ev.data);
displayData(str);
} else {
let fileReader = new FileReader();
str = myTextDecoder.decode( ev.data );
} else {
throw 'TODO: handle Blob?';
fileReader.addEventListener('load', function() {
str = myTextDecoder.decode(this.result);
displayData(str);
});
fileReader.readAsArrayBuffer(ev.data);
}
} else if (typeof ev.data == 'string') {
displayData(ev.data)
} else {
throw Error(`Cannot handle "${typeof ev.data}" websocket message.`);
}
};
/**
* Push data to buffer or write it in the terminal.
* This is used as a callback for FileReader.onload.
*
* @param str String decoded by FileReader.
* @param data The data of the EventMessage.
*/
function displayData(str?: string, data?: string) {
if (buffered) {
addonTerminal.__pushToBuffer(str || ev.data);
addonTerminal.__pushToBuffer(str || data);
} else {
addonTerminal.write(str || ev.data);
addonTerminal.write(str || data);
}
};
}

@@ -65,0 +85,0 @@ addonTerminal.__sendData = (data: string) => {

@@ -191,2 +191,26 @@ /**

});
describe('addMarker', () => {
it('should adjust a marker line when the buffer is trimmed', () => {
terminal.options.scrollback = 0;
buffer = new Buffer(terminal, true);
buffer.fillViewportRows();
const marker = buffer.addMarker(buffer.lines.length - 1);
assert.equal(marker.line, buffer.lines.length - 1);
buffer.lines.emit('trim', 1);
assert.equal(marker.line, buffer.lines.length - 2);
});
it('should dispose of a marker if it is trimmed off the buffer', () => {
terminal.options.scrollback = 0;
buffer = new Buffer(terminal, true);
buffer.fillViewportRows();
assert.equal(buffer.markers.length, 0);
const marker = buffer.addMarker(0);
assert.equal(marker.isDisposed, false);
assert.equal(buffer.markers.length, 1);
buffer.lines.emit('trim', 1);
assert.equal(marker.isDisposed, true);
assert.equal(buffer.markers.length, 0);
});
});
});

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

import { LineData, CharData, ITerminal, IBuffer } from './Types';
import { EventEmitter } from './EventEmitter';
import { IDisposable, IMarker } from 'xterm';

@@ -35,2 +37,3 @@ export const CHAR_DATA_ATTR_INDEX = 0;

public savedX: number;
public markers: Marker[] = [];

@@ -308,2 +311,47 @@ /**

}
public addMarker(y: number): Marker {
const marker = new Marker(y);
this.markers.push(marker);
marker.disposables.push(this._lines.addDisposableListener('trim', amount => {
marker.line -= amount;
// The marker should be disposed when the line is trimmed from the buffer
if (marker.line < 0) {
marker.dispose();
}
}));
marker.on('dispose', () => this._removeMarker(marker));
return marker;
}
private _removeMarker(marker: Marker): void {
// TODO: This could probably be optimized by relying on sort order and trimming the array using .length
this.markers.splice(this.markers.indexOf(marker), 1);
}
}
export class Marker extends EventEmitter implements IMarker {
private static NEXT_ID = 1;
private _id: number = Marker.NEXT_ID++;
public isDisposed: boolean = false;
public disposables: IDisposable[] = [];
public get id(): number { return this._id; }
constructor(
public line: number
) {
super();
}
public dispose(): void {
if (this.isDisposed) {
return;
}
this.isDisposed = true;
this.disposables.forEach(d => d.dispose());
this.disposables.length = 0;
this.emit('dispose');
}
}

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

[0xA825, 0xA826], [0xFB1E, 0xFB1E], [0xFE00, 0xFE0F],
[0xFE20, 0xFE23], [0xFEFF, 0xFEFF], [0xFFF9, 0xFFFB],
[0xFE20, 0xFE23], [0xFEFF, 0xFEFF], [0xFFF9, 0xFFFB]
];

@@ -55,0 +55,0 @@ const COMBINING_HIGH = [

@@ -20,3 +20,3 @@ /**

add: () => {},
remove: () => {},
remove: () => {}
},

@@ -23,0 +23,0 @@ getBoundingClientRect: () => {

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

*/
private isComposing: boolean;
private _isComposing: boolean;

@@ -29,3 +29,3 @@ /**

*/
private compositionPosition: IPosition;
private _compositionPosition: IPosition;

@@ -36,18 +36,18 @@ /**

*/
private isSendingComposition: boolean;
private _isSendingComposition: boolean;
/**
* Creates a new CompositionHelper.
* @param textarea The textarea that xterm uses for input.
* @param compositionView The element to display the in-progress composition in.
* @param terminal The Terminal to forward the finished composition to.
* @param _textarea The textarea that xterm uses for input.
* @param _compositionView The element to display the in-progress composition in.
* @param _terminal The Terminal to forward the finished composition to.
*/
constructor(
private textarea: HTMLTextAreaElement,
private compositionView: HTMLElement,
private terminal: ITerminal
private _textarea: HTMLTextAreaElement,
private _compositionView: HTMLElement,
private _terminal: ITerminal
) {
this.isComposing = false;
this.isSendingComposition = false;
this.compositionPosition = { start: null, end: null };
this._isComposing = false;
this._isSendingComposition = false;
this._compositionPosition = { start: null, end: null };
}

@@ -59,6 +59,6 @@

public compositionstart(): void {
this.isComposing = true;
this.compositionPosition.start = this.textarea.value.length;
this.compositionView.textContent = '';
this.compositionView.classList.add('active');
this._isComposing = true;
this._compositionPosition.start = this._textarea.value.length;
this._compositionView.textContent = '';
this._compositionView.classList.add('active');
}

@@ -71,6 +71,6 @@

public compositionupdate(ev: CompositionEvent): void {
this.compositionView.textContent = ev.data;
this._compositionView.textContent = ev.data;
this.updateCompositionElements();
setTimeout(() => {
this.compositionPosition.end = this.textarea.value.length;
this._compositionPosition.end = this._textarea.value.length;
}, 0);

@@ -84,3 +84,3 @@ }

public compositionend(): void {
this.finalizeComposition(true);
this._finalizeComposition(true);
}

@@ -94,3 +94,3 @@

public keydown(ev: KeyboardEvent): boolean {
if (this.isComposing || this.isSendingComposition) {
if (this._isComposing || this._isSendingComposition) {
if (ev.keyCode === 229) {

@@ -105,3 +105,3 @@ // Continue composing if the keyCode is the "composition character"

// pressed and the handler needs to be triggered before the command is executed.
this.finalizeComposition(false);
this._finalizeComposition(false);
}

@@ -113,3 +113,3 @@ }

// character (eg. numbers and punctuation) was pressed when the IME was active.
this.handleAnyTextareaChanges();
this._handleAnyTextareaChanges();
return false;

@@ -129,12 +129,12 @@ }

*/
private finalizeComposition(waitForPropogation: boolean): void {
this.compositionView.classList.remove('active');
this.isComposing = false;
this.clearTextareaPosition();
private _finalizeComposition(waitForPropogation: boolean): void {
this._compositionView.classList.remove('active');
this._isComposing = false;
this._clearTextareaPosition();
if (!waitForPropogation) {
// Cancel any delayed composition send requests and send the input immediately.
this.isSendingComposition = false;
const input = this.textarea.value.substring(this.compositionPosition.start, this.compositionPosition.end);
this.terminal.handler(input);
this._isSendingComposition = false;
const input = this._textarea.value.substring(this._compositionPosition.start, this._compositionPosition.end);
this._terminal.handler(input);
} else {

@@ -144,4 +144,4 @@ // Make a deep copy of the composition position here as a new compositionstart event may

const currentCompositionPosition = {
start: this.compositionPosition.start,
end: this.compositionPosition.end,
start: this._compositionPosition.start,
end: this._compositionPosition.end
};

@@ -157,11 +157,11 @@

// the following character if the following input is a vowel.
this.isSendingComposition = true;
this._isSendingComposition = true;
setTimeout(() => {
// Ensure that the input has not already been sent
if (this.isSendingComposition) {
this.isSendingComposition = false;
if (this._isSendingComposition) {
this._isSendingComposition = false;
let input;
if (this.isComposing) {
if (this._isComposing) {
// Use the end position to get the string if a new composition has started.
input = this.textarea.value.substring(currentCompositionPosition.start, currentCompositionPosition.end);
input = this._textarea.value.substring(currentCompositionPosition.start, currentCompositionPosition.end);
} else {

@@ -171,5 +171,5 @@ // Don't use the end position here in order to pick up any characters after the

// (eg. 2) after a composition character.
input = this.textarea.value.substring(currentCompositionPosition.start);
input = this._textarea.value.substring(currentCompositionPosition.start);
}
this.terminal.handler(input);
this._terminal.handler(input);
}

@@ -186,11 +186,11 @@ }, 0);

*/
private handleAnyTextareaChanges(): void {
const oldValue = this.textarea.value;
private _handleAnyTextareaChanges(): void {
const oldValue = this._textarea.value;
setTimeout(() => {
// Ignore if a composition has started since the timeout
if (!this.isComposing) {
const newValue = this.textarea.value;
if (!this._isComposing) {
const newValue = this._textarea.value;
const diff = newValue.replace(oldValue, '');
if (diff.length > 0) {
this.terminal.handler(diff);
this._terminal.handler(diff);
}

@@ -208,23 +208,23 @@ }

public updateCompositionElements(dontRecurse?: boolean): void {
if (!this.isComposing) {
if (!this._isComposing) {
return;
}
if (this.terminal.buffer.isCursorInViewport) {
const cellHeight = Math.ceil(this.terminal.charMeasure.height * this.terminal.options.lineHeight);
const cursorTop = this.terminal.buffer.y * cellHeight;
const cursorLeft = this.terminal.buffer.x * this.terminal.charMeasure.width;
if (this._terminal.buffer.isCursorInViewport) {
const cellHeight = Math.ceil(this._terminal.charMeasure.height * this._terminal.options.lineHeight);
const cursorTop = this._terminal.buffer.y * cellHeight;
const cursorLeft = this._terminal.buffer.x * this._terminal.charMeasure.width;
this.compositionView.style.left = cursorLeft + 'px';
this.compositionView.style.top = cursorTop + 'px';
this.compositionView.style.height = cellHeight + 'px';
this.compositionView.style.lineHeight = cellHeight + 'px';
this._compositionView.style.left = cursorLeft + 'px';
this._compositionView.style.top = cursorTop + 'px';
this._compositionView.style.height = cellHeight + 'px';
this._compositionView.style.lineHeight = cellHeight + 'px';
// Sync the textarea to the exact position of the composition view so the IME knows where the
// text is.
const compositionViewBounds = this.compositionView.getBoundingClientRect();
this.textarea.style.left = cursorLeft + 'px';
this.textarea.style.top = cursorTop + 'px';
this.textarea.style.width = compositionViewBounds.width + 'px';
this.textarea.style.height = compositionViewBounds.height + 'px';
this.textarea.style.lineHeight = compositionViewBounds.height + 'px';
const compositionViewBounds = this._compositionView.getBoundingClientRect();
this._textarea.style.left = cursorLeft + 'px';
this._textarea.style.top = cursorTop + 'px';
this._textarea.style.width = compositionViewBounds.width + 'px';
this._textarea.style.height = compositionViewBounds.height + 'px';
this._textarea.style.lineHeight = compositionViewBounds.height + 'px';
}

@@ -241,6 +241,6 @@

*/
private clearTextareaPosition(): void {
this.textarea.style.left = '';
this.textarea.style.top = '';
private _clearTextareaPosition(): void {
this._textarea.style.left = '';
this._textarea.style.top = '';
}
}

@@ -74,5 +74,2 @@ /**

private _resetStartingRow(): string {
let startRow = this._endRow - this._wrappedRowsForRow(this._endRow);
let endRow = this._endRow;
if (this._moveToRequestedRow().length === 0) {

@@ -79,0 +76,0 @@ return '';

@@ -7,13 +7,18 @@ /**

import { assert } from 'chai';
import * as Terminal from '../Terminal';
import * as Clipboard from './Clipboard';
describe('evaluatePastedTextProcessing', () => {
it('should replace carriage return + line feed with line feed on windows', () => {
const pastedText = 'foo\r\nbar\r\n';
const processedText = Clipboard.prepareTextForTerminal(pastedText, false);
const windowsProcessedText = Clipboard.prepareTextForTerminal(pastedText, true);
it('should replace carriage return and/or line feed with carriage return', () => {
const pastedText = {
unix: 'foo\nbar\n',
windows: 'foo\r\nbar\r\n'
};
assert.equal(processedText, 'foo\r\nbar\r\n');
assert.equal(windowsProcessedText, 'foo\rbar\r');
const processedText = {
unix: Clipboard.prepareTextForTerminal(pastedText.unix),
windows: Clipboard.prepareTextForTerminal(pastedText.windows)
};
assert.equal(processedText.unix, 'foo\rbar\r');
assert.equal(processedText.windows, 'foo\rbar\r');
});

@@ -20,0 +25,0 @@ it('should bracket pasted text in bracketedPasteMode', () => {

@@ -21,7 +21,4 @@ /**

*/
export function prepareTextForTerminal(text: string, isMSWindows: boolean): string {
if (isMSWindows) {
return text.replace(/\r?\n/g, '\r');
}
return text;
export function prepareTextForTerminal(text: string): string {
return text.replace(/\r?\n/g, '\r');
}

@@ -66,3 +63,3 @@

let dispatchPaste = function(text: string): void {
text = prepareTextForTerminal(text, term.browser.isMSWindows);
text = prepareTextForTerminal(text);
text = bracketTextForPaste(text, term.bracketedPasteMode);

@@ -69,0 +66,0 @@ term.handler(text);

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

const zone = this._zones[i];
if (zone.y > start && zone.y <= end + 1) {
if ((zone.y1 > start && zone.y1 <= end + 1) ||
(zone.y2 > start && zone.y2 <= end + 1) ||
(zone.y1 < start && zone.y2 > end + 1)) {
if (this._currentZone && this._currentZone === zone) {

@@ -177,6 +179,18 @@ this._currentZone.leaveCallback();

}
const x = coords[0];
const y = coords[1];
for (let i = 0; i < this._zones.length; i++) {
const zone = this._zones[i];
if (zone.y === coords[1] && zone.x1 <= coords[0] && zone.x2 > coords[0]) {
return zone;
if (zone.y1 === zone.y2) {
// Single line link
if (y === zone.y1 && x >= zone.x1 && x < zone.x2) {
return zone;
}
} else {
// Multi-line link
if ((y === zone.y1 && x >= zone.x1) ||
(y === zone.y2 && x < zone.x2) ||
(y > zone.y1 && y < zone.y2)) {
return zone;
}
}

@@ -191,4 +205,5 @@ }

public x1: number,
public y1: number,
public x2: number,
public y: number,
public y2: number,
public clickCallback: (e: MouseEvent) => any,

@@ -195,0 +210,0 @@ public hoverCallback: (e: MouseEvent) => any,

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

x2: number;
y: number;
y1: number;
y2: number;
clickCallback: (e: MouseEvent) => any;

@@ -17,0 +18,0 @@ hoverCallback: (e: MouseEvent) => any | undefined;

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

import { CharData, IInputHandler, IInputHandlingTerminal, ITerminal } from './Types';
import { CharData, IInputHandler, IInputHandlingTerminal } from './Types';
import { C0 } from './EscapeSequences';

@@ -10,0 +10,0 @@ import { DEFAULT_CHARSET } from './Charsets';

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

import { IMouseZoneManager, IMouseZone } from './input/Types';
import { ILinkMatcher, LineData, ITerminal, ILinkifier, IBuffer, IBufferAccessor, IElementAccessor } from './Types';
import { ILinkMatcher, LineData, ITerminal } from './Types';
import { Linkifier } from './Linkifier';
import { MockBuffer } from './utils/TestUtils.test';
import { MockBuffer, MockTerminal } from './utils/TestUtils.test';
import { CircularList } from './utils/CircularList';
class TestLinkifier extends Linkifier {
constructor(_terminal: IBufferAccessor & IElementAccessor) {
constructor(_terminal: ITerminal) {
super(_terminal);

@@ -36,3 +36,3 @@ Linkifier.TIME_BEFORE_LINKIFY = 0;

describe('Linkifier', () => {
let terminal: IBufferAccessor & IElementAccessor;
let terminal: ITerminal;
let linkifier: TestLinkifier;

@@ -42,6 +42,5 @@ let mouseZoneManager: TestMouseZoneManager;

beforeEach(() => {
terminal = {
buffer: new MockBuffer(),
element: <HTMLElement>{}
};
terminal = new MockTerminal();
terminal.cols = 100;
terminal.buffer = new MockBuffer();
terminal.buffer.lines = new CircularList<LineData>(20);

@@ -65,9 +64,15 @@ terminal.buffer.ydisp = 0;

function assertLinkifiesEntireRow(uri: string, done: MochaDone): void {
addRow(uri);
function assertLinkifiesRow(rowText: string, linkMatcherRegex: RegExp, links: {x: number, length: number}[], done: MochaDone): void {
addRow(rowText);
linkifier.registerLinkMatcher(linkMatcherRegex, () => {});
linkifier.linkifyRows();
// Allow linkify to happen
setTimeout(() => {
assert.equal(mouseZoneManager.zones[0].x1, 1);
assert.equal(mouseZoneManager.zones[0].x2, uri.length + 1);
assert.equal(mouseZoneManager.zones[0].y, terminal.buffer.lines.length);
assert.equal(mouseZoneManager.zones.length, links.length);
links.forEach((l, i) => {
assert.equal(mouseZoneManager.zones[i].x1, l.x + 1);
assert.equal(mouseZoneManager.zones[i].x2, l.x + l.length + 1);
assert.equal(mouseZoneManager.zones[i].y1, terminal.buffer.lines.length);
assert.equal(mouseZoneManager.zones[i].y2, terminal.buffer.lines.length);
});
done();

@@ -77,3 +82,3 @@ }, 0);

function assertLinkifiesRow(rowText: string, linkMatcherRegex: RegExp, links: {x: number, length: number}[], done: MochaDone): void {
function assertLinkifiesMultiLineLink(rowText: string, linkMatcherRegex: RegExp, links: {x1: number, y1: number, x2: number, y2: number}[], done: MochaDone): void {
addRow(rowText);

@@ -86,5 +91,6 @@ linkifier.registerLinkMatcher(linkMatcherRegex, () => {});

links.forEach((l, i) => {
assert.equal(mouseZoneManager.zones[i].x1, l.x + 1);
assert.equal(mouseZoneManager.zones[i].x2, l.x + l.length + 1);
assert.equal(mouseZoneManager.zones[i].y, terminal.buffer.lines.length);
assert.equal(mouseZoneManager.zones[i].x1, l.x1 + 1);
assert.equal(mouseZoneManager.zones[i].x2, l.x2 + 1);
assert.equal(mouseZoneManager.zones[i].y1, l.y1 + 1);
assert.equal(mouseZoneManager.zones[i].y2, l.y2 + 1);
});

@@ -138,2 +144,20 @@ done();

});
describe('multi-line links', () => {
it('should match links that start on line 1/2 of a wrapped line and end on the last character of line 1/2', done => {
terminal.cols = 4;
assertLinkifiesMultiLineLink('12345', /1234/, [{x1: 0, x2: 4, y1: 0, y2: 0}], done);
});
it('should match links that start on line 1/2 of a wrapped line and wrap to line 2/2', done => {
terminal.cols = 4;
assertLinkifiesMultiLineLink('12345', /12345/, [{x1: 0, x2: 1, y1: 0, y2: 1}], done);
});
it('should match links that start and end on line 2/2 of a wrapped line', done => {
terminal.cols = 4;
assertLinkifiesMultiLineLink('12345678', /5678/, [{x1: 0, x2: 4, y1: 1, y2: 1}], done);
});
it('should match links that start on line 2/3 of a wrapped line and wrap to line 3/3', done => {
terminal.cols = 4;
assertLinkifiesMultiLineLink('123456789', /56789/, [{x1: 0, x2: 1, y1: 1, y2: 2}], done);
});
});
});

@@ -151,3 +175,4 @@

assert.equal(mouseZoneManager.zones[0].x2, 5);
assert.equal(mouseZoneManager.zones[0].y, 1);
assert.equal(mouseZoneManager.zones[0].y1, 1);
assert.equal(mouseZoneManager.zones[0].y2, 1);
// Fires done()

@@ -154,0 +179,0 @@ mouseZoneManager.zones[0].clickCallback(<any>{});

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

import { IMouseZoneManager } from './input/Types';
import { ILinkHoverEvent, ILinkMatcher, LinkMatcherHandler, LinkMatcherValidationCallback, LineData, LinkHoverEventTypes, ILinkMatcherOptions, ITerminal, IBufferAccessor, ILinkifier, IElementAccessor } from './Types';
import { ILinkHoverEvent, ILinkMatcher, LinkMatcherHandler, LinkHoverEventTypes, ILinkMatcherOptions, ILinkifier, ITerminal } from './Types';
import { MouseZone } from './input/MouseZoneManager';

@@ -31,3 +31,3 @@ import { EventEmitter } from './EventEmitter';

constructor(
protected _terminal: IBufferAccessor & IElementAccessor
protected _terminal: ITerminal
) {

@@ -162,7 +162,28 @@ super();

private _linkifyRow(rowIndex: number): void {
const absoluteRowIndex = this._terminal.buffer.ydisp + rowIndex;
// Ensure the row exists
let absoluteRowIndex = this._terminal.buffer.ydisp + rowIndex;
if (absoluteRowIndex >= this._terminal.buffer.lines.length) {
return;
}
const text = this._terminal.buffer.translateBufferLineToString(absoluteRowIndex, false);
if ((<any>this._terminal.buffer.lines.get(absoluteRowIndex)).isWrapped) {
// Only attempt to linkify rows that start in the viewport
if (rowIndex !== 0) {
return;
}
// If the first row is wrapped, backtrack to find the origin row and linkify that
do {
rowIndex--;
absoluteRowIndex--;
} while ((<any>this._terminal.buffer.lines.get(absoluteRowIndex)).isWrapped);
}
// Construct full unwrapped line text
let text = this._terminal.buffer.translateBufferLineToString(absoluteRowIndex, false);
let currentIndex = absoluteRowIndex + 1;
while (currentIndex < this._terminal.buffer.lines.length &&
(<any>this._terminal.buffer.lines.get(currentIndex)).isWrapped) {
text += this._terminal.buffer.translateBufferLineToString(currentIndex++, false);
}
for (let i = 0; i < this._linkMatchers.length; i++) {

@@ -183,5 +204,2 @@ this._doLinkifyRow(rowIndex, text, this._linkMatchers[i]);

private _doLinkifyRow(rowIndex: number, text: string, matcher: ILinkMatcher, offset: number = 0): void {
// Iterate over nodes as we want to consider text nodes
let result = [];
// Find the first match

@@ -228,6 +246,16 @@ let match = text.match(matcher.regex);

private _addLink(x: number, y: number, uri: string, matcher: ILinkMatcher): void {
const x1 = x % this._terminal.cols;
const y1 = y + Math.floor(x / this._terminal.cols);
let x2 = (x1 + uri.length) % this._terminal.cols;
let y2 = y1 + Math.floor((x1 + uri.length) / this._terminal.cols);
if (x2 === 0) {
x2 = this._terminal.cols;
y2--;
}
this._mouseZoneManager.add(new MouseZone(
x + 1,
x + 1 + uri.length,
y + 1,
x1 + 1,
y1 + 1,
x2 + 1,
y2 + 1,
e => {

@@ -240,7 +268,7 @@ if (matcher.handler) {

e => {
this.emit(LinkHoverEventTypes.HOVER, <ILinkHoverEvent>{ x, y, length: uri.length});
this._terminal.element.style.cursor = 'pointer';
this.emit(LinkHoverEventTypes.HOVER, this._createLinkHoverEvent(x1, y1, x2, y2));
this._terminal.element.classList.add('xterm-cursor-pointer');
},
e => {
this.emit(LinkHoverEventTypes.TOOLTIP, <ILinkHoverEvent>{ x, y, length: uri.length});
this.emit(LinkHoverEventTypes.TOOLTIP, this._createLinkHoverEvent(x1, y1, x2, y2));
if (matcher.hoverTooltipCallback) {

@@ -251,4 +279,4 @@ matcher.hoverTooltipCallback(e, uri);

() => {
this.emit(LinkHoverEventTypes.LEAVE, <ILinkHoverEvent>{ x, y, length: uri.length});
this._terminal.element.style.cursor = '';
this.emit(LinkHoverEventTypes.LEAVE, this._createLinkHoverEvent(x1, y1, x2, y2));
this._terminal.element.classList.remove('xterm-cursor-pointer');
if (matcher.hoverLeaveCallback) {

@@ -266,2 +294,6 @@ matcher.hoverLeaveCallback();

}
private _createLinkHoverEvent(x1: number, y1: number, x2: number, y2: number): ILinkHoverEvent {
return { x1, y1, x2, y2, cols: this._terminal.cols };
}
}

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

import { C0 } from './EscapeSequences';
import { IInputHandler } from './Types';
import { IInputHandler, IInputHandlingTerminal } from './Types';
import { CHARSETS, DEFAULT_CHARSET } from './Charsets';

@@ -189,3 +189,2 @@

const l = data.length;
let j;
let cs;

@@ -351,3 +350,3 @@ let ch;

case 'H':
this._terminal.tabSet();
(<IInputHandlingTerminal>this._terminal).tabSet();
this._state = ParserState.NORMAL;

@@ -354,0 +353,0 @@ break;

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

import { IRenderLayer, IColorSet, IRenderDimensions } from './Types';
import { CharData, ITerminal, ITerminalOptions } from '../Types';
import { acquireCharAtlas, CHAR_ATLAS_CELL_SPACING } from './CharAtlas';
import { CHAR_DATA_WIDTH_INDEX, CHAR_DATA_CHAR_INDEX } from '../Buffer';
import { CharData, ITerminal } from '../Types';
import { DIM_OPACITY, INVERTED_DEFAULT_COLOR } from './atlas/Types';
import { CHAR_ATLAS_CELL_SPACING } from '../shared/atlas/Types';
import { acquireCharAtlas } from './atlas/CharAtlas';
import { CHAR_DATA_CHAR_INDEX } from '../Buffer';
export const INVERTED_DEFAULT_COLOR = -1;
const DIM_OPACITY = 0.5;
export abstract class BaseRenderLayer implements IRenderLayer {

@@ -97,3 +96,3 @@ private _canvas: HTMLCanvasElement;

public resize(terminal: ITerminal, dim: IRenderDimensions, charSizeChanged: boolean): void {
public resize(terminal: ITerminal, dim: IRenderDimensions): void {
this._scaledCellWidth = dim.scaledCellWidth;

@@ -115,5 +114,3 @@ this._scaledCellHeight = dim.scaledCellHeight;

if (charSizeChanged) {
this._refreshCharAtlas(terminal, this._colors);
}
this._refreshCharAtlas(terminal, this._colors);
}

@@ -188,3 +185,3 @@

} else {
this._ctx.fillStyle = this._colors.background;
this._ctx.fillStyle = this._colors.background.css;
this._ctx.fillRect(0, 0, this._canvas.width, this._canvas.height);

@@ -209,3 +206,3 @@ }

} else {
this._ctx.fillStyle = this._colors.background;
this._ctx.fillStyle = this._colors.background.css;
this._ctx.fillRect(

@@ -322,8 +319,8 @@ x * this._scaledCellWidth,

if (fg === INVERTED_DEFAULT_COLOR) {
this._ctx.fillStyle = this._colors.background;
this._ctx.fillStyle = this._colors.background.css;
} else if (fg < 256) {
// 256 color support
this._ctx.fillStyle = this._colors.ansi[fg];
this._ctx.fillStyle = this._colors.ansi[fg].css;
} else {
this._ctx.fillStyle = this._colors.foreground;
this._ctx.fillStyle = this._colors.foreground.css;
}

@@ -330,0 +327,0 @@

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

import jsdom = require('jsdom');
import { assert } from 'chai';

@@ -12,5 +13,22 @@ import { ColorManager } from './ColorManager';

let cm: ColorManager;
let dom: jsdom.JSDOM;
let document: Document;
let window: Window;
beforeEach(() => {
cm = new ColorManager();
dom = new jsdom.JSDOM('');
window = dom.window;
document = window.document;
(<any>window).HTMLCanvasElement.prototype.getContext = () => ({
createLinearGradient(): any {
return null;
},
fillRect(): void { },
getImageData(): any {
return {data: [0, 0, 0, 0xFF]};
}
});
cm = new ColorManager(document, false);
});

@@ -20,6 +38,6 @@

it('should fill all colors with values', () => {
for (let key in cm.colors) {
if (typeof key === 'string') {
for (let key of Object.keys(cm.colors)) {
if (key !== 'ansi') {
// A #rrggbb or rgba(...)
assert.ok(cm.colors[key].length >= 7);
assert.ok(cm.colors[key].css.length >= 7);
}

@@ -31,242 +49,242 @@ }

it('should fill 240 colors with expected values', () => {
assert.equal(cm.colors.ansi[16], '#000000');
assert.equal(cm.colors.ansi[17], '#00005f');
assert.equal(cm.colors.ansi[18], '#000087');
assert.equal(cm.colors.ansi[19], '#0000af');
assert.equal(cm.colors.ansi[20], '#0000d7');
assert.equal(cm.colors.ansi[21], '#0000ff');
assert.equal(cm.colors.ansi[22], '#005f00');
assert.equal(cm.colors.ansi[23], '#005f5f');
assert.equal(cm.colors.ansi[24], '#005f87');
assert.equal(cm.colors.ansi[25], '#005faf');
assert.equal(cm.colors.ansi[26], '#005fd7');
assert.equal(cm.colors.ansi[27], '#005fff');
assert.equal(cm.colors.ansi[28], '#008700');
assert.equal(cm.colors.ansi[29], '#00875f');
assert.equal(cm.colors.ansi[30], '#008787');
assert.equal(cm.colors.ansi[31], '#0087af');
assert.equal(cm.colors.ansi[32], '#0087d7');
assert.equal(cm.colors.ansi[33], '#0087ff');
assert.equal(cm.colors.ansi[34], '#00af00');
assert.equal(cm.colors.ansi[35], '#00af5f');
assert.equal(cm.colors.ansi[36], '#00af87');
assert.equal(cm.colors.ansi[37], '#00afaf');
assert.equal(cm.colors.ansi[38], '#00afd7');
assert.equal(cm.colors.ansi[39], '#00afff');
assert.equal(cm.colors.ansi[40], '#00d700');
assert.equal(cm.colors.ansi[41], '#00d75f');
assert.equal(cm.colors.ansi[42], '#00d787');
assert.equal(cm.colors.ansi[43], '#00d7af');
assert.equal(cm.colors.ansi[44], '#00d7d7');
assert.equal(cm.colors.ansi[45], '#00d7ff');
assert.equal(cm.colors.ansi[46], '#00ff00');
assert.equal(cm.colors.ansi[47], '#00ff5f');
assert.equal(cm.colors.ansi[48], '#00ff87');
assert.equal(cm.colors.ansi[49], '#00ffaf');
assert.equal(cm.colors.ansi[50], '#00ffd7');
assert.equal(cm.colors.ansi[51], '#00ffff');
assert.equal(cm.colors.ansi[52], '#5f0000');
assert.equal(cm.colors.ansi[53], '#5f005f');
assert.equal(cm.colors.ansi[54], '#5f0087');
assert.equal(cm.colors.ansi[55], '#5f00af');
assert.equal(cm.colors.ansi[56], '#5f00d7');
assert.equal(cm.colors.ansi[57], '#5f00ff');
assert.equal(cm.colors.ansi[58], '#5f5f00');
assert.equal(cm.colors.ansi[59], '#5f5f5f');
assert.equal(cm.colors.ansi[60], '#5f5f87');
assert.equal(cm.colors.ansi[61], '#5f5faf');
assert.equal(cm.colors.ansi[62], '#5f5fd7');
assert.equal(cm.colors.ansi[63], '#5f5fff');
assert.equal(cm.colors.ansi[64], '#5f8700');
assert.equal(cm.colors.ansi[65], '#5f875f');
assert.equal(cm.colors.ansi[66], '#5f8787');
assert.equal(cm.colors.ansi[67], '#5f87af');
assert.equal(cm.colors.ansi[68], '#5f87d7');
assert.equal(cm.colors.ansi[69], '#5f87ff');
assert.equal(cm.colors.ansi[70], '#5faf00');
assert.equal(cm.colors.ansi[71], '#5faf5f');
assert.equal(cm.colors.ansi[72], '#5faf87');
assert.equal(cm.colors.ansi[73], '#5fafaf');
assert.equal(cm.colors.ansi[74], '#5fafd7');
assert.equal(cm.colors.ansi[75], '#5fafff');
assert.equal(cm.colors.ansi[76], '#5fd700');
assert.equal(cm.colors.ansi[77], '#5fd75f');
assert.equal(cm.colors.ansi[78], '#5fd787');
assert.equal(cm.colors.ansi[79], '#5fd7af');
assert.equal(cm.colors.ansi[80], '#5fd7d7');
assert.equal(cm.colors.ansi[81], '#5fd7ff');
assert.equal(cm.colors.ansi[82], '#5fff00');
assert.equal(cm.colors.ansi[83], '#5fff5f');
assert.equal(cm.colors.ansi[84], '#5fff87');
assert.equal(cm.colors.ansi[85], '#5fffaf');
assert.equal(cm.colors.ansi[86], '#5fffd7');
assert.equal(cm.colors.ansi[87], '#5fffff');
assert.equal(cm.colors.ansi[88], '#870000');
assert.equal(cm.colors.ansi[89], '#87005f');
assert.equal(cm.colors.ansi[90], '#870087');
assert.equal(cm.colors.ansi[91], '#8700af');
assert.equal(cm.colors.ansi[92], '#8700d7');
assert.equal(cm.colors.ansi[93], '#8700ff');
assert.equal(cm.colors.ansi[94], '#875f00');
assert.equal(cm.colors.ansi[95], '#875f5f');
assert.equal(cm.colors.ansi[96], '#875f87');
assert.equal(cm.colors.ansi[97], '#875faf');
assert.equal(cm.colors.ansi[98], '#875fd7');
assert.equal(cm.colors.ansi[99], '#875fff');
assert.equal(cm.colors.ansi[100], '#878700');
assert.equal(cm.colors.ansi[101], '#87875f');
assert.equal(cm.colors.ansi[102], '#878787');
assert.equal(cm.colors.ansi[103], '#8787af');
assert.equal(cm.colors.ansi[104], '#8787d7');
assert.equal(cm.colors.ansi[105], '#8787ff');
assert.equal(cm.colors.ansi[106], '#87af00');
assert.equal(cm.colors.ansi[107], '#87af5f');
assert.equal(cm.colors.ansi[108], '#87af87');
assert.equal(cm.colors.ansi[109], '#87afaf');
assert.equal(cm.colors.ansi[110], '#87afd7');
assert.equal(cm.colors.ansi[111], '#87afff');
assert.equal(cm.colors.ansi[112], '#87d700');
assert.equal(cm.colors.ansi[113], '#87d75f');
assert.equal(cm.colors.ansi[114], '#87d787');
assert.equal(cm.colors.ansi[115], '#87d7af');
assert.equal(cm.colors.ansi[116], '#87d7d7');
assert.equal(cm.colors.ansi[117], '#87d7ff');
assert.equal(cm.colors.ansi[118], '#87ff00');
assert.equal(cm.colors.ansi[119], '#87ff5f');
assert.equal(cm.colors.ansi[120], '#87ff87');
assert.equal(cm.colors.ansi[121], '#87ffaf');
assert.equal(cm.colors.ansi[122], '#87ffd7');
assert.equal(cm.colors.ansi[123], '#87ffff');
assert.equal(cm.colors.ansi[124], '#af0000');
assert.equal(cm.colors.ansi[125], '#af005f');
assert.equal(cm.colors.ansi[126], '#af0087');
assert.equal(cm.colors.ansi[127], '#af00af');
assert.equal(cm.colors.ansi[128], '#af00d7');
assert.equal(cm.colors.ansi[129], '#af00ff');
assert.equal(cm.colors.ansi[130], '#af5f00');
assert.equal(cm.colors.ansi[131], '#af5f5f');
assert.equal(cm.colors.ansi[132], '#af5f87');
assert.equal(cm.colors.ansi[133], '#af5faf');
assert.equal(cm.colors.ansi[134], '#af5fd7');
assert.equal(cm.colors.ansi[135], '#af5fff');
assert.equal(cm.colors.ansi[136], '#af8700');
assert.equal(cm.colors.ansi[137], '#af875f');
assert.equal(cm.colors.ansi[138], '#af8787');
assert.equal(cm.colors.ansi[139], '#af87af');
assert.equal(cm.colors.ansi[140], '#af87d7');
assert.equal(cm.colors.ansi[141], '#af87ff');
assert.equal(cm.colors.ansi[142], '#afaf00');
assert.equal(cm.colors.ansi[143], '#afaf5f');
assert.equal(cm.colors.ansi[144], '#afaf87');
assert.equal(cm.colors.ansi[145], '#afafaf');
assert.equal(cm.colors.ansi[146], '#afafd7');
assert.equal(cm.colors.ansi[147], '#afafff');
assert.equal(cm.colors.ansi[148], '#afd700');
assert.equal(cm.colors.ansi[149], '#afd75f');
assert.equal(cm.colors.ansi[150], '#afd787');
assert.equal(cm.colors.ansi[151], '#afd7af');
assert.equal(cm.colors.ansi[152], '#afd7d7');
assert.equal(cm.colors.ansi[153], '#afd7ff');
assert.equal(cm.colors.ansi[154], '#afff00');
assert.equal(cm.colors.ansi[155], '#afff5f');
assert.equal(cm.colors.ansi[156], '#afff87');
assert.equal(cm.colors.ansi[157], '#afffaf');
assert.equal(cm.colors.ansi[158], '#afffd7');
assert.equal(cm.colors.ansi[159], '#afffff');
assert.equal(cm.colors.ansi[160], '#d70000');
assert.equal(cm.colors.ansi[161], '#d7005f');
assert.equal(cm.colors.ansi[162], '#d70087');
assert.equal(cm.colors.ansi[163], '#d700af');
assert.equal(cm.colors.ansi[164], '#d700d7');
assert.equal(cm.colors.ansi[165], '#d700ff');
assert.equal(cm.colors.ansi[166], '#d75f00');
assert.equal(cm.colors.ansi[167], '#d75f5f');
assert.equal(cm.colors.ansi[168], '#d75f87');
assert.equal(cm.colors.ansi[169], '#d75faf');
assert.equal(cm.colors.ansi[170], '#d75fd7');
assert.equal(cm.colors.ansi[171], '#d75fff');
assert.equal(cm.colors.ansi[172], '#d78700');
assert.equal(cm.colors.ansi[173], '#d7875f');
assert.equal(cm.colors.ansi[174], '#d78787');
assert.equal(cm.colors.ansi[175], '#d787af');
assert.equal(cm.colors.ansi[176], '#d787d7');
assert.equal(cm.colors.ansi[177], '#d787ff');
assert.equal(cm.colors.ansi[178], '#d7af00');
assert.equal(cm.colors.ansi[179], '#d7af5f');
assert.equal(cm.colors.ansi[180], '#d7af87');
assert.equal(cm.colors.ansi[181], '#d7afaf');
assert.equal(cm.colors.ansi[182], '#d7afd7');
assert.equal(cm.colors.ansi[183], '#d7afff');
assert.equal(cm.colors.ansi[184], '#d7d700');
assert.equal(cm.colors.ansi[185], '#d7d75f');
assert.equal(cm.colors.ansi[186], '#d7d787');
assert.equal(cm.colors.ansi[187], '#d7d7af');
assert.equal(cm.colors.ansi[188], '#d7d7d7');
assert.equal(cm.colors.ansi[189], '#d7d7ff');
assert.equal(cm.colors.ansi[190], '#d7ff00');
assert.equal(cm.colors.ansi[191], '#d7ff5f');
assert.equal(cm.colors.ansi[192], '#d7ff87');
assert.equal(cm.colors.ansi[193], '#d7ffaf');
assert.equal(cm.colors.ansi[194], '#d7ffd7');
assert.equal(cm.colors.ansi[195], '#d7ffff');
assert.equal(cm.colors.ansi[196], '#ff0000');
assert.equal(cm.colors.ansi[197], '#ff005f');
assert.equal(cm.colors.ansi[198], '#ff0087');
assert.equal(cm.colors.ansi[199], '#ff00af');
assert.equal(cm.colors.ansi[200], '#ff00d7');
assert.equal(cm.colors.ansi[201], '#ff00ff');
assert.equal(cm.colors.ansi[202], '#ff5f00');
assert.equal(cm.colors.ansi[203], '#ff5f5f');
assert.equal(cm.colors.ansi[204], '#ff5f87');
assert.equal(cm.colors.ansi[205], '#ff5faf');
assert.equal(cm.colors.ansi[206], '#ff5fd7');
assert.equal(cm.colors.ansi[207], '#ff5fff');
assert.equal(cm.colors.ansi[208], '#ff8700');
assert.equal(cm.colors.ansi[209], '#ff875f');
assert.equal(cm.colors.ansi[210], '#ff8787');
assert.equal(cm.colors.ansi[211], '#ff87af');
assert.equal(cm.colors.ansi[212], '#ff87d7');
assert.equal(cm.colors.ansi[213], '#ff87ff');
assert.equal(cm.colors.ansi[214], '#ffaf00');
assert.equal(cm.colors.ansi[215], '#ffaf5f');
assert.equal(cm.colors.ansi[216], '#ffaf87');
assert.equal(cm.colors.ansi[217], '#ffafaf');
assert.equal(cm.colors.ansi[218], '#ffafd7');
assert.equal(cm.colors.ansi[219], '#ffafff');
assert.equal(cm.colors.ansi[220], '#ffd700');
assert.equal(cm.colors.ansi[221], '#ffd75f');
assert.equal(cm.colors.ansi[222], '#ffd787');
assert.equal(cm.colors.ansi[223], '#ffd7af');
assert.equal(cm.colors.ansi[224], '#ffd7d7');
assert.equal(cm.colors.ansi[225], '#ffd7ff');
assert.equal(cm.colors.ansi[226], '#ffff00');
assert.equal(cm.colors.ansi[227], '#ffff5f');
assert.equal(cm.colors.ansi[228], '#ffff87');
assert.equal(cm.colors.ansi[229], '#ffffaf');
assert.equal(cm.colors.ansi[230], '#ffffd7');
assert.equal(cm.colors.ansi[231], '#ffffff');
assert.equal(cm.colors.ansi[232], '#080808');
assert.equal(cm.colors.ansi[233], '#121212');
assert.equal(cm.colors.ansi[234], '#1c1c1c');
assert.equal(cm.colors.ansi[235], '#262626');
assert.equal(cm.colors.ansi[236], '#303030');
assert.equal(cm.colors.ansi[237], '#3a3a3a');
assert.equal(cm.colors.ansi[238], '#444444');
assert.equal(cm.colors.ansi[239], '#4e4e4e');
assert.equal(cm.colors.ansi[240], '#585858');
assert.equal(cm.colors.ansi[241], '#626262');
assert.equal(cm.colors.ansi[242], '#6c6c6c');
assert.equal(cm.colors.ansi[243], '#767676');
assert.equal(cm.colors.ansi[244], '#808080');
assert.equal(cm.colors.ansi[245], '#8a8a8a');
assert.equal(cm.colors.ansi[246], '#949494');
assert.equal(cm.colors.ansi[247], '#9e9e9e');
assert.equal(cm.colors.ansi[248], '#a8a8a8');
assert.equal(cm.colors.ansi[249], '#b2b2b2');
assert.equal(cm.colors.ansi[250], '#bcbcbc');
assert.equal(cm.colors.ansi[251], '#c6c6c6');
assert.equal(cm.colors.ansi[252], '#d0d0d0');
assert.equal(cm.colors.ansi[253], '#dadada');
assert.equal(cm.colors.ansi[254], '#e4e4e4');
assert.equal(cm.colors.ansi[255], '#eeeeee');
assert.equal(cm.colors.ansi[16].css, '#000000');
assert.equal(cm.colors.ansi[17].css, '#00005f');
assert.equal(cm.colors.ansi[18].css, '#000087');
assert.equal(cm.colors.ansi[19].css, '#0000af');
assert.equal(cm.colors.ansi[20].css, '#0000d7');
assert.equal(cm.colors.ansi[21].css, '#0000ff');
assert.equal(cm.colors.ansi[22].css, '#005f00');
assert.equal(cm.colors.ansi[23].css, '#005f5f');
assert.equal(cm.colors.ansi[24].css, '#005f87');
assert.equal(cm.colors.ansi[25].css, '#005faf');
assert.equal(cm.colors.ansi[26].css, '#005fd7');
assert.equal(cm.colors.ansi[27].css, '#005fff');
assert.equal(cm.colors.ansi[28].css, '#008700');
assert.equal(cm.colors.ansi[29].css, '#00875f');
assert.equal(cm.colors.ansi[30].css, '#008787');
assert.equal(cm.colors.ansi[31].css, '#0087af');
assert.equal(cm.colors.ansi[32].css, '#0087d7');
assert.equal(cm.colors.ansi[33].css, '#0087ff');
assert.equal(cm.colors.ansi[34].css, '#00af00');
assert.equal(cm.colors.ansi[35].css, '#00af5f');
assert.equal(cm.colors.ansi[36].css, '#00af87');
assert.equal(cm.colors.ansi[37].css, '#00afaf');
assert.equal(cm.colors.ansi[38].css, '#00afd7');
assert.equal(cm.colors.ansi[39].css, '#00afff');
assert.equal(cm.colors.ansi[40].css, '#00d700');
assert.equal(cm.colors.ansi[41].css, '#00d75f');
assert.equal(cm.colors.ansi[42].css, '#00d787');
assert.equal(cm.colors.ansi[43].css, '#00d7af');
assert.equal(cm.colors.ansi[44].css, '#00d7d7');
assert.equal(cm.colors.ansi[45].css, '#00d7ff');
assert.equal(cm.colors.ansi[46].css, '#00ff00');
assert.equal(cm.colors.ansi[47].css, '#00ff5f');
assert.equal(cm.colors.ansi[48].css, '#00ff87');
assert.equal(cm.colors.ansi[49].css, '#00ffaf');
assert.equal(cm.colors.ansi[50].css, '#00ffd7');
assert.equal(cm.colors.ansi[51].css, '#00ffff');
assert.equal(cm.colors.ansi[52].css, '#5f0000');
assert.equal(cm.colors.ansi[53].css, '#5f005f');
assert.equal(cm.colors.ansi[54].css, '#5f0087');
assert.equal(cm.colors.ansi[55].css, '#5f00af');
assert.equal(cm.colors.ansi[56].css, '#5f00d7');
assert.equal(cm.colors.ansi[57].css, '#5f00ff');
assert.equal(cm.colors.ansi[58].css, '#5f5f00');
assert.equal(cm.colors.ansi[59].css, '#5f5f5f');
assert.equal(cm.colors.ansi[60].css, '#5f5f87');
assert.equal(cm.colors.ansi[61].css, '#5f5faf');
assert.equal(cm.colors.ansi[62].css, '#5f5fd7');
assert.equal(cm.colors.ansi[63].css, '#5f5fff');
assert.equal(cm.colors.ansi[64].css, '#5f8700');
assert.equal(cm.colors.ansi[65].css, '#5f875f');
assert.equal(cm.colors.ansi[66].css, '#5f8787');
assert.equal(cm.colors.ansi[67].css, '#5f87af');
assert.equal(cm.colors.ansi[68].css, '#5f87d7');
assert.equal(cm.colors.ansi[69].css, '#5f87ff');
assert.equal(cm.colors.ansi[70].css, '#5faf00');
assert.equal(cm.colors.ansi[71].css, '#5faf5f');
assert.equal(cm.colors.ansi[72].css, '#5faf87');
assert.equal(cm.colors.ansi[73].css, '#5fafaf');
assert.equal(cm.colors.ansi[74].css, '#5fafd7');
assert.equal(cm.colors.ansi[75].css, '#5fafff');
assert.equal(cm.colors.ansi[76].css, '#5fd700');
assert.equal(cm.colors.ansi[77].css, '#5fd75f');
assert.equal(cm.colors.ansi[78].css, '#5fd787');
assert.equal(cm.colors.ansi[79].css, '#5fd7af');
assert.equal(cm.colors.ansi[80].css, '#5fd7d7');
assert.equal(cm.colors.ansi[81].css, '#5fd7ff');
assert.equal(cm.colors.ansi[82].css, '#5fff00');
assert.equal(cm.colors.ansi[83].css, '#5fff5f');
assert.equal(cm.colors.ansi[84].css, '#5fff87');
assert.equal(cm.colors.ansi[85].css, '#5fffaf');
assert.equal(cm.colors.ansi[86].css, '#5fffd7');
assert.equal(cm.colors.ansi[87].css, '#5fffff');
assert.equal(cm.colors.ansi[88].css, '#870000');
assert.equal(cm.colors.ansi[89].css, '#87005f');
assert.equal(cm.colors.ansi[90].css, '#870087');
assert.equal(cm.colors.ansi[91].css, '#8700af');
assert.equal(cm.colors.ansi[92].css, '#8700d7');
assert.equal(cm.colors.ansi[93].css, '#8700ff');
assert.equal(cm.colors.ansi[94].css, '#875f00');
assert.equal(cm.colors.ansi[95].css, '#875f5f');
assert.equal(cm.colors.ansi[96].css, '#875f87');
assert.equal(cm.colors.ansi[97].css, '#875faf');
assert.equal(cm.colors.ansi[98].css, '#875fd7');
assert.equal(cm.colors.ansi[99].css, '#875fff');
assert.equal(cm.colors.ansi[100].css, '#878700');
assert.equal(cm.colors.ansi[101].css, '#87875f');
assert.equal(cm.colors.ansi[102].css, '#878787');
assert.equal(cm.colors.ansi[103].css, '#8787af');
assert.equal(cm.colors.ansi[104].css, '#8787d7');
assert.equal(cm.colors.ansi[105].css, '#8787ff');
assert.equal(cm.colors.ansi[106].css, '#87af00');
assert.equal(cm.colors.ansi[107].css, '#87af5f');
assert.equal(cm.colors.ansi[108].css, '#87af87');
assert.equal(cm.colors.ansi[109].css, '#87afaf');
assert.equal(cm.colors.ansi[110].css, '#87afd7');
assert.equal(cm.colors.ansi[111].css, '#87afff');
assert.equal(cm.colors.ansi[112].css, '#87d700');
assert.equal(cm.colors.ansi[113].css, '#87d75f');
assert.equal(cm.colors.ansi[114].css, '#87d787');
assert.equal(cm.colors.ansi[115].css, '#87d7af');
assert.equal(cm.colors.ansi[116].css, '#87d7d7');
assert.equal(cm.colors.ansi[117].css, '#87d7ff');
assert.equal(cm.colors.ansi[118].css, '#87ff00');
assert.equal(cm.colors.ansi[119].css, '#87ff5f');
assert.equal(cm.colors.ansi[120].css, '#87ff87');
assert.equal(cm.colors.ansi[121].css, '#87ffaf');
assert.equal(cm.colors.ansi[122].css, '#87ffd7');
assert.equal(cm.colors.ansi[123].css, '#87ffff');
assert.equal(cm.colors.ansi[124].css, '#af0000');
assert.equal(cm.colors.ansi[125].css, '#af005f');
assert.equal(cm.colors.ansi[126].css, '#af0087');
assert.equal(cm.colors.ansi[127].css, '#af00af');
assert.equal(cm.colors.ansi[128].css, '#af00d7');
assert.equal(cm.colors.ansi[129].css, '#af00ff');
assert.equal(cm.colors.ansi[130].css, '#af5f00');
assert.equal(cm.colors.ansi[131].css, '#af5f5f');
assert.equal(cm.colors.ansi[132].css, '#af5f87');
assert.equal(cm.colors.ansi[133].css, '#af5faf');
assert.equal(cm.colors.ansi[134].css, '#af5fd7');
assert.equal(cm.colors.ansi[135].css, '#af5fff');
assert.equal(cm.colors.ansi[136].css, '#af8700');
assert.equal(cm.colors.ansi[137].css, '#af875f');
assert.equal(cm.colors.ansi[138].css, '#af8787');
assert.equal(cm.colors.ansi[139].css, '#af87af');
assert.equal(cm.colors.ansi[140].css, '#af87d7');
assert.equal(cm.colors.ansi[141].css, '#af87ff');
assert.equal(cm.colors.ansi[142].css, '#afaf00');
assert.equal(cm.colors.ansi[143].css, '#afaf5f');
assert.equal(cm.colors.ansi[144].css, '#afaf87');
assert.equal(cm.colors.ansi[145].css, '#afafaf');
assert.equal(cm.colors.ansi[146].css, '#afafd7');
assert.equal(cm.colors.ansi[147].css, '#afafff');
assert.equal(cm.colors.ansi[148].css, '#afd700');
assert.equal(cm.colors.ansi[149].css, '#afd75f');
assert.equal(cm.colors.ansi[150].css, '#afd787');
assert.equal(cm.colors.ansi[151].css, '#afd7af');
assert.equal(cm.colors.ansi[152].css, '#afd7d7');
assert.equal(cm.colors.ansi[153].css, '#afd7ff');
assert.equal(cm.colors.ansi[154].css, '#afff00');
assert.equal(cm.colors.ansi[155].css, '#afff5f');
assert.equal(cm.colors.ansi[156].css, '#afff87');
assert.equal(cm.colors.ansi[157].css, '#afffaf');
assert.equal(cm.colors.ansi[158].css, '#afffd7');
assert.equal(cm.colors.ansi[159].css, '#afffff');
assert.equal(cm.colors.ansi[160].css, '#d70000');
assert.equal(cm.colors.ansi[161].css, '#d7005f');
assert.equal(cm.colors.ansi[162].css, '#d70087');
assert.equal(cm.colors.ansi[163].css, '#d700af');
assert.equal(cm.colors.ansi[164].css, '#d700d7');
assert.equal(cm.colors.ansi[165].css, '#d700ff');
assert.equal(cm.colors.ansi[166].css, '#d75f00');
assert.equal(cm.colors.ansi[167].css, '#d75f5f');
assert.equal(cm.colors.ansi[168].css, '#d75f87');
assert.equal(cm.colors.ansi[169].css, '#d75faf');
assert.equal(cm.colors.ansi[170].css, '#d75fd7');
assert.equal(cm.colors.ansi[171].css, '#d75fff');
assert.equal(cm.colors.ansi[172].css, '#d78700');
assert.equal(cm.colors.ansi[173].css, '#d7875f');
assert.equal(cm.colors.ansi[174].css, '#d78787');
assert.equal(cm.colors.ansi[175].css, '#d787af');
assert.equal(cm.colors.ansi[176].css, '#d787d7');
assert.equal(cm.colors.ansi[177].css, '#d787ff');
assert.equal(cm.colors.ansi[178].css, '#d7af00');
assert.equal(cm.colors.ansi[179].css, '#d7af5f');
assert.equal(cm.colors.ansi[180].css, '#d7af87');
assert.equal(cm.colors.ansi[181].css, '#d7afaf');
assert.equal(cm.colors.ansi[182].css, '#d7afd7');
assert.equal(cm.colors.ansi[183].css, '#d7afff');
assert.equal(cm.colors.ansi[184].css, '#d7d700');
assert.equal(cm.colors.ansi[185].css, '#d7d75f');
assert.equal(cm.colors.ansi[186].css, '#d7d787');
assert.equal(cm.colors.ansi[187].css, '#d7d7af');
assert.equal(cm.colors.ansi[188].css, '#d7d7d7');
assert.equal(cm.colors.ansi[189].css, '#d7d7ff');
assert.equal(cm.colors.ansi[190].css, '#d7ff00');
assert.equal(cm.colors.ansi[191].css, '#d7ff5f');
assert.equal(cm.colors.ansi[192].css, '#d7ff87');
assert.equal(cm.colors.ansi[193].css, '#d7ffaf');
assert.equal(cm.colors.ansi[194].css, '#d7ffd7');
assert.equal(cm.colors.ansi[195].css, '#d7ffff');
assert.equal(cm.colors.ansi[196].css, '#ff0000');
assert.equal(cm.colors.ansi[197].css, '#ff005f');
assert.equal(cm.colors.ansi[198].css, '#ff0087');
assert.equal(cm.colors.ansi[199].css, '#ff00af');
assert.equal(cm.colors.ansi[200].css, '#ff00d7');
assert.equal(cm.colors.ansi[201].css, '#ff00ff');
assert.equal(cm.colors.ansi[202].css, '#ff5f00');
assert.equal(cm.colors.ansi[203].css, '#ff5f5f');
assert.equal(cm.colors.ansi[204].css, '#ff5f87');
assert.equal(cm.colors.ansi[205].css, '#ff5faf');
assert.equal(cm.colors.ansi[206].css, '#ff5fd7');
assert.equal(cm.colors.ansi[207].css, '#ff5fff');
assert.equal(cm.colors.ansi[208].css, '#ff8700');
assert.equal(cm.colors.ansi[209].css, '#ff875f');
assert.equal(cm.colors.ansi[210].css, '#ff8787');
assert.equal(cm.colors.ansi[211].css, '#ff87af');
assert.equal(cm.colors.ansi[212].css, '#ff87d7');
assert.equal(cm.colors.ansi[213].css, '#ff87ff');
assert.equal(cm.colors.ansi[214].css, '#ffaf00');
assert.equal(cm.colors.ansi[215].css, '#ffaf5f');
assert.equal(cm.colors.ansi[216].css, '#ffaf87');
assert.equal(cm.colors.ansi[217].css, '#ffafaf');
assert.equal(cm.colors.ansi[218].css, '#ffafd7');
assert.equal(cm.colors.ansi[219].css, '#ffafff');
assert.equal(cm.colors.ansi[220].css, '#ffd700');
assert.equal(cm.colors.ansi[221].css, '#ffd75f');
assert.equal(cm.colors.ansi[222].css, '#ffd787');
assert.equal(cm.colors.ansi[223].css, '#ffd7af');
assert.equal(cm.colors.ansi[224].css, '#ffd7d7');
assert.equal(cm.colors.ansi[225].css, '#ffd7ff');
assert.equal(cm.colors.ansi[226].css, '#ffff00');
assert.equal(cm.colors.ansi[227].css, '#ffff5f');
assert.equal(cm.colors.ansi[228].css, '#ffff87');
assert.equal(cm.colors.ansi[229].css, '#ffffaf');
assert.equal(cm.colors.ansi[230].css, '#ffffd7');
assert.equal(cm.colors.ansi[231].css, '#ffffff');
assert.equal(cm.colors.ansi[232].css, '#080808');
assert.equal(cm.colors.ansi[233].css, '#121212');
assert.equal(cm.colors.ansi[234].css, '#1c1c1c');
assert.equal(cm.colors.ansi[235].css, '#262626');
assert.equal(cm.colors.ansi[236].css, '#303030');
assert.equal(cm.colors.ansi[237].css, '#3a3a3a');
assert.equal(cm.colors.ansi[238].css, '#444444');
assert.equal(cm.colors.ansi[239].css, '#4e4e4e');
assert.equal(cm.colors.ansi[240].css, '#585858');
assert.equal(cm.colors.ansi[241].css, '#626262');
assert.equal(cm.colors.ansi[242].css, '#6c6c6c');
assert.equal(cm.colors.ansi[243].css, '#767676');
assert.equal(cm.colors.ansi[244].css, '#808080');
assert.equal(cm.colors.ansi[245].css, '#8a8a8a');
assert.equal(cm.colors.ansi[246].css, '#949494');
assert.equal(cm.colors.ansi[247].css, '#9e9e9e');
assert.equal(cm.colors.ansi[248].css, '#a8a8a8');
assert.equal(cm.colors.ansi[249].css, '#b2b2b2');
assert.equal(cm.colors.ansi[250].css, '#bcbcbc');
assert.equal(cm.colors.ansi[251].css, '#c6c6c6');
assert.equal(cm.colors.ansi[252].css, '#d0d0d0');
assert.equal(cm.colors.ansi[253].css, '#dadada');
assert.equal(cm.colors.ansi[254].css, '#e4e4e4');
assert.equal(cm.colors.ansi[255].css, '#eeeeee');
});

@@ -283,4 +301,4 @@ });

it('should set a partial set of colors, using the default if not present', () => {
assert.equal(cm.colors.background, '#000000');
assert.equal(cm.colors.foreground, '#ffffff');
assert.equal(cm.colors.background.css, '#000000');
assert.equal(cm.colors.foreground.css, '#ffffff');
cm.setTheme({

@@ -290,12 +308,12 @@ background: '#FF0000',

});
assert.equal(cm.colors.background, '#FF0000');
assert.equal(cm.colors.foreground, '#00FF00');
assert.equal(cm.colors.background.css, '#FF0000');
assert.equal(cm.colors.foreground.css, '#00FF00');
cm.setTheme({
background: '#0000FF'
});
assert.equal(cm.colors.background, '#0000FF');
assert.equal(cm.colors.background.css, '#0000FF');
// FG reverts back to default
assert.equal(cm.colors.foreground, '#ffffff');
assert.equal(cm.colors.foreground.css, '#ffffff');
});
});
});

@@ -6,45 +6,51 @@ /**

import { IColorSet, IColorManager } from './Types';
import { IColorManager } from './Types';
import { IColor, IColorSet } from '../shared/Types';
import { ITheme } from 'xterm';
const DEFAULT_FOREGROUND = '#ffffff';
const DEFAULT_BACKGROUND = '#000000';
const DEFAULT_CURSOR = '#ffffff';
const DEFAULT_CURSOR_ACCENT = '#000000';
const DEFAULT_SELECTION = 'rgba(255, 255, 255, 0.3)';
export const DEFAULT_ANSI_COLORS = [
// dark:
'#2e3436',
'#cc0000',
'#4e9a06',
'#c4a000',
'#3465a4',
'#75507b',
'#06989a',
'#d3d7cf',
// bright:
'#555753',
'#ef2929',
'#8ae234',
'#fce94f',
'#729fcf',
'#ad7fa8',
'#34e2e2',
'#eeeeec'
];
const DEFAULT_FOREGROUND = fromHex('#ffffff');
const DEFAULT_BACKGROUND = fromHex('#000000');
const DEFAULT_CURSOR = fromHex('#ffffff');
const DEFAULT_CURSOR_ACCENT = fromHex('#000000');
const DEFAULT_SELECTION = {
css: 'rgba(255, 255, 255, 0.3)',
rgba: 0xFFFFFF77
};
/**
* Fills an existing 16 length string with the remaining 240 ANSI colors.
* @param first16Colors The first 16 ANSI colors.
*/
function generate256Colors(first16Colors: string[]): string[] {
let colors = first16Colors.slice();
// An IIFE to generate DEFAULT_ANSI_COLORS. Do not mutate DEFAULT_ANSI_COLORS, instead make a copy
// and mutate that.
export const DEFAULT_ANSI_COLORS = (() => {
const colors = [
// dark:
fromHex('#2e3436'),
fromHex('#cc0000'),
fromHex('#4e9a06'),
fromHex('#c4a000'),
fromHex('#3465a4'),
fromHex('#75507b'),
fromHex('#06989a'),
fromHex('#d3d7cf'),
// bright:
fromHex('#555753'),
fromHex('#ef2929'),
fromHex('#8ae234'),
fromHex('#fce94f'),
fromHex('#729fcf'),
fromHex('#ad7fa8'),
fromHex('#34e2e2'),
fromHex('#eeeeec')
];
// Fill in the remaining 240 ANSI colors.
// Generate colors (16-231)
let v = [0x00, 0x5f, 0x87, 0xaf, 0xd7, 0xff];
for (let i = 0; i < 216; i++) {
const r = toPaddedHex(v[(i / 36) % 6 | 0]);
const g = toPaddedHex(v[(i / 6) % 6 | 0]);
const b = toPaddedHex(v[i % 6]);
colors.push(`#${r}${g}${b}`);
const r = v[(i / 36) % 6 | 0];
const g = v[(i / 6) % 6 | 0];
const b = v[i % 6];
colors.push({
css: `#${toPaddedHex(r)}${toPaddedHex(g)}${toPaddedHex(b)}`,
// Use >>> 0 to force a conversion to an unsigned int
rgba: ((r << 24) | (g << 16) | (b << 8) | 0xFF) >>> 0
});
}

@@ -54,7 +60,18 @@

for (let i = 0; i < 24; i++) {
const c = toPaddedHex(8 + i * 10);
colors.push(`#${c}${c}${c}`);
const c = 8 + i * 10;
const ch = toPaddedHex(c);
colors.push({
css: `#${ch}${ch}${ch}`,
rgba: ((c << 24) | (c << 16) | (c << 8) | 0xFF) >>> 0
});
}
return colors;
})();
function fromHex(css: string): IColor {
return {
css,
rgba: parseInt(css.slice(1), 16) << 8 | 0xFF
};
}

@@ -72,4 +89,12 @@

public colors: IColorSet;
private _ctx: CanvasRenderingContext2D;
private _litmusColor: CanvasGradient;
constructor() {
constructor(document: Document, public allowTransparency: boolean) {
const canvas = document.createElement('canvas');
canvas.width = 1;
canvas.height = 1;
this._ctx = canvas.getContext('2d');
this._ctx.globalCompositeOperation = 'copy';
this._litmusColor = this._ctx.createLinearGradient(0, 0, 1, 1);
this.colors = {

@@ -81,3 +106,3 @@ foreground: DEFAULT_FOREGROUND,

selection: DEFAULT_SELECTION,
ansi: generate256Colors(DEFAULT_ANSI_COLORS)
ansi: DEFAULT_ANSI_COLORS.slice()
};

@@ -92,24 +117,76 @@ }

public setTheme(theme: ITheme): void {
this.colors.foreground = theme.foreground || DEFAULT_FOREGROUND;
this.colors.background = theme.background || DEFAULT_BACKGROUND;
this.colors.cursor = theme.cursor || DEFAULT_CURSOR;
this.colors.cursorAccent = theme.cursorAccent || DEFAULT_CURSOR_ACCENT;
this.colors.selection = theme.selection || DEFAULT_SELECTION;
this.colors.ansi[0] = theme.black || DEFAULT_ANSI_COLORS[0];
this.colors.ansi[1] = theme.red || DEFAULT_ANSI_COLORS[1];
this.colors.ansi[2] = theme.green || DEFAULT_ANSI_COLORS[2];
this.colors.ansi[3] = theme.yellow || DEFAULT_ANSI_COLORS[3];
this.colors.ansi[4] = theme.blue || DEFAULT_ANSI_COLORS[4];
this.colors.ansi[5] = theme.magenta || DEFAULT_ANSI_COLORS[5];
this.colors.ansi[6] = theme.cyan || DEFAULT_ANSI_COLORS[6];
this.colors.ansi[7] = theme.white || DEFAULT_ANSI_COLORS[7];
this.colors.ansi[8] = theme.brightBlack || DEFAULT_ANSI_COLORS[8];
this.colors.ansi[9] = theme.brightRed || DEFAULT_ANSI_COLORS[9];
this.colors.ansi[10] = theme.brightGreen || DEFAULT_ANSI_COLORS[10];
this.colors.ansi[11] = theme.brightYellow || DEFAULT_ANSI_COLORS[11];
this.colors.ansi[12] = theme.brightBlue || DEFAULT_ANSI_COLORS[12];
this.colors.ansi[13] = theme.brightMagenta || DEFAULT_ANSI_COLORS[13];
this.colors.ansi[14] = theme.brightCyan || DEFAULT_ANSI_COLORS[14];
this.colors.ansi[15] = theme.brightWhite || DEFAULT_ANSI_COLORS[15];
this.colors.foreground = this._parseColor(theme.foreground, DEFAULT_FOREGROUND);
this.colors.background = this._parseColor(theme.background, DEFAULT_BACKGROUND);
this.colors.cursor = this._parseColor(theme.cursor, DEFAULT_CURSOR, true);
this.colors.cursorAccent = this._parseColor(theme.cursorAccent, DEFAULT_CURSOR_ACCENT, true);
this.colors.selection = this._parseColor(theme.selection, DEFAULT_SELECTION, true);
this.colors.ansi[0] = this._parseColor(theme.black, DEFAULT_ANSI_COLORS[0]);
this.colors.ansi[1] = this._parseColor(theme.red, DEFAULT_ANSI_COLORS[1]);
this.colors.ansi[2] = this._parseColor(theme.green, DEFAULT_ANSI_COLORS[2]);
this.colors.ansi[3] = this._parseColor(theme.yellow, DEFAULT_ANSI_COLORS[3]);
this.colors.ansi[4] = this._parseColor(theme.blue, DEFAULT_ANSI_COLORS[4]);
this.colors.ansi[5] = this._parseColor(theme.magenta, DEFAULT_ANSI_COLORS[5]);
this.colors.ansi[6] = this._parseColor(theme.cyan, DEFAULT_ANSI_COLORS[6]);
this.colors.ansi[7] = this._parseColor(theme.white, DEFAULT_ANSI_COLORS[7]);
this.colors.ansi[8] = this._parseColor(theme.brightBlack, DEFAULT_ANSI_COLORS[8]);
this.colors.ansi[9] = this._parseColor(theme.brightRed, DEFAULT_ANSI_COLORS[9]);
this.colors.ansi[10] = this._parseColor(theme.brightGreen, DEFAULT_ANSI_COLORS[10]);
this.colors.ansi[11] = this._parseColor(theme.brightYellow, DEFAULT_ANSI_COLORS[11]);
this.colors.ansi[12] = this._parseColor(theme.brightBlue, DEFAULT_ANSI_COLORS[12]);
this.colors.ansi[13] = this._parseColor(theme.brightMagenta, DEFAULT_ANSI_COLORS[13]);
this.colors.ansi[14] = this._parseColor(theme.brightCyan, DEFAULT_ANSI_COLORS[14]);
this.colors.ansi[15] = this._parseColor(theme.brightWhite, DEFAULT_ANSI_COLORS[15]);
}
private _parseColor(
css: string,
fallback: IColor,
allowTransparency: boolean = this.allowTransparency
): IColor {
if (!css) {
return fallback;
}
// If parsing the value results in failure, then it must be ignored, and the attribute must
// retain its previous value.
// -- https://html.spec.whatwg.org/multipage/canvas.html#fill-and-stroke-styles
this._ctx.fillStyle = this._litmusColor;
this._ctx.fillStyle = css;
if (typeof this._ctx.fillStyle !== 'string') {
console.warn(`Color: ${css} is invalid using fallback ${fallback.css}`);
return fallback;
}
this._ctx.fillRect(0, 0, 1, 1);
const data = this._ctx.getImageData(0, 0, 1, 1).data;
if (!allowTransparency && data[3] !== 0xFF) {
// Ideally we'd just ignore the alpha channel, but...
//
// Browsers may not give back exactly the same RGB values we put in, because most/all
// convert the color to a pre-multiplied representation. getImageData converts that back to
// a un-premultipled representation, but the precision loss may make the RGB channels unuable
// on their own.
//
// E.g. In Chrome #12345610 turns into #10305010, and in the extreme case, 0xFFFFFF00 turns
// into 0x00000000.
//
// "Note: Due to the lossy nature of converting to and from premultiplied alpha color values,
// pixels that have just been set using putImageData() might be returned to an equivalent
// getImageData() as different values."
// -- https://html.spec.whatwg.org/multipage/canvas.html#pixel-manipulation
//
// So let's just use the fallback color in this case instead.
console.warn(
`Color: ${css} is using transparency, but allowTransparency is false. ` +
`Using fallback ${fallback.css}.`
);
return fallback;
}
return {
css,
rgba: (data[0] << 24 | data[1] << 16 | data[2] << 8 | data[3]) >>> 0
};
}
}

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

import { CHAR_DATA_WIDTH_INDEX, CHAR_DATA_CODE_INDEX, CHAR_DATA_CHAR_INDEX } from '../Buffer';
import { GridCache } from './GridCache';
import { FLAGS, IColorSet, IRenderDimensions } from './Types';
import { CHAR_DATA_WIDTH_INDEX } from '../Buffer';
import { IColorSet, IRenderDimensions } from './Types';
import { BaseRenderLayer } from './BaseRenderLayer';
import { CharData, IBuffer, ICharMeasure, ITerminal, ITerminalOptions } from '../Types';
import { CharData, ITerminal } from '../Types';

@@ -30,3 +29,2 @@ interface ICursorState {

private _cursorBlinkStateManager: CursorBlinkStateManager;
private _isFocused: boolean;

@@ -40,3 +38,3 @@ constructor(container: HTMLElement, zIndex: number, colors: IColorSet) {

style: null,
width: null,
width: null
};

@@ -51,4 +49,4 @@ this._cursorRenderers = {

public resize(terminal: ITerminal, dim: IRenderDimensions, charSizeChanged: boolean): void {
super.resize(terminal, dim, charSizeChanged);
public resize(terminal: ITerminal, dim: IRenderDimensions): void {
super.resize(terminal, dim);
// Resizing the canvas discards the contents of the canvas so clear state

@@ -60,3 +58,3 @@ this._state = {

style: null,
width: null,
width: null
};

@@ -145,3 +143,3 @@ }

this._ctx.save();
this._ctx.fillStyle = this._colors.cursor;
this._ctx.fillStyle = this._colors.cursor.css;
this._renderBlurCursor(terminal, terminal.buffer.x, viewportRelativeCursorY, charData);

@@ -194,3 +192,3 @@ this._ctx.restore();

style: null,
width: null,
width: null
};

@@ -202,3 +200,3 @@ }

this._ctx.save();
this._ctx.fillStyle = this._colors.cursor;
this._ctx.fillStyle = this._colors.cursor.css;
this.fillLeftLineAtCell(x, y);

@@ -210,5 +208,5 @@ this._ctx.restore();

this._ctx.save();
this._ctx.fillStyle = this._colors.cursor;
this._ctx.fillStyle = this._colors.cursor.css;
this.fillCells(x, y, charData[CHAR_DATA_WIDTH_INDEX], 1);
this._ctx.fillStyle = this._colors.cursorAccent;
this._ctx.fillStyle = this._colors.cursorAccent.css;
this.fillCharTrueColor(terminal, charData, x, y);

@@ -220,3 +218,3 @@ this._ctx.restore();

this._ctx.save();
this._ctx.fillStyle = this._colors.cursor;
this._ctx.fillStyle = this._colors.cursor.css;
this.fillBottomLineAtCells(x, y);

@@ -228,3 +226,3 @@ this._ctx.restore();

this._ctx.save();
this._ctx.strokeStyle = this._colors.cursor;
this._ctx.strokeStyle = this._colors.cursor.css;
this.strokeRectAtCell(x, y, charData[CHAR_DATA_WIDTH_INDEX], 1);

@@ -251,3 +249,3 @@ this._ctx.restore();

terminal: ITerminal,
private renderCallback: () => void
private _renderCallback: () => void
) {

@@ -287,3 +285,3 @@ this.isCursorVisible = true;

this._animationFrame = window.requestAnimationFrame(() => {
this.renderCallback();
this._renderCallback();
this._animationFrame = null;

@@ -319,3 +317,3 @@ });

this._animationFrame = window.requestAnimationFrame(() => {
this.renderCallback();
this._renderCallback();
this._animationFrame = null;

@@ -339,3 +337,3 @@ });

this._animationFrame = window.requestAnimationFrame(() => {
this.renderCallback();
this._renderCallback();
this._animationFrame = null;

@@ -342,0 +340,0 @@ });

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

import { ILinkHoverEvent, ITerminal, ILinkifierAccessor, IBuffer, ICharMeasure, LinkHoverEventTypes } from '../Types';
import { CHAR_DATA_ATTR_INDEX } from '../Buffer';
import { GridCache } from './GridCache';
import { FLAGS, IColorSet, IRenderDimensions } from './Types';
import { BaseRenderLayer, INVERTED_DEFAULT_COLOR } from './BaseRenderLayer';
import { ILinkHoverEvent, ITerminal, ILinkifierAccessor, LinkHoverEventTypes } from '../Types';
import { IColorSet, IRenderDimensions } from './Types';
import { BaseRenderLayer } from './BaseRenderLayer';

@@ -22,4 +20,4 @@ export class LinkRenderLayer extends BaseRenderLayer {

public resize(terminal: ITerminal, dim: IRenderDimensions, charSizeChanged: boolean): void {
super.resize(terminal, dim, charSizeChanged);
public resize(terminal: ITerminal, dim: IRenderDimensions): void {
super.resize(terminal, dim);
// Resizing the canvas discards the contents of the canvas so clear state

@@ -35,3 +33,8 @@ this._state = null;

if (this._state) {
this.clearCells(this._state.x, this._state.y, this._state.length, 1);
this.clearCells(this._state.x1, this._state.y1, this._state.cols - this._state.x1, 1);
const middleRowCount = this._state.y2 - this._state.y1 - 1;
if (middleRowCount > 0) {
this.clearCells(0, this._state.y1 + 1, this._state.cols, middleRowCount);
}
this.clearCells(0, this._state.y2, this._state.x2, 1);
this._state = null;

@@ -42,4 +45,14 @@ }

private _onLinkHover(e: ILinkHoverEvent): void {
this._ctx.fillStyle = this._colors.foreground;
this.fillBottomLineAtCells(e.x, e.y, e.length);
this._ctx.fillStyle = this._colors.foreground.css;
if (e.y1 === e.y2) {
// Single line link
this.fillBottomLineAtCells(e.x1, e.y1, e.x2 - e.x1);
} else {
// Multi-line link
this.fillBottomLineAtCells(e.x1, e.y1, e.cols - e.x1);
for (let y = e.y1 + 1; y < e.y2; y++) {
this.fillBottomLineAtCells(0, y, e.cols);
}
this.fillBottomLineAtCells(0, e.y2, e.x2);
}
this._state = e;

@@ -46,0 +59,0 @@ }

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

import { CHAR_DATA_WIDTH_INDEX, CHAR_DATA_CHAR_INDEX } from '../Buffer';
import { TextRenderLayer } from './TextRenderLayer';

@@ -12,3 +11,2 @@ import { SelectionRenderLayer } from './SelectionRenderLayer';

import { ColorManager } from './ColorManager';
import { BaseRenderLayer } from './BaseRenderLayer';
import { IRenderLayer, IColorSet, IRenderer, IRenderDimensions } from './Types';

@@ -36,3 +34,4 @@ import { ITerminal } from '../Types';

super();
this.colorManager = new ColorManager();
const allowTransparency = this._terminal.options.allowTransparency;
this.colorManager = new ColorManager(document, allowTransparency);
if (theme) {

@@ -43,3 +42,3 @@ this.colorManager.setTheme(theme);

this._renderLayers = [
new TextRenderLayer(this._terminal.screenElement, 0, this.colorManager.colors, this._terminal.options.allowTransparency),
new TextRenderLayer(this._terminal.screenElement, 0, this.colorManager.colors, allowTransparency),
new SelectionRenderLayer(this._terminal.screenElement, 1, this.colorManager.colors),

@@ -91,3 +90,3 @@ new LinkRenderLayer(this._terminal.screenElement, 2, this.colorManager.colors, this._terminal),

this._devicePixelRatio = devicePixelRatio;
this.onResize(this._terminal.cols, this._terminal.rows, true);
this.onResize(this._terminal.cols, this._terminal.rows);
}

@@ -114,3 +113,3 @@ }

public onResize(cols: number, rows: number, didCharSizeChange: boolean): void {
public onResize(cols: number, rows: number): void {
// Update character and canvas dimensions

@@ -120,3 +119,3 @@ this._updateDimensions();

// Resize all render layers
this._renderLayers.forEach(l => l.resize(this._terminal, this.dimensions, didCharSizeChange));
this._renderLayers.forEach(l => l.resize(this._terminal, this.dimensions));

@@ -141,3 +140,3 @@ // Force a refresh

public onCharSizeChanged(): void {
this.onResize(this._terminal.cols, this._terminal.rows, true);
this.onResize(this._terminal.cols, this._terminal.rows);
}

@@ -144,0 +143,0 @@

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

import { IBuffer, ICharMeasure, ITerminal } from '../Types';
import { CHAR_DATA_ATTR_INDEX } from '../Buffer';
import { GridCache } from './GridCache';
import { FLAGS, IColorSet, IRenderDimensions } from './Types';
import { ITerminal } from '../Types';
import { IColorSet, IRenderDimensions } from './Types';
import { BaseRenderLayer } from './BaseRenderLayer';

@@ -24,4 +22,4 @@

public resize(terminal: ITerminal, dim: IRenderDimensions, charSizeChanged: boolean): void {
super.resize(terminal, dim, charSizeChanged);
public resize(terminal: ITerminal, dim: IRenderDimensions): void {
super.resize(terminal, dim);
// Resizing the canvas discards the contents of the canvas so clear state

@@ -72,3 +70,3 @@ this._state = {

const startRowEndCol = viewportCappedStartRow === viewportCappedEndRow ? end[0] : terminal.cols;
this._ctx.fillStyle = this._colors.selection;
this._ctx.fillStyle = this._colors.selection.css;
this.fillCells(startCol, viewportCappedStartRow, startRowEndCol - startCol, 1);

@@ -75,0 +73,0 @@

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

import { FLAGS, IColorSet, IRenderDimensions } from './Types';
import { CharData, IBuffer, ICharMeasure, ITerminal } from '../Types';
import { CharData, ITerminal } from '../Types';
import { INVERTED_DEFAULT_COLOR } from './atlas/Types';
import { GridCache } from './GridCache';
import { BaseRenderLayer, INVERTED_DEFAULT_COLOR } from './BaseRenderLayer';
import { BaseRenderLayer } from './BaseRenderLayer';

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

*/
const OVERLAP_OWNED_CHAR_DATA: CharData = [null, '', 0, -1];
// const OVERLAP_OWNED_CHAR_DATA: CharData = [null, '', 0, -1];

@@ -32,4 +33,4 @@ export class TextRenderLayer extends BaseRenderLayer {

public resize(terminal: ITerminal, dim: IRenderDimensions, charSizeChanged: boolean): void {
super.resize(terminal, dim, charSizeChanged);
public resize(terminal: ITerminal, dim: IRenderDimensions): void {
super.resize(terminal, dim);

@@ -163,3 +164,3 @@ // Clear the character width cache if the font or width has changed

this._ctx.save();
this._ctx.fillStyle = (bg === INVERTED_DEFAULT_COLOR ? this._colors.foreground : this._colors.ansi[bg]);
this._ctx.fillStyle = (bg === INVERTED_DEFAULT_COLOR ? this._colors.foreground.css : this._colors.ansi[bg].css);
this.fillCells(x, y, width, 1);

@@ -180,8 +181,8 @@ this._ctx.restore();

if (fg === INVERTED_DEFAULT_COLOR) {
this._ctx.fillStyle = this._colors.background;
this._ctx.fillStyle = this._colors.background.css;
} else if (fg < 256) {
// 256 color support
this._ctx.fillStyle = this._colors.ansi[fg];
this._ctx.fillStyle = this._colors.ansi[fg].css;
} else {
this._ctx.fillStyle = this._colors.foreground;
this._ctx.fillStyle = this._colors.foreground.css;
}

@@ -246,11 +247,11 @@ this.fillBottomLineAtCells(x, y);

*/
private _clearChar(x: number, y: number): void {
let colsToClear = 1;
// Clear the adjacent character if it was wide
const state = this._state.cache[x][y];
if (state && state[CHAR_DATA_WIDTH_INDEX] === 2) {
colsToClear = 2;
}
this.clearCells(x, y, colsToClear, 1);
}
// private _clearChar(x: number, y: number): void {
// let colsToClear = 1;
// // Clear the adjacent character if it was wide
// const state = this._state.cache[x][y];
// if (state && state[CHAR_DATA_WIDTH_INDEX] === 2) {
// colsToClear = 2;
// }
// this.clearCells(x, y, colsToClear, 1);
// }
}

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

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

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

onWindowResize(devicePixelRatio: number): void;
onResize(cols: number, rows: number, didCharSizeChange: boolean): void;
onResize(cols: number, rows: number): void;
onCharSizeChanged(): void;

@@ -44,10 +45,4 @@ onBlur(): void;

export interface IColorSet {
foreground: string;
background: string;
cursor: string;
cursorAccent: string;
selection: string;
ansi: string[];
}
// TODO: We should probably rewrite the imports for IColorSet, but there's a lot of them
export { IColorSet };

@@ -109,3 +104,3 @@ export interface IRenderDimensions {

*/
resize(terminal: ITerminal, dim: IRenderDimensions, charSizeChanged: boolean): void;
resize(terminal: ITerminal, dim: IRenderDimensions): void;

@@ -112,0 +107,0 @@ /**

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

import jsdom = require('jsdom');
import { assert } from 'chai';
import { CharMeasure } from './utils/CharMeasure';
import { CircularList } from './utils/CircularList';
import { SelectionManager } from './SelectionManager';
import { SelectionModel } from './SelectionModel';
import { BufferSet } from './BufferSet';
import { LineData, CharData, ITerminal, ICircularList, IBuffer } from './Types';
import { LineData, CharData, ITerminal, IBuffer } from './Types';
import { MockTerminal } from './utils/TestUtils.test';

@@ -41,15 +39,7 @@

describe('SelectionManager', () => {
let dom: jsdom.JSDOM;
let window: Window;
let document: Document;
let terminal: ITerminal;
let buffer: IBuffer;
let rowContainer: HTMLElement;
let selectionManager: TestSelectionManager;
beforeEach(() => {
dom = new jsdom.JSDOM('');
window = dom.window;
document = window.document;
terminal = new TestMockTerminal();

@@ -329,2 +319,41 @@ terminal.cols = 80;

describe('selectLines', () => {
it('should select a single line', () => {
buffer.lines.length = 3;
buffer.lines.set(0, stringToRow('1'));
buffer.lines.set(1, stringToRow('2'));
buffer.lines.set(2, stringToRow('3'));
selectionManager.selectLines(1, 1);
assert.deepEqual(selectionManager.model.finalSelectionStart, [0, 1]);
assert.deepEqual(selectionManager.model.finalSelectionEnd, [terminal.cols, 1]);
});
it('should select multiple lines', () => {
buffer.lines.length = 5;
buffer.lines.set(0, stringToRow('1'));
buffer.lines.set(1, stringToRow('2'));
buffer.lines.set(2, stringToRow('3'));
buffer.lines.set(3, stringToRow('4'));
buffer.lines.set(4, stringToRow('5'));
selectionManager.selectLines(1, 3);
assert.deepEqual(selectionManager.model.finalSelectionStart, [0, 1]);
assert.deepEqual(selectionManager.model.finalSelectionEnd, [terminal.cols, 3]);
});
it('should select the to the start when requesting a negative row', () => {
buffer.lines.length = 2;
buffer.lines.set(0, stringToRow('1'));
buffer.lines.set(1, stringToRow('2'));
selectionManager.selectLines(-1, 0);
assert.deepEqual(selectionManager.model.finalSelectionStart, [0, 0]);
assert.deepEqual(selectionManager.model.finalSelectionEnd, [terminal.cols, 0]);
});
it('should select the to the end when requesting beyond the final row', () => {
buffer.lines.length = 2;
buffer.lines.set(0, stringToRow('1'));
buffer.lines.set(1, stringToRow('2'));
selectionManager.selectLines(1, 2);
assert.deepEqual(selectionManager.model.finalSelectionStart, [0, 1]);
assert.deepEqual(selectionManager.model.finalSelectionEnd, [terminal.cols, 1]);
});
});
describe('hasSelection', () => {

@@ -331,0 +360,0 @@ it('should return whether there is a selection', () => {

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

import { ITerminal, ICircularList, ISelectionManager, IBuffer, LineData, CharData, XtermListener } from './Types';
import { ITerminal, ISelectionManager, IBuffer, CharData, XtermListener } from './Types';
import { MouseHelper } from './utils/MouseHelper';
import * as Browser from './shared/utils/Browser';
import { CharMeasure } from './utils/CharMeasure';
import { CircularList } from './utils/CircularList';
import { EventEmitter } from './EventEmitter';

@@ -297,2 +296,12 @@ import { SelectionModel } from './SelectionModel';

public selectLines(start: number, end: number): void {
this._model.clearSelection();
start = Math.max(start, 0);
end = Math.min(end, this._terminal.buffer.lines.length - 1);
this._model.selectionStart = [0, start];
this._model.selectionEnd = [this._terminal.cols, end];
this.refresh();
this._terminal.emit('selection');
}
/**

@@ -299,0 +308,0 @@ * Handle the buffer being trimmed, adjust the selection position.

@@ -21,5 +21,2 @@ /**

describe('SelectionManager', () => {
let window: Window;
let document: Document;
let terminal: ITerminal;

@@ -26,0 +23,0 @@ let model: TestSelectionModel;

@@ -31,3 +31,3 @@ /**

const context = this._audioContext;
this._audioContext.decodeAudioData(this.base64ToArrayBuffer(this.removeMimeType(this._terminal.options.bellSound)), (buffer) => {
this._audioContext.decodeAudioData(this._base64ToArrayBuffer(this._removeMimeType(this._terminal.options.bellSound)), (buffer) => {
bellAudioSource.buffer = buffer;

@@ -42,3 +42,3 @@ bellAudioSource.connect(context.destination);

private base64ToArrayBuffer(base64: string): ArrayBuffer {
private _base64ToArrayBuffer(base64: string): ArrayBuffer {
const binaryString = window.atob(base64);

@@ -55,3 +55,3 @@ const len = binaryString.length;

private removeMimeType(dataURI: string): string {
private _removeMimeType(dataURI: string): string {
// Split the input to get the mime-type and the data itself

@@ -58,0 +58,0 @@ const splitUri = dataURI.split(',');

@@ -128,3 +128,3 @@ /**

xterm.writeBuffer.push(fromPty);
xterm.innerWrite();
xterm._innerWrite();

@@ -131,0 +131,0 @@ let fromEmulator = terminalToString(xterm);

@@ -23,16 +23,17 @@ /**

let term: TestTerminal;
const termOptions = {
cols: INIT_COLS,
rows: INIT_ROWS
};
beforeEach(() => {
term = new TestTerminal({
cols: INIT_COLS,
rows: INIT_ROWS
});
term = new TestTerminal(termOptions);
term.refresh = () => {};
(<any>term).renderer = new MockRenderer();
term.viewport = new MockViewport();
(<any>term).compositionHelper = new MockCompositionHelper();
(<any>term)._compositionHelper = new MockCompositionHelper();
// Force synchronous writes
term.write = (data) => {
term.writeBuffer.push(data);
(<any>term).innerWrite();
(<any>term)._innerWrite();
};

@@ -47,2 +48,11 @@ (<any>term).element = {

it('should not mutate the options parameter', () => {
term.setOption('cols', 1000);
assert.deepEqual(termOptions, {
cols: INIT_COLS,
rows: INIT_ROWS
});
});
it('should apply addons with Terminal.applyAddon', () => {

@@ -263,2 +273,30 @@ Terminal.applyAddon(attach);

describe('scrollToLine', () => {
let startYDisp;
beforeEach(() => {
for (let i = 0; i < term.rows * 3; i++) {
term.writeln('test');
}
startYDisp = (term.rows * 2) + 1;
});
it('should scroll to requested line', () => {
assert.equal(term.buffer.ydisp, startYDisp);
term.scrollToLine(0);
assert.equal(term.buffer.ydisp, 0);
term.scrollToLine(10);
assert.equal(term.buffer.ydisp, 10);
term.scrollToLine(startYDisp);
assert.equal(term.buffer.ydisp, startYDisp);
term.scrollToLine(20);
assert.equal(term.buffer.ydisp, 20);
});
it('should not scroll beyond boundary lines', () => {
assert.equal(term.buffer.ydisp, startYDisp);
term.scrollToLine(-1);
assert.equal(term.buffer.ydisp, 0);
term.scrollToLine(startYDisp + 1);
assert.equal(term.buffer.ydisp, startYDisp);
});
});
describe('keyDown', () => {

@@ -265,0 +303,0 @@ it('should scroll down, when a key is pressed and terminal is scrolled up', () => {

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

import { Terminal as PublicTerminal, ITerminalOptions as IPublicTerminalOptions, IEventEmitter as IPublicEventEmitter, IEventEmitter } from 'xterm';
import { Terminal as PublicTerminal, ITerminalOptions as IPublicTerminalOptions, IEventEmitter } from 'xterm';
import { IColorSet, IRenderer } from './renderer/Types';

@@ -88,2 +88,3 @@ import { IMouseZoneManager } from './input/Types';

setOption(key: string, value: any): void;
tabSet(): void;
}

@@ -94,2 +95,3 @@

syncScrollArea(): void;
getLinesScrolled(ev: WheelEvent): number;
onWheel(ev: WheelEvent): void;

@@ -178,5 +180,7 @@ onTouchStart(ev: TouchEvent): void;

export interface ILinkHoverEvent {
x: number;
y: number;
length: number;
x1: number;
y1: number;
x2: number;
y2: number;
cols: number;
}

@@ -280,3 +284,2 @@

maxLength: number;
forEach: (callbackfn: (value: T, index: number) => void) => void;

@@ -283,0 +286,0 @@ get(index: number): T;

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

import jsdom = require('jsdom');
import { ICharMeasure, ITerminal } from '../Types';
import { ICharMeasure } from '../Types';
import { assert } from 'chai';

@@ -10,0 +10,0 @@ import { CharMeasure } from './CharMeasure';

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

import { ICharMeasure, ITerminal, ITerminalOptions } from '../Types';
import { ICharMeasure, ITerminalOptions } from '../Types';
import { EventEmitter } from '../EventEmitter';

@@ -27,6 +27,3 @@

this._measureElement = this._document.createElement('span');
this._measureElement.style.position = 'absolute';
this._measureElement.style.top = '0';
this._measureElement.style.left = '-9999em';
this._measureElement.style.lineHeight = 'normal';
this._measureElement.classList.add('xterm-char-measure-element');
this._measureElement.textContent = 'W';

@@ -46,3 +43,3 @@ this._measureElement.setAttribute('aria-hidden', 'true');

public measure(options: ITerminalOptions): void {
this._measureElement.style.fontFamily = options.fontFamily;
this._measureElement.style.fontFamily = options.fontFamily;
this._measureElement.style.fontSize = `${options.fontSize}px`;

@@ -61,3 +58,2 @@ const geometry = this._measureElement.getBoundingClientRect();

}
}

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

class TestCircularList<T> extends CircularList<T> {
public get array(): T[] { return this._array; }
}
describe('CircularList', () => {

@@ -15,0 +11,0 @@ describe('push', () => {

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

public get forEach(): (callbackfn: (value: T, index: number) => void) => void {
return (callbackfn: (value: T, index: number) => void) => {
let i = 0;
let length = this.length;
for (let i = 0; i < length; i++) {
callbackfn(this.get(i), i);
}
};
}
/**

@@ -73,0 +63,0 @@ * Gets the value at an index.

@@ -10,5 +10,15 @@ /**

import * as Browser from '../shared/utils/Browser';
import { ITheme, IDisposable } from 'xterm';
import { ITheme, IDisposable, IMarker } from 'xterm';
export class MockTerminal implements ITerminal {
markers: IMarker[];
addMarker(cursorYOffset: number): IMarker {
throw new Error('Method not implemented.');
}
selectLines(start: number, end: number): void {
throw new Error('Method not implemented.');
}
scrollToLine(line: number): void {
throw new Error('Method not implemented.');
}
static string: any;

@@ -273,2 +283,5 @@ getOption(key: any): any {

}
tabSet(): void {
throw new Error('Method not implemented.');
}
}

@@ -316,3 +329,3 @@

setTheme(theme: ITheme): IColorSet { return <IColorSet>{}; }
onResize(cols: number, rows: number, didCharSizeChange: boolean): void {}
onResize(cols: number, rows: number): void {}
onCharSizeChanged(): void {}

@@ -344,2 +357,5 @@ onBlur(): void {}

syncScrollArea(): void { }
getLinesScrolled(ev: WheelEvent): number {
throw new Error('Method not implemented.');
}
}

@@ -346,0 +362,0 @@

@@ -18,20 +18,25 @@ /**

public scrollBarWidth: number = 0;
private currentRowHeight: number = 0;
private lastRecordedBufferLength: number = 0;
private lastRecordedViewportHeight: number = 0;
private lastRecordedBufferHeight: number = 0;
private lastTouchY: number;
private _currentRowHeight: number = 0;
private _lastRecordedBufferLength: number = 0;
private _lastRecordedViewportHeight: number = 0;
private _lastRecordedBufferHeight: number = 0;
private _lastTouchY: number;
// Stores a partial line amount when scrolling, this is used to keep track of how much of a line
// is scrolled so we can "scroll" over partial lines and feel natural on touchpads. This is a
// quick fix and could have a more robust solution in place that reset the value when needed.
private _wheelPartialScroll: number = 0;
/**
* Creates a new Viewport.
* @param terminal The terminal this viewport belongs to.
* @param viewportElement The DOM element acting as the viewport.
* @param scrollArea The DOM element acting as the scroll area.
* @param charMeasure A DOM element used to measure the character size of. the terminal.
* @param _terminal The terminal this viewport belongs to.
* @param _viewportElement The DOM element acting as the viewport.
* @param _scrollArea The DOM element acting as the scroll area.
* @param _charMeasure A DOM element used to measure the character size of. the terminal.
*/
constructor(
private terminal: ITerminal,
private viewportElement: HTMLElement,
private scrollArea: HTMLElement,
private charMeasure: CharMeasure
private _terminal: ITerminal,
private _viewportElement: HTMLElement,
private _scrollArea: HTMLElement,
private _charMeasure: CharMeasure
) {

@@ -41,4 +46,4 @@ // Measure the width of the scrollbar. If it is 0 we can assume it's an OSX overlay scrollbar.

// therefore we account for a standard amount to make it visible
this.scrollBarWidth = (this.viewportElement.offsetWidth - this.scrollArea.offsetWidth) || FALLBACK_SCROLL_BAR_WIDTH;
this.viewportElement.addEventListener('scroll', this.onScroll.bind(this));
this.scrollBarWidth = (this._viewportElement.offsetWidth - this._scrollArea.offsetWidth) || FALLBACK_SCROLL_BAR_WIDTH;
this._viewportElement.addEventListener('scroll', this._onScroll.bind(this));

@@ -50,3 +55,3 @@ // Perform this async to ensure the CharMeasure is ready.

public onThemeChanged(colors: IColorSet): void {
this.viewportElement.style.backgroundColor = colors.background;
this._viewportElement.style.backgroundColor = colors.background.css;
}

@@ -58,10 +63,10 @@

*/
private refresh(): void {
if (this.charMeasure.height > 0) {
this.currentRowHeight = this.terminal.renderer.dimensions.scaledCellHeight / window.devicePixelRatio;
this.lastRecordedViewportHeight = this.viewportElement.offsetHeight;
const newBufferHeight = Math.round(this.currentRowHeight * this.lastRecordedBufferLength) + (this.lastRecordedViewportHeight - this.terminal.renderer.dimensions.canvasHeight);
if (this.lastRecordedBufferHeight !== newBufferHeight) {
this.lastRecordedBufferHeight = newBufferHeight;
this.scrollArea.style.height = this.lastRecordedBufferHeight + 'px';
private _refresh(): void {
if (this._charMeasure.height > 0) {
this._currentRowHeight = this._terminal.renderer.dimensions.scaledCellHeight / window.devicePixelRatio;
this._lastRecordedViewportHeight = this._viewportElement.offsetHeight;
const newBufferHeight = Math.round(this._currentRowHeight * this._lastRecordedBufferLength) + (this._lastRecordedViewportHeight - this._terminal.renderer.dimensions.canvasHeight);
if (this._lastRecordedBufferHeight !== newBufferHeight) {
this._lastRecordedBufferHeight = newBufferHeight;
this._scrollArea.style.height = this._lastRecordedBufferHeight + 'px';
}

@@ -75,13 +80,13 @@ }

public syncScrollArea(): void {
if (this.lastRecordedBufferLength !== this.terminal.buffer.lines.length) {
if (this._lastRecordedBufferLength !== this._terminal.buffer.lines.length) {
// If buffer height changed
this.lastRecordedBufferLength = this.terminal.buffer.lines.length;
this.refresh();
} else if (this.lastRecordedViewportHeight !== (<any>this.terminal).renderer.dimensions.canvasHeight) {
this._lastRecordedBufferLength = this._terminal.buffer.lines.length;
this._refresh();
} else if (this._lastRecordedViewportHeight !== (<any>this._terminal).renderer.dimensions.canvasHeight) {
// If viewport height changed
this.refresh();
this._refresh();
} else {
// If size has changed, refresh viewport
if (this.terminal.renderer.dimensions.scaledCellHeight / window.devicePixelRatio !== this.currentRowHeight) {
this.refresh();
if (this._terminal.renderer.dimensions.scaledCellHeight / window.devicePixelRatio !== this._currentRowHeight) {
this._refresh();
}

@@ -91,5 +96,5 @@ }

// Sync scrollTop
const scrollTop = this.terminal.buffer.ydisp * this.currentRowHeight;
if (this.viewportElement.scrollTop !== scrollTop) {
this.viewportElement.scrollTop = scrollTop;
const scrollTop = this._terminal.buffer.ydisp * this._currentRowHeight;
if (this._viewportElement.scrollTop !== scrollTop) {
this._viewportElement.scrollTop = scrollTop;
}

@@ -103,12 +108,12 @@ }

*/
private onScroll(ev: Event): void {
private _onScroll(ev: Event): void {
// Don't attempt to scroll if the element is not visible, otherwise scrollTop will be corrupt
// which causes the terminal to scroll the buffer to the top
if (!this.viewportElement.offsetParent) {
if (!this._viewportElement.offsetParent) {
return;
}
const newRow = Math.round(this.viewportElement.scrollTop / this.currentRowHeight);
const diff = newRow - this.terminal.buffer.ydisp;
this.terminal.scrollLines(diff, true);
const newRow = Math.round(this._viewportElement.scrollTop / this._currentRowHeight);
const diff = newRow - this._terminal.buffer.ydisp;
this._terminal.scrollLines(diff, true);
}

@@ -123,19 +128,52 @@

public onWheel(ev: WheelEvent): void {
if (ev.deltaY === 0) {
// Do nothing if it's not a vertical scroll event
const amount = this._getPixelsScrolled(ev);
if (amount === 0) {
return;
}
this._viewportElement.scrollTop += amount;
// Prevent the page from scrolling when the terminal scrolls
ev.preventDefault();
}
private _getPixelsScrolled(ev: WheelEvent): number {
// Do nothing if it's not a vertical scroll event
if (ev.deltaY === 0) {
return 0;
}
// Fallback to WheelEvent.DOM_DELTA_PIXEL
let multiplier = 1;
let amount = ev.deltaY;
if (ev.deltaMode === WheelEvent.DOM_DELTA_LINE) {
multiplier = this.currentRowHeight;
amount *= this._currentRowHeight;
} else if (ev.deltaMode === WheelEvent.DOM_DELTA_PAGE) {
multiplier = this.currentRowHeight * this.terminal.rows;
amount *= this._currentRowHeight * this._terminal.rows;
}
this.viewportElement.scrollTop += ev.deltaY * multiplier;
// Prevent the page from scrolling when the terminal scrolls
ev.preventDefault();
return amount;
}
/**
* Gets the number of pixels scrolled by the mouse event taking into account what type of delta
* is being used.
* @param ev The mouse wheel event.
*/
public getLinesScrolled(ev: WheelEvent): number {
// Do nothing if it's not a vertical scroll event
if (ev.deltaY === 0) {
return 0;
}
// Fallback to WheelEvent.DOM_DELTA_LINE
let amount = ev.deltaY;
if (ev.deltaMode === WheelEvent.DOM_DELTA_PIXEL) {
amount /= this._currentRowHeight + 0.0; // Prevent integer division
this._wheelPartialScroll += amount;
amount = Math.floor(Math.abs(this._wheelPartialScroll)) * (this._wheelPartialScroll > 0 ? 1 : -1);
this._wheelPartialScroll %= 1;
} else if (ev.deltaMode === WheelEvent.DOM_DELTA_PAGE) {
amount *= this._terminal.rows;
}
return amount;
}
/**
* Handles the touchstart event, recording the touch occurred.

@@ -145,3 +183,3 @@ * @param ev The touch event.

public onTouchStart(ev: TouchEvent): void {
this.lastTouchY = ev.touches[0].pageY;
this._lastTouchY = ev.touches[0].pageY;
}

@@ -154,10 +192,10 @@

public onTouchMove(ev: TouchEvent): void {
let deltaY = this.lastTouchY - ev.touches[0].pageY;
this.lastTouchY = ev.touches[0].pageY;
let deltaY = this._lastTouchY - ev.touches[0].pageY;
this._lastTouchY = ev.touches[0].pageY;
if (deltaY === 0) {
return;
}
this.viewportElement.scrollTop += deltaY;
this._viewportElement.scrollTop += deltaY;
ev.preventDefault();
}
}

@@ -8,3 +8,4 @@ {

"sourceMap": true,
"removeComments": true
"removeComments": true,
"noUnusedLocals": true
},

@@ -11,0 +12,0 @@ "include": [

@@ -46,2 +46,14 @@ {

],
"trailing-comma": [
true,
{
"multiline": {
"objects": "never",
"arrays": "never",
"functions": "never",
"typeLiterals": "ignore"
},
"esSpecCompliant": true
}
],
"triple-equals": [

@@ -48,0 +60,0 @@ true,

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

allowTransparency?: boolean;
/**

@@ -59,3 +60,3 @@ * A data uri of the sound to use for the bell (needs bellStyle = 'sound').

* Whether to enable the rendering of bold text.
*
*
* @deprecated Use fontWeight and fontWeightBold instead.

@@ -240,2 +241,8 @@ */

export interface IMarker extends IDisposable {
readonly id: number;
readonly isDisposed: boolean;
readonly line: number;
}
export interface ILocalizableStrings {

@@ -272,2 +279,8 @@ blankLine: string;

/**
* (EXPERIMENTAL) Get all markers registered against the buffer. If the alt
* buffer is active this will always return [].
*/
markers: IMarker[];
/**
* Natural language strings that can be localized.

@@ -411,2 +424,9 @@ */

/**
* (EXPERIMENTAL) Adds a marker to the normal buffer and returns it. If the
* alt buffer is active, undefined is returned.
* @param cursorYOffset The y position offset of the marker from the cursor.
*/
addMarker(cursorYOffset: number): IMarker;
/**
* Gets whether the terminal has an active selection.

@@ -433,2 +453,9 @@ */

/**
* Selects text in the buffer between 2 lines.
* @param start The 0-based line index to select from (inclusive).
* @param end The 0-based line index to select to (inclusive).
*/
selectLines(start: number, end: number): void;
/**
* Destroys the terminal and detaches it from the DOM.

@@ -461,2 +488,8 @@ */

/**
* Scrolls to a line within the buffer.
* @param line The 0-based line index to scroll to.
*/
scrollToLine(line: number): void;
/**
* Clear the entire buffer, making the prompt line the new first line.

@@ -463,0 +496,0 @@ */

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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

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 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

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 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