malwoden
Version:
   
1,000 lines (985 loc) • 172 kB
JavaScript
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/* global Reflect, Promise */
var extendStatics = function(d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
function __extends(d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
}
var __assign = function() {
__assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
function __awaiter(thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
}
function __generator(thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
}
var Color = /** @class */ (function () {
function Color(r, g, b) {
this.r = r;
this.g = g;
this.b = b;
}
Color.prototype.isEqual = function (color) {
return this.r === color.r && this.g === color.g && this.b === color.b;
};
Color.prototype.cssColor = function () {
return "rgb(" + this.r + "," + this.g + "," + this.b + ")";
};
Color.prototype.sanitizeElement = function (rgb) {
return Math.round(Math.min(Math.max(rgb, 0), 255));
};
Color.prototype.add = function (other, fractionOther) {
if (fractionOther === void 0) { fractionOther = 1; }
return new Color(this.sanitizeElement(this.r + other.r * fractionOther), this.sanitizeElement(this.g + other.g * fractionOther), this.sanitizeElement(this.b + other.b * fractionOther));
};
Color.prototype.blend = function (other, fractionOther) {
if (fractionOther === void 0) { fractionOther = 0.5; }
var fractionThis = 1.0 - fractionOther;
return new Color(this.sanitizeElement(this.r * fractionThis + other.r * fractionOther), this.sanitizeElement(this.g * fractionThis + other.g * fractionOther), this.sanitizeElement(this.b * fractionThis + other.b * fractionOther));
};
Color.prototype.blendPercent = function (other, percentOther) {
return this.blend(other, percentOther / 100);
};
Color.prototype.toGrayscale = function () {
var total = this.r + this.g + this.b;
return new Color(this.sanitizeElement(total / 3), this.sanitizeElement(total / 3), this.sanitizeElement(total / 3));
};
// CSS Extended Color Palette
// https://en.wikipedia.org/wiki/Web_colors
// Pink Colors
Color.MediumVioletRed = new Color(199, 21, 133);
Color.DeepPink = new Color(255, 20, 147);
Color.PaleVioletRed = new Color(219, 112, 147);
Color.HotPink = new Color(255, 105, 180);
Color.LightPink = new Color(255, 182, 193);
Color.Pink = new Color(255, 192, 203);
// Red Colors
Color.DarkRed = new Color(139, 0, 0);
Color.Red = new Color(255, 0, 0);
Color.Firebrick = new Color(178, 34, 34);
Color.Crimson = new Color(220, 20, 60);
Color.IndianRed = new Color(205, 92, 92);
Color.LightCoral = new Color(240, 128, 128);
Color.Salmon = new Color(250, 128, 114);
Color.DarkSalmon = new Color(233, 150, 122);
Color.LightSalmon = new Color(255, 160, 122);
// Orange Colors
Color.OrangeRed = new Color(255, 69, 0);
Color.Tomato = new Color(255, 99, 71);
Color.DarkOrange = new Color(255, 140, 0);
Color.Coral = new Color(255, 127, 80);
Color.Orange = new Color(255, 165, 0);
// Yellow Colors
Color.DarkKhaki = new Color(189, 183, 107);
Color.Gold = new Color(255, 215, 0);
Color.Khaki = new Color(240, 230, 140);
Color.PeachPuff = new Color(255, 218, 185);
Color.Yellow = new Color(255, 255, 0);
Color.PaleGoldenrod = new Color(238, 232, 170);
Color.Moccasin = new Color(255, 228, 181);
Color.PapayaWhip = new Color(255, 239, 213);
Color.LightGoldenrodYellow = new Color(250, 250, 210);
Color.LemonChiffon = new Color(255, 250, 205);
Color.LightYellow = new Color(255, 255, 224);
// Brown Colors
Color.Maroon = new Color(128, 0, 0);
Color.Brown = new Color(165, 42, 42);
Color.SaddleBrown = new Color(139, 69, 19);
Color.Sienna = new Color(160, 82, 45);
Color.Chocolate = new Color(210, 105, 30);
Color.DarkGoldenrod = new Color(184, 134, 11);
Color.Peru = new Color(205, 133, 63);
Color.RosyBrown = new Color(188, 143, 143);
Color.Goldenrod = new Color(218, 165, 32);
Color.SandyBrown = new Color(244, 164, 96);
Color.Tan = new Color(210, 180, 140);
Color.Burlywood = new Color(222, 184, 135);
Color.Wheat = new Color(245, 222, 179);
Color.NavajoWhite = new Color(255, 222, 173);
Color.Bisque = new Color(255, 228, 196);
Color.BlanchedAlmond = new Color(255, 235, 205);
Color.Cornsilk = new Color(255, 248, 220);
// Purple/Violet/Magenta Colors
Color.Indigo = new Color(75, 0, 130);
Color.Purple = new Color(128, 0, 128);
Color.DarkMagenta = new Color(139, 9, 139);
Color.DarkViolet = new Color(148, 0, 211);
Color.DarkSlateBlue = new Color(72, 61, 129);
Color.BlueViolet = new Color(138, 43, 226);
Color.DarkOrchid = new Color(153, 50, 204);
Color.Fuchsia = new Color(255, 0, 255);
Color.Magenta = new Color(255, 0, 255); // Alias Fuchsia
Color.SlateBlue = new Color(106, 90, 205);
Color.MediumSlateBlue = new Color(123, 104, 238);
Color.MediumOrchid = new Color(186, 85, 211);
Color.MediumPurple = new Color(147, 112, 219);
Color.Orchid = new Color(218, 11, 214);
Color.Violet = new Color(238, 130, 238);
Color.Plum = new Color(221, 160, 221);
Color.Thistle = new Color(216, 191, 216);
Color.Lavender = new Color(230, 230, 250);
// White Colors
Color.MistyRose = new Color(255, 228, 225);
Color.AntiqueWhite = new Color(250, 235, 215);
Color.Linen = new Color(250, 240, 230);
Color.Beige = new Color(245, 245, 220);
Color.WhiteSmoke = new Color(245, 245, 245);
Color.LavenderBlush = new Color(255, 240, 245);
Color.OldLace = new Color(253, 245, 230);
Color.AliceBlue = new Color(240, 248, 255);
Color.Seashell = new Color(255, 245, 238);
Color.GhostWhite = new Color(248, 248, 255);
Color.Honeydew = new Color(240, 255, 240);
Color.FloralWhite = new Color(255, 250, 240);
Color.Azure = new Color(240, 255, 255);
Color.MintCream = new Color(245, 255, 250);
Color.Snow = new Color(255, 250, 250);
Color.Ivory = new Color(255, 255, 240);
Color.White = new Color(255, 255, 255);
// Grey + Black Colors
Color.Black = new Color(0, 0, 0);
Color.DarkSlateGray = new Color(47, 79, 79);
Color.DimGray = new Color(105, 105, 105);
Color.SlateGray = new Color(112, 128, 144);
Color.Gray = new Color(128, 128, 128);
Color.LightSlateGray = new Color(119, 136, 153);
Color.DarkGray = new Color(169, 169, 169);
Color.Silver = new Color(192, 192, 192);
Color.LightGray = new Color(211, 211, 211);
Color.Gainsboro = new Color(220, 220, 220);
// Green Colors
Color.DarkGreen = new Color(0, 100, 0);
Color.Green = new Color(0, 128, 0);
Color.DarkOliveGreen = new Color(85, 107, 47);
Color.ForestGreen = new Color(34, 139, 34);
Color.SeaGreen = new Color(46, 139, 87);
Color.Olive = new Color(128, 128, 0);
Color.OliveDrab = new Color(107, 142, 35);
Color.MediumSeaGreen = new Color(60, 179, 113);
Color.LimeGreen = new Color(50, 205, 50);
Color.Lime = new Color(0, 255, 0);
Color.SpringGreen = new Color(0, 255, 127);
Color.MediumSpringGreen = new Color(0, 250, 154);
Color.DarkSeaGreen = new Color(143, 188, 143);
Color.MediumAquamarine = new Color(102, 205, 170);
Color.YellowGreen = new Color(154, 205, 50);
Color.LawnGreen = new Color(124, 252, 0);
Color.Chartreuse = new Color(127, 255, 0);
Color.LightGreen = new Color(133, 238, 144);
Color.GreenYellow = new Color(173, 255, 47);
Color.PaleGreen = new Color(152, 251, 152);
// Cyan Colors
Color.Teal = new Color(0, 128, 128);
Color.DarkCyan = new Color(0, 139, 139);
Color.LightSeaGreen = new Color(32, 178, 170);
Color.CadetBlue = new Color(95, 158, 160);
Color.DarkTurquoise = new Color(0, 206, 209);
Color.MediumTurquoise = new Color(72, 209, 204);
Color.Turquoise = new Color(64, 224, 208);
Color.Aqua = new Color(0, 255, 255);
Color.Cyan = new Color(0, 255, 255);
Color.Aquamarine = new Color(127, 255, 212);
Color.PaleTurquoise = new Color(175, 238, 238);
Color.LightCyan = new Color(244, 255, 255);
// Blue Colors
Color.Navy = new Color(0, 0, 128);
Color.DarkBlue = new Color(0, 0, 139);
Color.MediumBlue = new Color(0, 0, 205);
Color.Blue = new Color(0, 0, 225);
Color.MidnightBlue = new Color(25, 25, 112);
Color.RoyalBlue = new Color(65, 105, 225);
Color.SteelBlue = new Color(70, 130, 180);
Color.DodgerBlue = new Color(30, 144, 255);
Color.DeepSkyBlue = new Color(0, 191, 255);
Color.CornflowerBlue = new Color(100, 149, 237);
Color.SkyBlue = new Color(135, 206, 235);
Color.LightSkyBlue = new Color(135, 206, 250);
Color.LightSteelBlue = new Color(176, 196, 222);
Color.LightBlue = new Color(173, 216, 230);
Color.PowderBlue = new Color(176, 224, 230);
return Color;
}());
/**
* Represents a glyph to be drawn to the screen.
*/
var Glyph = /** @class */ (function () {
/**
* Creates a Glyph from a single character.
*
* @param char - A single character.
* @param fore - A foreground color (default white)
* @param back - A background color (default black)
*/
function Glyph(char, fore, back) {
if (fore === void 0) { fore = Color.White; }
if (back === void 0) { back = Color.Black; }
this.char = char.charCodeAt(0);
this.fore = fore;
this.back = back;
}
/**
* Creates a glyph from a charCode.
*
* @param char - A number representing a charCode.
* @param fore - A foreground color (default white)
* @param back - A background color (default black)
*/
Glyph.fromCharCode = function (char, fore, back) {
if (fore === void 0) { fore = Color.White; }
if (back === void 0) { back = Color.Black; }
return new Glyph(String.fromCharCode(char), fore, back);
};
/**
* Checks to see if two glyphs are equal.
* @param other Glyph - The other glyph.
*/
Glyph.prototype.isEqual = function (other) {
if (other instanceof Glyph === false)
return false;
return (this.char === other.char &&
this.fore.isEqual(other.fore) &&
this.back.isEqual(other.back));
};
return Glyph;
}());
var BaseTerminal = /** @class */ (function () {
function BaseTerminal(config) {
var _a, _b;
this.width = config.width;
this.height = config.height;
this.foreColor = (_a = config.foreColor) !== null && _a !== void 0 ? _a : Color.White;
this.backColor = (_b = config.backColor) !== null && _b !== void 0 ? _b : Color.Black;
}
BaseTerminal.prototype.size = function () {
return {
x: this.width,
y: this.height,
};
};
BaseTerminal.prototype.clear = function () {
this.fill({ x: 0, y: 0 }, { x: this.width - 1, y: this.height - 1 }, new Glyph(" "));
};
BaseTerminal.prototype.fill = function (v1, v2, glyph) {
for (var x = v1.x; x <= v2.x; x++) {
for (var y = v1.y; y <= v2.y; y++) {
this.drawGlyph({ x: x, y: y }, glyph);
}
}
};
BaseTerminal.prototype.writeAt = function (pos, text, fore, back) {
if (fore === void 0) { fore = this.foreColor; }
if (back === void 0) { back = this.backColor; }
for (var i = 0; i < text.length; i++) {
if (pos.x + i >= this.width)
break;
this.drawGlyph({
x: pos.x + i,
y: pos.y,
}, Glyph.fromCharCode(text.charCodeAt(i), fore, back));
}
};
BaseTerminal.prototype.drawCharCode = function (pos, charCode, foreColor, backColor) {
if (foreColor === void 0) { foreColor = this.foreColor; }
if (backColor === void 0) { backColor = this.backColor; }
this.drawGlyph(pos, Glyph.fromCharCode(charCode, foreColor, backColor));
};
return BaseTerminal;
}());
var Table = /** @class */ (function () {
function Table(width, height) {
this.items = [];
this.width = width;
this.height = height;
// ToDo - Initialize empty array
}
Table.prototype.fill = function (value) {
var size = this.width * this.height;
for (var i = 0; i < size; i++) {
this.items[i] = value;
}
};
Table.prototype.get = function (_a) {
var x = _a.x, y = _a.y;
if (!this.isInBounds({ x: x, y: y }))
return undefined;
var index = y * this.width + x;
return this.items[index];
};
Table.prototype.set = function (pos, item) {
if (this.isInBounds(pos) === false)
throw new Error(pos.x + ":" + pos.y + " is not in bounds");
var index = pos.y * this.width + pos.x;
if (item !== undefined)
this.items[index] = item;
else
delete this.items[index];
};
Table.prototype.clear = function (pos) {
var index = pos.y * this.width + pos.x;
delete this.items[index];
};
Table.prototype.isInBounds = function (_a) {
var x = _a.x, y = _a.y;
if (x < 0 || x >= this.width || y < 0 || y >= this.height) {
return false;
}
else {
return true;
}
};
Table.prototype.getNeighbors = function (pos, predicate, topology) {
var _this = this;
if (topology === void 0) { topology = "eight"; }
var neighbors = [];
neighbors.push({ x: pos.x + 1, y: pos.y });
neighbors.push({ x: pos.x, y: pos.y + -1 });
neighbors.push({ x: pos.x + -1, y: pos.y });
neighbors.push({ x: pos.x, y: pos.y + 1 });
if (topology === "eight") {
neighbors.push({ x: pos.x + 1, y: pos.y - 1 });
neighbors.push({ x: pos.x + -1, y: pos.y + -1 });
neighbors.push({ x: pos.x + -1, y: pos.y + 1 });
neighbors.push({ x: pos.x + 1, y: pos.y + 1 });
}
neighbors = neighbors.filter(function (v) { return _this.isInBounds(v); });
if (predicate) {
neighbors = neighbors.filter(function (v) { return predicate(v, _this.get(v)); });
}
return neighbors;
};
Table.prototype.floodFillSelect = function (pos, targetValue) {
if (!targetValue) {
targetValue = this.get(pos);
}
// If given a target value, must match start position
if (this.get(pos) !== targetValue) {
return [];
}
var horizon = [pos];
// "x:y", for quick indexing
var floodFill = new Set();
while (horizon.length) {
var point = horizon.shift();
var value = this.get(point);
// If not the right type of value, we're done.
if (value !== targetValue)
continue;
// If we've already marked this spot
if (floodFill.has(point.x + ":" + point.y))
continue;
// If it is the proper value, collect it
floodFill.add(point.x + ":" + point.y);
// The add it's neighbors to the search horizon
var neighbors = this.getNeighbors(point, undefined, "four");
horizon.push.apply(horizon, neighbors);
}
var fill = Array.from(floodFill.keys()).map(function (str) {
var _a = str.split(":"), x = _a[0], y = _a[1];
return {
x: Number.parseInt(x),
y: Number.parseInt(y),
};
});
return fill;
};
Table.prototype.filter = function (match) {
var matches = [];
for (var y = 0; y < this.height; y++) {
for (var x = 0; x < this.width; x++) {
if (match({ x: x, y: y }, this.get({ x: x, y: y }))) {
matches.push({ x: x, y: y });
}
}
}
return matches;
};
Table.prototype.clone = function () {
var t = new Table(this.width, this.height);
t.items = this.items.slice();
return t;
};
Table.prototype.isSameSize = function (other) {
return this.width === other.width && this.height === other.height;
};
return Table;
}());
/** Represents glyph data, agnostic to how it is rendered. */
var Display = /** @class */ (function () {
/**
* Creates a new Display
* @param width - The number of glyphs wide the display is
* @param height - The number of glyphs tall the display is
*/
function Display(width, height) {
this.width = width;
this.height = height;
this.glyphs = new Table(width, height);
this.changedGlyphs = new Table(width, height);
}
/**
* Returns a Vector representing the width/height of the display.
*/
Display.prototype.size = function () {
return { x: this.width, y: this.height };
};
/**
* Sets a single glyph in the display.
*
* @param pos Vector2 - The position of the Glyph
* @param glyph Glyph - The Glyph
*/
Display.prototype.setGlyph = function (pos, glyph) {
if (this.glyphs.isInBounds(pos) === false)
return;
if (glyph.isEqual(this.glyphs.get(pos))) {
this.changedGlyphs.set(pos, undefined);
}
else {
this.changedGlyphs.set(pos, glyph);
}
};
/**
* Calls the callback with each x/y/glyph pair.
* The terminal needs to decide how to render the display.
* The callback is called bottom to top, right to left.
*/
Display.prototype.render = function (callback) {
for (var y = this.height - 1; y >= 0; y--) {
for (var x = this.width - 1; x >= 0; x--) {
var glyph = this.changedGlyphs.get({ x: x, y: y });
if (!glyph)
continue;
callback({ x: x, y: y }, glyph);
this.glyphs.set({ x: x, y: y }, glyph);
this.changedGlyphs.set({ x: x, y: y }, undefined);
}
}
};
return Display;
}());
var Font = /** @class */ (function () {
function Font(family, size) {
this.family = family;
this.size = size;
}
return Font;
}());
/**
* Renders a display by writing fonts to a canvas.
*/
var CanvasTerminal = /** @class */ (function (_super) {
__extends(CanvasTerminal, _super);
/**
* Creates a new CanvasTerminal.
*
* @param config - The config for the CanvasTerminal
* @param config.width - The width of the terminal in characters.
* @param config.height - The height of the terminal in characters.
* @param config.font Font - A font object
* @param config.mountNode - Will mount the canvas as a child of this node if provided.
*/
function CanvasTerminal(config) {
var _this = _super.call(this, config) || this;
_this.scale = window.devicePixelRatio;
_this.display = new Display(config.width, config.height);
_this.font = config.font;
_this.canvas = window.document.createElement("canvas");
_this.context = _this.canvas.getContext("2d");
// Setup font
_this.context.font = _this.font.size * _this.scale + "px " + _this.font.family + ", monospace";
_this.context.textAlign = "center";
_this.context.textBaseline = "middle";
_this.lineHeight = Math.ceil(_this.font.size) * _this.scale;
_this.charWidth =
Math.ceil(_this.context.measureText("W").width) * _this.scale;
// Setup canvas
var canvasWidth = _this.charWidth * _this.display.width;
var canvasHeight = _this.lineHeight * _this.display.height;
_this.canvas.width = canvasWidth * _this.scale;
_this.canvas.height = canvasHeight * _this.scale;
_this.canvas.style.width = canvasWidth + "px";
_this.canvas.style.height = canvasHeight + "px";
// Mount the canvas
if (config.mountNode) {
config.mountNode.appendChild(_this.canvas);
}
else {
window.document.body.appendChild(_this.canvas);
}
return _this;
}
/**
* Draws a glyph on the display.
*
* @param pos Vector2 - Position of the Glyph
* @param glyph Glyph - The Glyph to render
*/
CanvasTerminal.prototype.drawGlyph = function (pos, glyph) {
this.display.setGlyph(pos, glyph);
};
/**
* Renders the display to the canvas.
* Usually drawn once per animation frame.
*/
CanvasTerminal.prototype.render = function () {
var _this = this;
// Setup font
this.context.font = this.font.size * this.scale + "px " + this.font.family + ", monospace";
this.context.textAlign = "center";
this.context.textBaseline = "middle";
this.display.render(function (pos, glyph) {
// Fill the background
_this.context.fillStyle = glyph.back.cssColor();
_this.context.fillRect(pos.x * _this.charWidth * _this.scale, pos.y * _this.lineHeight * _this.scale, _this.charWidth * _this.scale, _this.lineHeight * _this.scale);
// Dont bother drawing empty characters
if (glyph.char === 0 || " ".charCodeAt(0) === glyph.char) {
return;
}
// Fill the char
_this.context.fillStyle = glyph.fore.cssColor();
_this.context.fillText(String.fromCharCode(glyph.char), (pos.x * _this.charWidth + _this.charWidth / 2) * _this.scale, (pos.y * _this.lineHeight + _this.lineHeight / 2) * _this.scale);
});
};
CanvasTerminal.prototype.windowToTilePoint = function (pixel) {
var rect = this.canvas.getBoundingClientRect();
return {
x: Math.floor((pixel.x - rect.left) / this.charWidth),
y: Math.floor((pixel.y - rect.top) / this.lineHeight),
};
};
/**
* Deletes the terminal, removing the canvas.
*/
CanvasTerminal.prototype.delete = function () {
var _a;
(_a = this.canvas.parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(this.canvas);
};
return CanvasTerminal;
}(BaseTerminal));
/// Unicode code points for various special characters that also exist on
/// [code page 437][font].
///
/// [font]: http://en.wikipedia.org/wiki/Code_page_437
var CharCode;
(function (CharCode) {
// 1 - 15.
CharCode[CharCode["whiteSmilingFace"] = 9786] = "whiteSmilingFace";
CharCode[CharCode["blackSmilingFace"] = 9787] = "blackSmilingFace";
CharCode[CharCode["blackHeartSuit"] = 9829] = "blackHeartSuit";
CharCode[CharCode["blackDiamondSuit"] = 9830] = "blackDiamondSuit";
CharCode[CharCode["blackClubSuit"] = 9827] = "blackClubSuit";
CharCode[CharCode["blackSpadeSuit"] = 9824] = "blackSpadeSuit";
CharCode[CharCode["bullet"] = 8226] = "bullet";
CharCode[CharCode["inverseBullet"] = 9688] = "inverseBullet";
CharCode[CharCode["whiteCircle"] = 9675] = "whiteCircle";
CharCode[CharCode["inverseWhiteCircle"] = 9689] = "inverseWhiteCircle";
CharCode[CharCode["maleSign"] = 9794] = "maleSign";
CharCode[CharCode["femaleSign"] = 9792] = "femaleSign";
CharCode[CharCode["eighthNote"] = 9834] = "eighthNote";
CharCode[CharCode["beamedEighthNotes"] = 9835] = "beamedEighthNotes";
CharCode[CharCode["whiteSunWithRays"] = 9788] = "whiteSunWithRays";
// 16 - 31.
CharCode[CharCode["blackRightPointingPointer"] = 9658] = "blackRightPointingPointer";
CharCode[CharCode["blackLeftPointingPointer"] = 9668] = "blackLeftPointingPointer";
CharCode[CharCode["upDownArrow"] = 8597] = "upDownArrow";
CharCode[CharCode["doubleExclamationMark"] = 8252] = "doubleExclamationMark";
CharCode[CharCode["pilcrow"] = 182] = "pilcrow";
CharCode[CharCode["sectionSign"] = 167] = "sectionSign";
CharCode[CharCode["blackRectangle"] = 9644] = "blackRectangle";
CharCode[CharCode["upDownArrowWithBase"] = 8616] = "upDownArrowWithBase";
CharCode[CharCode["upwardsArrow"] = 8593] = "upwardsArrow";
CharCode[CharCode["downwardsArrow"] = 8595] = "downwardsArrow";
CharCode[CharCode["rightwardsArrow"] = 8594] = "rightwardsArrow";
CharCode[CharCode["leftwardsArrow"] = 8592] = "leftwardsArrow";
CharCode[CharCode["rightAngle"] = 8735] = "rightAngle";
CharCode[CharCode["leftRightArrow"] = 8596] = "leftRightArrow";
CharCode[CharCode["blackUpPointingTriangle"] = 9650] = "blackUpPointingTriangle";
CharCode[CharCode["blackDownPointingTriangle"] = 9660] = "blackDownPointingTriangle";
// 32 - 47.
CharCode[CharCode["space"] = 32] = "space";
CharCode[CharCode["exclamationPoint"] = 33] = "exclamationPoint";
CharCode[CharCode["doubleQuote"] = 34] = "doubleQuote";
CharCode[CharCode["numberSign"] = 35] = "numberSign";
CharCode[CharCode["dollarSign"] = 36] = "dollarSign";
CharCode[CharCode["percent"] = 37] = "percent";
CharCode[CharCode["ampersand"] = 38] = "ampersand";
CharCode[CharCode["apostrophe"] = 39] = "apostrophe";
CharCode[CharCode["leftParenthesis"] = 40] = "leftParenthesis";
CharCode[CharCode["rightParenthesis"] = 41] = "rightParenthesis";
CharCode[CharCode["asterisk"] = 42] = "asterisk";
CharCode[CharCode["plus"] = 43] = "plus";
CharCode[CharCode["comma"] = 44] = "comma";
CharCode[CharCode["minus"] = 45] = "minus";
CharCode[CharCode["period"] = 46] = "period";
CharCode[CharCode["slash"] = 47] = "slash";
// 48 - 63.
CharCode[CharCode["zero"] = 48] = "zero";
CharCode[CharCode["one"] = 49] = "one";
CharCode[CharCode["two"] = 50] = "two";
CharCode[CharCode["three"] = 51] = "three";
CharCode[CharCode["four"] = 52] = "four";
CharCode[CharCode["five"] = 53] = "five";
CharCode[CharCode["six"] = 54] = "six";
CharCode[CharCode["seven"] = 55] = "seven";
CharCode[CharCode["eight"] = 56] = "eight";
CharCode[CharCode["nine"] = 57] = "nine";
CharCode[CharCode["colon"] = 58] = "colon";
CharCode[CharCode["semicolon"] = 59] = "semicolon";
CharCode[CharCode["lessThan"] = 60] = "lessThan";
CharCode[CharCode["equals"] = 61] = "equals";
CharCode[CharCode["greaterThan"] = 62] = "greaterThan";
CharCode[CharCode["questionMark"] = 63] = "questionMark";
// 64 - 95.
CharCode[CharCode["at"] = 64] = "at";
CharCode[CharCode["aUpper"] = 65] = "aUpper";
CharCode[CharCode["bUpper"] = 66] = "bUpper";
CharCode[CharCode["cUpper"] = 67] = "cUpper";
CharCode[CharCode["dUpper"] = 68] = "dUpper";
CharCode[CharCode["eUpper"] = 69] = "eUpper";
CharCode[CharCode["fUpper"] = 70] = "fUpper";
CharCode[CharCode["gUpper"] = 71] = "gUpper";
CharCode[CharCode["hUpper"] = 72] = "hUpper";
CharCode[CharCode["iUpper"] = 73] = "iUpper";
CharCode[CharCode["jUpper"] = 74] = "jUpper";
CharCode[CharCode["kUpper"] = 75] = "kUpper";
CharCode[CharCode["lUpper"] = 76] = "lUpper";
CharCode[CharCode["mUpper"] = 77] = "mUpper";
CharCode[CharCode["nUpper"] = 78] = "nUpper";
CharCode[CharCode["oUpper"] = 79] = "oUpper";
CharCode[CharCode["pUpper"] = 80] = "pUpper";
CharCode[CharCode["qUpper"] = 81] = "qUpper";
CharCode[CharCode["rUpper"] = 82] = "rUpper";
CharCode[CharCode["sUpper"] = 83] = "sUpper";
CharCode[CharCode["tUpper"] = 84] = "tUpper";
CharCode[CharCode["uUpper"] = 85] = "uUpper";
CharCode[CharCode["vUpper"] = 86] = "vUpper";
CharCode[CharCode["wUpper"] = 87] = "wUpper";
CharCode[CharCode["xUpper"] = 88] = "xUpper";
CharCode[CharCode["yUpper"] = 89] = "yUpper";
CharCode[CharCode["zUpper"] = 90] = "zUpper";
CharCode[CharCode["leftBracket"] = 91] = "leftBracket";
CharCode[CharCode["backSlash"] = 92] = "backSlash";
CharCode[CharCode["rightBracket"] = 93] = "rightBracket";
CharCode[CharCode["caret"] = 94] = "caret";
CharCode[CharCode["underscore"] = 95] = "underscore";
// 96 - 127.
CharCode[CharCode["accent"] = 96] = "accent";
CharCode[CharCode["aLower"] = 97] = "aLower";
CharCode[CharCode["bLower"] = 98] = "bLower";
CharCode[CharCode["cLower"] = 99] = "cLower";
CharCode[CharCode["dLower"] = 100] = "dLower";
CharCode[CharCode["eLower"] = 101] = "eLower";
CharCode[CharCode["fLower"] = 102] = "fLower";
CharCode[CharCode["gLower"] = 103] = "gLower";
CharCode[CharCode["hLower"] = 104] = "hLower";
CharCode[CharCode["iLower"] = 105] = "iLower";
CharCode[CharCode["jLower"] = 106] = "jLower";
CharCode[CharCode["kLower"] = 107] = "kLower";
CharCode[CharCode["lLower"] = 108] = "lLower";
CharCode[CharCode["mLower"] = 109] = "mLower";
CharCode[CharCode["nLower"] = 110] = "nLower";
CharCode[CharCode["oLower"] = 111] = "oLower";
CharCode[CharCode["pLower"] = 112] = "pLower";
CharCode[CharCode["qLower"] = 113] = "qLower";
CharCode[CharCode["rLower"] = 114] = "rLower";
CharCode[CharCode["sLower"] = 115] = "sLower";
CharCode[CharCode["tLower"] = 116] = "tLower";
CharCode[CharCode["uLower"] = 117] = "uLower";
CharCode[CharCode["vLower"] = 118] = "vLower";
CharCode[CharCode["wLower"] = 119] = "wLower";
CharCode[CharCode["xLower"] = 120] = "xLower";
CharCode[CharCode["yLower"] = 121] = "yLower";
CharCode[CharCode["zLower"] = 122] = "zLower";
CharCode[CharCode["leftBrace"] = 123] = "leftBrace";
CharCode[CharCode["pipe"] = 124] = "pipe";
CharCode[CharCode["rightBrace"] = 125] = "rightBrace";
CharCode[CharCode["tilde"] = 126] = "tilde";
CharCode[CharCode["house"] = 8962] = "house";
// 128 - 143.
CharCode[CharCode["latinCapitalLetterCWithCedilla"] = 199] = "latinCapitalLetterCWithCedilla";
CharCode[CharCode["latinSmallLetterUWithDiaeresis"] = 252] = "latinSmallLetterUWithDiaeresis";
CharCode[CharCode["latinSmallLetterEWithAcute"] = 233] = "latinSmallLetterEWithAcute";
CharCode[CharCode["latinSmallLetterAWithCircumflex"] = 226] = "latinSmallLetterAWithCircumflex";
CharCode[CharCode["latinSmallLetterAWithDiaeresis"] = 228] = "latinSmallLetterAWithDiaeresis";
CharCode[CharCode["latinSmallLetterAWithGrave"] = 224] = "latinSmallLetterAWithGrave";
CharCode[CharCode["latinSmallLetterAWithRingAbove"] = 229] = "latinSmallLetterAWithRingAbove";
CharCode[CharCode["latinSmallLetterCWithCedilla"] = 231] = "latinSmallLetterCWithCedilla";
CharCode[CharCode["latinSmallLetterEWithCircumflex"] = 234] = "latinSmallLetterEWithCircumflex";
CharCode[CharCode["latinSmallLetterEWithDiaeresis"] = 235] = "latinSmallLetterEWithDiaeresis";
CharCode[CharCode["latinSmallLetterEWithGrave"] = 232] = "latinSmallLetterEWithGrave";
CharCode[CharCode["latinSmallLetterIWithDiaeresis"] = 239] = "latinSmallLetterIWithDiaeresis";
CharCode[CharCode["latinSmallLetterIWithCircumflex"] = 238] = "latinSmallLetterIWithCircumflex";
CharCode[CharCode["latinSmallLetterIWithGrave"] = 236] = "latinSmallLetterIWithGrave";
CharCode[CharCode["latinCapitalLetterAWithDiaeresis"] = 196] = "latinCapitalLetterAWithDiaeresis";
CharCode[CharCode["latinCapitalLetterAWithRingAbove"] = 197] = "latinCapitalLetterAWithRingAbove";
// 144 - 159.
CharCode[CharCode["latinCapitalLetterEWithAcute"] = 201] = "latinCapitalLetterEWithAcute";
CharCode[CharCode["latinSmallLetterAe"] = 230] = "latinSmallLetterAe";
CharCode[CharCode["latinCapitalLetterAe"] = 198] = "latinCapitalLetterAe";
CharCode[CharCode["latinSmallLetterOWithCircumflex"] = 244] = "latinSmallLetterOWithCircumflex";
CharCode[CharCode["latinSmallLetterOWithDiaeresis"] = 246] = "latinSmallLetterOWithDiaeresis";
CharCode[CharCode["latinSmallLetterOWithGrave"] = 242] = "latinSmallLetterOWithGrave";
CharCode[CharCode["latinSmallLetterUWithCircumflex"] = 251] = "latinSmallLetterUWithCircumflex";
CharCode[CharCode["latinSmallLetterUWithGrave"] = 249] = "latinSmallLetterUWithGrave";
CharCode[CharCode["latinSmallLetterYWithDiaeresis"] = 255] = "latinSmallLetterYWithDiaeresis";
CharCode[CharCode["latinCapitalLetterOWithDiaeresis"] = 214] = "latinCapitalLetterOWithDiaeresis";
CharCode[CharCode["latinCapitalLetterUWithDiaeresis"] = 220] = "latinCapitalLetterUWithDiaeresis";
CharCode[CharCode["centSign"] = 162] = "centSign";
CharCode[CharCode["poundSign"] = 163] = "poundSign";
CharCode[CharCode["yenSign"] = 165] = "yenSign";
CharCode[CharCode["pesetaSign"] = 8359] = "pesetaSign";
CharCode[CharCode["latinSmallLetterFWithHook"] = 402] = "latinSmallLetterFWithHook";
// 160 - 175.
CharCode[CharCode["latinSmallLetterAWithAcute"] = 225] = "latinSmallLetterAWithAcute";
CharCode[CharCode["latinSmallLetterIWithAcute"] = 237] = "latinSmallLetterIWithAcute";
CharCode[CharCode["latinSmallLetterOWithAcute"] = 243] = "latinSmallLetterOWithAcute";
CharCode[CharCode["latinSmallLetterUWithAcute"] = 250] = "latinSmallLetterUWithAcute";
CharCode[CharCode["latinSmallLetterNWithTilde"] = 241] = "latinSmallLetterNWithTilde";
CharCode[CharCode["latinCapitalLetterNWithTilde"] = 209] = "latinCapitalLetterNWithTilde";
CharCode[CharCode["feminineOrdinalIndicator"] = 170] = "feminineOrdinalIndicator";
CharCode[CharCode["masculineOrdinalIndicator"] = 186] = "masculineOrdinalIndicator";
CharCode[CharCode["invertedQuestionMark"] = 191] = "invertedQuestionMark";
CharCode[CharCode["reversedNotSign"] = 8976] = "reversedNotSign";
CharCode[CharCode["notSign"] = 172] = "notSign";
CharCode[CharCode["vulgarFractionOneHalf"] = 189] = "vulgarFractionOneHalf";
CharCode[CharCode["vulgarFractionOneQuarter"] = 188] = "vulgarFractionOneQuarter";
CharCode[CharCode["invertedExclamationMark"] = 161] = "invertedExclamationMark";
CharCode[CharCode["leftPointingDoubleAngleQuotationMark"] = 171] = "leftPointingDoubleAngleQuotationMark";
CharCode[CharCode["rightPointingDoubleAngleQuotationMark"] = 187] = "rightPointingDoubleAngleQuotationMark";
// 176 - 191.
CharCode[CharCode["lightShade"] = 9617] = "lightShade";
CharCode[CharCode["mediumShade"] = 9618] = "mediumShade";
CharCode[CharCode["darkShade"] = 9619] = "darkShade";
CharCode[CharCode["boxDrawingsLightVertical"] = 9474] = "boxDrawingsLightVertical";
CharCode[CharCode["boxDrawingsLightVerticalAndLeft"] = 9508] = "boxDrawingsLightVerticalAndLeft";
CharCode[CharCode["boxDrawingsVerticalSingleAndLeftDouble"] = 9569] = "boxDrawingsVerticalSingleAndLeftDouble";
CharCode[CharCode["boxDrawingsVerticalDoubleAndLeftSingle"] = 9570] = "boxDrawingsVerticalDoubleAndLeftSingle";
CharCode[CharCode["boxDrawingsDownDoubleAndLeftSingle"] = 9558] = "boxDrawingsDownDoubleAndLeftSingle";
CharCode[CharCode["boxDrawingsDownSingleAndLeftDouble"] = 9557] = "boxDrawingsDownSingleAndLeftDouble";
CharCode[CharCode["boxDrawingsDoubleVerticalAndLeft"] = 9571] = "boxDrawingsDoubleVerticalAndLeft";
CharCode[CharCode["boxDrawingsDoubleVertical"] = 9553] = "boxDrawingsDoubleVertical";
CharCode[CharCode["boxDrawingsDoubleDownAndLeft"] = 9559] = "boxDrawingsDoubleDownAndLeft";
CharCode[CharCode["boxDrawingsDoubleUpAndLeft"] = 9565] = "boxDrawingsDoubleUpAndLeft";
CharCode[CharCode["boxDrawingsUpDoubleAndLeftSingle"] = 9564] = "boxDrawingsUpDoubleAndLeftSingle";
CharCode[CharCode["boxDrawingsUpSingleAndLeftDouble"] = 9563] = "boxDrawingsUpSingleAndLeftDouble";
CharCode[CharCode["boxDrawingsLightDownAndLeft"] = 9488] = "boxDrawingsLightDownAndLeft";
// 192 - 207.
CharCode[CharCode["boxDrawingsLightUpAndRight"] = 9492] = "boxDrawingsLightUpAndRight";
CharCode[CharCode["boxDrawingsLightUpAndHorizontal"] = 9524] = "boxDrawingsLightUpAndHorizontal";
CharCode[CharCode["boxDrawingsLightDownAndHorizontal"] = 9516] = "boxDrawingsLightDownAndHorizontal";
CharCode[CharCode["boxDrawingsLightVerticalAndRight"] = 9500] = "boxDrawingsLightVerticalAndRight";
CharCode[CharCode["boxDrawingsLightHorizontal"] = 9472] = "boxDrawingsLightHorizontal";
CharCode[CharCode["boxDrawingsLightVerticalAndHorizontal"] = 9532] = "boxDrawingsLightVerticalAndHorizontal";
CharCode[CharCode["boxDrawingsVerticalSingleAndRightDouble"] = 9566] = "boxDrawingsVerticalSingleAndRightDouble";
CharCode[CharCode["boxDrawingsVerticalDoubleAndRightSingle"] = 9567] = "boxDrawingsVerticalDoubleAndRightSingle";
CharCode[CharCode["boxDrawingsDoubleUpAndRight"] = 9562] = "boxDrawingsDoubleUpAndRight";
CharCode[CharCode["boxDrawingsDoubleDownAndRight"] = 9556] = "boxDrawingsDoubleDownAndRight";
CharCode[CharCode["boxDrawingsDoubleUpAndHorizontal"] = 9577] = "boxDrawingsDoubleUpAndHorizontal";
CharCode[CharCode["boxDrawingsDoubleDownAndHorizontal"] = 9574] = "boxDrawingsDoubleDownAndHorizontal";
CharCode[CharCode["boxDrawingsDoubleVerticalAndRight"] = 9568] = "boxDrawingsDoubleVerticalAndRight";
CharCode[CharCode["boxDrawingsDoubleHorizontal"] = 9552] = "boxDrawingsDoubleHorizontal";
CharCode[CharCode["boxDrawingsDoubleVerticalAndHorizontal"] = 9580] = "boxDrawingsDoubleVerticalAndHorizontal";
CharCode[CharCode["boxDrawingsUpSingleAndHorizontalDouble"] = 9575] = "boxDrawingsUpSingleAndHorizontalDouble";
// 208 - 223.
CharCode[CharCode["boxDrawingsUpDoubleAndHorizontalSingle"] = 9576] = "boxDrawingsUpDoubleAndHorizontalSingle";
CharCode[CharCode["boxDrawingsDownSingleAndHorizontalDouble"] = 9572] = "boxDrawingsDownSingleAndHorizontalDouble";
CharCode[CharCode["boxDrawingsDownDoubleAndHorizontalSingle"] = 9573] = "boxDrawingsDownDoubleAndHorizontalSingle";
CharCode[CharCode["boxDrawingsUpDoubleAndRightSingle"] = 9561] = "boxDrawingsUpDoubleAndRightSingle";
CharCode[CharCode["boxDrawingsUpSingleAndRightDouble"] = 9560] = "boxDrawingsUpSingleAndRightDouble";
CharCode[CharCode["boxDrawingsDownSingleAndRightDouble"] = 9554] = "boxDrawingsDownSingleAndRightDouble";
CharCode[CharCode["boxDrawingsDownDoubleAndRightSingle"] = 9555] = "boxDrawingsDownDoubleAndRightSingle";
CharCode[CharCode["boxDrawingsVerticalDoubleAndHorizontalSingle"] = 9579] = "boxDrawingsVerticalDoubleAndHorizontalSingle";
CharCode[CharCode["boxDrawingsVerticalSingleAndHorizontalDouble"] = 9578] = "boxDrawingsVerticalSingleAndHorizontalDouble";
CharCode[CharCode["boxDrawingsLightUpAndLeft"] = 9496] = "boxDrawingsLightUpAndLeft";
CharCode[CharCode["boxDrawingsLightDownAndRight"] = 9484] = "boxDrawingsLightDownAndRight";
CharCode[CharCode["fullBlock"] = 9608] = "fullBlock";
CharCode[CharCode["lowerHalfBlock"] = 9604] = "lowerHalfBlock";
CharCode[CharCode["leftHalfBlock"] = 9612] = "leftHalfBlock";
CharCode[CharCode["rightHalfBlock"] = 9616] = "rightHalfBlock";
CharCode[CharCode["upperHalfBlock"] = 9600] = "upperHalfBlock";
// 224 - 239.
CharCode[CharCode["greekSmallLetterAlpha"] = 945] = "greekSmallLetterAlpha";
CharCode[CharCode["latinSmallLetterSharpS"] = 223] = "latinSmallLetterSharpS";
CharCode[CharCode["greekCapitalLetterGamma"] = 915] = "greekCapitalLetterGamma";
CharCode[CharCode["greekSmallLetterPi"] = 960] = "greekSmallLetterPi";
CharCode[CharCode["greekCapitalLetterSigma"] = 931] = "greekCapitalLetterSigma";
CharCode[CharCode["greekSmallLetterSigma"] = 963] = "greekSmallLetterSigma";
CharCode[CharCode["microSign"] = 181] = "microSign";
CharCode[CharCode["greekSmallLetterTau"] = 964] = "greekSmallLetterTau";
CharCode[CharCode["greekCapitalLetterPhi"] = 934] = "greekCapitalLetterPhi";
CharCode[CharCode["greekCapitalLetterTheta"] = 920] = "greekCapitalLetterTheta";
CharCode[CharCode["greekCapitalLetterOmega"] = 937] = "greekCapitalLetterOmega";
CharCode[CharCode["greekSmallLetterDelta"] = 948] = "greekSmallLetterDelta";
CharCode[CharCode["infinity"] = 8734] = "infinity";
CharCode[CharCode["greekSmallLetterPhi"] = 966] = "greekSmallLetterPhi";
CharCode[CharCode["greekSmallLetterEpsilon"] = 949] = "greekSmallLetterEpsilon";
CharCode[CharCode["intersection"] = 8745] = "intersection";
// 240 - 254.
CharCode[CharCode["identicalTo"] = 8801] = "identicalTo";
CharCode[CharCode["plusMinusSign"] = 177] = "plusMinusSign";
CharCode[CharCode["greaterThanOrEqualTo"] = 8805] = "greaterThanOrEqualTo";
CharCode[CharCode["lessThanOrEqualTo"] = 8804] = "lessThanOrEqualTo";
CharCode[CharCode["topHalfIntegral"] = 8992] = "topHalfIntegral";
CharCode[CharCode["bottomHalfIntegral"] = 8993] = "bottomHalfIntegral";
CharCode[CharCode["divisionSign"] = 247] = "divisionSign";
CharCode[CharCode["almostEqualTo"] = 8776] = "almostEqualTo";
CharCode[CharCode["degreeSign"] = 176] = "degreeSign";
CharCode[CharCode["bulletOperator"] = 8729] = "bulletOperator";
CharCode[CharCode["middleDot"] = 183] = "middleDot";
CharCode[CharCode["squareRoot"] = 8730] = "squareRoot";
CharCode[CharCode["superscriptLatinSmallLetterN"] = 8319] = "superscriptLatinSmallLetterN";
CharCode[CharCode["superscriptTwo"] = 178] = "superscriptTwo";
CharCode[CharCode["blackSquare"] = 9632] = "blackSquare";
})(CharCode || (CharCode = {}));
var _a;
var unicodeMap = (_a = {},
// 1 - 15.
_a[CharCode.whiteSmilingFace] = 1,
_a[CharCode.blackSmilingFace] = 2,
_a[CharCode.blackHeartSuit] = 3,
_a[CharCode.blackDiamondSuit] = 4,
_a[CharCode.blackClubSuit] = 5,
_a[CharCode.blackSpadeSuit] = 6,
_a[CharCode.bullet] = 7,
_a[CharCode.inverseBullet] = 8,
_a[CharCode.whiteCircle] = 9,
_a[CharCode.inverseWhiteCircle] = 10,
_a[CharCode.maleSign] = 11,
_a[CharCode.femaleSign] = 12,
_a[CharCode.eighthNote] = 13,
_a[CharCode.beamedEighthNotes] = 14,
_a[CharCode.whiteSunWithRays] = 15,
// 16 - 31.
_a[CharCode.blackRightPointingPointer] = 16,
_a[CharCode.blackLeftPointingPointer] = 17,
_a[CharCode.upDownArrow] = 18,
_a[CharCode.doubleExclamationMark] = 19,
_a[CharCode.pilcrow] = 20,
_a[CharCode.sectionSign] = 21,
_a[CharCode.blackRectangle] = 22,
_a[CharCode.upDownArrowWithBase] = 23,
_a[CharCode.upwardsArrow] = 24,
_a[CharCode.downwardsArrow] = 25,
_a[CharCode.rightwardsArrow] = 26,
_a[CharCode.leftwardsArrow] = 27,
_a[CharCode.rightAngle] = 28,
_a[CharCode.leftRightArrow] = 29,
_a[CharCode.blackUpPointingTriangle] = 30,
_a[CharCode.blackDownPointingTriangle] = 31,
// 127.
_a[CharCode.house] = 127,
// 128 - 143.
_a[CharCode.latinCapitalLetterCWithCedilla] = 128,
_a[CharCode.latinSmallLetterUWithDiaeresis] = 129,
_a[CharCode.latinSmallLetterEWithAcute] = 130,
_a[CharCode.latinSmallLetterAWithCircumflex] = 131,
_a[CharCode.latinSmallLetterAWithDiaeresis] = 132,
_a[CharCode.latinSmallLetterAWithGrave] = 133,
_a[CharCode.latinSmallLetterAWithRingAbove] = 134,
_a[CharCode.latinSmallLetterCWithCedilla] = 135,
_a[CharCode.latinSmallLetterEWithCircumflex] = 136,
_a[CharCode.latinSmallLetterEWithDiaeresis] = 137,
_a[CharCode.latinSmallLetterEWithGrave] = 138,
_a[CharCode.latinSmallLetterIWithDiaeresis] = 139,
_a[CharCode.latinSmallLetterIWithCircumflex] = 140,
_a[CharCode.latinSmallLetterIWithGrave] = 141,
_a[CharCode.latinCapitalLetterAWithDiaeresis] = 142,
_a[CharCode.latinCapitalLetterAWithRingAbove] = 143,
// 144 - 159.
_a[CharCode.latinCapitalLetterEWithAcute] = 144,
_a[CharCode.latinSmallLetterAe] = 145,
_a[CharCode.latinCapitalLetterAe] = 146,
_a[CharCode.latinSmallLetterOWithCircumflex] = 147,
_a[CharCode.latinSmallLetterOWithDiaeresis] = 148,
_a[CharCode.latinSmallLetterOWithGrave] = 149,
_a[CharCode.latinSmallLetterUWithCircumflex] = 150,
_a[CharCode.latinSmallLetterUWithGrave] = 151,
_a[CharCode.latinSmallLetterYWithDiaeresis] = 152,
_a[CharCode.latinCapitalLetterOWithDiaeresis] = 153,
_a[CharCode.latinCapitalLetterUWithDiaeresis] = 154,
_a[CharCode.centSign] = 155,
_a[CharCode.poundSign] = 156,
_a[CharCode.yenSign] = 157,
_a[CharCode.pesetaSign] = 158,
_a[CharCode.latinSmallLetterFWithHook] = 159,
// 160 - 175.
_a[CharCode.latinSmallLetterAWithAcute] = 160,
_a[CharCode.latinSmallLetterIWithAcute] = 161,
_a[CharCode.latinSmallLetterOWithAcute] = 162,
_a[CharCode.latinSmallLetterUWithAcute] = 163,
_a[CharCode.latinSmallLetterNWithTilde] = 164,
_a[CharCode.latinCapitalLetterNWithTilde] = 165,
_a[CharCode.feminineOrdinalIndicator] = 166,
_a[CharCode.masculineOrdinalIndicator] = 167,
_a[CharCode.invertedQuestionMark] = 168,
_a[CharCode.reversedNotSign] = 169,
_a[CharCode.notSign] = 170,
_a[CharCode.vulgarFractionOneHalf] = 171,
_a[CharCode.vulgarFractionOneQuarter] = 172,
_a[CharCode.invertedExclamationMark] = 173,
_a[CharCode.leftPointingDoubleAngleQuotationMark] = 174,
_a[CharCode.rightPointingDoubleAngleQuotationMark] = 175,
// 176 - 191.
_a[CharCode.lightShade] = 176,
_a[CharCode.mediumShade] = 177,
_a[CharCode.darkShade] = 178,
_a[CharCode.boxDrawingsLightVertical] = 179,
_a[CharCode.boxDrawingsLightVerticalAndLeft] = 180,
_a[CharCode.boxDrawingsVerticalSingleAndLeftDouble] = 181,
_a[CharCode.boxDrawingsVerticalDoubleAndLeftSingle] = 182,
_a[CharCode.boxDrawingsDownDoubleAndLeftSingle] = 183,
_a[Char