-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathrice-box.go
229 lines (215 loc) · 695 KB
/
rice-box.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
package terminal
import (
"github.com/GeertJohan/go.rice/embedded"
"time"
)
func init() {
// define files
file4 := &embedded.EmbeddedFile{
Filename: `addons/attach/attach.js`,
FileModTime: time.Unix(1512991935, 0),
Content: string("/**\r\n * Copyright (c) 2014 The xterm.js authors. All rights reserved.\r\n * @license MIT\r\n *\r\n * Implements the attach method, that attaches the terminal to a WebSocket stream.\r\n */\r\n\r\n(function (attach) {\r\n if (typeof exports === 'object' && typeof module === 'object') {\r\n /*\r\n * CommonJS environment\r\n */\r\n module.exports = attach(require('../../Terminal').Terminal);\r\n } else if (typeof define == 'function') {\r\n /*\r\n * Require.js is available\r\n */\r\n define(['../../xterm'], attach);\r\n } else {\r\n /*\r\n * Plain browser environment\r\n */\r\n attach(window.Terminal);\r\n }\r\n})(function (Terminal) {\r\n 'use strict';\r\n\r\n var exports = {};\r\n\r\n /**\r\n * Attaches the given terminal to the given socket.\r\n *\r\n * @param {Terminal} term - The terminal to be attached to the given socket.\r\n * @param {WebSocket} socket - The socket to attach the current terminal.\r\n * @param {boolean} bidirectional - Whether the terminal should send data\r\n * to the socket as well.\r\n * @param {boolean} buffered - Whether the rendering of incoming data\r\n * should happen instantly or at a maximum\r\n * frequency of 1 rendering per 10ms.\r\n */\r\n exports.attach = function (term, socket, bidirectional, buffered) {\r\n bidirectional = (typeof bidirectional == 'undefined') ? true : bidirectional;\r\n term.socket = socket;\r\n\r\n term._flushBuffer = function () {\r\n term.write(term._attachSocketBuffer);\r\n term._attachSocketBuffer = null;\r\n };\r\n\r\n term._pushToBuffer = function (data) {\r\n if (term._attachSocketBuffer) {\r\n term._attachSocketBuffer += data;\r\n } else {\r\n term._attachSocketBuffer = data;\r\n setTimeout(term._flushBuffer, 10);\r\n }\r\n };\r\n\r\n term._getMessage = function (ev) {\r\n if (buffered) {\r\n term._pushToBuffer(ev.data);\r\n } else {\r\n term.write(ev.data);\r\n }\r\n };\r\n\r\n term._sendData = function (data) {\r\n socket.send(data);\r\n };\r\n\r\n socket.addEventListener('message', term._getMessage);\r\n\r\n if (bidirectional) {\r\n term.on('data', term._sendData);\r\n }\r\n\r\n socket.addEventListener('close', term.detach.bind(term, socket));\r\n socket.addEventListener('error', term.detach.bind(term, socket));\r\n };\r\n\r\n /**\r\n * Detaches the given terminal from the given socket\r\n *\r\n * @param {Terminal} term - The terminal to be detached from the given socket.\r\n * @param {WebSocket} socket - The socket from which to detach the current\r\n * terminal.\r\n */\r\n exports.detach = function (term, socket) {\r\n term.off('data', term._sendData);\r\n\r\n socket = (typeof socket == 'undefined') ? term.socket : socket;\r\n\r\n if (socket) {\r\n socket.removeEventListener('message', term._getMessage);\r\n }\r\n\r\n delete term.socket;\r\n };\r\n\r\n /**\r\n * Attaches the current terminal to the given socket\r\n *\r\n * @param {WebSocket} socket - The socket to attach the current terminal.\r\n * @param {boolean} bidirectional - Whether the terminal should send data\r\n * to the socket as well.\r\n * @param {boolean} buffered - Whether the rendering of incoming data\r\n * should happen instantly or at a maximum\r\n * frequency of 1 rendering per 10ms.\r\n */\r\n Terminal.prototype.attach = function (socket, bidirectional, buffered) {\r\n return exports.attach(this, socket, bidirectional, buffered);\r\n };\r\n\r\n /**\r\n * Detaches the current terminal from the given socket.\r\n *\r\n * @param {WebSocket} socket - The socket from which to detach the current\r\n * terminal.\r\n */\r\n Terminal.prototype.detach = function (socket) {\r\n return exports.detach(this, socket);\r\n };\r\n\r\n return exports;\r\n});\r\n"),
}
file5 := &embedded.EmbeddedFile{
Filename: `addons/attach/index.html`,
FileModTime: time.Unix(1512991935, 0),
Content: string("<!doctype html>\r\n<html>\r\n <head>\r\n <link rel=\"stylesheet\" href=\"../../src/xterm.css\" />\r\n <link rel=\"stylesheet\" href=\"../../demo/style.css\" />\r\n <script src=\"../../src/xterm.js\"></script>\r\n <script src=\"attach.js\"></script>\r\n <style>\r\n body {\r\n color: #111;\r\n }\r\n \r\n h1, h2 {\r\n color: #444;\r\n border-bottom: 1px solid #ddd;\r\n text-align: left;\r\n }\r\n \r\n form {\r\n margin-bottom: 32px;\r\n }\r\n \r\n input, button {\r\n line-height: 22px;\r\n font-size: 16px;\r\n display: inline-block;\r\n border-radius: 2px;\r\n border: 1px solid #ccc;\r\n }\r\n \r\n input {\r\n height: 22px;\r\n padding-left: 4px;\r\n padding-right: 4px;\r\n }\r\n \r\n button {\r\n height: 28px;\r\n background-color: #ccc;\r\n cursor: pointer;\r\n color: #333;\r\n }\r\n \r\n .container {\r\n max-width: 900px;\r\n margin: 0 auto;\r\n }\r\n </style>\r\n </head>\r\n <body>\r\n <div class=\"container\">\r\n \r\n <h1>\r\n xterm.js: socket attach\r\n </h1>\r\n <p>\r\n Attach the terminal to a WebSocket terminal stream with ease. Perfect for attaching to your\r\n Docker containers.\r\n </p>\r\n <h2>\r\n Socket information\r\n </h2>\r\n <form id=\"socket-form\">\r\n <input id=\"socket-url\"\r\n type=\"text\"\r\n placeholder=\"Enter socket url (e.g. ws://mysock)\"\r\n autofocus />\r\n <button>\r\n Attach\r\n </button>\r\n </form>\r\n <div id=\"terminal-container\"></div>\r\n \r\n </div>\r\n <script>\r\n var term = new Terminal(),\r\n container = document.getElementById('terminal-container'),\r\n socketUrl = document.getElementById('socket-url'),\r\n socketForm = document.getElementById('socket-form');\r\n \r\n socketForm.addEventListener('submit', function (ev) {\r\n ev.preventDefault();\r\n var url = socketUrl.value,\r\n sock = new WebSocket(url);\r\n sock.addEventListener('open', function () {\r\n term.attach(sock);\r\n });\r\n });\r\n \r\n term.open(container);\r\n </script>\r\n </body>\r\n</html>"),
}
file6 := &embedded.EmbeddedFile{
Filename: `addons/attach/package.json`,
FileModTime: time.Unix(1512991935, 0),
Content: string("{\r\n \"name\": \"xterm.attach\",\r\n \"main\": \"attach.js\",\r\n \"private\": true\r\n}\r\n"),
}
file8 := &embedded.EmbeddedFile{
Filename: `addons/fit/fit.js`,
FileModTime: time.Unix(1512991935, 0),
Content: string("/**\r\n * Copyright (c) 2014 The xterm.js authors. All rights reserved.\r\n * @license MIT\r\n *\r\n * Fit terminal columns and rows to the dimensions of its DOM element.\r\n *\r\n * ## Approach\r\n *\r\n * Rows: Truncate the division of the terminal parent element height by the\r\n * terminal row height.\r\n * Columns: Truncate the division of the terminal parent element width by the\r\n * terminal character width (apply display: inline at the terminal\r\n * row and truncate its width with the current number of columns).\r\n */\r\n\r\n(function (fit) {\r\n if (typeof exports === 'object' && typeof module === 'object') {\r\n /*\r\n * CommonJS environment\r\n */\r\n module.exports = fit(require('../../Terminal').Terminal);\r\n } else if (typeof define == 'function') {\r\n /*\r\n * Require.js is available\r\n */\r\n define(['../../xterm'], fit);\r\n } else {\r\n /*\r\n * Plain browser environment\r\n */\r\n fit(window.Terminal);\r\n }\r\n})(function (Terminal) {\r\n var exports = {};\r\n\r\n exports.proposeGeometry = function (term) {\r\n if (!term.element.parentElement) {\r\n return null;\r\n }\r\n var parentElementStyle = window.getComputedStyle(term.element.parentElement);\r\n var parentElementHeight = parseInt(parentElementStyle.getPropertyValue('height'));\r\n var parentElementWidth = Math.max(0, parseInt(parentElementStyle.getPropertyValue('width')) - 17);\r\n var elementStyle = window.getComputedStyle(term.element);\r\n var elementPaddingVer = parseInt(elementStyle.getPropertyValue('padding-top')) + parseInt(elementStyle.getPropertyValue('padding-bottom'));\r\n var elementPaddingHor = parseInt(elementStyle.getPropertyValue('padding-right')) + parseInt(elementStyle.getPropertyValue('padding-left'));\r\n var availableHeight = parentElementHeight - elementPaddingVer;\r\n var availableWidth = parentElementWidth - elementPaddingHor;\r\n var geometry = {\r\n cols: Math.floor(availableWidth / term.charMeasure.width),\r\n rows: Math.floor(availableHeight / Math.floor(term.charMeasure.height * term.getOption('lineHeight')))\r\n };\r\n\r\n return geometry;\r\n };\r\n\r\n exports.fit = function (term) {\r\n // Wrap fit in a setTimeout as charMeasure needs time to get initialized\r\n // after calling Terminal.open\r\n setTimeout(function () {\r\n var geometry = exports.proposeGeometry(term);\r\n\r\n if (geometry) {\r\n // Force a full render\r\n if (term.rows !== geometry.rows || term.cols !== geometry.cols) {\r\n term.renderer.clear();\r\n term.resize(geometry.cols, geometry.rows);\r\n }\r\n }\r\n }, 0);\r\n };\r\n\r\n Terminal.prototype.proposeGeometry = function () {\r\n return exports.proposeGeometry(this);\r\n };\r\n\r\n Terminal.prototype.fit = function () {\r\n return exports.fit(this);\r\n };\r\n\r\n return exports;\r\n});\r\n"),
}
file9 := &embedded.EmbeddedFile{
Filename: `addons/fit/package.json`,
FileModTime: time.Unix(1512991935, 0),
Content: string("{\r\n \"name\": \"xterm.fit\",\r\n \"main\": \"fit.js\",\r\n \"private\": true\r\n}\r\n"),
}
fileb := &embedded.EmbeddedFile{
Filename: `addons/fullscreen/fullscreen.css`,
FileModTime: time.Unix(1512991935, 0),
Content: string(".xterm.fullscreen {\r\n position: fixed;\r\n top: 0;\r\n bottom: 0;\r\n left: 0;\r\n right: 0;\r\n width: auto;\r\n height: auto;\r\n z-index: 255;\r\n}\r\n"),
}
filec := &embedded.EmbeddedFile{
Filename: `addons/fullscreen/fullscreen.js`,
FileModTime: time.Unix(1512991935, 0),
Content: string("/**\r\n * Copyright (c) 2014 The xterm.js authors. All rights reserved.\r\n * @license MIT\r\n */\r\n\r\n(function (fullscreen) {\r\n if (typeof exports === 'object' && typeof module === 'object') {\r\n /*\r\n * CommonJS environment\r\n */\r\n module.exports = fullscreen(require('../../Terminal').Terminal);\r\n } else if (typeof define == 'function') {\r\n /*\r\n * Require.js is available\r\n */\r\n define(['../../xterm'], fullscreen);\r\n } else {\r\n /*\r\n * Plain browser environment\r\n */\r\n fullscreen(window.Terminal);\r\n }\r\n})(function (Terminal) {\r\n var exports = {};\r\n\r\n /**\r\n * Toggle the given terminal's fullscreen mode.\r\n * @param {Terminal} term - The terminal to toggle full screen mode\r\n * @param {boolean} fullscreen - Toggle fullscreen on (true) or off (false)\r\n */\r\n exports.toggleFullScreen = function (term, fullscreen) {\r\n var fn;\r\n\r\n if (typeof fullscreen == 'undefined') {\r\n fn = (term.element.classList.contains('fullscreen')) ? 'remove' : 'add';\r\n } else if (!fullscreen) {\r\n fn = 'remove';\r\n } else {\r\n fn = 'add';\r\n }\r\n\r\n term.element.classList[fn]('fullscreen');\r\n };\r\n\r\n Terminal.prototype.toggleFullscreen = function (fullscreen) {\r\n exports.toggleFullScreen(this, fullscreen);\r\n };\r\n\r\n return exports;\r\n});\r\n"),
}
filed := &embedded.EmbeddedFile{
Filename: `addons/fullscreen/package.json`,
FileModTime: time.Unix(1512991935, 0),
Content: string("{\r\n \"name\": \"xterm.fullscreen\",\r\n \"main\": \"fullscreen.js\",\r\n \"private\": true\r\n}\r\n"),
}
filef := &embedded.EmbeddedFile{
Filename: `addons/search/search.js`,
FileModTime: time.Unix(1512991935, 0),
Content: string("(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){\r\n\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nvar SearchHelper = (function () {\r\n function SearchHelper(_terminal) {\r\n this._terminal = _terminal;\r\n }\r\n SearchHelper.prototype.findNext = function (term) {\r\n if (!term || term.length === 0) {\r\n return false;\r\n }\r\n var result;\r\n var startRow = this._terminal.buffer.ydisp;\r\n if (this._terminal.selectionManager.selectionEnd) {\r\n startRow = this._terminal.selectionManager.selectionEnd[1];\r\n }\r\n for (var y = startRow + 1; y < this._terminal.buffer.ybase + this._terminal.rows; y++) {\r\n result = this._findInLine(term, y);\r\n if (result) {\r\n break;\r\n }\r\n }\r\n if (!result) {\r\n for (var y = 0; y < startRow; y++) {\r\n result = this._findInLine(term, y);\r\n if (result) {\r\n break;\r\n }\r\n }\r\n }\r\n return this._selectResult(result);\r\n };\r\n SearchHelper.prototype.findPrevious = function (term) {\r\n if (!term || term.length === 0) {\r\n return false;\r\n }\r\n var result;\r\n var startRow = this._terminal.buffer.ydisp;\r\n if (this._terminal.selectionManager.selectionStart) {\r\n startRow = this._terminal.selectionManager.selectionStart[1];\r\n }\r\n for (var y = startRow - 1; y >= 0; y--) {\r\n result = this._findInLine(term, y);\r\n if (result) {\r\n break;\r\n }\r\n }\r\n if (!result) {\r\n for (var y = this._terminal.buffer.ybase + this._terminal.rows - 1; y > startRow; y--) {\r\n result = this._findInLine(term, y);\r\n if (result) {\r\n break;\r\n }\r\n }\r\n }\r\n return this._selectResult(result);\r\n };\r\n SearchHelper.prototype._findInLine = function (term, y) {\r\n var lowerStringLine = this._terminal.buffer.translateBufferLineToString(y, true).toLowerCase();\r\n var lowerTerm = term.toLowerCase();\r\n var searchIndex = lowerStringLine.indexOf(lowerTerm);\r\n if (searchIndex >= 0) {\r\n return {\r\n term: term,\r\n col: searchIndex,\r\n row: y\r\n };\r\n }\r\n };\r\n SearchHelper.prototype._selectResult = function (result) {\r\n if (!result) {\r\n return false;\r\n }\r\n this._terminal.selectionManager.setSelection(result.col, result.row, result.term.length);\r\n this._terminal.scrollDisp(result.row - this._terminal.buffer.ydisp, false);\r\n return true;\r\n };\r\n return SearchHelper;\r\n}());\r\nexports.SearchHelper = SearchHelper;\r\n\r\n\r\n\r\n},{}],2:[function(require,module,exports){\r\n\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nvar SearchHelper_1 = require(\"./SearchHelper\");\r\n(function (addon) {\r\n if (typeof window !== 'undefined' && 'Terminal' in window) {\r\n addon(window.Terminal);\r\n }\r\n else if (typeof exports === 'object' && typeof module === 'object') {\r\n module.exports = addon(require('../../Terminal').Terminal);\r\n }\r\n else if (typeof define === 'function') {\r\n define(['../../xterm'], addon);\r\n }\r\n})(function (Terminal) {\r\n Terminal.prototype.findNext = function (term) {\r\n if (!this._searchHelper) {\r\n this.searchHelper = new SearchHelper_1.SearchHelper(this);\r\n }\r\n return this.searchHelper.findNext(term);\r\n };\r\n Terminal.prototype.findPrevious = function (term) {\r\n if (!this._searchHelper) {\r\n this.searchHelper = new SearchHelper_1.SearchHelper(this);\r\n }\r\n return this.searchHelper.findPrevious(term);\r\n };\r\n});\r\n\r\n\r\n\r\n},{\"../../Terminal\":undefined,\"./SearchHelper\":1}]},{},[2])\r\n//# sourceMappingURL=search.js.map\r\n"),
}
fileg := &embedded.EmbeddedFile{
Filename: `addons/search/search.js.map`,
FileModTime: time.Unix(1512991935, 0),
Content: string("{\"version\":3,\"file\":\"search.js\",\"sources\":[\"../../../src/addons/search/search.ts\",\"../../../src/addons/search/SearchHelper.ts\",\"../../../node_modules/browser-pack/_prelude.js\"],\"sourcesContent\":[\"/**\\r\\n * Copyright (c) 2017 The xterm.js authors. All rights reserved.\\r\\n * @license MIT\\r\\n */\\r\\n\\r\\nimport { SearchHelper } from './SearchHelper';\\r\\n\\r\\ndeclare var exports: any;\\r\\ndeclare var module: any;\\r\\ndeclare var define: any;\\r\\ndeclare var require: any;\\r\\ndeclare var window: any;\\r\\n\\r\\n(function (addon) {\\r\\n if (typeof window !== 'undefined' && 'Terminal' in window) {\\r\\n /**\\r\\n * Plain browser environment\\r\\n */\\r\\n addon(window.Terminal);\\r\\n } else if (typeof exports === 'object' && typeof module === 'object') {\\r\\n /**\\r\\n * CommonJS environment\\r\\n */\\r\\n module.exports = addon(require('../../Terminal').Terminal);\\r\\n } else if (typeof define === 'function') {\\r\\n /**\\r\\n * Require.js is available\\r\\n */\\r\\n define(['../../xterm'], addon);\\r\\n }\\r\\n})((Terminal: any) => {\\r\\n /**\\r\\n * Find the next instance of the term, then scroll to and select it. If it\\r\\n * doesn't exist, do nothing.\\r\\n * @param term Tne search term.\\r\\n * @return Whether a result was found.\\r\\n */\\r\\n Terminal.prototype.findNext = function(term: string): boolean {\\r\\n if (!this._searchHelper) {\\r\\n this.searchHelper = new SearchHelper(this);\\r\\n }\\r\\n return (<SearchHelper>this.searchHelper).findNext(term);\\r\\n };\\r\\n\\r\\n /**\\r\\n * Find the previous instance of the term, then scroll to and select it. If it\\r\\n * doesn't exist, do nothing.\\r\\n * @param term Tne search term.\\r\\n * @return Whether a result was found.\\r\\n */\\r\\n Terminal.prototype.findPrevious = function(term: string): boolean {\\r\\n if (!this._searchHelper) {\\r\\n this.searchHelper = new SearchHelper(this);\\r\\n }\\r\\n return (<SearchHelper>this.searchHelper).findPrevious(term);\\r\\n };\\r\\n});\\r\\n\",\"/**\\r\\n * Copyright (c) 2017 The xterm.js authors. All rights reserved.\\r\\n * @license MIT\\r\\n */\\r\\n\\r\\n// import { ITerminal } from '../../Interfaces';\\r\\n// import { translateBufferLineToString } from '../../utils/BufferLine';\\r\\n\\r\\ninterface ISearchResult {\\r\\n term: string;\\r\\n col: number;\\r\\n row: number;\\r\\n}\\r\\n\\r\\n/**\\r\\n * A class that knows how to search the terminal and how to display the results.\\r\\n */\\r\\nexport class SearchHelper {\\r\\n constructor(private _terminal: any) {\\r\\n // TODO: Search for multiple instances on 1 line\\r\\n // TODO: Don't use the actual selection, instead use a \\\"find selection\\\" so multiple instances can be highlighted\\r\\n // TODO: Highlight other instances in the viewport\\r\\n // TODO: Support regex, case sensitivity, etc.\\r\\n }\\r\\n\\r\\n /**\\r\\n * Find the next instance of the term, then scroll to and select it. If it\\r\\n * doesn't exist, do nothing.\\r\\n * @param term Tne search term.\\r\\n * @return Whether a result was found.\\r\\n */\\r\\n public findNext(term: string): boolean {\\r\\n if (!term || term.length === 0) {\\r\\n return false;\\r\\n }\\r\\n\\r\\n let result: ISearchResult;\\r\\n\\r\\n let startRow = this._terminal.buffer.ydisp;\\r\\n if (this._terminal.selectionManager.selectionEnd) {\\r\\n // Start from the selection end if there is a selection\\r\\n startRow = this._terminal.selectionManager.selectionEnd[1];\\r\\n }\\r\\n\\r\\n // Search from ydisp + 1 to end\\r\\n for (let y = startRow + 1; y < this._terminal.buffer.ybase + this._terminal.rows; y++) {\\r\\n result = this._findInLine(term, y);\\r\\n if (result) {\\r\\n break;\\r\\n }\\r\\n }\\r\\n\\r\\n // Search from the top to the current ydisp\\r\\n if (!result) {\\r\\n for (let y = 0; y < startRow; y++) {\\r\\n result = this._findInLine(term, y);\\r\\n if (result) {\\r\\n break;\\r\\n }\\r\\n }\\r\\n }\\r\\n\\r\\n // Set selection and scroll if a result was found\\r\\n return this._selectResult(result);\\r\\n }\\r\\n\\r\\n /**\\r\\n * Find the previous instance of the term, then scroll to and select it. If it\\r\\n * doesn't exist, do nothing.\\r\\n * @param term Tne search term.\\r\\n * @return Whether a result was found.\\r\\n */\\r\\n public findPrevious(term: string): boolean {\\r\\n if (!term || term.length === 0) {\\r\\n return false;\\r\\n }\\r\\n\\r\\n let result: ISearchResult;\\r\\n\\r\\n let startRow = this._terminal.buffer.ydisp;\\r\\n if (this._terminal.selectionManager.selectionStart) {\\r\\n // Start from the selection end if there is a selection\\r\\n startRow = this._terminal.selectionManager.selectionStart[1];\\r\\n }\\r\\n\\r\\n // Search from ydisp + 1 to end\\r\\n for (let y = startRow - 1; y >= 0; y--) {\\r\\n result = this._findInLine(term, y);\\r\\n if (result) {\\r\\n break;\\r\\n }\\r\\n }\\r\\n\\r\\n // Search from the top to the current ydisp\\r\\n if (!result) {\\r\\n for (let y = this._terminal.buffer.ybase + this._terminal.rows - 1; y > startRow; y--) {\\r\\n result = this._findInLine(term, y);\\r\\n if (result) {\\r\\n break;\\r\\n }\\r\\n }\\r\\n }\\r\\n\\r\\n // Set selection and scroll if a result was found\\r\\n return this._selectResult(result);\\r\\n }\\r\\n\\r\\n /**\\r\\n * Searches a line for a search term.\\r\\n * @param term Tne search term.\\r\\n * @param y The line to search.\\r\\n * @return The search result if it was found.\\r\\n */\\r\\n private _findInLine(term: string, y: number): ISearchResult {\\r\\n const lowerStringLine = this._terminal.buffer.translateBufferLineToString(y, true).toLowerCase();\\r\\n const lowerTerm = term.toLowerCase();\\r\\n const searchIndex = lowerStringLine.indexOf(lowerTerm);\\r\\n if (searchIndex >= 0) {\\r\\n return {\\r\\n term,\\r\\n col: searchIndex,\\r\\n row: y\\r\\n };\\r\\n }\\r\\n }\\r\\n\\r\\n /**\\r\\n * Selects and scrolls to a result.\\r\\n * @param result The result to select.\\r\\n * @return Whethera result was selected.\\r\\n */\\r\\n private _selectResult(result: ISearchResult): boolean {\\r\\n if (!result) {\\r\\n return false;\\r\\n }\\r\\n this._terminal.selectionManager.setSelection(result.col, result.row, result.term.length);\\r\\n this._terminal.scrollDisp(result.row - this._terminal.buffer.ydisp, false);\\r\\n return true;\\r\\n }\\r\\n}\\r\\n\",null],\"names\":[],\"mappings\":\"AEAA;;;ADiBA;AACA;AAAA;AAKA;AAQA;AACA;AACA;AACA;AAEA;AAEA;AACA;AAEA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AAQA;AACA;AACA;AACA;AAEA;AAEA;AACA;AAEA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AA1Ha;;;;;;;ADZb;AAQA;AACA;AAIA;AACA;AAAA;AAIA;AACA;AAAA;AAIA;AACA;AACA;AAOA;AACA;AACA;AACA;AACA;AACA;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;;;\"}"),
}
filei := &embedded.EmbeddedFile{
Filename: `addons/terminado/package.json`,
FileModTime: time.Unix(1512991935, 0),
Content: string("{\r\n \"name\": \"xterm.terminado\",\r\n \"main\": \"terminado.js\",\r\n \"private\": true\r\n}\r\n"),
}
filej := &embedded.EmbeddedFile{
Filename: `addons/terminado/terminado.js`,
FileModTime: time.Unix(1512991935, 0),
Content: string("/**\r\n * Copyright (c) 2016 The xterm.js authors. All rights reserved.\r\n * @license MIT\r\n *\r\n * This module provides methods for attaching a terminal to a terminado\r\n * WebSocket stream.\r\n */\r\n\r\n(function (attach) {\r\n if (typeof exports === 'object' && typeof module === 'object') {\r\n /*\r\n * CommonJS environment\r\n */\r\n module.exports = attach(require('../../Terminal').Terminal);\r\n } else if (typeof define == 'function') {\r\n /*\r\n * Require.js is available\r\n */\r\n define(['../../xterm'], attach);\r\n } else {\r\n /*\r\n * Plain browser environment\r\n */\r\n attach(window.Terminal);\r\n }\r\n})(function (Terminal) {\r\n 'use strict';\r\n\r\n var exports = {};\r\n\r\n /**\r\n * Attaches the given terminal to the given socket.\r\n *\r\n * @param {Terminal} term - The terminal to be attached to the given socket.\r\n * @param {WebSocket} socket - The socket to attach the current terminal.\r\n * @param {boolean} bidirectional - Whether the terminal should send data\r\n * to the socket as well.\r\n * @param {boolean} buffered - Whether the rendering of incoming data\r\n * should happen instantly or at a maximum\r\n * frequency of 1 rendering per 10ms.\r\n */\r\n exports.terminadoAttach = function (term, socket, bidirectional, buffered) {\r\n bidirectional = (typeof bidirectional == 'undefined') ? true : bidirectional;\r\n term.socket = socket;\r\n\r\n term._flushBuffer = function () {\r\n term.write(term._attachSocketBuffer);\r\n term._attachSocketBuffer = null;\r\n };\r\n\r\n term._pushToBuffer = function (data) {\r\n if (term._attachSocketBuffer) {\r\n term._attachSocketBuffer += data;\r\n } else {\r\n term._attachSocketBuffer = data;\r\n setTimeout(term._flushBuffer, 10);\r\n }\r\n };\r\n\r\n term._getMessage = function (ev) {\r\n var data = JSON.parse(ev.data)\r\n if( data[0] == \"stdout\" ) {\r\n if (buffered) {\r\n term._pushToBuffer(data[1]);\r\n } else {\r\n term.write(data[1]);\r\n }\r\n }\r\n };\r\n\r\n term._sendData = function (data) {\r\n socket.send(JSON.stringify(['stdin', data]));\r\n };\r\n\r\n term._setSize = function (size) {\r\n socket.send(JSON.stringify(['set_size', size.rows, size.cols]));\r\n };\r\n\r\n socket.addEventListener('message', term._getMessage);\r\n\r\n if (bidirectional) {\r\n term.on('data', term._sendData);\r\n }\r\n term.on('resize', term._setSize);\r\n\r\n socket.addEventListener('close', term.terminadoDetach.bind(term, socket));\r\n socket.addEventListener('error', term.terminadoDetach.bind(term, socket));\r\n };\r\n\r\n /**\r\n * Detaches the given terminal from the given socket\r\n *\r\n * @param {Xterm} term - The terminal to be detached from the given socket.\r\n * @param {WebSocket} socket - The socket from which to detach the current\r\n * terminal.\r\n */\r\n exports.terminadoDetach = function (term, socket) {\r\n term.off('data', term._sendData);\r\n\r\n socket = (typeof socket == 'undefined') ? term.socket : socket;\r\n\r\n if (socket) {\r\n socket.removeEventListener('message', term._getMessage);\r\n }\r\n\r\n delete term.socket;\r\n };\r\n\r\n /**\r\n * Attaches the current terminal to the given socket\r\n *\r\n * @param {WebSocket} socket - The socket to attach the current terminal.\r\n * @param {boolean} bidirectional - Whether the terminal should send data\r\n * to the socket as well.\r\n * @param {boolean} buffered - Whether the rendering of incoming data\r\n * should happen instantly or at a maximum\r\n * frequency of 1 rendering per 10ms.\r\n */\r\n Terminal.prototype.terminadoAttach = function (socket, bidirectional, buffered) {\r\n return exports.terminadoAttach(this, socket, bidirectional, buffered);\r\n };\r\n\r\n /**\r\n * Detaches the current terminal from the given socket.\r\n *\r\n * @param {WebSocket} socket - The socket from which to detach the current\r\n * terminal.\r\n */\r\n Terminal.prototype.terminadoDetach = function (socket) {\r\n return exports.terminadoDetach(this, socket);\r\n };\r\n\r\n return exports;\r\n});\r\n"),
}
filek := &embedded.EmbeddedFile{
Filename: `base64.js`,
FileModTime: time.Unix(1487580210, 0),
Content: string("var keyStr = \"ABCDEFGHIJKLMNOP\" +\n \"QRSTUVWXYZabcdef\" +\n \"ghijklmnopqrstuv\" +\n \"wxyz0123456789+/\" +\n \"=\";\n\n function encode64(input) {\n input = escape(input);\n var output = \"\";\n var chr1, chr2, chr3 = \"\";\n var enc1, enc2, enc3, enc4 = \"\";\n var i = 0;\n\n do {\n chr1 = input.charCodeAt(i++);\n chr2 = input.charCodeAt(i++);\n chr3 = input.charCodeAt(i++);\n\n enc1 = chr1 >> 2;\n enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);\n enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);\n enc4 = chr3 & 63;\n\n if (isNaN(chr2)) {\n enc3 = enc4 = 64;\n } else if (isNaN(chr3)) {\n enc4 = 64;\n }\n\n output = output +\n keyStr.charAt(enc1) +\n keyStr.charAt(enc2) +\n keyStr.charAt(enc3) +\n keyStr.charAt(enc4);\n chr1 = chr2 = chr3 = \"\";\n enc1 = enc2 = enc3 = enc4 = \"\";\n } while (i < input.length);\n\n return output;\n }\n\n function decode64(input) {\n var output = \"\";\n var chr1, chr2, chr3 = \"\";\n var enc1, enc2, enc3, enc4 = \"\";\n var i = 0;\n\n // remove all characters that are not A-Z, a-z, 0-9, +, /, or =\n var base64test = /[^A-Za-z0-9\\+\\/\\=]/g;\n if (base64test.exec(input)) {\n console.log(\"There were invalid base64 characters in the input text.\\n\" +\n \"Valid base64 characters are A-Z, a-z, 0-9, '+', '/',and '='\\n\" +\n \"Expect errors in decoding.\");\n }\n input = input.replace(/[^A-Za-z0-9\\+\\/\\=]/g, \"\");\n\n do {\n enc1 = keyStr.indexOf(input.charAt(i++));\n enc2 = keyStr.indexOf(input.charAt(i++));\n enc3 = keyStr.indexOf(input.charAt(i++));\n enc4 = keyStr.indexOf(input.charAt(i++));\n\n chr1 = (enc1 << 2) | (enc2 >> 4);\n chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);\n chr3 = ((enc3 & 3) << 6) | enc4;\n\n output = output + String.fromCharCode(chr1);\n\n if (enc3 != 64) {\n output = output + String.fromCharCode(chr2);\n }\n if (enc4 != 64) {\n output = output + String.fromCharCode(chr3);\n }\n\n chr1 = chr2 = chr3 = \"\";\n enc1 = enc2 = enc3 = enc4 = \"\";\n\n } while (i < input.length);\n\n return unescape(output);\n }\n"),
}
filel := &embedded.EmbeddedFile{
Filename: `favicon.ico`,
FileModTime: time.Unix(1487580210, 0),
Content: string("\x00\x00\x01\x00\x01\x00\x10\x10\x00\x00\x01\x00 \x00h\x04\x00\x00\x16\x00\x00\x00(\x00\x00\x00\x10\x00\x00\x00 \x00\x00\x00\x01\x00 \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x9c\xa5\xa2\x14\x98\xa0\x9d\x9a\x92\x9a\x97\xf6\x8d\x95\x92\xfc\x87\x8f\x8c\xfc\x82\x8a\x87\xfc~\x85\x82\xfcy\x80}\xfct|x\xfcpxt\xfckso\xfcfnj\xfc`hd\xfc[b_\xf5W^Z\x97QXT\x11\x9e\xa6\xa3\x9a\xb4\xb9\xb7\xfb\xcc\xce\xcd\xff\xbe\xc1\xc0\xff\xae\xb1\xb0\xff\x9d\xa1\xa0\xff\x95\x99\x98\xff\x90\x95\x93\xff\x8c\x91\x8f\xff\x87\x8c\x8b\xff\x82\x87\x86\xff~\x83\x81\xffy\u007f}\xffszw\xff`fc\xf9RYU\x90\x9d\xa6\xa3\xf6\xd6\xd8\xd7\xff#$#\xff\x02\x03\x02\xff\x01\x02\x01\xff\x01\x02\x01\xff\x01\x02\x01\xff\x01\x02\x01\xff\x01\x02\x01\xff\x01\x02\x01\xff\x01\x02\x01\xff\x01\x02\x01\xff\x01\x02\x01\xff\x12\x14\x13\xffryv\xffRYU\U000dc962\xfc\xd7\xd8\xd7\xff\x06\x06\x06\xff\x11\x1f\x18\xff\x11\x1f\x18\xff\x11\x1f\x18\xff\x11\x1f\x18\xff\x11\x1f\x18\xff\x11\x1f\x18\xff\x11\x1f\x18\xff\x11 \x18\xff\x11 \x19\xff\x11 \x19\xff\x00\x00\x00\xffz\x80~\xffQXT\xff\x9c\xa5\xa2\xfc\xd7\xd8\xd7\xff\x06\a\x06\xff\x1a1&\xff\x1a2'\xff\x1b2'\xff\x1b2'\xff\x1b3(\xff\x1b3(\xff\x1b4(\xff\x1c4)\xff\x1c4)\xff\x1c5)\xff\x00\x00\x00\xff}\x83\x81\xffQXT\xff\x9c\xa5\xa2\xfc\xd7\xd8\xd7\xff\x06\a\a\xff\x1d3)\xff\x1a1'\xff\x190'\xff\x191'\xff\xf1\xf3\xf2\xff\xf1\xf3\xf2\xff\xf1\xf3\xf2\xff\xea\xed\xec\xff\x1a2(\xff\x1a2(\xff\x00\x00\x00\xff\x81\x86\x84\xffQXT\xff\x9c\xa5\xa2\xfc\xd7\xd8\xd7\xff\x06\a\a\xff:ZL\xff\xc8\xd1\xce\xffd}s\xff'J;\xff&J;\xff&J;\xff&J;\xff'K<\xff'K<\xff'L<\xff\x00\x00\x00\xff\x83\x89\x87\xffQXT\xff\x9c\xa5\xa2\xfc\xd7\xd8\xd7\xff\x06\b\a\xff=VL\xffUja\xff\xcb\xd3\xcf\xff\xcd\xd6\xd3\xff%E7\xff#C6\xff#D6\xff#D6\xff#E6\xff#E7\xff\x00\x00\x00\xff\x87\x8c\x8a\xffQXT\xff\x9c\xa5\xa2\xfc\xd7\xd8\xd7\xff\b\t\t\xff_\x82s\xff\x8a\xa3\x99\xff\xdb\xe3\xe0\xff\xc6\xd2\xcd\xffPxi\xff7eS\xff2aN\xff2bO\xff2bO\xff2cO\xff\x00\x00\x00\xff\x8a\x8f\x8d\xffQXT\xff\x9c\xa5\xa2\xfc\xd7\xd8\xd7\xff\t\v\n\xffYuj\xff\xd4\xde\xd9\xffl\x84z\xffRqe\xffQqd\xffMna\xff6^N\xff+VF\xff+VF\xff,WF\xff\x00\x00\x00\xff\x8d\x92\x91\xffQXT\xff\x9c\xa5\xa2\xfc\xd7\xd8\xd7\xff\n\f\v\xff\x81\xa6\x97\xff\u007f\xa4\x95\xff}\xa2\x94\xffy\xa2\x92\xffv\xa0\x90\xfft\x9f\x8e\xffr\x9d\x8c\xffi\x98\x85\xffT\x89u\xffA|e\xff\x00\x00\x00\xff\x90\x95\x93\xffQXT\xff\x9c\xa5\xa2\xfc\xd7\xd8\xd7\xff\f\x0e\r\xfft\x90\x84\xffq\x90\x84\xffp\x8e\x82\xffm\x8d\x80\xffk\x8c\u007f\xffi\x8b~\xffg\x89|\xffe\x88{\xffd\x87y\xff`\x85v\xff\x00\x00\x00\xff\x93\x98\x96\xffQXT\xff\x9c\xa5\xa2\xfc\xd7\xd8\xd7\xff\r\x10\x0f\xff\x9b\xbf\xb1\xff\x98\xbe\xaf\xff\x97\xbd\xae\xff\x94\xbc\xac\xff\x92\xba\xaa\xff\x90\xb9\xa9\xff\x8e\xb8\xa8\xff\x8d\xb6\xa5\xff\x8a\xb5\xa4\xff\x87\xb3\xa2\xff\x00\x00\x00\xff\x97\x9b\x9a\xffQXT\xff\x9d\xa6\xa3\xf4\xd5\xd7\xd6\xff364\xff\a\b\b\xff\a\b\b\xff\a\b\b\xff\a\b\b\xff\a\b\b\xff\a\b\b\xff\a\b\b\xff\a\b\b\xff\x06\a\a\xff\x06\a\a\xff-1/\xff\x96\x99\x98\xffRYU𝦣\x92\xb1\xb6\xb4\xfa\xd5\xd7\xd7\xff\xdd\xde\xdd\xff\xdc\xde\xdd\xff\xdc\xdd\xdd\xff\xdc\xdd\xdd\xff\xdc\xdd\xdd\xff\xdc\xdd\xdd\xff\xdc\xdd\xdd\xff\xdc\xdd\xdd\xff\xd9\xdb\xdb\xff\xcb\xcd\xcc\xff\xb1\xb4\xb2\xffrwt\xf9RYU\x88\x9c\xa5\xa2\x0e\x98\xa0\x9d\x87\x94\x9c\x99\ue355\x92\xfb\x88\x90\x8d\xfb\x83\x8b\x88\xfb~\x86\x83\xfbz\x81~\xfbu}y\xfbpxt\xfbkso\xfbfnj\xfbaie\xfb^eb\xecW^Z\x83QXT\f\x80\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80\x01\x00\x00"),
}
filem := &embedded.EmbeddedFile{
Filename: `main.js`,
FileModTime: time.Unix(1512991935, 0),
Content: string("var term,\r\n socket\r\n\r\nvar terminalContainer = document.getElementById('terminal-container'),\r\n actionElements = {\r\n findText: document.getElementById('find-text'),\r\n findNext: document.getElementById('find-next'),\r\n findPrevious: document.getElementById('find-previous'),\r\n toggleOptions: document.getElementById('toggle-options'),\r\n },\r\n loginElements = {\r\n user: document.getElementById('userName'),\r\n password: document.getElementById('password'),\r\n login: document.getElementById('ssh-login'),\r\n },\r\n optionElements = {\r\n cursorBlink: document.getElementById('option-cursor-blink'),\r\n cursorStyle: document.getElementById('option-cursor-style'),\r\n scrollback: document.getElementById('option-scrollback'),\r\n tabstopwidth: document.getElementById('option-tabstopwidth'),\r\n bellStyle: document.getElementById('option-bell-style')\r\n },\r\n colsElement = document.getElementById('cols'),\r\n rowsElement = document.getElementById('rows');\r\n\r\n\r\nvar urlPrefix = getQueryStringByName(\"url_prefix\")\r\nvar protocol = getQueryStringByName(\"protocol\")\r\nvar hostname = getQueryStringByName(\"hostname\")\r\nvar file = getQueryStringByName(\"file\")\r\nvar port = getQueryStringByName(\"port\")\r\nvar cmd = getQueryStringByName(\"cmd\")\r\nvar is_debug = getQueryStringByName(\"debug\")\r\nvar user = getQueryStringByName(\"user\")\r\nvar password = getQueryStringByName(\"password\")\r\n\r\n//根据QueryString参数名称获取值\r\nfunction getQueryStringByName(name) {\r\n var result = location.search.match(new RegExp(\"[\\?\\&]\" + name + \"=([^\\&]+)\", \"i\"));\r\n if (result == null || result.length < 1) {\r\n return \"\";\r\n }\r\n return result[1];\r\n}\r\n\r\nfunction startsWith(s, prefix) {\r\n return s.indexOf(prefix) == 0;\r\n}\r\n\r\nfunction changeClassList(ele, add, del) {\r\n var klsList = ele.classList;\r\n klsList.add(add);\r\n klsList.remove(del);\r\n}\r\n\r\nfunction toggleLogin() {\r\n var loginEl = document.getElementById(\"login\");\r\n var optionsEl = document.getElementById(\"options\");\r\n\r\n changeClassList(optionsEl, \"hide\", \"active\")\r\n \r\n var klsList = loginEl.classList;\r\n if (klsList.contains(\"hide\")) {\r\n changeClassList(loginEl, \"active\", \"hide\")\r\n } else {\r\n changeClassList(loginEl, \"hide\", \"active\")\r\n }\r\n}\r\n\r\nfunction toggleLogin() {\r\n var loginEl = document.getElementById(\"login\");\r\n var optionsEl = document.getElementById(\"options\");\r\n\r\n changeClassList(optionsEl, \"hide\", \"active\")\r\n \r\n var klsList = loginEl.classList;\r\n if (klsList.contains(\"hide\")) {\r\n changeClassList(loginEl, \"active\", \"hide\")\r\n } else {\r\n changeClassList(loginEl, \"hide\", \"active\")\r\n }\r\n}\r\n\r\n\r\nfunction toggleOptions() {\r\n var loginEl = document.getElementById(\"login\");\r\n var optionsEl = document.getElementById(\"options\");\r\n\r\n changeClassList(loginEl, \"hide\", \"active\")\r\n\r\n var klsList = optionsEl.classList;\r\n if (klsList.contains(\"hide\")) {\r\n changeClassList(optionsEl, \"active\", \"hide\")\r\n } else {\r\n changeClassList(optionsEl, \"hide\", \"active\")\r\n }\r\n}\r\n\r\nactionElements.findNext.addEventListener('click', function() {\r\n term.findNext(actionElements.findText.value);\r\n});\r\nactionElements.findPrevious.addEventListener('click', function() {\r\n term.findPrevious(actionElements.findText.value);\r\n});\r\nactionElements.toggleOptions.addEventListener('click', function() {\r\n toggleOptions();\r\n});\r\nloginElements.login.addEventListener('click', function() {\r\n user = loginElements.user.value;\r\n password = loginElements.password.value;\r\n\r\n toggleLogin();\r\n connect();\r\n});\r\n\r\nfunction setTerminalSize() {\r\n var cols = parseInt(colsElement.value, 10);\r\n var rows = parseInt(rowsElement.value, 10);\r\n var viewportElement = document.querySelector('.xterm-viewport');\r\n var scrollBarWidth = viewportElement.offsetWidth - viewportElement.clientWidth;\r\n var width = (cols * term.charMeasure.width + 20 /*room for scrollbar*/).toString() + 'px';\r\n var height = (rows * term.charMeasure.height).toString() + 'px';\r\n\r\n terminalContainer.style.width = width;\r\n terminalContainer.style.height = height;\r\n term.resize(cols, rows);\r\n}\r\n\r\ncolsElement.addEventListener('change', setTerminalSize);\r\nrowsElement.addEventListener('change', setTerminalSize);\r\n\r\n\r\noptionElements.cursorBlink.addEventListener('change', function () {\r\n term.setOption('cursorBlink', optionElements.cursorBlink.checked);\r\n});\r\noptionElements.cursorStyle.addEventListener('change', function () {\r\n term.setOption('cursorStyle', optionElements.cursorStyle.value);\r\n});\r\noptionElements.bellStyle.addEventListener('change', function () {\r\n term.setOption('bellStyle', optionElements.bellStyle.value);\r\n});\r\noptionElements.scrollback.addEventListener('change', function () {\r\n term.setOption('scrollback', parseInt(optionElements.scrollback.value, 10));\r\n});\r\noptionElements.tabstopwidth.addEventListener('change', function () {\r\n term.setOption('tabStopWidth', parseInt(optionElements.tabstopwidth.value, 10));\r\n});\r\n\r\nfunction connect() {\r\n if(protocol == \"ssh\") {\r\n if (undefined == password || null == password || \"\" == password) {\r\n toggleLogin()\r\n return\r\n }\r\n }\r\n\r\n var target_url = \"ws://\" + document.location.host + urlPrefix + \"/\" + protocol + \"?hostname=\" + hostname + \"&port=\" + port + \"&user=\" + user + \"&password=\" + password + \"&debug=\" + is_debug\r\n if (\"replay\" == protocol) {\r\n target_url = \"ws://\" + document.location.host + urlPrefix + \"/\" + protocol + \"?file=\" + file + \"&user=\" + user + \"&password=\" + password\r\n } else if (\"ssh_exec\" == protocol) {\r\n target_url = \"ws://\" + document.location.host + urlPrefix + \"/\" + protocol + \"?dump_file=\" + file + \"&hostname=\" + hostname + \"&port=\" + port + \"&user=\" + user + \"&password=\" + password + \"&cmd=\" + cmd + \"&debug=\" + is_debug\r\n }\r\n\r\n createTerminal(target_url);\r\n}\r\n\r\nfunction createTerminal(targetUrl) {\r\n // Clean terminal\r\n while (terminalContainer.children.length) {\r\n terminalContainer.removeChild(terminalContainer.children[0]);\r\n }\r\n term = new Terminal({\r\n cursorBlink: optionElements.cursorBlink.checked,\r\n scrollback: parseInt(optionElements.scrollback.value, 10),\r\n tabStopWidth: parseInt(optionElements.tabstopwidth.value, 10)\r\n });\r\n term.on('resize', function (size) {\r\n //if (!pid) {\r\n // return;\r\n //}\r\n //var cols = size.cols,\r\n // rows = size.rows,\r\n // url = '/terminals/' + pid + '/size?cols=' + cols + '&rows=' + rows;\r\n\r\n //fetch(url, {method: 'POST'});\r\n });\r\n\r\n term.open(terminalContainer);\r\n term.fit();\r\n\r\n // fit is called within a setTimeout, cols and rows need this.\r\n setTimeout(function () {\r\n colsElement.value = term.cols;\r\n rowsElement.value = term.rows;\r\n\r\n // Set terminal size again to set the specific dimensions on the demo\r\n setTerminalSize();\r\n\r\n socket = new WebSocket(targetUrl + '&columns=' + term.cols + '&rows=' + term.rows);\r\n socket.onopen = function() {\r\n term.attach(socket);\r\n term._initialized = true;\r\n };\r\n socket.onclose = function() {\r\n //term.destroy();\r\n };\r\n socket.onerror = function() {\r\n alert(\"连接出错!\");\r\n };\r\n }, 0);\r\n}\r\n\r\nwindow.addEventListener('load', function () {\r\n if (undefined == protocol || null == protocol || \"\" == protocol) {\r\n protocol = \"ssh\"\r\n if (undefined == port || null == port || \"\" == port) {\r\n port = \"22\"\r\n }\r\n } else if (\"telnet\" == protocol) {\r\n if (undefined == port || null == port || \"\" == port) {\r\n port = \"23\"\r\n }\r\n } else if (\"ssh\" == protocol) {\r\n if (undefined == port || null == port || \"\" == port) {\r\n port = \"22\"\r\n }\r\n }\r\n\r\n if (\"replay\" == protocol) {\r\n if (undefined == file || null == file || \"\" == file) {\r\n alert(\"file is empty.\")\r\n return\r\n }\r\n } else {\r\n if (undefined == hostname || null == hostname || \"\" == hostname) {\r\n alert(\"hostname is empty.\")\r\n return\r\n }\r\n }\r\n\r\n if(undefined != urlPrefix && null != urlPrefix && \"\" != urlPrefix) {\r\n if (urlPrefix[urlPrefix.length-1] == \"/\") {\r\n urlPrefix = urlPrefix.substr(0, urlPrefix.length-1)\r\n }\r\n }\r\n\r\n if(undefined != urlPrefix && null != urlPrefix && \"\" != urlPrefix) {\r\n if (urlPrefix.indexOf(\"/\") != 0) {\r\n urlPrefix = \"/\" + urlPrefix\r\n }\r\n }\r\n\r\n connect()\r\n}, false);"),
}
filen := &embedded.EmbeddedFile{
Filename: `terminal.html`,
FileModTime: time.Unix(1512991935, 0),
Content: string("<!doctype html>\r\n<html>\r\n<head>\r\n <meta name=\"author\" content=\"[email protected]\"/>\r\n <title>Simple TTY</title>\r\n <link rel=\"shortcut icon\" href=\"/static/favicon.ico\">\r\n <style>\r\n body {\r\n margin-top: 0;\r\n font-family: helvetica, sans-serif, arial;\r\n font-size: 14px;\r\n color: #111;\r\n }\r\n\r\n h1 {\r\n text-align: center;\r\n }\r\n\r\n #terminal-container {\r\n width: 800px;\r\n height: 450px;\r\n margin: 0 auto;\r\n padding: 2px;\r\n }\r\n\r\n #options, #login {\r\n width: 300px;\r\n /*-webkit-transition: height .5s;*/\r\n /*-moz-transition: height .5s;*/\r\n /*-o-transition: height .5s;*/\r\n }\r\n\r\n #options.active {\r\n margin: 0;\r\n height: 350px;\r\n }\r\n\r\n #login.active {\r\n margin: 0;\r\n height: 200px;\r\n }\r\n\r\n .hide {\r\n display: none;\r\n }\r\n\r\n </style>\r\n\r\n <link rel=\"stylesheet\" href=\"./xterm.css\"/>\r\n <link rel=\"stylesheet\" href=\"./addons/fullscreen/fullscreen.css\"/>\r\n <script src=\"./xterm.js\"></script>\r\n <script src=\"./addons/attach/attach.js\"></script>\r\n <script src=\"./addons/fit/fit.js\"></script>\r\n <script src=\"./addons/fullscreen/fullscreen.js\"></script>\r\n <script src=\"./addons/search/search.js\"></script>\r\n</head>\r\n<body>\r\n<div style=\"overflow: hidden;\">\r\n <div style=\"float:right;\">\r\n <p style=\"margin: 3px;height: 25px;line-height: 20px\">\r\n <label><input id=\"find-text\"/></label>\r\n <button id=\"find-next\" >查找</button>\r\n <button id=\"find-previous\" >向前</button>\r\n <button id=\"toggle-options\">选项</button>\r\n <!-- button onclick=\"toggleLogin()\">登录</button -->\r\n </p>\r\n <div id=\"login\" class=\"hide\">\r\n <h2 style=\"margin-top:0\">请输入用户名和密码</h2>\r\n <p>\r\n <label>用户名 <input type=\"text\" id=\"userName\"> </label>\r\n </p>\r\n <p>\r\n <label>密码 <input type=\"password\" id=\"password\"></label>\r\n </p>\r\n <button id=\"ssh-login\">确认</button>\r\n </div>\r\n <div id=\"options\" class=\"hide\">\r\n <h2 style=\"margin-top:0\">选项</h2>\r\n <p>\r\n <label><input type=\"checkbox\" id=\"option-cursor-blink\"> 光标闪烁</label>\r\n </p>\r\n <p>\r\n <label>\r\n 光标样式\r\n <select id=\"option-cursor-style\">\r\n <option value=\"block\">block</option>\r\n <option value=\"underline\">underline</option>\r\n <option value=\"bar\">bar</option>\r\n </select>\r\n </label>\r\n </p>\r\n <p>\r\n <label>\r\n 铃声(试验性功能)\r\n <select id=\"option-bell-style\">\r\n <option value=\"\">none</option>\r\n <option value=\"sound\">sound</option>\r\n <option value=\"visual\">visual</option>\r\n <option value=\"both\">both</option>\r\n </select>\r\n </label>\r\n </p>\r\n <p>\r\n <label>屏幕缓冲区 <input type=\"number\" id=\"option-scrollback\" value=\"1000\"/></label>\r\n </p>\r\n <p>\r\n <label>Tab 字符宽度 <input type=\"number\" id=\"option-tabstopwidth\" value=\"8\"/></label>\r\n </p>\r\n <div>\r\n <h3>大小</h3>\r\n <p>\r\n <label for=\"cols\">列</label>\r\n <input type=\"number\" id=\"cols\" value=\"80\"/>\r\n </p>\r\n <p>\r\n <label for=\"rows\">行</label>\r\n <input type=\"number\" id=\"rows\" value=\"32\"/>\r\n </p>\r\n </div>\r\n </div>\r\n </div>\r\n</div>\r\n<div id=\"terminal-container\"></div>\r\n<script src=\"./main.js\"></script>\r\n\r\n</body>\r\n</html>\r\n"),
}
fileo := &embedded.EmbeddedFile{
Filename: `xterm.css`,
FileModTime: time.Unix(1512991935, 0),
Content: string("/**\r\n * Copyright (c) 2014 The xterm.js authors. All rights reserved.\r\n * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)\r\n * https://github.com/chjj/term.js\r\n * @license MIT\r\n *\r\n * Permission is hereby granted, free of charge, to any person obtaining a copy\r\n * of this software and associated documentation files (the \"Software\"), to deal\r\n * in the Software without restriction, including without limitation the rights\r\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\n * copies of the Software, and to permit persons to whom the Software is\r\n * furnished to do so, subject to the following conditions:\r\n *\r\n * The above copyright notice and this permission notice shall be included in\r\n * all copies or substantial portions of the Software.\r\n *\r\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\n * THE SOFTWARE.\r\n *\r\n * Originally forked from (with the author's permission):\r\n * Fabrice Bellard's javascript vt100 for jslinux:\r\n * http://bellard.org/jslinux/\r\n * Copyright (c) 2011 Fabrice Bellard\r\n * The original design remains. The terminal itself\r\n * has been extended to include xterm CSI codes, among\r\n * other features.\r\n */\r\n\r\n/**\r\n * Default styles for xterm.js\r\n */\r\n\r\n.xterm {\r\n font-family: courier-new, courier, monospace;\r\n font-feature-settings: \"liga\" 0;\r\n position: relative;\r\n user-select: none;\r\n -ms-user-select: none;\r\n -webkit-user-select: none;\r\n}\r\n\r\n.xterm.focus,\r\n.xterm:focus {\r\n outline: none;\r\n}\r\n\r\n.xterm .xterm-helpers {\r\n position: absolute;\r\n top: 0;\r\n /**\r\n * The z-index of the helpers must be higher than the canvases in order for\r\n * IMEs to appear on top.\r\n */\r\n z-index: 10;\r\n}\r\n\r\n.xterm .xterm-helper-textarea {\r\n /*\r\n * HACK: to fix IE's blinking cursor\r\n * Move textarea out of the screen to the far left, so that the cursor is not visible.\r\n */\r\n position: absolute;\r\n opacity: 0;\r\n left: -9999em;\r\n top: 0;\r\n width: 0;\r\n height: 0;\r\n z-index: -10;\r\n /** Prevent wrapping so the IME appears against the textarea at the correct position */\r\n white-space: nowrap;\r\n overflow: hidden;\r\n resize: none;\r\n}\r\n\r\n.xterm .composition-view {\r\n /* TODO: Composition position got messed up somewhere */\r\n background: #000;\r\n color: #FFF;\r\n display: none;\r\n position: absolute;\r\n white-space: nowrap;\r\n z-index: 1;\r\n}\r\n\r\n.xterm .composition-view.active {\r\n display: block;\r\n}\r\n\r\n.xterm .xterm-viewport {\r\n /* On OS X this is required in order for the scroll bar to appear fully opaque */\r\n background-color: #000;\r\n overflow-y: scroll;\r\n}\r\n\r\n.xterm canvas {\r\n position: absolute;\r\n left: 0;\r\n top: 0;\r\n}\r\n\r\n.xterm .xterm-scroll-area {\r\n visibility: hidden;\r\n}\r\n\r\n.xterm .xterm-char-measure-element {\r\n display: inline-block;\r\n visibility: hidden;\r\n position: absolute;\r\n left: -9999em;\r\n}\r\n\r\n.xterm.enable-mouse-events {\r\n /* When mouse events are enabled (eg. tmux), revert to the standard pointer cursor */\r\n cursor: default;\r\n}\r\n\r\n.xterm:not(.enable-mouse-events) {\r\n cursor: text;\r\n}\r\n"),
}
filep := &embedded.EmbeddedFile{
Filename: `xterm.js`,
FileModTime: time.Unix(1512991935, 0),
Content: string("(function(f){if(typeof exports===\"object\"&&typeof module!==\"undefined\"){module.exports=f()}else if(typeof define===\"function\"&&define.amd){define([],f)}else{var g;if(typeof window!==\"undefined\"){g=window}else if(typeof global!==\"undefined\"){g=global}else if(typeof self!==\"undefined\"){g=self}else{g=this}g.Terminal = f()}})(function(){var define,module,exports;return (function 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){\r\n\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nvar CircularList_1 = require(\"./utils/CircularList\");\r\nexports.CHAR_DATA_ATTR_INDEX = 0;\r\nexports.CHAR_DATA_CHAR_INDEX = 1;\r\nexports.CHAR_DATA_WIDTH_INDEX = 2;\r\nexports.CHAR_DATA_CODE_INDEX = 3;\r\nvar Buffer = (function () {\r\n function Buffer(_terminal, _hasScrollback) {\r\n this._terminal = _terminal;\r\n this._hasScrollback = _hasScrollback;\r\n this.clear();\r\n }\r\n Object.defineProperty(Buffer.prototype, \"lines\", {\r\n get: function () {\r\n return this._lines;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Buffer.prototype, \"hasScrollback\", {\r\n get: function () {\r\n return this._hasScrollback && this.lines.maxLength > this._terminal.rows;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Buffer.prototype, \"isCursorInViewport\", {\r\n get: function () {\r\n var absoluteY = this.ybase + this.y;\r\n var relativeY = absoluteY - this.ydisp;\r\n return (relativeY >= 0 && relativeY < this._terminal.rows);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Buffer.prototype._getCorrectBufferLength = function (rows) {\r\n if (!this._hasScrollback) {\r\n return rows;\r\n }\r\n return rows + this._terminal.options.scrollback;\r\n };\r\n Buffer.prototype.fillViewportRows = function () {\r\n if (this._lines.length === 0) {\r\n var i = this._terminal.rows;\r\n while (i--) {\r\n this.lines.push(this._terminal.blankLine());\r\n }\r\n }\r\n };\r\n Buffer.prototype.clear = function () {\r\n this.ydisp = 0;\r\n this.ybase = 0;\r\n this.y = 0;\r\n this.x = 0;\r\n this._lines = new CircularList_1.CircularList(this._getCorrectBufferLength(this._terminal.rows));\r\n this.scrollTop = 0;\r\n this.scrollBottom = this._terminal.rows - 1;\r\n this.setupTabStops();\r\n };\r\n Buffer.prototype.resize = function (newCols, newRows) {\r\n var newMaxLength = this._getCorrectBufferLength(newRows);\r\n if (newMaxLength > this._lines.maxLength) {\r\n this._lines.maxLength = newMaxLength;\r\n }\r\n if (this._lines.length > 0) {\r\n if (this._terminal.cols < newCols) {\r\n var ch = [this._terminal.defAttr, ' ', 1, 32];\r\n for (var i = 0; i < this._lines.length; i++) {\r\n if (this._lines.get(i) === undefined) {\r\n this._lines.set(i, this._terminal.blankLine(undefined, undefined, newCols));\r\n }\r\n while (this._lines.get(i).length < newCols) {\r\n this._lines.get(i).push(ch);\r\n }\r\n }\r\n }\r\n var addToY = 0;\r\n if (this._terminal.rows < newRows) {\r\n for (var y = this._terminal.rows; y < newRows; y++) {\r\n if (this._lines.length < newRows + this.ybase) {\r\n if (this.ybase > 0 && this._lines.length <= this.ybase + this.y + addToY + 1) {\r\n this.ybase--;\r\n addToY++;\r\n if (this.ydisp > 0) {\r\n this.ydisp--;\r\n }\r\n }\r\n else {\r\n this._lines.push(this._terminal.blankLine(undefined, undefined, newCols));\r\n }\r\n }\r\n }\r\n }\r\n else {\r\n for (var y = this._terminal.rows; y > newRows; y--) {\r\n if (this._lines.length > newRows + this.ybase) {\r\n if (this._lines.length > this.ybase + this.y + 1) {\r\n this._lines.pop();\r\n }\r\n else {\r\n this.ybase++;\r\n this.ydisp++;\r\n }\r\n }\r\n }\r\n }\r\n if (newMaxLength < this._lines.maxLength) {\r\n var amountToTrim = this._lines.length - newMaxLength;\r\n if (amountToTrim > 0) {\r\n this._lines.trimStart(amountToTrim);\r\n this.ybase = Math.max(this.ybase - amountToTrim, 0);\r\n this.ydisp = Math.max(this.ydisp - amountToTrim, 0);\r\n }\r\n this._lines.maxLength = newMaxLength;\r\n }\r\n if (this.y >= newRows) {\r\n this.y = newRows - 1;\r\n }\r\n if (addToY) {\r\n this.y += addToY;\r\n }\r\n if (this.x >= newCols) {\r\n this.x = newCols - 1;\r\n }\r\n this.scrollTop = 0;\r\n }\r\n this.scrollBottom = newRows - 1;\r\n };\r\n Buffer.prototype.translateBufferLineToString = function (lineIndex, trimRight, startCol, endCol) {\r\n if (startCol === void 0) { startCol = 0; }\r\n if (endCol === void 0) { endCol = null; }\r\n var lineString = '';\r\n var line = this.lines.get(lineIndex);\r\n if (!line) {\r\n return '';\r\n }\r\n var startIndex = startCol;\r\n endCol = endCol || line.length;\r\n var endIndex = endCol;\r\n for (var i = 0; i < line.length; i++) {\r\n var char = line[i];\r\n lineString += char[exports.CHAR_DATA_CHAR_INDEX];\r\n if (char[exports.CHAR_DATA_WIDTH_INDEX] === 0) {\r\n if (startCol >= i) {\r\n startIndex--;\r\n }\r\n if (endCol >= i) {\r\n endIndex--;\r\n }\r\n }\r\n else {\r\n if (char[exports.CHAR_DATA_CHAR_INDEX].length > 1) {\r\n if (startCol > i) {\r\n startIndex += char[exports.CHAR_DATA_CHAR_INDEX].length - 1;\r\n }\r\n if (endCol > i) {\r\n endIndex += char[exports.CHAR_DATA_CHAR_INDEX].length - 1;\r\n }\r\n }\r\n }\r\n }\r\n if (trimRight) {\r\n var rightWhitespaceIndex = lineString.search(/\\s+$/);\r\n if (rightWhitespaceIndex !== -1) {\r\n endIndex = Math.min(endIndex, rightWhitespaceIndex);\r\n }\r\n if (endIndex <= startIndex) {\r\n return '';\r\n }\r\n }\r\n return lineString.substring(startIndex, endIndex);\r\n };\r\n Buffer.prototype.setupTabStops = function (i) {\r\n if (i != null) {\r\n if (!this.tabs[i]) {\r\n i = this.prevStop(i);\r\n }\r\n }\r\n else {\r\n this.tabs = {};\r\n i = 0;\r\n }\r\n for (; i < this._terminal.cols; i += this._terminal.options.tabStopWidth) {\r\n this.tabs[i] = true;\r\n }\r\n };\r\n Buffer.prototype.prevStop = function (x) {\r\n if (x == null) {\r\n x = this.x;\r\n }\r\n while (!this.tabs[--x] && x > 0)\r\n ;\r\n return x >= this._terminal.cols ? this._terminal.cols - 1 : x < 0 ? 0 : x;\r\n };\r\n Buffer.prototype.nextStop = function (x) {\r\n if (x == null) {\r\n x = this.x;\r\n }\r\n while (!this.tabs[++x] && x < this._terminal.cols)\r\n ;\r\n return x >= this._terminal.cols ? this._terminal.cols - 1 : x < 0 ? 0 : x;\r\n };\r\n return Buffer;\r\n}());\r\nexports.Buffer = Buffer;\r\n\r\n\r\n\r\n},{\"./utils/CircularList\":29}],2:[function(require,module,exports){\r\n\"use strict\";\r\nvar __extends = (this && this.__extends) || (function () {\r\n var extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\r\n return function (d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n };\r\n})();\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nvar Buffer_1 = require(\"./Buffer\");\r\nvar EventEmitter_1 = require(\"./EventEmitter\");\r\nvar BufferSet = (function (_super) {\r\n __extends(BufferSet, _super);\r\n function BufferSet(_terminal) {\r\n var _this = _super.call(this) || this;\r\n _this._terminal = _terminal;\r\n _this._normal = new Buffer_1.Buffer(_this._terminal, true);\r\n _this._normal.fillViewportRows();\r\n _this._alt = new Buffer_1.Buffer(_this._terminal, false);\r\n _this._activeBuffer = _this._normal;\r\n _this.setupTabStops();\r\n return _this;\r\n }\r\n Object.defineProperty(BufferSet.prototype, \"alt\", {\r\n get: function () {\r\n return this._alt;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(BufferSet.prototype, \"active\", {\r\n get: function () {\r\n return this._activeBuffer;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(BufferSet.prototype, \"normal\", {\r\n get: function () {\r\n return this._normal;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n BufferSet.prototype.activateNormalBuffer = function () {\r\n this._alt.clear();\r\n this._activeBuffer = this._normal;\r\n this.emit('activate', this._normal);\r\n };\r\n BufferSet.prototype.activateAltBuffer = function () {\r\n this._alt.fillViewportRows();\r\n this._activeBuffer = this._alt;\r\n this.emit('activate', this._alt);\r\n };\r\n BufferSet.prototype.resize = function (newCols, newRows) {\r\n this._normal.resize(newCols, newRows);\r\n this._alt.resize(newCols, newRows);\r\n };\r\n BufferSet.prototype.setupTabStops = function (i) {\r\n this._normal.setupTabStops(i);\r\n this._alt.setupTabStops(i);\r\n };\r\n return BufferSet;\r\n}(EventEmitter_1.EventEmitter));\r\nexports.BufferSet = BufferSet;\r\n\r\n\r\n\r\n},{\"./Buffer\":1,\"./EventEmitter\":6}],3:[function(require,module,exports){\r\n\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.CHARSETS = {};\r\nexports.DEFAULT_CHARSET = exports.CHARSETS['B'];\r\nexports.CHARSETS['0'] = {\r\n '`': '\\u25c6',\r\n 'a': '\\u2592',\r\n 'b': '\\u0009',\r\n 'c': '\\u000c',\r\n 'd': '\\u000d',\r\n 'e': '\\u000a',\r\n 'f': '\\u00b0',\r\n 'g': '\\u00b1',\r\n 'h': '\\u2424',\r\n 'i': '\\u000b',\r\n 'j': '\\u2518',\r\n 'k': '\\u2510',\r\n 'l': '\\u250c',\r\n 'm': '\\u2514',\r\n 'n': '\\u253c',\r\n 'o': '\\u23ba',\r\n 'p': '\\u23bb',\r\n 'q': '\\u2500',\r\n 'r': '\\u23bc',\r\n 's': '\\u23bd',\r\n 't': '\\u251c',\r\n 'u': '\\u2524',\r\n 'v': '\\u2534',\r\n 'w': '\\u252c',\r\n 'x': '\\u2502',\r\n 'y': '\\u2264',\r\n 'z': '\\u2265',\r\n '{': '\\u03c0',\r\n '|': '\\u2260',\r\n '}': '\\u00a3',\r\n '~': '\\u00b7'\r\n};\r\nexports.CHARSETS['A'] = {\r\n '#': '£'\r\n};\r\nexports.CHARSETS['B'] = null;\r\nexports.CHARSETS['4'] = {\r\n '#': '£',\r\n '@': '¾',\r\n '[': 'ij',\r\n '\\\\': '½',\r\n ']': '|',\r\n '{': '¨',\r\n '|': 'f',\r\n '}': '¼',\r\n '~': '´'\r\n};\r\nexports.CHARSETS['C'] =\r\n exports.CHARSETS['5'] = {\r\n '[': 'Ä',\r\n '\\\\': 'Ö',\r\n ']': 'Å',\r\n '^': 'Ü',\r\n '`': 'é',\r\n '{': 'ä',\r\n '|': 'ö',\r\n '}': 'å',\r\n '~': 'ü'\r\n };\r\nexports.CHARSETS['R'] = {\r\n '#': '£',\r\n '@': 'à',\r\n '[': '°',\r\n '\\\\': 'ç',\r\n ']': '§',\r\n '{': 'é',\r\n '|': 'ù',\r\n '}': 'è',\r\n '~': '¨'\r\n};\r\nexports.CHARSETS['Q'] = {\r\n '@': 'à',\r\n '[': 'â',\r\n '\\\\': 'ç',\r\n ']': 'ê',\r\n '^': 'î',\r\n '`': 'ô',\r\n '{': 'é',\r\n '|': 'ù',\r\n '}': 'è',\r\n '~': 'û'\r\n};\r\nexports.CHARSETS['K'] = {\r\n '@': '§',\r\n '[': 'Ä',\r\n '\\\\': 'Ö',\r\n ']': 'Ü',\r\n '{': 'ä',\r\n '|': 'ö',\r\n '}': 'ü',\r\n '~': 'ß'\r\n};\r\nexports.CHARSETS['Y'] = {\r\n '#': '£',\r\n '@': '§',\r\n '[': '°',\r\n '\\\\': 'ç',\r\n ']': 'é',\r\n '`': 'ù',\r\n '{': 'à',\r\n '|': 'ò',\r\n '}': 'è',\r\n '~': 'ì'\r\n};\r\nexports.CHARSETS['E'] =\r\n exports.CHARSETS['6'] = {\r\n '@': 'Ä',\r\n '[': 'Æ',\r\n '\\\\': 'Ø',\r\n ']': 'Å',\r\n '^': 'Ü',\r\n '`': 'ä',\r\n '{': 'æ',\r\n '|': 'ø',\r\n '}': 'å',\r\n '~': 'ü'\r\n };\r\nexports.CHARSETS['Z'] = {\r\n '#': '£',\r\n '@': '§',\r\n '[': '¡',\r\n '\\\\': 'Ñ',\r\n ']': '¿',\r\n '{': '°',\r\n '|': 'ñ',\r\n '}': 'ç'\r\n};\r\nexports.CHARSETS['H'] =\r\n exports.CHARSETS['7'] = {\r\n '@': 'É',\r\n '[': 'Ä',\r\n '\\\\': 'Ö',\r\n ']': 'Å',\r\n '^': 'Ü',\r\n '`': 'é',\r\n '{': 'ä',\r\n '|': 'ö',\r\n '}': 'å',\r\n '~': 'ü'\r\n };\r\nexports.CHARSETS['='] = {\r\n '#': 'ù',\r\n '@': 'à',\r\n '[': 'é',\r\n '\\\\': 'ç',\r\n ']': 'ê',\r\n '^': 'î',\r\n '_': 'è',\r\n '`': 'ô',\r\n '{': 'ä',\r\n '|': 'ö',\r\n '}': 'ü',\r\n '~': 'û'\r\n};\r\n\r\n\r\n\r\n},{}],4:[function(require,module,exports){\r\n\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nvar CompositionHelper = (function () {\r\n function CompositionHelper(textarea, compositionView, terminal) {\r\n this.textarea = textarea;\r\n this.compositionView = compositionView;\r\n this.terminal = terminal;\r\n this.isComposing = false;\r\n this.isSendingComposition = false;\r\n this.compositionPosition = { start: null, end: null };\r\n }\r\n CompositionHelper.prototype.compositionstart = function () {\r\n this.isComposing = true;\r\n this.compositionPosition.start = this.textarea.value.length;\r\n this.compositionView.textContent = '';\r\n this.compositionView.classList.add('active');\r\n };\r\n CompositionHelper.prototype.compositionupdate = function (ev) {\r\n var _this = this;\r\n this.compositionView.textContent = ev.data;\r\n this.updateCompositionElements();\r\n setTimeout(function () {\r\n _this.compositionPosition.end = _this.textarea.value.length;\r\n }, 0);\r\n };\r\n CompositionHelper.prototype.compositionend = function () {\r\n this.finalizeComposition(true);\r\n };\r\n CompositionHelper.prototype.keydown = function (ev) {\r\n if (this.isComposing || this.isSendingComposition) {\r\n if (ev.keyCode === 229) {\r\n return false;\r\n }\r\n else if (ev.keyCode === 16 || ev.keyCode === 17 || ev.keyCode === 18) {\r\n return false;\r\n }\r\n else {\r\n this.finalizeComposition(false);\r\n }\r\n }\r\n if (ev.keyCode === 229) {\r\n this.handleAnyTextareaChanges();\r\n return false;\r\n }\r\n return true;\r\n };\r\n CompositionHelper.prototype.finalizeComposition = function (waitForPropogation) {\r\n var _this = this;\r\n this.compositionView.classList.remove('active');\r\n this.isComposing = false;\r\n this.clearTextareaPosition();\r\n if (!waitForPropogation) {\r\n this.isSendingComposition = false;\r\n var input = this.textarea.value.substring(this.compositionPosition.start, this.compositionPosition.end);\r\n this.terminal.handler(input);\r\n }\r\n else {\r\n var currentCompositionPosition_1 = {\r\n start: this.compositionPosition.start,\r\n end: this.compositionPosition.end,\r\n };\r\n this.isSendingComposition = true;\r\n setTimeout(function () {\r\n if (_this.isSendingComposition) {\r\n _this.isSendingComposition = false;\r\n var input = void 0;\r\n if (_this.isComposing) {\r\n input = _this.textarea.value.substring(currentCompositionPosition_1.start, currentCompositionPosition_1.end);\r\n }\r\n else {\r\n input = _this.textarea.value.substring(currentCompositionPosition_1.start);\r\n }\r\n _this.terminal.handler(input);\r\n }\r\n }, 0);\r\n }\r\n };\r\n CompositionHelper.prototype.handleAnyTextareaChanges = function () {\r\n var _this = this;\r\n var oldValue = this.textarea.value;\r\n setTimeout(function () {\r\n if (!_this.isComposing) {\r\n var newValue = _this.textarea.value;\r\n var diff = newValue.replace(oldValue, '');\r\n if (diff.length > 0) {\r\n _this.terminal.handler(diff);\r\n }\r\n }\r\n }, 0);\r\n };\r\n CompositionHelper.prototype.updateCompositionElements = function (dontRecurse) {\r\n var _this = this;\r\n if (!this.isComposing) {\r\n return;\r\n }\r\n if (this.terminal.buffer.isCursorInViewport) {\r\n var cellHeight = Math.ceil(this.terminal.charMeasure.height * this.terminal.options.lineHeight);\r\n var cursorTop = this.terminal.buffer.y * cellHeight;\r\n var cursorLeft = this.terminal.buffer.x * this.terminal.charMeasure.width;\r\n this.compositionView.style.left = cursorLeft + 'px';\r\n this.compositionView.style.top = cursorTop + 'px';\r\n this.compositionView.style.height = cellHeight + 'px';\r\n this.compositionView.style.lineHeight = cellHeight + 'px';\r\n var compositionViewBounds = this.compositionView.getBoundingClientRect();\r\n this.textarea.style.left = cursorLeft + 'px';\r\n this.textarea.style.top = cursorTop + 'px';\r\n this.textarea.style.width = compositionViewBounds.width + 'px';\r\n this.textarea.style.height = compositionViewBounds.height + 'px';\r\n this.textarea.style.lineHeight = compositionViewBounds.height + 'px';\r\n }\r\n if (!dontRecurse) {\r\n setTimeout(function () { return _this.updateCompositionElements(true); }, 0);\r\n }\r\n };\r\n ;\r\n CompositionHelper.prototype.clearTextareaPosition = function () {\r\n this.textarea.style.left = '';\r\n this.textarea.style.top = '';\r\n };\r\n ;\r\n return CompositionHelper;\r\n}());\r\nexports.CompositionHelper = CompositionHelper;\r\n\r\n\r\n\r\n},{}],5:[function(require,module,exports){\r\n\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nvar C0;\r\n(function (C0) {\r\n C0.NUL = '\\x00';\r\n C0.SOH = '\\x01';\r\n C0.STX = '\\x02';\r\n C0.ETX = '\\x03';\r\n C0.EOT = '\\x04';\r\n C0.ENQ = '\\x05';\r\n C0.ACK = '\\x06';\r\n C0.BEL = '\\x07';\r\n C0.BS = '\\x08';\r\n C0.HT = '\\x09';\r\n C0.LF = '\\x0a';\r\n C0.VT = '\\x0b';\r\n C0.FF = '\\x0c';\r\n C0.CR = '\\x0d';\r\n C0.SO = '\\x0e';\r\n C0.SI = '\\x0f';\r\n C0.DLE = '\\x10';\r\n C0.DC1 = '\\x11';\r\n C0.DC2 = '\\x12';\r\n C0.DC3 = '\\x13';\r\n C0.DC4 = '\\x14';\r\n C0.NAK = '\\x15';\r\n C0.SYN = '\\x16';\r\n C0.ETB = '\\x17';\r\n C0.CAN = '\\x18';\r\n C0.EM = '\\x19';\r\n C0.SUB = '\\x1a';\r\n C0.ESC = '\\x1b';\r\n C0.FS = '\\x1c';\r\n C0.GS = '\\x1d';\r\n C0.RS = '\\x1e';\r\n C0.US = '\\x1f';\r\n C0.SP = '\\x20';\r\n C0.DEL = '\\x7f';\r\n})(C0 = exports.C0 || (exports.C0 = {}));\r\n;\r\n\r\n\r\n\r\n},{}],6:[function(require,module,exports){\r\n\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nvar EventEmitter = (function () {\r\n function EventEmitter() {\r\n this._events = this._events || {};\r\n }\r\n EventEmitter.prototype.on = function (type, listener) {\r\n this._events[type] = this._events[type] || [];\r\n this._events[type].push(listener);\r\n };\r\n EventEmitter.prototype.off = function (type, listener) {\r\n if (!this._events[type]) {\r\n return;\r\n }\r\n var obj = this._events[type];\r\n var i = obj.length;\r\n while (i--) {\r\n if (obj[i] === listener || obj[i].listener === listener) {\r\n obj.splice(i, 1);\r\n return;\r\n }\r\n }\r\n };\r\n EventEmitter.prototype.removeAllListeners = function (type) {\r\n if (this._events[type]) {\r\n delete this._events[type];\r\n }\r\n };\r\n EventEmitter.prototype.once = function (type, listener) {\r\n function on() {\r\n var args = Array.prototype.slice.call(arguments);\r\n this.off(type, on);\r\n listener.apply(this, args);\r\n }\r\n on.listener = listener;\r\n this.on(type, on);\r\n };\r\n EventEmitter.prototype.emit = function (type) {\r\n var args = [];\r\n for (var _i = 1; _i < arguments.length; _i++) {\r\n args[_i - 1] = arguments[_i];\r\n }\r\n if (!this._events[type]) {\r\n return;\r\n }\r\n var obj = this._events[type];\r\n for (var i = 0; i < obj.length; i++) {\r\n obj[i].apply(this, args);\r\n }\r\n };\r\n EventEmitter.prototype.listeners = function (type) {\r\n return this._events[type] || [];\r\n };\r\n EventEmitter.prototype.destroy = function () {\r\n this._events = {};\r\n };\r\n return EventEmitter;\r\n}());\r\nexports.EventEmitter = EventEmitter;\r\n\r\n\r\n\r\n},{}],7:[function(require,module,exports){\r\n\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nvar EscapeSequences_1 = require(\"./EscapeSequences\");\r\nvar Charsets_1 = require(\"./Charsets\");\r\nvar Buffer_1 = require(\"./Buffer\");\r\nvar Types_1 = require(\"./renderer/Types\");\r\nvar InputHandler = (function () {\r\n function InputHandler(_terminal) {\r\n this._terminal = _terminal;\r\n }\r\n InputHandler.prototype.addChar = function (char, code) {\r\n if (char >= ' ') {\r\n var ch_width = exports.wcwidth(code);\r\n if (this._terminal.charset && this._terminal.charset[char]) {\r\n char = this._terminal.charset[char];\r\n }\r\n var row = this._terminal.buffer.y + this._terminal.buffer.ybase;\r\n if (!ch_width && this._terminal.buffer.x) {\r\n if (this._terminal.buffer.lines.get(row)[this._terminal.buffer.x - 1]) {\r\n if (!this._terminal.buffer.lines.get(row)[this._terminal.buffer.x - 1][Buffer_1.CHAR_DATA_WIDTH_INDEX]) {\r\n if (this._terminal.buffer.lines.get(row)[this._terminal.buffer.x - 2]) {\r\n this._terminal.buffer.lines.get(row)[this._terminal.buffer.x - 2][Buffer_1.CHAR_DATA_CHAR_INDEX] += char;\r\n this._terminal.buffer.lines.get(row)[this._terminal.buffer.x - 2][3] = char.charCodeAt(0);\r\n }\r\n }\r\n else {\r\n this._terminal.buffer.lines.get(row)[this._terminal.buffer.x - 1][Buffer_1.CHAR_DATA_CHAR_INDEX] += char;\r\n this._terminal.buffer.lines.get(row)[this._terminal.buffer.x - 1][3] = char.charCodeAt(0);\r\n }\r\n this._terminal.updateRange(this._terminal.buffer.y);\r\n }\r\n return;\r\n }\r\n if (this._terminal.buffer.x + ch_width - 1 >= this._terminal.cols) {\r\n if (this._terminal.wraparoundMode) {\r\n this._terminal.buffer.x = 0;\r\n this._terminal.buffer.y++;\r\n if (this._terminal.buffer.y > this._terminal.buffer.scrollBottom) {\r\n this._terminal.buffer.y--;\r\n this._terminal.scroll(true);\r\n }\r\n else {\r\n this._terminal.buffer.lines.get(this._terminal.buffer.y).isWrapped = true;\r\n }\r\n }\r\n else {\r\n if (ch_width === 2)\r\n return;\r\n }\r\n }\r\n row = this._terminal.buffer.y + this._terminal.buffer.ybase;\r\n if (this._terminal.insertMode) {\r\n for (var moves = 0; moves < ch_width; ++moves) {\r\n var removed = this._terminal.buffer.lines.get(this._terminal.buffer.y + this._terminal.buffer.ybase).pop();\r\n if (removed[Buffer_1.CHAR_DATA_WIDTH_INDEX] === 0\r\n && this._terminal.buffer.lines.get(row)[this._terminal.cols - 2]\r\n && this._terminal.buffer.lines.get(row)[this._terminal.cols - 2][Buffer_1.CHAR_DATA_WIDTH_INDEX] === 2) {\r\n this._terminal.buffer.lines.get(row)[this._terminal.cols - 2] = [this._terminal.curAttr, ' ', 1, ' '.charCodeAt(0)];\r\n }\r\n this._terminal.buffer.lines.get(row).splice(this._terminal.buffer.x, 0, [this._terminal.curAttr, ' ', 1, ' '.charCodeAt(0)]);\r\n }\r\n }\r\n this._terminal.buffer.lines.get(row)[this._terminal.buffer.x] = [this._terminal.curAttr, char, ch_width, char.charCodeAt(0)];\r\n this._terminal.buffer.x++;\r\n this._terminal.updateRange(this._terminal.buffer.y);\r\n if (ch_width === 2) {\r\n this._terminal.buffer.lines.get(row)[this._terminal.buffer.x] = [this._terminal.curAttr, '', 0, undefined];\r\n this._terminal.buffer.x++;\r\n }\r\n }\r\n };\r\n InputHandler.prototype.bell = function () {\r\n this._terminal.bell();\r\n };\r\n InputHandler.prototype.lineFeed = function () {\r\n if (this._terminal.convertEol) {\r\n this._terminal.buffer.x = 0;\r\n }\r\n this._terminal.buffer.y++;\r\n if (this._terminal.buffer.y > this._terminal.buffer.scrollBottom) {\r\n this._terminal.buffer.y--;\r\n this._terminal.scroll();\r\n }\r\n if (this._terminal.buffer.x >= this._terminal.cols) {\r\n this._terminal.buffer.x--;\r\n }\r\n this._terminal.emit('lineFeed');\r\n };\r\n InputHandler.prototype.carriageReturn = function () {\r\n this._terminal.buffer.x = 0;\r\n };\r\n InputHandler.prototype.backspace = function () {\r\n if (this._terminal.buffer.x > 0) {\r\n this._terminal.buffer.x--;\r\n }\r\n };\r\n InputHandler.prototype.tab = function () {\r\n this._terminal.buffer.x = this._terminal.buffer.nextStop();\r\n };\r\n InputHandler.prototype.shiftOut = function () {\r\n this._terminal.setgLevel(1);\r\n };\r\n InputHandler.prototype.shiftIn = function () {\r\n this._terminal.setgLevel(0);\r\n };\r\n InputHandler.prototype.insertChars = function (params) {\r\n var param = params[0];\r\n if (param < 1)\r\n param = 1;\r\n var row = this._terminal.buffer.y + this._terminal.buffer.ybase;\r\n var j = this._terminal.buffer.x;\r\n var ch = [this._terminal.eraseAttr(), ' ', 1, 32];\r\n while (param-- && j < this._terminal.cols) {\r\n this._terminal.buffer.lines.get(row).splice(j++, 0, ch);\r\n this._terminal.buffer.lines.get(row).pop();\r\n }\r\n };\r\n InputHandler.prototype.cursorUp = function (params) {\r\n var param = params[0];\r\n if (param < 1) {\r\n param = 1;\r\n }\r\n this._terminal.buffer.y -= param;\r\n if (this._terminal.buffer.y < 0) {\r\n this._terminal.buffer.y = 0;\r\n }\r\n };\r\n InputHandler.prototype.cursorDown = function (params) {\r\n var param = params[0];\r\n if (param < 1) {\r\n param = 1;\r\n }\r\n this._terminal.buffer.y += param;\r\n if (this._terminal.buffer.y >= this._terminal.rows) {\r\n this._terminal.buffer.y = this._terminal.rows - 1;\r\n }\r\n if (this._terminal.buffer.x >= this._terminal.cols) {\r\n this._terminal.buffer.x--;\r\n }\r\n };\r\n InputHandler.prototype.cursorForward = function (params) {\r\n var param = params[0];\r\n if (param < 1) {\r\n param = 1;\r\n }\r\n this._terminal.buffer.x += param;\r\n if (this._terminal.buffer.x >= this._terminal.cols) {\r\n this._terminal.buffer.x = this._terminal.cols - 1;\r\n }\r\n };\r\n InputHandler.prototype.cursorBackward = function (params) {\r\n var param = params[0];\r\n if (param < 1) {\r\n param = 1;\r\n }\r\n if (this._terminal.buffer.x >= this._terminal.cols) {\r\n this._terminal.buffer.x--;\r\n }\r\n this._terminal.buffer.x -= param;\r\n if (this._terminal.buffer.x < 0) {\r\n this._terminal.buffer.x = 0;\r\n }\r\n };\r\n InputHandler.prototype.cursorNextLine = function (params) {\r\n var param = params[0];\r\n if (param < 1) {\r\n param = 1;\r\n }\r\n this._terminal.buffer.y += param;\r\n if (this._terminal.buffer.y >= this._terminal.rows) {\r\n this._terminal.buffer.y = this._terminal.rows - 1;\r\n }\r\n this._terminal.buffer.x = 0;\r\n };\r\n InputHandler.prototype.cursorPrecedingLine = function (params) {\r\n var param = params[0];\r\n if (param < 1) {\r\n param = 1;\r\n }\r\n this._terminal.buffer.y -= param;\r\n if (this._terminal.buffer.y < 0) {\r\n this._terminal.buffer.y = 0;\r\n }\r\n this._terminal.buffer.x = 0;\r\n };\r\n InputHandler.prototype.cursorCharAbsolute = function (params) {\r\n var param = params[0];\r\n if (param < 1) {\r\n param = 1;\r\n }\r\n this._terminal.buffer.x = param - 1;\r\n };\r\n InputHandler.prototype.cursorPosition = function (params) {\r\n var col;\r\n var row = params[0] - 1;\r\n if (params.length >= 2) {\r\n col = params[1] - 1;\r\n }\r\n else {\r\n col = 0;\r\n }\r\n if (row < 0) {\r\n row = 0;\r\n }\r\n else if (row >= this._terminal.rows) {\r\n row = this._terminal.rows - 1;\r\n }\r\n if (col < 0) {\r\n col = 0;\r\n }\r\n else if (col >= this._terminal.cols) {\r\n col = this._terminal.cols - 1;\r\n }\r\n this._terminal.buffer.x = col;\r\n this._terminal.buffer.y = row;\r\n };\r\n InputHandler.prototype.cursorForwardTab = function (params) {\r\n var param = params[0] || 1;\r\n while (param--) {\r\n this._terminal.buffer.x = this._terminal.buffer.nextStop();\r\n }\r\n };\r\n InputHandler.prototype.eraseInDisplay = function (params) {\r\n var j;\r\n switch (params[0]) {\r\n case 0:\r\n this._terminal.eraseRight(this._terminal.buffer.x, this._terminal.buffer.y);\r\n j = this._terminal.buffer.y + 1;\r\n for (; j < this._terminal.rows; j++) {\r\n this._terminal.eraseLine(j);\r\n }\r\n break;\r\n case 1:\r\n this._terminal.eraseLeft(this._terminal.buffer.x, this._terminal.buffer.y);\r\n j = this._terminal.buffer.y;\r\n while (j--) {\r\n this._terminal.eraseLine(j);\r\n }\r\n break;\r\n case 2:\r\n j = this._terminal.rows;\r\n while (j--)\r\n this._terminal.eraseLine(j);\r\n break;\r\n case 3:\r\n var scrollBackSize = this._terminal.buffer.lines.length - this._terminal.rows;\r\n if (scrollBackSize > 0) {\r\n this._terminal.buffer.lines.trimStart(scrollBackSize);\r\n this._terminal.buffer.ybase = Math.max(this._terminal.buffer.ybase - scrollBackSize, 0);\r\n this._terminal.buffer.ydisp = Math.max(this._terminal.buffer.ydisp - scrollBackSize, 0);\r\n this._terminal.emit('scroll', 0);\r\n }\r\n break;\r\n }\r\n };\r\n InputHandler.prototype.eraseInLine = function (params) {\r\n switch (params[0]) {\r\n case 0:\r\n this._terminal.eraseRight(this._terminal.buffer.x, this._terminal.buffer.y);\r\n break;\r\n case 1:\r\n this._terminal.eraseLeft(this._terminal.buffer.x, this._terminal.buffer.y);\r\n break;\r\n case 2:\r\n this._terminal.eraseLine(this._terminal.buffer.y);\r\n break;\r\n }\r\n };\r\n InputHandler.prototype.insertLines = function (params) {\r\n var param = params[0];\r\n if (param < 1) {\r\n param = 1;\r\n }\r\n var row = this._terminal.buffer.y + this._terminal.buffer.ybase;\r\n var scrollBottomRowsOffset = this._terminal.rows - 1 - this._terminal.buffer.scrollBottom;\r\n var scrollBottomAbsolute = this._terminal.rows - 1 + this._terminal.buffer.ybase - scrollBottomRowsOffset + 1;\r\n while (param--) {\r\n this._terminal.buffer.lines.splice(scrollBottomAbsolute - 1, 1);\r\n this._terminal.buffer.lines.splice(row, 0, this._terminal.blankLine(true));\r\n }\r\n this._terminal.updateRange(this._terminal.buffer.y);\r\n this._terminal.updateRange(this._terminal.buffer.scrollBottom);\r\n };\r\n InputHandler.prototype.deleteLines = function (params) {\r\n var param = params[0];\r\n if (param < 1) {\r\n param = 1;\r\n }\r\n var row = this._terminal.buffer.y + this._terminal.buffer.ybase;\r\n var j;\r\n j = this._terminal.rows - 1 - this._terminal.buffer.scrollBottom;\r\n j = this._terminal.rows - 1 + this._terminal.buffer.ybase - j;\r\n while (param--) {\r\n this._terminal.buffer.lines.splice(row, 1);\r\n this._terminal.buffer.lines.splice(j, 0, this._terminal.blankLine(true));\r\n }\r\n this._terminal.updateRange(this._terminal.buffer.y);\r\n this._terminal.updateRange(this._terminal.buffer.scrollBottom);\r\n };\r\n InputHandler.prototype.deleteChars = function (params) {\r\n var param = params[0];\r\n if (param < 1) {\r\n param = 1;\r\n }\r\n var row = this._terminal.buffer.y + this._terminal.buffer.ybase;\r\n var ch = [this._terminal.eraseAttr(), ' ', 1, 32];\r\n while (param--) {\r\n this._terminal.buffer.lines.get(row).splice(this._terminal.buffer.x, 1);\r\n this._terminal.buffer.lines.get(row).push(ch);\r\n }\r\n };\r\n InputHandler.prototype.scrollUp = function (params) {\r\n var param = params[0] || 1;\r\n while (param--) {\r\n this._terminal.buffer.lines.splice(this._terminal.buffer.ybase + this._terminal.buffer.scrollTop, 1);\r\n this._terminal.buffer.lines.splice(this._terminal.buffer.ybase + this._terminal.buffer.scrollBottom, 0, this._terminal.blankLine());\r\n }\r\n this._terminal.updateRange(this._terminal.buffer.scrollTop);\r\n this._terminal.updateRange(this._terminal.buffer.scrollBottom);\r\n };\r\n InputHandler.prototype.scrollDown = function (params) {\r\n var param = params[0] || 1;\r\n while (param--) {\r\n this._terminal.buffer.lines.splice(this._terminal.buffer.ybase + this._terminal.buffer.scrollBottom, 1);\r\n this._terminal.buffer.lines.splice(this._terminal.buffer.ybase + this._terminal.buffer.scrollTop, 0, this._terminal.blankLine());\r\n }\r\n this._terminal.updateRange(this._terminal.buffer.scrollTop);\r\n this._terminal.updateRange(this._terminal.buffer.scrollBottom);\r\n };\r\n InputHandler.prototype.eraseChars = function (params) {\r\n var param = params[0];\r\n if (param < 1) {\r\n param = 1;\r\n }\r\n var row = this._terminal.buffer.y + this._terminal.buffer.ybase;\r\n var j = this._terminal.buffer.x;\r\n var ch = [this._terminal.eraseAttr(), ' ', 1, 32];\r\n while (param-- && j < this._terminal.cols) {\r\n this._terminal.buffer.lines.get(row)[j++] = ch;\r\n }\r\n };\r\n InputHandler.prototype.cursorBackwardTab = function (params) {\r\n var param = params[0] || 1;\r\n while (param--) {\r\n this._terminal.buffer.x = this._terminal.buffer.prevStop();\r\n }\r\n };\r\n InputHandler.prototype.charPosAbsolute = function (params) {\r\n var param = params[0];\r\n if (param < 1) {\r\n param = 1;\r\n }\r\n this._terminal.buffer.x = param - 1;\r\n if (this._terminal.buffer.x >= this._terminal.cols) {\r\n this._terminal.buffer.x = this._terminal.cols - 1;\r\n }\r\n };\r\n InputHandler.prototype.HPositionRelative = function (params) {\r\n var param = params[0];\r\n if (param < 1) {\r\n param = 1;\r\n }\r\n this._terminal.buffer.x += param;\r\n if (this._terminal.buffer.x >= this._terminal.cols) {\r\n this._terminal.buffer.x = this._terminal.cols - 1;\r\n }\r\n };\r\n InputHandler.prototype.repeatPrecedingCharacter = function (params) {\r\n var param = params[0] || 1;\r\n var line = this._terminal.buffer.lines.get(this._terminal.buffer.ybase + this._terminal.buffer.y);\r\n var ch = line[this._terminal.buffer.x - 1] || [this._terminal.defAttr, ' ', 1, 32];\r\n while (param--) {\r\n line[this._terminal.buffer.x++] = ch;\r\n }\r\n };\r\n InputHandler.prototype.sendDeviceAttributes = function (params) {\r\n if (params[0] > 0) {\r\n return;\r\n }\r\n if (!this._terminal.prefix) {\r\n if (this._terminal.is('xterm') || this._terminal.is('rxvt-unicode') || this._terminal.is('screen')) {\r\n this._terminal.send(EscapeSequences_1.C0.ESC + '[?1;2c');\r\n }\r\n else if (this._terminal.is('linux')) {\r\n this._terminal.send(EscapeSequences_1.C0.ESC + '[?6c');\r\n }\r\n }\r\n else if (this._terminal.prefix === '>') {\r\n if (this._terminal.is('xterm')) {\r\n this._terminal.send(EscapeSequences_1.C0.ESC + '[>0;276;0c');\r\n }\r\n else if (this._terminal.is('rxvt-unicode')) {\r\n this._terminal.send(EscapeSequences_1.C0.ESC + '[>85;95;0c');\r\n }\r\n else if (this._terminal.is('linux')) {\r\n this._terminal.send(params[0] + 'c');\r\n }\r\n else if (this._terminal.is('screen')) {\r\n this._terminal.send(EscapeSequences_1.C0.ESC + '[>83;40003;0c');\r\n }\r\n }\r\n };\r\n InputHandler.prototype.linePosAbsolute = function (params) {\r\n var param = params[0];\r\n if (param < 1) {\r\n param = 1;\r\n }\r\n this._terminal.buffer.y = param - 1;\r\n if (this._terminal.buffer.y >= this._terminal.rows) {\r\n this._terminal.buffer.y = this._terminal.rows - 1;\r\n }\r\n };\r\n InputHandler.prototype.VPositionRelative = function (params) {\r\n var param = params[0];\r\n if (param < 1) {\r\n param = 1;\r\n }\r\n this._terminal.buffer.y += param;\r\n if (this._terminal.buffer.y >= this._terminal.rows) {\r\n this._terminal.buffer.y = this._terminal.rows - 1;\r\n }\r\n if (this._terminal.buffer.x >= this._terminal.cols) {\r\n this._terminal.buffer.x--;\r\n }\r\n };\r\n InputHandler.prototype.HVPosition = function (params) {\r\n if (params[0] < 1)\r\n params[0] = 1;\r\n if (params[1] < 1)\r\n params[1] = 1;\r\n this._terminal.buffer.y = params[0] - 1;\r\n if (this._terminal.buffer.y >= this._terminal.rows) {\r\n this._terminal.buffer.y = this._terminal.rows - 1;\r\n }\r\n this._terminal.buffer.x = params[1] - 1;\r\n if (this._terminal.buffer.x >= this._terminal.cols) {\r\n this._terminal.buffer.x = this._terminal.cols - 1;\r\n }\r\n };\r\n InputHandler.prototype.tabClear = function (params) {\r\n var param = params[0];\r\n if (param <= 0) {\r\n delete this._terminal.buffer.tabs[this._terminal.buffer.x];\r\n }\r\n else if (param === 3) {\r\n this._terminal.buffer.tabs = {};\r\n }\r\n };\r\n InputHandler.prototype.setMode = function (params) {\r\n if (params.length > 1) {\r\n for (var i = 0; i < params.length; i++) {\r\n this.setMode([params[i]]);\r\n }\r\n return;\r\n }\r\n if (!this._terminal.prefix) {\r\n switch (params[0]) {\r\n case 4:\r\n this._terminal.insertMode = true;\r\n break;\r\n case 20:\r\n break;\r\n }\r\n }\r\n else if (this._terminal.prefix === '?') {\r\n switch (params[0]) {\r\n case 1:\r\n this._terminal.applicationCursor = true;\r\n break;\r\n case 2:\r\n this._terminal.setgCharset(0, Charsets_1.DEFAULT_CHARSET);\r\n this._terminal.setgCharset(1, Charsets_1.DEFAULT_CHARSET);\r\n this._terminal.setgCharset(2, Charsets_1.DEFAULT_CHARSET);\r\n this._terminal.setgCharset(3, Charsets_1.DEFAULT_CHARSET);\r\n break;\r\n case 3:\r\n this._terminal.savedCols = this._terminal.cols;\r\n this._terminal.resize(132, this._terminal.rows);\r\n break;\r\n case 6:\r\n this._terminal.originMode = true;\r\n break;\r\n case 7:\r\n this._terminal.wraparoundMode = true;\r\n break;\r\n case 12:\r\n break;\r\n case 66:\r\n this._terminal.log('Serial port requested application keypad.');\r\n this._terminal.applicationKeypad = true;\r\n this._terminal.viewport.syncScrollArea();\r\n break;\r\n case 9:\r\n case 1000:\r\n case 1002:\r\n case 1003:\r\n this._terminal.x10Mouse = params[0] === 9;\r\n this._terminal.vt200Mouse = params[0] === 1000;\r\n this._terminal.normalMouse = params[0] > 1000;\r\n this._terminal.mouseEvents = true;\r\n this._terminal.element.classList.add('enable-mouse-events');\r\n this._terminal.selectionManager.disable();\r\n this._terminal.log('Binding to mouse events.');\r\n break;\r\n case 1004:\r\n this._terminal.sendFocus = true;\r\n break;\r\n case 1005:\r\n this._terminal.utfMouse = true;\r\n break;\r\n case 1006:\r\n this._terminal.sgrMouse = true;\r\n break;\r\n case 1015:\r\n this._terminal.urxvtMouse = true;\r\n break;\r\n case 25:\r\n this._terminal.cursorHidden = false;\r\n break;\r\n case 1049:\r\n case 47:\r\n case 1047:\r\n this._terminal.buffers.activateAltBuffer();\r\n this._terminal.selectionManager.setBuffer(this._terminal.buffer);\r\n this._terminal.viewport.syncScrollArea();\r\n this._terminal.showCursor();\r\n break;\r\n }\r\n }\r\n };\r\n InputHandler.prototype.resetMode = function (params) {\r\n if (params.length > 1) {\r\n for (var i = 0; i < params.length; i++) {\r\n this.resetMode([params[i]]);\r\n }\r\n return;\r\n }\r\n if (!this._terminal.prefix) {\r\n switch (params[0]) {\r\n case 4:\r\n this._terminal.insertMode = false;\r\n break;\r\n case 20:\r\n break;\r\n }\r\n }\r\n else if (this._terminal.prefix === '?') {\r\n switch (params[0]) {\r\n case 1:\r\n this._terminal.applicationCursor = false;\r\n break;\r\n case 3:\r\n if (this._terminal.cols === 132 && this._terminal.savedCols) {\r\n this._terminal.resize(this._terminal.savedCols, this._terminal.rows);\r\n }\r\n delete this._terminal.savedCols;\r\n break;\r\n case 6:\r\n this._terminal.originMode = false;\r\n break;\r\n case 7:\r\n this._terminal.wraparoundMode = false;\r\n break;\r\n case 12:\r\n break;\r\n case 66:\r\n this._terminal.log('Switching back to normal keypad.');\r\n this._terminal.applicationKeypad = false;\r\n this._terminal.viewport.syncScrollArea();\r\n break;\r\n case 9:\r\n case 1000:\r\n case 1002:\r\n case 1003:\r\n this._terminal.x10Mouse = false;\r\n this._terminal.vt200Mouse = false;\r\n this._terminal.normalMouse = false;\r\n this._terminal.mouseEvents = false;\r\n this._terminal.element.classList.remove('enable-mouse-events');\r\n this._terminal.selectionManager.enable();\r\n break;\r\n case 1004:\r\n this._terminal.sendFocus = false;\r\n break;\r\n case 1005:\r\n this._terminal.utfMouse = false;\r\n break;\r\n case 1006:\r\n this._terminal.sgrMouse = false;\r\n break;\r\n case 1015:\r\n this._terminal.urxvtMouse = false;\r\n break;\r\n case 25:\r\n this._terminal.cursorHidden = true;\r\n break;\r\n case 1049:\r\n case 47:\r\n case 1047:\r\n this._terminal.buffers.activateNormalBuffer();\r\n this._terminal.selectionManager.setBuffer(this._terminal.buffer);\r\n this._terminal.refresh(0, this._terminal.rows - 1);\r\n this._terminal.viewport.syncScrollArea();\r\n this._terminal.showCursor();\r\n break;\r\n }\r\n }\r\n };\r\n InputHandler.prototype.charAttributes = function (params) {\r\n if (params.length === 1 && params[0] === 0) {\r\n this._terminal.curAttr = this._terminal.defAttr;\r\n return;\r\n }\r\n var l = params.length;\r\n var flags = this._terminal.curAttr >> 18;\r\n var fg = (this._terminal.curAttr >> 9) & 0x1ff;\r\n var bg = this._terminal.curAttr & 0x1ff;\r\n var p;\r\n for (var i = 0; i < l; i++) {\r\n p = params[i];\r\n if (p >= 30 && p <= 37) {\r\n fg = p - 30;\r\n }\r\n else if (p >= 40 && p <= 47) {\r\n bg = p - 40;\r\n }\r\n else if (p >= 90 && p <= 97) {\r\n p += 8;\r\n fg = p - 90;\r\n }\r\n else if (p >= 100 && p <= 107) {\r\n p += 8;\r\n bg = p - 100;\r\n }\r\n else if (p === 0) {\r\n flags = this._terminal.defAttr >> 18;\r\n fg = (this._terminal.defAttr >> 9) & 0x1ff;\r\n bg = this._terminal.defAttr & 0x1ff;\r\n }\r\n else if (p === 1) {\r\n flags |= Types_1.FLAGS.BOLD;\r\n }\r\n else if (p === 4) {\r\n flags |= Types_1.FLAGS.UNDERLINE;\r\n }\r\n else if (p === 5) {\r\n flags |= Types_1.FLAGS.BLINK;\r\n }\r\n else if (p === 7) {\r\n flags |= Types_1.FLAGS.INVERSE;\r\n }\r\n else if (p === 8) {\r\n flags |= Types_1.FLAGS.INVISIBLE;\r\n }\r\n else if (p === 2) {\r\n flags |= Types_1.FLAGS.DIM;\r\n }\r\n else if (p === 22) {\r\n flags &= ~Types_1.FLAGS.BOLD;\r\n flags &= ~Types_1.FLAGS.DIM;\r\n }\r\n else if (p === 24) {\r\n flags &= ~Types_1.FLAGS.UNDERLINE;\r\n }\r\n else if (p === 25) {\r\n flags &= ~Types_1.FLAGS.BLINK;\r\n }\r\n else if (p === 27) {\r\n flags &= ~Types_1.FLAGS.INVERSE;\r\n }\r\n else if (p === 28) {\r\n flags &= ~Types_1.FLAGS.INVISIBLE;\r\n }\r\n else if (p === 39) {\r\n fg = (this._terminal.defAttr >> 9) & 0x1ff;\r\n }\r\n else if (p === 49) {\r\n bg = this._terminal.defAttr & 0x1ff;\r\n }\r\n else if (p === 38) {\r\n if (params[i + 1] === 2) {\r\n i += 2;\r\n fg = this._terminal.matchColor(params[i] & 0xff, params[i + 1] & 0xff, params[i + 2] & 0xff);\r\n if (fg === -1)\r\n fg = 0x1ff;\r\n i += 2;\r\n }\r\n else if (params[i + 1] === 5) {\r\n i += 2;\r\n p = params[i] & 0xff;\r\n fg = p;\r\n }\r\n }\r\n else if (p === 48) {\r\n if (params[i + 1] === 2) {\r\n i += 2;\r\n bg = this._terminal.matchColor(params[i] & 0xff, params[i + 1] & 0xff, params[i + 2] & 0xff);\r\n if (bg === -1)\r\n bg = 0x1ff;\r\n i += 2;\r\n }\r\n else if (params[i + 1] === 5) {\r\n i += 2;\r\n p = params[i] & 0xff;\r\n bg = p;\r\n }\r\n }\r\n else if (p === 100) {\r\n fg = (this._terminal.defAttr >> 9) & 0x1ff;\r\n bg = this._terminal.defAttr & 0x1ff;\r\n }\r\n else {\r\n this._terminal.error('Unknown SGR attribute: %d.', p);\r\n }\r\n }\r\n this._terminal.curAttr = (flags << 18) | (fg << 9) | bg;\r\n };\r\n InputHandler.prototype.deviceStatus = function (params) {\r\n if (!this._terminal.prefix) {\r\n switch (params[0]) {\r\n case 5:\r\n this._terminal.send(EscapeSequences_1.C0.ESC + '[0n');\r\n break;\r\n case 6:\r\n this._terminal.send(EscapeSequences_1.C0.ESC + '['\r\n + (this._terminal.buffer.y + 1)\r\n + ';'\r\n + (this._terminal.buffer.x + 1)\r\n + 'R');\r\n break;\r\n }\r\n }\r\n else if (this._terminal.prefix === '?') {\r\n switch (params[0]) {\r\n case 6:\r\n this._terminal.send(EscapeSequences_1.C0.ESC + '[?'\r\n + (this._terminal.buffer.y + 1)\r\n + ';'\r\n + (this._terminal.buffer.x + 1)\r\n + 'R');\r\n break;\r\n case 15:\r\n break;\r\n case 25:\r\n break;\r\n case 26:\r\n break;\r\n case 53:\r\n break;\r\n }\r\n }\r\n };\r\n InputHandler.prototype.softReset = function (params) {\r\n this._terminal.cursorHidden = false;\r\n this._terminal.insertMode = false;\r\n this._terminal.originMode = false;\r\n this._terminal.wraparoundMode = true;\r\n this._terminal.applicationKeypad = false;\r\n this._terminal.viewport.syncScrollArea();\r\n this._terminal.applicationCursor = false;\r\n this._terminal.buffer.scrollTop = 0;\r\n this._terminal.buffer.scrollBottom = this._terminal.rows - 1;\r\n this._terminal.curAttr = this._terminal.defAttr;\r\n this._terminal.buffer.x = this._terminal.buffer.y = 0;\r\n this._terminal.charset = null;\r\n this._terminal.glevel = 0;\r\n this._terminal.charsets = [null];\r\n };\r\n InputHandler.prototype.setCursorStyle = function (params) {\r\n var param = params[0] < 1 ? 1 : params[0];\r\n switch (param) {\r\n case 1:\r\n case 2:\r\n this._terminal.setOption('cursorStyle', 'block');\r\n break;\r\n case 3:\r\n case 4:\r\n this._terminal.setOption('cursorStyle', 'underline');\r\n break;\r\n case 5:\r\n case 6:\r\n this._terminal.setOption('cursorStyle', 'bar');\r\n break;\r\n }\r\n var isBlinking = param % 2 === 1;\r\n this._terminal.setOption('cursorBlink', isBlinking);\r\n };\r\n InputHandler.prototype.setScrollRegion = function (params) {\r\n if (this._terminal.prefix)\r\n return;\r\n this._terminal.buffer.scrollTop = (params[0] || 1) - 1;\r\n this._terminal.buffer.scrollBottom = (params[1] && params[1] <= this._terminal.rows ? params[1] : this._terminal.rows) - 1;\r\n this._terminal.buffer.x = 0;\r\n this._terminal.buffer.y = 0;\r\n };\r\n InputHandler.prototype.saveCursor = function (params) {\r\n this._terminal.buffer.savedX = this._terminal.buffer.x;\r\n this._terminal.buffer.savedY = this._terminal.buffer.y;\r\n };\r\n InputHandler.prototype.restoreCursor = function (params) {\r\n this._terminal.buffer.x = this._terminal.buffer.savedX || 0;\r\n this._terminal.buffer.y = this._terminal.buffer.savedY || 0;\r\n };\r\n return InputHandler;\r\n}());\r\nexports.InputHandler = InputHandler;\r\nexports.wcwidth = (function (opts) {\r\n var COMBINING_BMP = [\r\n [0x0300, 0x036F], [0x0483, 0x0486], [0x0488, 0x0489],\r\n [0x0591, 0x05BD], [0x05BF, 0x05BF], [0x05C1, 0x05C2],\r\n [0x05C4, 0x05C5], [0x05C7, 0x05C7], [0x0600, 0x0603],\r\n [0x0610, 0x0615], [0x064B, 0x065E], [0x0670, 0x0670],\r\n [0x06D6, 0x06E4], [0x06E7, 0x06E8], [0x06EA, 0x06ED],\r\n [0x070F, 0x070F], [0x0711, 0x0711], [0x0730, 0x074A],\r\n [0x07A6, 0x07B0], [0x07EB, 0x07F3], [0x0901, 0x0902],\r\n [0x093C, 0x093C], [0x0941, 0x0948], [0x094D, 0x094D],\r\n [0x0951, 0x0954], [0x0962, 0x0963], [0x0981, 0x0981],\r\n [0x09BC, 0x09BC], [0x09C1, 0x09C4], [0x09CD, 0x09CD],\r\n [0x09E2, 0x09E3], [0x0A01, 0x0A02], [0x0A3C, 0x0A3C],\r\n [0x0A41, 0x0A42], [0x0A47, 0x0A48], [0x0A4B, 0x0A4D],\r\n [0x0A70, 0x0A71], [0x0A81, 0x0A82], [0x0ABC, 0x0ABC],\r\n [0x0AC1, 0x0AC5], [0x0AC7, 0x0AC8], [0x0ACD, 0x0ACD],\r\n [0x0AE2, 0x0AE3], [0x0B01, 0x0B01], [0x0B3C, 0x0B3C],\r\n [0x0B3F, 0x0B3F], [0x0B41, 0x0B43], [0x0B4D, 0x0B4D],\r\n [0x0B56, 0x0B56], [0x0B82, 0x0B82], [0x0BC0, 0x0BC0],\r\n [0x0BCD, 0x0BCD], [0x0C3E, 0x0C40], [0x0C46, 0x0C48],\r\n [0x0C4A, 0x0C4D], [0x0C55, 0x0C56], [0x0CBC, 0x0CBC],\r\n [0x0CBF, 0x0CBF], [0x0CC6, 0x0CC6], [0x0CCC, 0x0CCD],\r\n [0x0CE2, 0x0CE3], [0x0D41, 0x0D43], [0x0D4D, 0x0D4D],\r\n [0x0DCA, 0x0DCA], [0x0DD2, 0x0DD4], [0x0DD6, 0x0DD6],\r\n [0x0E31, 0x0E31], [0x0E34, 0x0E3A], [0x0E47, 0x0E4E],\r\n [0x0EB1, 0x0EB1], [0x0EB4, 0x0EB9], [0x0EBB, 0x0EBC],\r\n [0x0EC8, 0x0ECD], [0x0F18, 0x0F19], [0x0F35, 0x0F35],\r\n [0x0F37, 0x0F37], [0x0F39, 0x0F39], [0x0F71, 0x0F7E],\r\n [0x0F80, 0x0F84], [0x0F86, 0x0F87], [0x0F90, 0x0F97],\r\n [0x0F99, 0x0FBC], [0x0FC6, 0x0FC6], [0x102D, 0x1030],\r\n [0x1032, 0x1032], [0x1036, 0x1037], [0x1039, 0x1039],\r\n [0x1058, 0x1059], [0x1160, 0x11FF], [0x135F, 0x135F],\r\n [0x1712, 0x1714], [0x1732, 0x1734], [0x1752, 0x1753],\r\n [0x1772, 0x1773], [0x17B4, 0x17B5], [0x17B7, 0x17BD],\r\n [0x17C6, 0x17C6], [0x17C9, 0x17D3], [0x17DD, 0x17DD],\r\n [0x180B, 0x180D], [0x18A9, 0x18A9], [0x1920, 0x1922],\r\n [0x1927, 0x1928], [0x1932, 0x1932], [0x1939, 0x193B],\r\n [0x1A17, 0x1A18], [0x1B00, 0x1B03], [0x1B34, 0x1B34],\r\n [0x1B36, 0x1B3A], [0x1B3C, 0x1B3C], [0x1B42, 0x1B42],\r\n [0x1B6B, 0x1B73], [0x1DC0, 0x1DCA], [0x1DFE, 0x1DFF],\r\n [0x200B, 0x200F], [0x202A, 0x202E], [0x2060, 0x2063],\r\n [0x206A, 0x206F], [0x20D0, 0x20EF], [0x302A, 0x302F],\r\n [0x3099, 0x309A], [0xA806, 0xA806], [0xA80B, 0xA80B],\r\n [0xA825, 0xA826], [0xFB1E, 0xFB1E], [0xFE00, 0xFE0F],\r\n [0xFE20, 0xFE23], [0xFEFF, 0xFEFF], [0xFFF9, 0xFFFB],\r\n ];\r\n var COMBINING_HIGH = [\r\n [0x10A01, 0x10A03], [0x10A05, 0x10A06], [0x10A0C, 0x10A0F],\r\n [0x10A38, 0x10A3A], [0x10A3F, 0x10A3F], [0x1D167, 0x1D169],\r\n [0x1D173, 0x1D182], [0x1D185, 0x1D18B], [0x1D1AA, 0x1D1AD],\r\n [0x1D242, 0x1D244], [0xE0001, 0xE0001], [0xE0020, 0xE007F],\r\n [0xE0100, 0xE01EF]\r\n ];\r\n function bisearch(ucs, data) {\r\n var min = 0;\r\n var max = data.length - 1;\r\n var mid;\r\n if (ucs < data[0][0] || ucs > data[max][1])\r\n return false;\r\n while (max >= min) {\r\n mid = (min + max) >> 1;\r\n if (ucs > data[mid][1])\r\n min = mid + 1;\r\n else if (ucs < data[mid][0])\r\n max = mid - 1;\r\n else\r\n return true;\r\n }\r\n return false;\r\n }\r\n function wcwidthBMP(ucs) {\r\n if (ucs === 0)\r\n return opts.nul;\r\n if (ucs < 32 || (ucs >= 0x7f && ucs < 0xa0))\r\n return opts.control;\r\n if (bisearch(ucs, COMBINING_BMP))\r\n return 0;\r\n if (isWideBMP(ucs)) {\r\n return 2;\r\n }\r\n return 1;\r\n }\r\n function isWideBMP(ucs) {\r\n return (ucs >= 0x1100 && (ucs <= 0x115f ||\r\n ucs === 0x2329 ||\r\n ucs === 0x232a ||\r\n (ucs >= 0x2e80 && ucs <= 0xa4cf && ucs !== 0x303f) ||\r\n (ucs >= 0xac00 && ucs <= 0xd7a3) ||\r\n (ucs >= 0xf900 && ucs <= 0xfaff) ||\r\n (ucs >= 0xfe10 && ucs <= 0xfe19) ||\r\n (ucs >= 0xfe30 && ucs <= 0xfe6f) ||\r\n (ucs >= 0xff00 && ucs <= 0xff60) ||\r\n (ucs >= 0xffe0 && ucs <= 0xffe6)));\r\n }\r\n function wcwidthHigh(ucs) {\r\n if (bisearch(ucs, COMBINING_HIGH))\r\n return 0;\r\n if ((ucs >= 0x20000 && ucs <= 0x2fffd) || (ucs >= 0x30000 && ucs <= 0x3fffd)) {\r\n return 2;\r\n }\r\n return 1;\r\n }\r\n var control = opts.control | 0;\r\n var table = null;\r\n function init_table() {\r\n var CODEPOINTS = 65536;\r\n var BITWIDTH = 2;\r\n var ITEMSIZE = 32;\r\n var CONTAINERSIZE = CODEPOINTS * BITWIDTH / ITEMSIZE;\r\n var CODEPOINTS_PER_ITEM = ITEMSIZE / BITWIDTH;\r\n table = (typeof Uint32Array === 'undefined')\r\n ? new Array(CONTAINERSIZE)\r\n : new Uint32Array(CONTAINERSIZE);\r\n for (var i = 0; i < CONTAINERSIZE; ++i) {\r\n var num = 0;\r\n var pos = CODEPOINTS_PER_ITEM;\r\n while (pos--)\r\n num = (num << 2) | wcwidthBMP(CODEPOINTS_PER_ITEM * i + pos);\r\n table[i] = num;\r\n }\r\n return table;\r\n }\r\n return function (num) {\r\n num = num | 0;\r\n if (num < 32)\r\n return control | 0;\r\n if (num < 127)\r\n return 1;\r\n var t = table || init_table();\r\n if (num < 65536)\r\n return t[num >> 4] >> ((num & 15) << 1) & 3;\r\n return wcwidthHigh(num);\r\n };\r\n})({ nul: 0, control: 0 });\r\n\r\n\r\n\r\n},{\"./Buffer\":1,\"./Charsets\":3,\"./EscapeSequences\":5,\"./renderer/Types\":26}],8:[function(require,module,exports){\r\n\"use strict\";\r\nvar __extends = (this && this.__extends) || (function () {\r\n var extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\r\n return function (d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n };\r\n})();\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nvar Types_1 = require(\"./Types\");\r\nvar MouseZoneManager_1 = require(\"./input/MouseZoneManager\");\r\nvar EventEmitter_1 = require(\"./EventEmitter\");\r\nvar protocolClause = '(https?:\\\\/\\\\/)';\r\nvar domainCharacterSet = '[\\\\da-z\\\\.-]+';\r\nvar negatedDomainCharacterSet = '[^\\\\da-z\\\\.-]+';\r\nvar domainBodyClause = '(' + domainCharacterSet + ')';\r\nvar tldClause = '([a-z\\\\.]{2,6})';\r\nvar ipClause = '((\\\\d{1,3}\\\\.){3}\\\\d{1,3})';\r\nvar localHostClause = '(localhost)';\r\nvar portClause = '(:\\\\d{1,5})';\r\nvar hostClause = '((' + domainBodyClause + '\\\\.' + tldClause + ')|' + ipClause + '|' + localHostClause + ')' + portClause + '?';\r\nvar pathClause = '(\\\\/[\\\\/\\\\w\\\\.\\\\-%~]*)*';\r\nvar queryStringHashFragmentCharacterSet = '[0-9\\\\w\\\\[\\\\]\\\\(\\\\)\\\\/\\\\?\\\\!#@$%&\\'*+,:;~\\\\=\\\\.\\\\-]*';\r\nvar queryStringClause = '(\\\\?' + queryStringHashFragmentCharacterSet + ')?';\r\nvar hashFragmentClause = '(#' + queryStringHashFragmentCharacterSet + ')?';\r\nvar negatedPathCharacterSet = '[^\\\\/\\\\w\\\\.\\\\-%]+';\r\nvar bodyClause = hostClause + pathClause + queryStringClause + hashFragmentClause;\r\nvar start = '(?:^|' + negatedDomainCharacterSet + ')(';\r\nvar end = ')($|' + negatedPathCharacterSet + ')';\r\nvar strictUrlRegex = new RegExp(start + protocolClause + bodyClause + end);\r\nvar HYPERTEXT_LINK_MATCHER_ID = 0;\r\nvar Linkifier = (function (_super) {\r\n __extends(Linkifier, _super);\r\n function Linkifier(_terminal) {\r\n var _this = _super.call(this) || this;\r\n _this._terminal = _terminal;\r\n _this._linkMatchers = [];\r\n _this._nextLinkMatcherId = HYPERTEXT_LINK_MATCHER_ID;\r\n _this._rowsToLinkify = {\r\n start: null,\r\n end: null\r\n };\r\n _this.registerLinkMatcher(strictUrlRegex, null, { matchIndex: 1 });\r\n return _this;\r\n }\r\n Linkifier.prototype.attachToDom = function (mouseZoneManager) {\r\n this._mouseZoneManager = mouseZoneManager;\r\n };\r\n Linkifier.prototype.linkifyRows = function (start, end) {\r\n var _this = this;\r\n if (!this._mouseZoneManager) {\r\n return;\r\n }\r\n if (!this._rowsToLinkify.start) {\r\n this._rowsToLinkify.start = start;\r\n this._rowsToLinkify.end = end;\r\n }\r\n else {\r\n this._rowsToLinkify.start = this._rowsToLinkify.start < start ? this._rowsToLinkify.start : start;\r\n this._rowsToLinkify.end = this._rowsToLinkify.end > end ? this._rowsToLinkify.end : end;\r\n }\r\n this._mouseZoneManager.clearAll(start, end);\r\n if (this._rowsTimeoutId) {\r\n clearTimeout(this._rowsTimeoutId);\r\n }\r\n this._rowsTimeoutId = setTimeout(function () { return _this._linkifyRows(); }, Linkifier.TIME_BEFORE_LINKIFY);\r\n };\r\n Linkifier.prototype._linkifyRows = function () {\r\n this._rowsTimeoutId = null;\r\n for (var i = this._rowsToLinkify.start; i <= this._rowsToLinkify.end; i++) {\r\n this._linkifyRow(i);\r\n }\r\n this._rowsToLinkify.start = null;\r\n this._rowsToLinkify.end = null;\r\n };\r\n Linkifier.prototype.setHypertextLinkHandler = function (handler) {\r\n this._linkMatchers[HYPERTEXT_LINK_MATCHER_ID].handler = handler;\r\n };\r\n Linkifier.prototype.setHypertextValidationCallback = function (callback) {\r\n this._linkMatchers[HYPERTEXT_LINK_MATCHER_ID].validationCallback = callback;\r\n };\r\n Linkifier.prototype.registerLinkMatcher = function (regex, handler, options) {\r\n if (options === void 0) { options = {}; }\r\n if (this._nextLinkMatcherId !== HYPERTEXT_LINK_MATCHER_ID && !handler) {\r\n throw new Error('handler must be defined');\r\n }\r\n var matcher = {\r\n id: this._nextLinkMatcherId++,\r\n regex: regex,\r\n handler: handler,\r\n matchIndex: options.matchIndex,\r\n validationCallback: options.validationCallback,\r\n hoverTooltipCallback: options.tooltipCallback,\r\n hoverLeaveCallback: options.leaveCallback,\r\n priority: options.priority || 0\r\n };\r\n this._addLinkMatcherToList(matcher);\r\n return matcher.id;\r\n };\r\n Linkifier.prototype._addLinkMatcherToList = function (matcher) {\r\n if (this._linkMatchers.length === 0) {\r\n this._linkMatchers.push(matcher);\r\n return;\r\n }\r\n for (var i = this._linkMatchers.length - 1; i >= 0; i--) {\r\n if (matcher.priority <= this._linkMatchers[i].priority) {\r\n this._linkMatchers.splice(i + 1, 0, matcher);\r\n return;\r\n }\r\n }\r\n this._linkMatchers.splice(0, 0, matcher);\r\n };\r\n Linkifier.prototype.deregisterLinkMatcher = function (matcherId) {\r\n for (var i = 1; i < this._linkMatchers.length; i++) {\r\n if (this._linkMatchers[i].id === matcherId) {\r\n this._linkMatchers.splice(i, 1);\r\n return true;\r\n }\r\n }\r\n return false;\r\n };\r\n Linkifier.prototype._linkifyRow = function (rowIndex) {\r\n var absoluteRowIndex = this._terminal.buffer.ydisp + rowIndex;\r\n if (absoluteRowIndex >= this._terminal.buffer.lines.length) {\r\n return;\r\n }\r\n var text = this._terminal.buffer.translateBufferLineToString(absoluteRowIndex, false);\r\n for (var i = 0; i < this._linkMatchers.length; i++) {\r\n this._doLinkifyRow(rowIndex, text, this._linkMatchers[i]);\r\n }\r\n };\r\n Linkifier.prototype._doLinkifyRow = function (rowIndex, text, matcher, offset) {\r\n var _this = this;\r\n if (offset === void 0) { offset = 0; }\r\n var result = [];\r\n var isHttpLinkMatcher = matcher.id === HYPERTEXT_LINK_MATCHER_ID;\r\n var match = text.match(matcher.regex);\r\n if (!match || match.length === 0) {\r\n return;\r\n }\r\n var uri = match[typeof matcher.matchIndex !== 'number' ? 0 : matcher.matchIndex];\r\n var index = text.indexOf(uri);\r\n if (matcher.validationCallback) {\r\n matcher.validationCallback(uri, function (isValid) {\r\n if (_this._rowsTimeoutId) {\r\n return;\r\n }\r\n if (isValid) {\r\n _this._addLink(offset + index, rowIndex, uri, matcher);\r\n }\r\n });\r\n }\r\n else {\r\n this._addLink(offset + index, rowIndex, uri, matcher);\r\n }\r\n var remainingStartIndex = index + uri.length;\r\n var remainingText = text.substr(remainingStartIndex);\r\n if (remainingText.length > 0) {\r\n this._doLinkifyRow(rowIndex, remainingText, matcher, offset + remainingStartIndex);\r\n }\r\n };\r\n Linkifier.prototype._addLink = function (x, y, uri, matcher) {\r\n var _this = this;\r\n this._mouseZoneManager.add(new MouseZoneManager_1.MouseZone(x + 1, x + 1 + uri.length, y + 1, function (e) {\r\n if (matcher.handler) {\r\n return matcher.handler(e, uri);\r\n }\r\n window.open(uri, '_blank');\r\n }, function (e) {\r\n _this.emit(Types_1.LinkHoverEventTypes.HOVER, { x: x, y: y, length: uri.length });\r\n _this._terminal.element.style.cursor = 'pointer';\r\n }, function (e) {\r\n _this.emit(Types_1.LinkHoverEventTypes.TOOLTIP, { x: x, y: y, length: uri.length });\r\n if (matcher.hoverTooltipCallback) {\r\n matcher.hoverTooltipCallback(e, uri);\r\n }\r\n }, function () {\r\n _this.emit(Types_1.LinkHoverEventTypes.LEAVE, { x: x, y: y, length: uri.length });\r\n _this._terminal.element.style.cursor = '';\r\n if (matcher.hoverLeaveCallback) {\r\n matcher.hoverLeaveCallback();\r\n }\r\n }));\r\n };\r\n Linkifier.TIME_BEFORE_LINKIFY = 200;\r\n return Linkifier;\r\n}(EventEmitter_1.EventEmitter));\r\nexports.Linkifier = Linkifier;\r\n\r\n\r\n\r\n},{\"./EventEmitter\":6,\"./Types\":13,\"./input/MouseZoneManager\":16}],9:[function(require,module,exports){\r\n\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nvar EscapeSequences_1 = require(\"./EscapeSequences\");\r\nvar Charsets_1 = require(\"./Charsets\");\r\nvar normalStateHandler = {};\r\nnormalStateHandler[EscapeSequences_1.C0.BEL] = function (parser, handler) { return handler.bell(); };\r\nnormalStateHandler[EscapeSequences_1.C0.LF] = function (parser, handler) { return handler.lineFeed(); };\r\nnormalStateHandler[EscapeSequences_1.C0.VT] = normalStateHandler[EscapeSequences_1.C0.LF];\r\nnormalStateHandler[EscapeSequences_1.C0.FF] = normalStateHandler[EscapeSequences_1.C0.LF];\r\nnormalStateHandler[EscapeSequences_1.C0.CR] = function (parser, handler) { return handler.carriageReturn(); };\r\nnormalStateHandler[EscapeSequences_1.C0.BS] = function (parser, handler) { return handler.backspace(); };\r\nnormalStateHandler[EscapeSequences_1.C0.HT] = function (parser, handler) { return handler.tab(); };\r\nnormalStateHandler[EscapeSequences_1.C0.SO] = function (parser, handler) { return handler.shiftOut(); };\r\nnormalStateHandler[EscapeSequences_1.C0.SI] = function (parser, handler) { return handler.shiftIn(); };\r\nnormalStateHandler[EscapeSequences_1.C0.ESC] = function (parser, handler) { return parser.setState(ParserState.ESCAPED); };\r\nvar escapedStateHandler = {};\r\nescapedStateHandler['['] = function (parser, terminal) {\r\n terminal.params = [];\r\n terminal.currentParam = 0;\r\n parser.setState(ParserState.CSI_PARAM);\r\n};\r\nescapedStateHandler[']'] = function (parser, terminal) {\r\n terminal.params = [];\r\n terminal.currentParam = 0;\r\n parser.setState(ParserState.OSC);\r\n};\r\nescapedStateHandler['P'] = function (parser, terminal) {\r\n terminal.params = [];\r\n terminal.currentParam = 0;\r\n parser.setState(ParserState.DCS);\r\n};\r\nescapedStateHandler['_'] = function (parser, terminal) {\r\n parser.setState(ParserState.IGNORE);\r\n};\r\nescapedStateHandler['^'] = function (parser, terminal) {\r\n parser.setState(ParserState.IGNORE);\r\n};\r\nescapedStateHandler['c'] = function (parser, terminal) {\r\n terminal.reset();\r\n};\r\nescapedStateHandler['E'] = function (parser, terminal) {\r\n terminal.buffer.x = 0;\r\n terminal.index();\r\n parser.setState(ParserState.NORMAL);\r\n};\r\nescapedStateHandler['D'] = function (parser, terminal) {\r\n terminal.index();\r\n parser.setState(ParserState.NORMAL);\r\n};\r\nescapedStateHandler['M'] = function (parser, terminal) {\r\n terminal.reverseIndex();\r\n parser.setState(ParserState.NORMAL);\r\n};\r\nescapedStateHandler['%'] = function (parser, terminal) {\r\n terminal.setgLevel(0);\r\n terminal.setgCharset(0, Charsets_1.DEFAULT_CHARSET);\r\n parser.setState(ParserState.NORMAL);\r\n parser.skipNextChar();\r\n};\r\nescapedStateHandler[EscapeSequences_1.C0.CAN] = function (parser) { return parser.setState(ParserState.NORMAL); };\r\nvar csiParamStateHandler = {};\r\ncsiParamStateHandler['?'] = function (parser) { return parser.setPrefix('?'); };\r\ncsiParamStateHandler['>'] = function (parser) { return parser.setPrefix('>'); };\r\ncsiParamStateHandler['!'] = function (parser) { return parser.setPrefix('!'); };\r\ncsiParamStateHandler['0'] = function (parser) { return parser.setParam(parser.getParam() * 10); };\r\ncsiParamStateHandler['1'] = function (parser) { return parser.setParam(parser.getParam() * 10 + 1); };\r\ncsiParamStateHandler['2'] = function (parser) { return parser.setParam(parser.getParam() * 10 + 2); };\r\ncsiParamStateHandler['3'] = function (parser) { return parser.setParam(parser.getParam() * 10 + 3); };\r\ncsiParamStateHandler['4'] = function (parser) { return parser.setParam(parser.getParam() * 10 + 4); };\r\ncsiParamStateHandler['5'] = function (parser) { return parser.setParam(parser.getParam() * 10 + 5); };\r\ncsiParamStateHandler['6'] = function (parser) { return parser.setParam(parser.getParam() * 10 + 6); };\r\ncsiParamStateHandler['7'] = function (parser) { return parser.setParam(parser.getParam() * 10 + 7); };\r\ncsiParamStateHandler['8'] = function (parser) { return parser.setParam(parser.getParam() * 10 + 8); };\r\ncsiParamStateHandler['9'] = function (parser) { return parser.setParam(parser.getParam() * 10 + 9); };\r\ncsiParamStateHandler['$'] = function (parser) { return parser.setPostfix('$'); };\r\ncsiParamStateHandler['\"'] = function (parser) { return parser.setPostfix('\"'); };\r\ncsiParamStateHandler[' '] = function (parser) { return parser.setPostfix(' '); };\r\ncsiParamStateHandler['\\''] = function (parser) { return parser.setPostfix('\\''); };\r\ncsiParamStateHandler[';'] = function (parser) { return parser.finalizeParam(); };\r\ncsiParamStateHandler[EscapeSequences_1.C0.CAN] = function (parser) { return parser.setState(ParserState.NORMAL); };\r\nvar csiStateHandler = {};\r\ncsiStateHandler['@'] = function (handler, params, prefix) { return handler.insertChars(params); };\r\ncsiStateHandler['A'] = function (handler, params, prefix) { return handler.cursorUp(params); };\r\ncsiStateHandler['B'] = function (handler, params, prefix) { return handler.cursorDown(params); };\r\ncsiStateHandler['C'] = function (handler, params, prefix) { return handler.cursorForward(params); };\r\ncsiStateHandler['D'] = function (handler, params, prefix) { return handler.cursorBackward(params); };\r\ncsiStateHandler['E'] = function (handler, params, prefix) { return handler.cursorNextLine(params); };\r\ncsiStateHandler['F'] = function (handler, params, prefix) { return handler.cursorPrecedingLine(params); };\r\ncsiStateHandler['G'] = function (handler, params, prefix) { return handler.cursorCharAbsolute(params); };\r\ncsiStateHandler['H'] = function (handler, params, prefix) { return handler.cursorPosition(params); };\r\ncsiStateHandler['I'] = function (handler, params, prefix) { return handler.cursorForwardTab(params); };\r\ncsiStateHandler['J'] = function (handler, params, prefix) { return handler.eraseInDisplay(params); };\r\ncsiStateHandler['K'] = function (handler, params, prefix) { return handler.eraseInLine(params); };\r\ncsiStateHandler['L'] = function (handler, params, prefix) { return handler.insertLines(params); };\r\ncsiStateHandler['M'] = function (handler, params, prefix) { return handler.deleteLines(params); };\r\ncsiStateHandler['P'] = function (handler, params, prefix) { return handler.deleteChars(params); };\r\ncsiStateHandler['S'] = function (handler, params, prefix) { return handler.scrollUp(params); };\r\ncsiStateHandler['T'] = function (handler, params, prefix) {\r\n if (params.length < 2 && !prefix) {\r\n handler.scrollDown(params);\r\n }\r\n};\r\ncsiStateHandler['X'] = function (handler, params, prefix) { return handler.eraseChars(params); };\r\ncsiStateHandler['Z'] = function (handler, params, prefix) { return handler.cursorBackwardTab(params); };\r\ncsiStateHandler['`'] = function (handler, params, prefix) { return handler.charPosAbsolute(params); };\r\ncsiStateHandler['a'] = function (handler, params, prefix) { return handler.HPositionRelative(params); };\r\ncsiStateHandler['b'] = function (handler, params, prefix) { return handler.repeatPrecedingCharacter(params); };\r\ncsiStateHandler['c'] = function (handler, params, prefix) { return handler.sendDeviceAttributes(params); };\r\ncsiStateHandler['d'] = function (handler, params, prefix) { return handler.linePosAbsolute(params); };\r\ncsiStateHandler['e'] = function (handler, params, prefix) { return handler.VPositionRelative(params); };\r\ncsiStateHandler['f'] = function (handler, params, prefix) { return handler.HVPosition(params); };\r\ncsiStateHandler['g'] = function (handler, params, prefix) { return handler.tabClear(params); };\r\ncsiStateHandler['h'] = function (handler, params, prefix) { return handler.setMode(params); };\r\ncsiStateHandler['l'] = function (handler, params, prefix) { return handler.resetMode(params); };\r\ncsiStateHandler['m'] = function (handler, params, prefix) { return handler.charAttributes(params); };\r\ncsiStateHandler['n'] = function (handler, params, prefix) { return handler.deviceStatus(params); };\r\ncsiStateHandler['p'] = function (handler, params, prefix) {\r\n switch (prefix) {\r\n case '!':\r\n handler.softReset(params);\r\n break;\r\n }\r\n};\r\ncsiStateHandler['q'] = function (handler, params, prefix, postfix) {\r\n if (postfix === ' ') {\r\n handler.setCursorStyle(params);\r\n }\r\n};\r\ncsiStateHandler['r'] = function (handler, params) { return handler.setScrollRegion(params); };\r\ncsiStateHandler['s'] = function (handler, params) { return handler.saveCursor(params); };\r\ncsiStateHandler['u'] = function (handler, params) { return handler.restoreCursor(params); };\r\ncsiStateHandler[EscapeSequences_1.C0.CAN] = function (handler, params, prefix, postfix, parser) { return parser.setState(ParserState.NORMAL); };\r\nvar ParserState;\r\n(function (ParserState) {\r\n ParserState[ParserState[\"NORMAL\"] = 0] = \"NORMAL\";\r\n ParserState[ParserState[\"ESCAPED\"] = 1] = \"ESCAPED\";\r\n ParserState[ParserState[\"CSI_PARAM\"] = 2] = \"CSI_PARAM\";\r\n ParserState[ParserState[\"CSI\"] = 3] = \"CSI\";\r\n ParserState[ParserState[\"OSC\"] = 4] = \"OSC\";\r\n ParserState[ParserState[\"CHARSET\"] = 5] = \"CHARSET\";\r\n ParserState[ParserState[\"DCS\"] = 6] = \"DCS\";\r\n ParserState[ParserState[\"IGNORE\"] = 7] = \"IGNORE\";\r\n})(ParserState = exports.ParserState || (exports.ParserState = {}));\r\nvar Parser = (function () {\r\n function Parser(_inputHandler, _terminal) {\r\n this._inputHandler = _inputHandler;\r\n this._terminal = _terminal;\r\n this._state = ParserState.NORMAL;\r\n }\r\n Parser.prototype.parse = function (data) {\r\n var l = data.length;\r\n var j;\r\n var cs;\r\n var ch;\r\n var code;\r\n var low;\r\n var cursorStartX = this._terminal.buffer.x;\r\n var cursorStartY = this._terminal.buffer.y;\r\n if (this._terminal.debug) {\r\n this._terminal.log('data: ' + data);\r\n }\r\n this._position = 0;\r\n if (this._terminal.surrogate_high) {\r\n data = this._terminal.surrogate_high + data;\r\n this._terminal.surrogate_high = '';\r\n }\r\n for (; this._position < l; this._position++) {\r\n ch = data[this._position];\r\n code = data.charCodeAt(this._position);\r\n if (0xD800 <= code && code <= 0xDBFF) {\r\n low = data.charCodeAt(this._position + 1);\r\n if (isNaN(low)) {\r\n this._terminal.surrogate_high = ch;\r\n continue;\r\n }\r\n code = ((code - 0xD800) * 0x400) + (low - 0xDC00) + 0x10000;\r\n ch += data.charAt(this._position + 1);\r\n }\r\n if (0xDC00 <= code && code <= 0xDFFF)\r\n continue;\r\n switch (this._state) {\r\n case ParserState.NORMAL:\r\n if (ch in normalStateHandler) {\r\n normalStateHandler[ch](this, this._inputHandler);\r\n }\r\n else {\r\n this._inputHandler.addChar(ch, code);\r\n }\r\n break;\r\n case ParserState.ESCAPED:\r\n if (ch in escapedStateHandler) {\r\n escapedStateHandler[ch](this, this._terminal);\r\n break;\r\n }\r\n switch (ch) {\r\n case '(':\r\n case ')':\r\n case '*':\r\n case '+':\r\n case '-':\r\n case '.':\r\n switch (ch) {\r\n case '(':\r\n this._terminal.gcharset = 0;\r\n break;\r\n case ')':\r\n this._terminal.gcharset = 1;\r\n break;\r\n case '*':\r\n this._terminal.gcharset = 2;\r\n break;\r\n case '+':\r\n this._terminal.gcharset = 3;\r\n break;\r\n case '-':\r\n this._terminal.gcharset = 1;\r\n break;\r\n case '.':\r\n this._terminal.gcharset = 2;\r\n break;\r\n }\r\n this._state = ParserState.CHARSET;\r\n break;\r\n case '/':\r\n this._terminal.gcharset = 3;\r\n this._state = ParserState.CHARSET;\r\n this._position--;\r\n break;\r\n case 'N':\r\n break;\r\n case 'O':\r\n break;\r\n case 'n':\r\n this._terminal.setgLevel(2);\r\n break;\r\n case 'o':\r\n this._terminal.setgLevel(3);\r\n break;\r\n case '|':\r\n this._terminal.setgLevel(3);\r\n break;\r\n case '}':\r\n this._terminal.setgLevel(2);\r\n break;\r\n case '~':\r\n this._terminal.setgLevel(1);\r\n break;\r\n case '7':\r\n this._inputHandler.saveCursor();\r\n this._state = ParserState.NORMAL;\r\n break;\r\n case '8':\r\n this._inputHandler.restoreCursor();\r\n this._state = ParserState.NORMAL;\r\n break;\r\n case '#':\r\n this._state = ParserState.NORMAL;\r\n this._position++;\r\n break;\r\n case 'H':\r\n this._terminal.tabSet();\r\n this._state = ParserState.NORMAL;\r\n break;\r\n case '=':\r\n this._terminal.log('Serial port requested application keypad.');\r\n this._terminal.applicationKeypad = true;\r\n if (this._terminal.viewport) {\r\n this._terminal.viewport.syncScrollArea();\r\n }\r\n this._state = ParserState.NORMAL;\r\n break;\r\n case '>':\r\n this._terminal.log('Switching back to normal keypad.');\r\n this._terminal.applicationKeypad = false;\r\n if (this._terminal.viewport) {\r\n this._terminal.viewport.syncScrollArea();\r\n }\r\n this._state = ParserState.NORMAL;\r\n break;\r\n default:\r\n this._state = ParserState.NORMAL;\r\n this._terminal.error('Unknown ESC control: %s.', ch);\r\n break;\r\n }\r\n break;\r\n case ParserState.CHARSET:\r\n if (ch in Charsets_1.CHARSETS) {\r\n cs = Charsets_1.CHARSETS[ch];\r\n if (ch === '/') {\r\n this.skipNextChar();\r\n }\r\n }\r\n else {\r\n cs = Charsets_1.DEFAULT_CHARSET;\r\n }\r\n this._terminal.setgCharset(this._terminal.gcharset, cs);\r\n this._terminal.gcharset = null;\r\n this._state = ParserState.NORMAL;\r\n break;\r\n case ParserState.OSC:\r\n if (ch === EscapeSequences_1.C0.ESC || ch === EscapeSequences_1.C0.BEL) {\r\n if (ch === EscapeSequences_1.C0.ESC)\r\n this._position++;\r\n this._terminal.params.push(this._terminal.currentParam);\r\n switch (this._terminal.params[0]) {\r\n case 0:\r\n case 1:\r\n case 2:\r\n if (this._terminal.params[1]) {\r\n this._terminal.title = this._terminal.params[1];\r\n this._terminal.handleTitle(this._terminal.title);\r\n }\r\n break;\r\n case 3:\r\n break;\r\n case 4:\r\n case 5:\r\n break;\r\n case 10:\r\n case 11:\r\n case 12:\r\n case 13:\r\n case 14:\r\n case 15:\r\n case 16:\r\n case 17:\r\n case 18:\r\n case 19:\r\n break;\r\n case 46:\r\n break;\r\n case 50:\r\n break;\r\n case 51:\r\n break;\r\n case 52:\r\n break;\r\n case 104:\r\n case 105:\r\n case 110:\r\n case 111:\r\n case 112:\r\n case 113:\r\n case 114:\r\n case 115:\r\n case 116:\r\n case 117:\r\n case 118:\r\n break;\r\n }\r\n this._terminal.params = [];\r\n this._terminal.currentParam = 0;\r\n this._state = ParserState.NORMAL;\r\n }\r\n else {\r\n if (!this._terminal.params.length) {\r\n if (ch >= '0' && ch <= '9') {\r\n this._terminal.currentParam =\r\n this._terminal.currentParam * 10 + ch.charCodeAt(0) - 48;\r\n }\r\n else if (ch === ';') {\r\n this._terminal.params.push(this._terminal.currentParam);\r\n this._terminal.currentParam = '';\r\n }\r\n }\r\n else {\r\n this._terminal.currentParam += ch;\r\n }\r\n }\r\n break;\r\n case ParserState.CSI_PARAM:\r\n if (ch in csiParamStateHandler) {\r\n csiParamStateHandler[ch](this);\r\n break;\r\n }\r\n this.finalizeParam();\r\n this._state = ParserState.CSI;\r\n case ParserState.CSI:\r\n if (ch in csiStateHandler) {\r\n if (this._terminal.debug) {\r\n this._terminal.log(\"CSI \" + (this._terminal.prefix ? this._terminal.prefix : '') + \" \" + (this._terminal.params ? this._terminal.params.join(';') : '') + \" \" + (this._terminal.postfix ? this._terminal.postfix : '') + \" \" + ch);\r\n }\r\n csiStateHandler[ch](this._inputHandler, this._terminal.params, this._terminal.prefix, this._terminal.postfix, this);\r\n }\r\n else {\r\n this._terminal.error('Unknown CSI code: %s.', ch);\r\n }\r\n this._state = ParserState.NORMAL;\r\n this._terminal.prefix = '';\r\n this._terminal.postfix = '';\r\n break;\r\n case ParserState.DCS:\r\n if (ch === EscapeSequences_1.C0.ESC || ch === EscapeSequences_1.C0.BEL) {\r\n if (ch === EscapeSequences_1.C0.ESC)\r\n this._position++;\r\n var pt = void 0;\r\n var valid = void 0;\r\n switch (this._terminal.prefix) {\r\n case '':\r\n break;\r\n case '$q':\r\n pt = this._terminal.currentParam;\r\n valid = false;\r\n switch (pt) {\r\n case '\"q':\r\n pt = '0\"q';\r\n break;\r\n case '\"p':\r\n pt = '61\"p';\r\n break;\r\n case 'r':\r\n pt = ''\r\n + (this._terminal.buffer.scrollTop + 1)\r\n + ';'\r\n + (this._terminal.buffer.scrollBottom + 1)\r\n + 'r';\r\n break;\r\n case 'm':\r\n pt = '0m';\r\n break;\r\n default:\r\n this._terminal.error('Unknown DCS Pt: %s.', pt);\r\n pt = '';\r\n break;\r\n }\r\n this._terminal.send(EscapeSequences_1.C0.ESC + 'P' + +valid + '$r' + pt + EscapeSequences_1.C0.ESC + '\\\\');\r\n break;\r\n case '+p':\r\n break;\r\n case '+q':\r\n pt = this._terminal.currentParam;\r\n valid = false;\r\n this._terminal.send(EscapeSequences_1.C0.ESC + 'P' + +valid + '+r' + pt + EscapeSequences_1.C0.ESC + '\\\\');\r\n break;\r\n default:\r\n this._terminal.error('Unknown DCS prefix: %s.', this._terminal.prefix);\r\n break;\r\n }\r\n this._terminal.currentParam = 0;\r\n this._terminal.prefix = '';\r\n this._state = ParserState.NORMAL;\r\n }\r\n else if (!this._terminal.currentParam) {\r\n if (!this._terminal.prefix && ch !== '$' && ch !== '+') {\r\n this._terminal.currentParam = ch;\r\n }\r\n else if (this._terminal.prefix.length === 2) {\r\n this._terminal.currentParam = ch;\r\n }\r\n else {\r\n this._terminal.prefix += ch;\r\n }\r\n }\r\n else {\r\n this._terminal.currentParam += ch;\r\n }\r\n break;\r\n case ParserState.IGNORE:\r\n if (ch === EscapeSequences_1.C0.ESC || ch === EscapeSequences_1.C0.BEL) {\r\n if (ch === EscapeSequences_1.C0.ESC)\r\n this._position++;\r\n this._state = ParserState.NORMAL;\r\n }\r\n break;\r\n }\r\n }\r\n if (this._terminal.buffer.x !== cursorStartX || this._terminal.buffer.y !== cursorStartY) {\r\n this._terminal.emit('cursormove');\r\n }\r\n return this._state;\r\n };\r\n Parser.prototype.setState = function (state) {\r\n this._state = state;\r\n };\r\n Parser.prototype.setPrefix = function (prefix) {\r\n this._terminal.prefix = prefix;\r\n };\r\n Parser.prototype.setPostfix = function (postfix) {\r\n this._terminal.postfix = postfix;\r\n };\r\n Parser.prototype.setParam = function (param) {\r\n this._terminal.currentParam = param;\r\n };\r\n Parser.prototype.getParam = function () {\r\n return this._terminal.currentParam;\r\n };\r\n Parser.prototype.finalizeParam = function () {\r\n this._terminal.params.push(this._terminal.currentParam);\r\n this._terminal.currentParam = 0;\r\n };\r\n Parser.prototype.skipNextChar = function () {\r\n this._position++;\r\n };\r\n return Parser;\r\n}());\r\nexports.Parser = Parser;\r\n\r\n\r\n\r\n},{\"./Charsets\":3,\"./EscapeSequences\":5}],10:[function(require,module,exports){\r\n\"use strict\";\r\nvar __extends = (this && this.__extends) || (function () {\r\n var extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\r\n return function (d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n };\r\n})();\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nvar MouseHelper_1 = require(\"./utils/MouseHelper\");\r\nvar Browser = require(\"./utils/Browser\");\r\nvar EventEmitter_1 = require(\"./EventEmitter\");\r\nvar SelectionModel_1 = require(\"./SelectionModel\");\r\nvar Buffer_1 = require(\"./Buffer\");\r\nvar DRAG_SCROLL_MAX_THRESHOLD = 50;\r\nvar DRAG_SCROLL_MAX_SPEED = 15;\r\nvar DRAG_SCROLL_INTERVAL = 50;\r\nvar WORD_SEPARATORS = ' ()[]{}\\'\"';\r\nvar NON_BREAKING_SPACE_CHAR = String.fromCharCode(160);\r\nvar ALL_NON_BREAKING_SPACE_REGEX = new RegExp(NON_BREAKING_SPACE_CHAR, 'g');\r\nvar SelectionMode;\r\n(function (SelectionMode) {\r\n SelectionMode[SelectionMode[\"NORMAL\"] = 0] = \"NORMAL\";\r\n SelectionMode[SelectionMode[\"WORD\"] = 1] = \"WORD\";\r\n SelectionMode[SelectionMode[\"LINE\"] = 2] = \"LINE\";\r\n})(SelectionMode || (SelectionMode = {}));\r\nvar SelectionManager = (function (_super) {\r\n __extends(SelectionManager, _super);\r\n function SelectionManager(_terminal, _buffer, _charMeasure) {\r\n var _this = _super.call(this) || this;\r\n _this._terminal = _terminal;\r\n _this._buffer = _buffer;\r\n _this._charMeasure = _charMeasure;\r\n _this._enabled = true;\r\n _this._initListeners();\r\n _this.enable();\r\n _this._model = new SelectionModel_1.SelectionModel(_terminal);\r\n _this._activeSelectionMode = SelectionMode.NORMAL;\r\n return _this;\r\n }\r\n SelectionManager.prototype._initListeners = function () {\r\n var _this = this;\r\n this._mouseMoveListener = function (event) { return _this._onMouseMove(event); };\r\n this._mouseUpListener = function (event) { return _this._onMouseUp(event); };\r\n this._buffer.lines.on('trim', function (amount) { return _this._onTrim(amount); });\r\n };\r\n SelectionManager.prototype.disable = function () {\r\n this.clearSelection();\r\n this._enabled = false;\r\n };\r\n SelectionManager.prototype.enable = function () {\r\n this._enabled = true;\r\n };\r\n SelectionManager.prototype.setBuffer = function (buffer) {\r\n this._buffer = buffer;\r\n this.clearSelection();\r\n };\r\n Object.defineProperty(SelectionManager.prototype, \"selectionStart\", {\r\n get: function () { return this._model.finalSelectionStart; },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(SelectionManager.prototype, \"selectionEnd\", {\r\n get: function () { return this._model.finalSelectionEnd; },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(SelectionManager.prototype, \"hasSelection\", {\r\n get: function () {\r\n var start = this._model.finalSelectionStart;\r\n var end = this._model.finalSelectionEnd;\r\n if (!start || !end) {\r\n return false;\r\n }\r\n return start[0] !== end[0] || start[1] !== end[1];\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(SelectionManager.prototype, \"selectionText\", {\r\n get: function () {\r\n var start = this._model.finalSelectionStart;\r\n var end = this._model.finalSelectionEnd;\r\n if (!start || !end) {\r\n return '';\r\n }\r\n var startRowEndCol = start[1] === end[1] ? end[0] : null;\r\n var result = [];\r\n result.push(this._buffer.translateBufferLineToString(start[1], true, start[0], startRowEndCol));\r\n for (var i = start[1] + 1; i <= end[1] - 1; i++) {\r\n var bufferLine = this._buffer.lines.get(i);\r\n var lineText = this._buffer.translateBufferLineToString(i, true);\r\n if (bufferLine.isWrapped) {\r\n result[result.length - 1] += lineText;\r\n }\r\n else {\r\n result.push(lineText);\r\n }\r\n }\r\n if (start[1] !== end[1]) {\r\n var bufferLine = this._buffer.lines.get(end[1]);\r\n var lineText = this._buffer.translateBufferLineToString(end[1], true, 0, end[0]);\r\n if (bufferLine.isWrapped) {\r\n result[result.length - 1] += lineText;\r\n }\r\n else {\r\n result.push(lineText);\r\n }\r\n }\r\n var formattedResult = result.map(function (line) {\r\n return line.replace(ALL_NON_BREAKING_SPACE_REGEX, ' ');\r\n }).join(Browser.isMSWindows ? '\\r\\n' : '\\n');\r\n return formattedResult;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n SelectionManager.prototype.clearSelection = function () {\r\n this._model.clearSelection();\r\n this._removeMouseDownListeners();\r\n this.refresh();\r\n };\r\n SelectionManager.prototype.refresh = function (isNewSelection) {\r\n var _this = this;\r\n if (!this._refreshAnimationFrame) {\r\n this._refreshAnimationFrame = window.requestAnimationFrame(function () { return _this._refresh(); });\r\n }\r\n if (Browser.isLinux && isNewSelection) {\r\n var selectionText = this.selectionText;\r\n if (selectionText.length) {\r\n this.emit('newselection', this.selectionText);\r\n }\r\n }\r\n };\r\n SelectionManager.prototype._refresh = function () {\r\n this._refreshAnimationFrame = null;\r\n this.emit('refresh', { start: this._model.finalSelectionStart, end: this._model.finalSelectionEnd });\r\n };\r\n SelectionManager.prototype.selectAll = function () {\r\n this._model.isSelectAllActive = true;\r\n this.refresh();\r\n };\r\n SelectionManager.prototype._onTrim = function (amount) {\r\n var needsRefresh = this._model.onTrim(amount);\r\n if (needsRefresh) {\r\n this.refresh();\r\n }\r\n };\r\n SelectionManager.prototype._getMouseBufferCoords = function (event) {\r\n var coords = this._terminal.mouseHelper.getCoords(event, this._terminal.element, this._charMeasure, this._terminal.options.lineHeight, this._terminal.cols, this._terminal.rows, true);\r\n if (!coords) {\r\n return null;\r\n }\r\n coords[0]--;\r\n coords[1]--;\r\n coords[1] += this._terminal.buffer.ydisp;\r\n return coords;\r\n };\r\n SelectionManager.prototype._getMouseEventScrollAmount = function (event) {\r\n var offset = MouseHelper_1.MouseHelper.getCoordsRelativeToElement(event, this._terminal.element)[1];\r\n var terminalHeight = this._terminal.rows * Math.ceil(this._charMeasure.height * this._terminal.options.lineHeight);\r\n if (offset >= 0 && offset <= terminalHeight) {\r\n return 0;\r\n }\r\n if (offset > terminalHeight) {\r\n offset -= terminalHeight;\r\n }\r\n offset = Math.min(Math.max(offset, -DRAG_SCROLL_MAX_THRESHOLD), DRAG_SCROLL_MAX_THRESHOLD);\r\n offset /= DRAG_SCROLL_MAX_THRESHOLD;\r\n return (offset / Math.abs(offset)) + Math.round(offset * (DRAG_SCROLL_MAX_SPEED - 1));\r\n };\r\n SelectionManager.prototype.onMouseDown = function (event) {\r\n if (event.button === 2 && this.hasSelection) {\r\n return;\r\n }\r\n if (event.button !== 0) {\r\n return;\r\n }\r\n if (!this._enabled) {\r\n var shouldForceSelection = Browser.isMac ? event.altKey : event.shiftKey;\r\n if (!shouldForceSelection) {\r\n return;\r\n }\r\n event.stopPropagation();\r\n }\r\n event.preventDefault();\r\n this._dragScrollAmount = 0;\r\n if (this._enabled && event.shiftKey) {\r\n this._onIncrementalClick(event);\r\n }\r\n else {\r\n if (event.detail === 1) {\r\n this._onSingleClick(event);\r\n }\r\n else if (event.detail === 2) {\r\n this._onDoubleClick(event);\r\n }\r\n else if (event.detail === 3) {\r\n this._onTripleClick(event);\r\n }\r\n }\r\n this._addMouseDownListeners();\r\n this.refresh(true);\r\n };\r\n SelectionManager.prototype._addMouseDownListeners = function () {\r\n var _this = this;\r\n this._terminal.element.ownerDocument.addEventListener('mousemove', this._mouseMoveListener);\r\n this._terminal.element.ownerDocument.addEventListener('mouseup', this._mouseUpListener);\r\n this._dragScrollIntervalTimer = setInterval(function () { return _this._dragScroll(); }, DRAG_SCROLL_INTERVAL);\r\n };\r\n SelectionManager.prototype._removeMouseDownListeners = function () {\r\n this._terminal.element.ownerDocument.removeEventListener('mousemove', this._mouseMoveListener);\r\n this._terminal.element.ownerDocument.removeEventListener('mouseup', this._mouseUpListener);\r\n clearInterval(this._dragScrollIntervalTimer);\r\n this._dragScrollIntervalTimer = null;\r\n };\r\n SelectionManager.prototype._onIncrementalClick = function (event) {\r\n if (this._model.selectionStart) {\r\n this._model.selectionEnd = this._getMouseBufferCoords(event);\r\n }\r\n };\r\n SelectionManager.prototype._onSingleClick = function (event) {\r\n this._model.selectionStartLength = 0;\r\n this._model.isSelectAllActive = false;\r\n this._activeSelectionMode = SelectionMode.NORMAL;\r\n this._model.selectionStart = this._getMouseBufferCoords(event);\r\n if (!this._model.selectionStart) {\r\n return;\r\n }\r\n this._model.selectionEnd = null;\r\n var line = this._buffer.lines.get(this._model.selectionStart[1]);\r\n if (!line) {\r\n return;\r\n }\r\n if (line.length >= this._model.selectionStart[0]) {\r\n return;\r\n }\r\n var char = line[this._model.selectionStart[0]];\r\n if (char[Buffer_1.CHAR_DATA_WIDTH_INDEX] === 0) {\r\n this._model.selectionStart[0]++;\r\n }\r\n };\r\n SelectionManager.prototype._onDoubleClick = function (event) {\r\n var coords = this._getMouseBufferCoords(event);\r\n if (coords) {\r\n this._activeSelectionMode = SelectionMode.WORD;\r\n this._selectWordAt(coords);\r\n }\r\n };\r\n SelectionManager.prototype._onTripleClick = function (event) {\r\n var coords = this._getMouseBufferCoords(event);\r\n if (coords) {\r\n this._activeSelectionMode = SelectionMode.LINE;\r\n this._selectLineAt(coords[1]);\r\n }\r\n };\r\n SelectionManager.prototype._onMouseMove = function (event) {\r\n event.stopImmediatePropagation();\r\n var previousSelectionEnd = this._model.selectionEnd ? [this._model.selectionEnd[0], this._model.selectionEnd[1]] : null;\r\n this._model.selectionEnd = this._getMouseBufferCoords(event);\r\n if (!this._model.selectionEnd) {\r\n this.refresh(true);\r\n return;\r\n }\r\n if (this._activeSelectionMode === SelectionMode.LINE) {\r\n if (this._model.selectionEnd[1] < this._model.selectionStart[1]) {\r\n this._model.selectionEnd[0] = 0;\r\n }\r\n else {\r\n this._model.selectionEnd[0] = this._terminal.cols;\r\n }\r\n }\r\n else if (this._activeSelectionMode === SelectionMode.WORD) {\r\n this._selectToWordAt(this._model.selectionEnd);\r\n }\r\n this._dragScrollAmount = this._getMouseEventScrollAmount(event);\r\n if (this._dragScrollAmount > 0) {\r\n this._model.selectionEnd[0] = this._terminal.cols - 1;\r\n }\r\n else if (this._dragScrollAmount < 0) {\r\n this._model.selectionEnd[0] = 0;\r\n }\r\n if (this._model.selectionEnd[1] < this._buffer.lines.length) {\r\n var char = this._buffer.lines.get(this._model.selectionEnd[1])[this._model.selectionEnd[0]];\r\n if (char && char[Buffer_1.CHAR_DATA_WIDTH_INDEX] === 0) {\r\n this._model.selectionEnd[0]++;\r\n }\r\n }\r\n if (!previousSelectionEnd ||\r\n previousSelectionEnd[0] !== this._model.selectionEnd[0] ||\r\n previousSelectionEnd[1] !== this._model.selectionEnd[1]) {\r\n this.refresh(true);\r\n }\r\n };\r\n SelectionManager.prototype._dragScroll = function () {\r\n if (this._dragScrollAmount) {\r\n this._terminal.scrollDisp(this._dragScrollAmount, false);\r\n if (this._dragScrollAmount > 0) {\r\n this._model.selectionEnd = [this._terminal.cols - 1, this._terminal.buffer.ydisp + this._terminal.rows];\r\n }\r\n else {\r\n this._model.selectionEnd = [0, this._terminal.buffer.ydisp];\r\n }\r\n this.refresh();\r\n }\r\n };\r\n SelectionManager.prototype._onMouseUp = function (event) {\r\n this._removeMouseDownListeners();\r\n };\r\n SelectionManager.prototype._convertViewportColToCharacterIndex = function (bufferLine, coords) {\r\n var charIndex = coords[0];\r\n for (var i = 0; coords[0] >= i; i++) {\r\n var char = bufferLine[i];\r\n if (char[Buffer_1.CHAR_DATA_WIDTH_INDEX] === 0) {\r\n charIndex--;\r\n }\r\n else if (char[Buffer_1.CHAR_DATA_CHAR_INDEX].length > 1 && coords[0] !== i) {\r\n charIndex += char[Buffer_1.CHAR_DATA_CHAR_INDEX].length - 1;\r\n }\r\n }\r\n return charIndex;\r\n };\r\n SelectionManager.prototype.setSelection = function (col, row, length) {\r\n this._model.clearSelection();\r\n this._removeMouseDownListeners();\r\n this._model.selectionStart = [col, row];\r\n this._model.selectionStartLength = length;\r\n this.refresh();\r\n };\r\n SelectionManager.prototype._getWordAt = function (coords) {\r\n var bufferLine = this._buffer.lines.get(coords[1]);\r\n if (!bufferLine) {\r\n return null;\r\n }\r\n var line = this._buffer.translateBufferLineToString(coords[1], false);\r\n var startIndex = this._convertViewportColToCharacterIndex(bufferLine, coords);\r\n var endIndex = startIndex;\r\n var charOffset = coords[0] - startIndex;\r\n var leftWideCharCount = 0;\r\n var rightWideCharCount = 0;\r\n var leftLongCharOffset = 0;\r\n var rightLongCharOffset = 0;\r\n if (line.charAt(startIndex) === ' ') {\r\n while (startIndex > 0 && line.charAt(startIndex - 1) === ' ') {\r\n startIndex--;\r\n }\r\n while (endIndex < line.length && line.charAt(endIndex + 1) === ' ') {\r\n endIndex++;\r\n }\r\n }\r\n else {\r\n var startCol = coords[0];\r\n var endCol = coords[0];\r\n if (bufferLine[startCol][Buffer_1.CHAR_DATA_WIDTH_INDEX] === 0) {\r\n leftWideCharCount++;\r\n startCol--;\r\n }\r\n if (bufferLine[endCol][Buffer_1.CHAR_DATA_WIDTH_INDEX] === 2) {\r\n rightWideCharCount++;\r\n endCol++;\r\n }\r\n if (bufferLine[endCol][Buffer_1.CHAR_DATA_CHAR_INDEX].length > 1) {\r\n rightLongCharOffset += bufferLine[endCol][Buffer_1.CHAR_DATA_CHAR_INDEX].length - 1;\r\n endIndex += bufferLine[endCol][Buffer_1.CHAR_DATA_CHAR_INDEX].length - 1;\r\n }\r\n while (startCol > 0 && startIndex > 0 && !this._isCharWordSeparator(bufferLine[startCol - 1])) {\r\n var char = bufferLine[startCol - 1];\r\n if (char[Buffer_1.CHAR_DATA_WIDTH_INDEX] === 0) {\r\n leftWideCharCount++;\r\n startCol--;\r\n }\r\n else if (char[Buffer_1.CHAR_DATA_CHAR_INDEX].length > 1) {\r\n leftLongCharOffset += char[Buffer_1.CHAR_DATA_CHAR_INDEX].length - 1;\r\n startIndex -= char[Buffer_1.CHAR_DATA_CHAR_INDEX].length - 1;\r\n }\r\n startIndex--;\r\n startCol--;\r\n }\r\n while (endCol < bufferLine.length && endIndex + 1 < line.length && !this._isCharWordSeparator(bufferLine[endCol + 1])) {\r\n var char = bufferLine[endCol + 1];\r\n if (char[Buffer_1.CHAR_DATA_WIDTH_INDEX] === 2) {\r\n rightWideCharCount++;\r\n endCol++;\r\n }\r\n else if (char[Buffer_1.CHAR_DATA_CHAR_INDEX].length > 1) {\r\n rightLongCharOffset += char[Buffer_1.CHAR_DATA_CHAR_INDEX].length - 1;\r\n endIndex += char[Buffer_1.CHAR_DATA_CHAR_INDEX].length - 1;\r\n }\r\n endIndex++;\r\n endCol++;\r\n }\r\n }\r\n endIndex++;\r\n var start = startIndex\r\n + charOffset\r\n - leftWideCharCount\r\n + leftLongCharOffset;\r\n var length = Math.min(this._terminal.cols, endIndex\r\n - startIndex\r\n + leftWideCharCount\r\n + rightWideCharCount\r\n - leftLongCharOffset\r\n - rightLongCharOffset);\r\n return { start: start, length: length };\r\n };\r\n SelectionManager.prototype._selectWordAt = function (coords) {\r\n var wordPosition = this._getWordAt(coords);\r\n if (wordPosition) {\r\n this._model.selectionStart = [wordPosition.start, coords[1]];\r\n this._model.selectionStartLength = wordPosition.length;\r\n }\r\n };\r\n SelectionManager.prototype._selectToWordAt = function (coords) {\r\n var wordPosition = this._getWordAt(coords);\r\n if (wordPosition) {\r\n this._model.selectionEnd = [this._model.areSelectionValuesReversed() ? wordPosition.start : (wordPosition.start + wordPosition.length), coords[1]];\r\n }\r\n };\r\n SelectionManager.prototype._isCharWordSeparator = function (charData) {\r\n if (charData[Buffer_1.CHAR_DATA_WIDTH_INDEX] === 0) {\r\n return false;\r\n }\r\n return WORD_SEPARATORS.indexOf(charData[Buffer_1.CHAR_DATA_CHAR_INDEX]) >= 0;\r\n };\r\n SelectionManager.prototype._selectLineAt = function (line) {\r\n this._model.selectionStart = [0, line];\r\n this._model.selectionStartLength = this._terminal.cols;\r\n };\r\n return SelectionManager;\r\n}(EventEmitter_1.EventEmitter));\r\nexports.SelectionManager = SelectionManager;\r\n\r\n\r\n\r\n},{\"./Buffer\":1,\"./EventEmitter\":6,\"./SelectionModel\":11,\"./utils/Browser\":27,\"./utils/MouseHelper\":31}],11:[function(require,module,exports){\r\n\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nvar SelectionModel = (function () {\r\n function SelectionModel(_terminal) {\r\n this._terminal = _terminal;\r\n this.clearSelection();\r\n }\r\n SelectionModel.prototype.clearSelection = function () {\r\n this.selectionStart = null;\r\n this.selectionEnd = null;\r\n this.isSelectAllActive = false;\r\n this.selectionStartLength = 0;\r\n };\r\n Object.defineProperty(SelectionModel.prototype, \"finalSelectionStart\", {\r\n get: function () {\r\n if (this.isSelectAllActive) {\r\n return [0, 0];\r\n }\r\n if (!this.selectionEnd || !this.selectionStart) {\r\n return this.selectionStart;\r\n }\r\n return this.areSelectionValuesReversed() ? this.selectionEnd : this.selectionStart;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(SelectionModel.prototype, \"finalSelectionEnd\", {\r\n get: function () {\r\n if (this.isSelectAllActive) {\r\n return [this._terminal.cols, this._terminal.buffer.ybase + this._terminal.rows - 1];\r\n }\r\n if (!this.selectionStart) {\r\n return null;\r\n }\r\n if (!this.selectionEnd || this.areSelectionValuesReversed()) {\r\n return [this.selectionStart[0] + this.selectionStartLength, this.selectionStart[1]];\r\n }\r\n if (this.selectionStartLength) {\r\n if (this.selectionEnd[1] === this.selectionStart[1]) {\r\n return [Math.max(this.selectionStart[0] + this.selectionStartLength, this.selectionEnd[0]), this.selectionEnd[1]];\r\n }\r\n }\r\n return this.selectionEnd;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n SelectionModel.prototype.areSelectionValuesReversed = function () {\r\n var start = this.selectionStart;\r\n var end = this.selectionEnd;\r\n if (!start || !end) {\r\n return false;\r\n }\r\n return start[1] > end[1] || (start[1] === end[1] && start[0] > end[0]);\r\n };\r\n SelectionModel.prototype.onTrim = function (amount) {\r\n if (this.selectionStart) {\r\n this.selectionStart[1] -= amount;\r\n }\r\n if (this.selectionEnd) {\r\n this.selectionEnd[1] -= amount;\r\n }\r\n if (this.selectionEnd && this.selectionEnd[1] < 0) {\r\n this.clearSelection();\r\n return true;\r\n }\r\n if (this.selectionStart && this.selectionStart[1] < 0) {\r\n this.selectionStart[1] = 0;\r\n }\r\n return false;\r\n };\r\n return SelectionModel;\r\n}());\r\nexports.SelectionModel = SelectionModel;\r\n\r\n\r\n\r\n},{}],12:[function(require,module,exports){\r\n\"use strict\";\r\nvar __extends = (this && this.__extends) || (function () {\r\n var extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\r\n return function (d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n };\r\n})();\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nvar BufferSet_1 = require(\"./BufferSet\");\r\nvar CompositionHelper_1 = require(\"./CompositionHelper\");\r\nvar EventEmitter_1 = require(\"./EventEmitter\");\r\nvar Viewport_1 = require(\"./Viewport\");\r\nvar Clipboard_1 = require(\"./handlers/Clipboard\");\r\nvar EscapeSequences_1 = require(\"./EscapeSequences\");\r\nvar InputHandler_1 = require(\"./InputHandler\");\r\nvar Parser_1 = require(\"./Parser\");\r\nvar Renderer_1 = require(\"./renderer/Renderer\");\r\nvar Linkifier_1 = require(\"./Linkifier\");\r\nvar SelectionManager_1 = require(\"./SelectionManager\");\r\nvar CharMeasure_1 = require(\"./utils/CharMeasure\");\r\nvar Browser = require(\"./utils/Browser\");\r\nvar MouseHelper_1 = require(\"./utils/MouseHelper\");\r\nvar Sounds_1 = require(\"./utils/Sounds\");\r\nvar ColorManager_1 = require(\"./renderer/ColorManager\");\r\nvar MouseZoneManager_1 = require(\"./input/MouseZoneManager\");\r\nvar CharAtlas_1 = require(\"./renderer/CharAtlas\");\r\nvar document = (typeof window !== 'undefined') ? window.document : null;\r\nvar WRITE_BUFFER_PAUSE_THRESHOLD = 5;\r\nvar WRITE_BATCH_SIZE = 300;\r\nvar DEFAULT_OPTIONS = {\r\n convertEol: false,\r\n termName: 'xterm',\r\n geometry: [80, 24],\r\n cursorBlink: false,\r\n cursorStyle: 'block',\r\n bellSound: Sounds_1.BellSound,\r\n bellStyle: 'none',\r\n enableBold: true,\r\n fontFamily: 'courier-new, courier, monospace',\r\n fontSize: 15,\r\n lineHeight: 1.0,\r\n letterSpacing: 0,\r\n scrollback: 1000,\r\n screenKeys: false,\r\n debug: false,\r\n cancelEvents: false,\r\n disableStdin: false,\r\n useFlowControl: false,\r\n tabStopWidth: 8,\r\n theme: null\r\n};\r\nvar Terminal = (function (_super) {\r\n __extends(Terminal, _super);\r\n function Terminal(options) {\r\n if (options === void 0) { options = {}; }\r\n var _this = _super.call(this) || this;\r\n _this.browser = Browser;\r\n _this.options = options;\r\n _this.setup();\r\n return _this;\r\n }\r\n Terminal.prototype.setup = function () {\r\n var _this = this;\r\n Object.keys(DEFAULT_OPTIONS).forEach(function (key) {\r\n if (_this.options[key] == null) {\r\n _this.options[key] = DEFAULT_OPTIONS[key];\r\n }\r\n _this[key] = _this.options[key];\r\n });\r\n this.parent = document ? document.body : null;\r\n this.cols = this.options.cols || this.options.geometry[0];\r\n this.rows = this.options.rows || this.options.geometry[1];\r\n this.geometry = [this.cols, this.rows];\r\n if (this.options.handler) {\r\n this.on('data', this.options.handler);\r\n }\r\n this.cursorState = 0;\r\n this.cursorHidden = false;\r\n this.sendDataQueue = '';\r\n this.customKeyEventHandler = null;\r\n this.applicationKeypad = false;\r\n this.applicationCursor = false;\r\n this.originMode = false;\r\n this.insertMode = false;\r\n this.wraparoundMode = true;\r\n this.charset = null;\r\n this.gcharset = null;\r\n this.glevel = 0;\r\n this.charsets = [null];\r\n this.readable = true;\r\n this.writable = true;\r\n this.defAttr = (0 << 18) | (257 << 9) | (256 << 0);\r\n this.curAttr = (0 << 18) | (257 << 9) | (256 << 0);\r\n this.params = [];\r\n this.currentParam = 0;\r\n this.prefix = '';\r\n this.postfix = '';\r\n this.writeBuffer = [];\r\n this.writeInProgress = false;\r\n this.xoffSentToCatchUp = false;\r\n this.writeStopped = false;\r\n this.surrogate_high = '';\r\n this.userScrolling = false;\r\n this.inputHandler = new InputHandler_1.InputHandler(this);\r\n this.parser = new Parser_1.Parser(this.inputHandler, this);\r\n this.renderer = this.renderer || null;\r\n this.selectionManager = this.selectionManager || null;\r\n this.linkifier = this.linkifier || new Linkifier_1.Linkifier(this);\r\n this._mouseZoneManager = this._mouseZoneManager || null;\r\n this.buffers = new BufferSet_1.BufferSet(this);\r\n this.buffer = this.buffers.active;\r\n this.buffers.on('activate', function (buffer) {\r\n _this.buffer = buffer;\r\n });\r\n if (this.selectionManager) {\r\n this.selectionManager.setBuffer(this.buffer);\r\n }\r\n };\r\n Terminal.prototype.eraseAttr = function () {\r\n return (this.defAttr & ~0x1ff) | (this.curAttr & 0x1ff);\r\n };\r\n Terminal.prototype.focus = function () {\r\n this.textarea.focus();\r\n };\r\n Object.defineProperty(Terminal.prototype, \"isFocused\", {\r\n get: function () {\r\n return document.activeElement === this.textarea;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Terminal.prototype.getOption = function (key) {\r\n if (!(key in DEFAULT_OPTIONS)) {\r\n throw new Error('No option with key \"' + key + '\"');\r\n }\r\n if (typeof this.options[key] !== 'undefined') {\r\n return this.options[key];\r\n }\r\n return this[key];\r\n };\r\n Terminal.prototype.setOption = function (key, value) {\r\n if (!(key in DEFAULT_OPTIONS)) {\r\n throw new Error('No option with key \"' + key + '\"');\r\n }\r\n switch (key) {\r\n case 'bellStyle':\r\n if (!value) {\r\n value = 'none';\r\n }\r\n break;\r\n case 'cursorStyle':\r\n if (!value) {\r\n value = 'block';\r\n }\r\n break;\r\n case 'lineHeight':\r\n if (value < 1) {\r\n console.warn(key + \" cannot be less than 1, value: \" + value);\r\n return;\r\n }\r\n case 'tabStopWidth':\r\n if (value < 1) {\r\n console.warn(key + \" cannot be less than 1, value: \" + value);\r\n return;\r\n }\r\n break;\r\n case 'theme':\r\n if (this.renderer) {\r\n this._setTheme(value);\r\n return;\r\n }\r\n break;\r\n case 'scrollback':\r\n if (value < 0) {\r\n console.warn(key + \" cannot be less than 0, value: \" + value);\r\n return;\r\n }\r\n if (this.options[key] !== value) {\r\n var newBufferLength = this.rows + value;\r\n if (this.buffer.lines.length > newBufferLength) {\r\n var amountToTrim = this.buffer.lines.length - newBufferLength;\r\n var needsRefresh = (this.buffer.ydisp - amountToTrim < 0);\r\n this.buffer.lines.trimStart(amountToTrim);\r\n this.buffer.ybase = Math.max(this.buffer.ybase - amountToTrim, 0);\r\n this.buffer.ydisp = Math.max(this.buffer.ydisp - amountToTrim, 0);\r\n if (needsRefresh) {\r\n this.refresh(0, this.rows - 1);\r\n }\r\n }\r\n }\r\n break;\r\n }\r\n this[key] = value;\r\n this.options[key] = value;\r\n switch (key) {\r\n case 'fontFamily':\r\n case 'fontSize':\r\n this.renderer.clear();\r\n this.charMeasure.measure(this.options);\r\n break;\r\n case 'enableBold':\r\n case 'letterSpacing':\r\n case 'lineHeight':\r\n this.renderer.clear();\r\n this.renderer.onResize(this.cols, this.rows, false);\r\n this.refresh(0, this.rows - 1);\r\n case 'scrollback':\r\n this.buffers.resize(this.cols, this.rows);\r\n this.viewport.syncScrollArea();\r\n break;\r\n case 'tabStopWidth':\r\n this.buffers.setupTabStops();\r\n break;\r\n case 'bellSound':\r\n case 'bellStyle':\r\n this.syncBellSound();\r\n break;\r\n }\r\n if (this.renderer) {\r\n this.renderer.onOptionsChanged();\r\n }\r\n };\r\n Terminal.prototype._onTextAreaFocus = function () {\r\n if (this.sendFocus) {\r\n this.send(EscapeSequences_1.C0.ESC + '[I');\r\n }\r\n this.element.classList.add('focus');\r\n this.showCursor();\r\n this.emit('focus');\r\n };\r\n ;\r\n Terminal.prototype.blur = function () {\r\n return this.textarea.blur();\r\n };\r\n Terminal.prototype._onTextAreaBlur = function () {\r\n this.refresh(this.buffer.y, this.buffer.y);\r\n if (this.sendFocus) {\r\n this.send(EscapeSequences_1.C0.ESC + '[O');\r\n }\r\n this.element.classList.remove('focus');\r\n this.emit('blur');\r\n };\r\n Terminal.prototype.initGlobal = function () {\r\n var _this = this;\r\n this.bindKeys();\r\n on(this.element, 'copy', function (event) {\r\n if (!_this.hasSelection()) {\r\n return;\r\n }\r\n Clipboard_1.copyHandler(event, _this, _this.selectionManager);\r\n });\r\n var pasteHandlerWrapper = function (event) { return Clipboard_1.pasteHandler(event, _this); };\r\n on(this.textarea, 'paste', pasteHandlerWrapper);\r\n on(this.element, 'paste', pasteHandlerWrapper);\r\n if (Browser.isFirefox) {\r\n on(this.element, 'mousedown', function (event) {\r\n if (event.button === 2) {\r\n Clipboard_1.rightClickHandler(event, _this.textarea, _this.selectionManager);\r\n }\r\n });\r\n }\r\n else {\r\n on(this.element, 'contextmenu', function (event) {\r\n Clipboard_1.rightClickHandler(event, _this.textarea, _this.selectionManager);\r\n });\r\n }\r\n if (Browser.isLinux) {\r\n on(this.element, 'auxclick', function (event) {\r\n if (event.button === 1) {\r\n Clipboard_1.moveTextAreaUnderMouseCursor(event, _this.textarea);\r\n }\r\n });\r\n }\r\n };\r\n Terminal.prototype.bindKeys = function () {\r\n var _this = this;\r\n var self = this;\r\n on(this.element, 'keydown', function (ev) {\r\n if (document.activeElement !== this) {\r\n return;\r\n }\r\n self._keyDown(ev);\r\n }, true);\r\n on(this.element, 'keypress', function (ev) {\r\n if (document.activeElement !== this) {\r\n return;\r\n }\r\n self._keyPress(ev);\r\n }, true);\r\n on(this.element, 'keyup', function (ev) {\r\n if (!wasMondifierKeyOnlyEvent(ev)) {\r\n _this.focus();\r\n }\r\n }, true);\r\n on(this.textarea, 'keydown', function (ev) {\r\n _this._keyDown(ev);\r\n }, true);\r\n on(this.textarea, 'keypress', function (ev) {\r\n _this._keyPress(ev);\r\n _this.textarea.value = '';\r\n }, true);\r\n on(this.textarea, 'compositionstart', function () { return _this.compositionHelper.compositionstart(); });\r\n on(this.textarea, 'compositionupdate', function (e) { return _this.compositionHelper.compositionupdate(e); });\r\n on(this.textarea, 'compositionend', function () { return _this.compositionHelper.compositionend(); });\r\n this.on('refresh', function () { return _this.compositionHelper.updateCompositionElements(); });\r\n this.on('refresh', function (data) { return _this.queueLinkification(data.start, data.end); });\r\n };\r\n Terminal.prototype.open = function (parent) {\r\n var _this = this;\r\n var i = 0;\r\n var div;\r\n this.parent = parent || this.parent;\r\n if (!this.parent) {\r\n throw new Error('Terminal requires a parent element.');\r\n }\r\n this.context = this.parent.ownerDocument.defaultView;\r\n this.document = this.parent.ownerDocument;\r\n this.body = this.document.body;\r\n CharAtlas_1.initialize(this.document);\r\n this.element = this.document.createElement('div');\r\n this.element.classList.add('terminal');\r\n this.element.classList.add('xterm');\r\n this.element.setAttribute('tabindex', '0');\r\n this.viewportElement = document.createElement('div');\r\n this.viewportElement.classList.add('xterm-viewport');\r\n this.element.appendChild(this.viewportElement);\r\n this.viewportScrollArea = document.createElement('div');\r\n this.viewportScrollArea.classList.add('xterm-scroll-area');\r\n this.viewportElement.appendChild(this.viewportScrollArea);\r\n this.syncBellSound();\r\n this._mouseZoneManager = new MouseZoneManager_1.MouseZoneManager(this);\r\n this.on('scroll', function () { return _this._mouseZoneManager.clearAll(); });\r\n this.linkifier.attachToDom(this._mouseZoneManager);\r\n this.helperContainer = document.createElement('div');\r\n this.helperContainer.classList.add('xterm-helpers');\r\n this.element.appendChild(this.helperContainer);\r\n this.textarea = document.createElement('textarea');\r\n this.textarea.classList.add('xterm-helper-textarea');\r\n this.textarea.setAttribute('autocorrect', 'off');\r\n this.textarea.setAttribute('autocapitalize', 'off');\r\n this.textarea.setAttribute('spellcheck', 'false');\r\n this.textarea.tabIndex = 0;\r\n this.textarea.addEventListener('focus', function () { return _this._onTextAreaFocus(); });\r\n this.textarea.addEventListener('blur', function () { return _this._onTextAreaBlur(); });\r\n this.helperContainer.appendChild(this.textarea);\r\n this.compositionView = document.createElement('div');\r\n this.compositionView.classList.add('composition-view');\r\n this.compositionHelper = new CompositionHelper_1.CompositionHelper(this.textarea, this.compositionView, this);\r\n this.helperContainer.appendChild(this.compositionView);\r\n this.charSizeStyleElement = document.createElement('style');\r\n this.helperContainer.appendChild(this.charSizeStyleElement);\r\n this.parent.appendChild(this.element);\r\n this.charMeasure = new CharMeasure_1.CharMeasure(document, this.helperContainer);\r\n this.renderer = new Renderer_1.Renderer(this, this.options.theme);\r\n this.options.theme = null;\r\n this.viewport = new Viewport_1.Viewport(this, this.viewportElement, this.viewportScrollArea, this.charMeasure);\r\n this.viewport.onThemeChanged(this.renderer.colorManager.colors);\r\n this.on('cursormove', function () { return _this.renderer.onCursorMove(); });\r\n this.on('resize', function () { return _this.renderer.onResize(_this.cols, _this.rows, false); });\r\n this.on('blur', function () { return _this.renderer.onBlur(); });\r\n this.on('focus', function () { return _this.renderer.onFocus(); });\r\n window.addEventListener('resize', function () { return _this.renderer.onWindowResize(window.devicePixelRatio); });\r\n this.charMeasure.on('charsizechanged', function () { return _this.renderer.onResize(_this.cols, _this.rows, true); });\r\n this.renderer.on('resize', function (dimensions) { return _this.viewport.syncScrollArea(); });\r\n this.selectionManager = new SelectionManager_1.SelectionManager(this, this.buffer, this.charMeasure);\r\n this.element.addEventListener('mousedown', function (e) { return _this.selectionManager.onMouseDown(e); });\r\n this.selectionManager.on('refresh', function (data) { return _this.renderer.onSelectionChanged(data.start, data.end); });\r\n this.selectionManager.on('newselection', function (text) {\r\n _this.textarea.value = text;\r\n _this.textarea.focus();\r\n _this.textarea.select();\r\n });\r\n this.on('scroll', function () {\r\n _this.viewport.syncScrollArea();\r\n _this.selectionManager.refresh();\r\n });\r\n this.viewportElement.addEventListener('scroll', function () { return _this.selectionManager.refresh(); });\r\n this.mouseHelper = new MouseHelper_1.MouseHelper(this.renderer);\r\n this.charMeasure.measure(this.options);\r\n this.refresh(0, this.rows - 1);\r\n this.initGlobal();\r\n this.bindMouse();\r\n };\r\n Terminal.prototype._setTheme = function (theme) {\r\n var colors = this.renderer.setTheme(theme);\r\n if (this.viewport) {\r\n this.viewport.onThemeChanged(colors);\r\n }\r\n };\r\n Terminal.loadAddon = function (addon, callback) {\r\n if (typeof exports === 'object' && typeof module === 'object') {\r\n return require('./addons/' + addon + '/' + addon);\r\n }\r\n else if (typeof define === 'function') {\r\n return require(['./addons/' + addon + '/' + addon], callback);\r\n }\r\n else {\r\n console.error('Cannot load a module without a CommonJS or RequireJS environment.');\r\n return false;\r\n }\r\n };\r\n Terminal.prototype.bindMouse = function () {\r\n var _this = this;\r\n var el = this.element;\r\n var self = this;\r\n var pressed = 32;\r\n function sendButton(ev) {\r\n var button;\r\n var pos;\r\n button = getButton(ev);\r\n pos = self.mouseHelper.getRawByteCoords(ev, self.element, self.charMeasure, self.options.lineHeight, self.cols, self.rows);\r\n if (!pos)\r\n return;\r\n sendEvent(button, pos);\r\n switch (ev.overrideType || ev.type) {\r\n case 'mousedown':\r\n pressed = button;\r\n break;\r\n case 'mouseup':\r\n pressed = 32;\r\n break;\r\n case 'wheel':\r\n break;\r\n }\r\n }\r\n function sendMove(ev) {\r\n var button = pressed;\r\n var pos = self.mouseHelper.getRawByteCoords(ev, self.element, self.charMeasure, self.options.lineHeight, self.cols, self.rows);\r\n if (!pos)\r\n return;\r\n button += 32;\r\n sendEvent(button, pos);\r\n }\r\n function encode(data, ch) {\r\n if (!self.utfMouse) {\r\n if (ch === 255) {\r\n data.push(0);\r\n return;\r\n }\r\n if (ch > 127)\r\n ch = 127;\r\n data.push(ch);\r\n }\r\n else {\r\n if (ch === 2047) {\r\n data.push(0);\r\n return;\r\n }\r\n if (ch < 127) {\r\n data.push(ch);\r\n }\r\n else {\r\n if (ch > 2047)\r\n ch = 2047;\r\n data.push(0xC0 | (ch >> 6));\r\n data.push(0x80 | (ch & 0x3F));\r\n }\r\n }\r\n }\r\n function sendEvent(button, pos) {\r\n if (self.vt300Mouse) {\r\n button &= 3;\r\n pos.x -= 32;\r\n pos.y -= 32;\r\n var data_1 = EscapeSequences_1.C0.ESC + '[24';\r\n if (button === 0)\r\n data_1 += '1';\r\n else if (button === 1)\r\n data_1 += '3';\r\n else if (button === 2)\r\n data_1 += '5';\r\n else if (button === 3)\r\n return;\r\n else\r\n data_1 += '0';\r\n data_1 += '~[' + pos.x + ',' + pos.y + ']\\r';\r\n self.send(data_1);\r\n return;\r\n }\r\n if (self.decLocator) {\r\n button &= 3;\r\n pos.x -= 32;\r\n pos.y -= 32;\r\n if (button === 0)\r\n button = 2;\r\n else if (button === 1)\r\n button = 4;\r\n else if (button === 2)\r\n button = 6;\r\n else if (button === 3)\r\n button = 3;\r\n self.send(EscapeSequences_1.C0.ESC + '['\r\n + button\r\n + ';'\r\n + (button === 3 ? 4 : 0)\r\n + ';'\r\n + pos.y\r\n + ';'\r\n + pos.x\r\n + ';'\r\n + pos.page || 0\r\n + '&w');\r\n return;\r\n }\r\n if (self.urxvtMouse) {\r\n pos.x -= 32;\r\n pos.y -= 32;\r\n pos.x++;\r\n pos.y++;\r\n self.send(EscapeSequences_1.C0.ESC + '[' + button + ';' + pos.x + ';' + pos.y + 'M');\r\n return;\r\n }\r\n if (self.sgrMouse) {\r\n pos.x -= 32;\r\n pos.y -= 32;\r\n self.send(EscapeSequences_1.C0.ESC + '[<'\r\n + (((button & 3) === 3 ? button & ~3 : button) - 32)\r\n + ';'\r\n + pos.x\r\n + ';'\r\n + pos.y\r\n + ((button & 3) === 3 ? 'm' : 'M'));\r\n return;\r\n }\r\n var data = [];\r\n encode(data, button);\r\n encode(data, pos.x);\r\n encode(data, pos.y);\r\n self.send(EscapeSequences_1.C0.ESC + '[M' + String.fromCharCode.apply(String, data));\r\n }\r\n function getButton(ev) {\r\n var button;\r\n var shift;\r\n var meta;\r\n var ctrl;\r\n var mod;\r\n switch (ev.overrideType || ev.type) {\r\n case 'mousedown':\r\n button = ev.button != null\r\n ? +ev.button\r\n : ev.which != null\r\n ? ev.which - 1\r\n : null;\r\n if (Browser.isMSIE) {\r\n button = button === 1 ? 0 : button === 4 ? 1 : button;\r\n }\r\n break;\r\n case 'mouseup':\r\n button = 3;\r\n break;\r\n case 'DOMMouseScroll':\r\n button = ev.detail < 0\r\n ? 64\r\n : 65;\r\n break;\r\n case 'wheel':\r\n button = ev.wheelDeltaY > 0\r\n ? 64\r\n : 65;\r\n break;\r\n }\r\n shift = ev.shiftKey ? 4 : 0;\r\n meta = ev.metaKey ? 8 : 0;\r\n ctrl = ev.ctrlKey ? 16 : 0;\r\n mod = shift | meta | ctrl;\r\n if (self.vt200Mouse) {\r\n mod &= ctrl;\r\n }\r\n else if (!self.normalMouse) {\r\n mod = 0;\r\n }\r\n button = (32 + (mod << 2)) + button;\r\n return button;\r\n }\r\n on(el, 'mousedown', function (ev) {\r\n ev.preventDefault();\r\n _this.focus();\r\n if (!_this.mouseEvents)\r\n return;\r\n sendButton(ev);\r\n if (_this.vt200Mouse) {\r\n ev.overrideType = 'mouseup';\r\n sendButton(ev);\r\n return _this.cancel(ev);\r\n }\r\n if (_this.normalMouse)\r\n on(_this.document, 'mousemove', sendMove);\r\n if (!_this.x10Mouse) {\r\n var handler_1 = function (ev) {\r\n sendButton(ev);\r\n if (_this.normalMouse)\r\n off(_this.document, 'mousemove', sendMove);\r\n off(_this.document, 'mouseup', handler_1);\r\n return _this.cancel(ev);\r\n };\r\n on(_this.document, 'mouseup', handler_1);\r\n }\r\n return _this.cancel(ev);\r\n });\r\n on(el, 'wheel', function (ev) {\r\n if (!_this.mouseEvents)\r\n return;\r\n if (_this.x10Mouse || _this.vt300Mouse || _this.decLocator)\r\n return;\r\n sendButton(ev);\r\n ev.preventDefault();\r\n });\r\n on(el, 'wheel', function (ev) {\r\n if (_this.mouseEvents)\r\n return;\r\n _this.viewport.onWheel(ev);\r\n return _this.cancel(ev);\r\n });\r\n on(el, 'touchstart', function (ev) {\r\n if (_this.mouseEvents)\r\n return;\r\n _this.viewport.onTouchStart(ev);\r\n return _this.cancel(ev);\r\n });\r\n on(el, 'touchmove', function (ev) {\r\n if (_this.mouseEvents)\r\n return;\r\n _this.viewport.onTouchMove(ev);\r\n return _this.cancel(ev);\r\n });\r\n };\r\n Terminal.prototype.destroy = function () {\r\n _super.prototype.destroy.call(this);\r\n this.readable = false;\r\n this.writable = false;\r\n this.handler = function () { };\r\n this.write = function () { };\r\n if (this.element && this.element.parentNode) {\r\n this.element.parentNode.removeChild(this.element);\r\n }\r\n };\r\n Terminal.prototype.refresh = function (start, end) {\r\n if (this.renderer) {\r\n this.renderer.queueRefresh(start, end);\r\n }\r\n };\r\n Terminal.prototype.queueLinkification = function (start, end) {\r\n if (this.linkifier) {\r\n this.linkifier.linkifyRows(start, end);\r\n }\r\n };\r\n Terminal.prototype.showCursor = function () {\r\n if (!this.cursorState) {\r\n this.cursorState = 1;\r\n this.refresh(this.buffer.y, this.buffer.y);\r\n }\r\n };\r\n Terminal.prototype.scroll = function (isWrapped) {\r\n var newLine = this.blankLine(undefined, isWrapped);\r\n var topRow = this.buffer.ybase + this.buffer.scrollTop;\r\n var bottomRow = this.buffer.ybase + this.buffer.scrollBottom;\r\n if (this.buffer.scrollTop === 0) {\r\n var willBufferBeTrimmed = this.buffer.lines.length === this.buffer.lines.maxLength;\r\n if (bottomRow === this.buffer.lines.length - 1) {\r\n this.buffer.lines.push(newLine);\r\n }\r\n else {\r\n this.buffer.lines.splice(bottomRow + 1, 0, newLine);\r\n }\r\n if (!willBufferBeTrimmed) {\r\n this.buffer.ybase++;\r\n if (!this.userScrolling) {\r\n this.buffer.ydisp++;\r\n }\r\n }\r\n else {\r\n if (this.userScrolling) {\r\n this.buffer.ydisp = Math.max(this.buffer.ydisp - 1, 0);\r\n }\r\n }\r\n }\r\n else {\r\n var scrollRegionHeight = bottomRow - topRow + 1;\r\n this.buffer.lines.shiftElements(topRow + 1, scrollRegionHeight - 1, -1);\r\n this.buffer.lines.set(bottomRow, newLine);\r\n }\r\n if (!this.userScrolling) {\r\n this.buffer.ydisp = this.buffer.ybase;\r\n }\r\n this.updateRange(this.buffer.scrollTop);\r\n this.updateRange(this.buffer.scrollBottom);\r\n this.emit('scroll', this.buffer.ydisp);\r\n };\r\n Terminal.prototype.scrollDisp = function (disp, suppressScrollEvent) {\r\n if (disp < 0) {\r\n if (this.buffer.ydisp === 0) {\r\n return;\r\n }\r\n this.userScrolling = true;\r\n }\r\n else if (disp + this.buffer.ydisp >= this.buffer.ybase) {\r\n this.userScrolling = false;\r\n }\r\n var oldYdisp = this.buffer.ydisp;\r\n this.buffer.ydisp = Math.max(Math.min(this.buffer.ydisp + disp, this.buffer.ybase), 0);\r\n if (oldYdisp === this.buffer.ydisp) {\r\n return;\r\n }\r\n if (!suppressScrollEvent) {\r\n this.emit('scroll', this.buffer.ydisp);\r\n }\r\n this.refresh(0, this.rows - 1);\r\n };\r\n Terminal.prototype.scrollPages = function (pageCount) {\r\n this.scrollDisp(pageCount * (this.rows - 1));\r\n };\r\n Terminal.prototype.scrollToTop = function () {\r\n this.scrollDisp(-this.buffer.ydisp);\r\n };\r\n Terminal.prototype.scrollToBottom = function () {\r\n this.scrollDisp(this.buffer.ybase - this.buffer.ydisp);\r\n };\r\n Terminal.prototype.write = function (data) {\r\n var _this = this;\r\n this.writeBuffer.push(data);\r\n if (this.options.useFlowControl && !this.xoffSentToCatchUp && this.writeBuffer.length >= WRITE_BUFFER_PAUSE_THRESHOLD) {\r\n this.send(EscapeSequences_1.C0.DC3);\r\n this.xoffSentToCatchUp = true;\r\n }\r\n if (!this.writeInProgress && this.writeBuffer.length > 0) {\r\n this.writeInProgress = true;\r\n setTimeout(function () {\r\n _this.innerWrite();\r\n });\r\n }\r\n };\r\n Terminal.prototype.innerWrite = function () {\r\n var _this = this;\r\n var writeBatch = this.writeBuffer.splice(0, WRITE_BATCH_SIZE);\r\n while (writeBatch.length > 0) {\r\n var data = writeBatch.shift();\r\n if (this.xoffSentToCatchUp && writeBatch.length === 0 && this.writeBuffer.length === 0) {\r\n this.send(EscapeSequences_1.C0.DC1);\r\n this.xoffSentToCatchUp = false;\r\n }\r\n this.refreshStart = this.buffer.y;\r\n this.refreshEnd = this.buffer.y;\r\n var state = this.parser.parse(data);\r\n this.parser.setState(state);\r\n this.updateRange(this.buffer.y);\r\n this.refresh(this.refreshStart, this.refreshEnd);\r\n }\r\n if (this.writeBuffer.length > 0) {\r\n setTimeout(function () { return _this.innerWrite(); }, 0);\r\n }\r\n else {\r\n this.writeInProgress = false;\r\n }\r\n };\r\n Terminal.prototype.writeln = function (data) {\r\n this.write(data + '\\r\\n');\r\n };\r\n Terminal.prototype.attachCustomKeyEventHandler = function (customKeyEventHandler) {\r\n this.customKeyEventHandler = customKeyEventHandler;\r\n };\r\n Terminal.prototype.setHypertextLinkHandler = function (handler) {\r\n if (!this.linkifier) {\r\n throw new Error('Cannot attach a hypertext link handler before Terminal.open is called');\r\n }\r\n this.linkifier.setHypertextLinkHandler(handler);\r\n this.refresh(0, this.rows - 1);\r\n };\r\n Terminal.prototype.setHypertextValidationCallback = function (callback) {\r\n if (!this.linkifier) {\r\n throw new Error('Cannot attach a hypertext validation callback before Terminal.open is called');\r\n }\r\n this.linkifier.setHypertextValidationCallback(callback);\r\n this.refresh(0, this.rows - 1);\r\n };\r\n Terminal.prototype.registerLinkMatcher = function (regex, handler, options) {\r\n if (this.linkifier) {\r\n var matcherId = this.linkifier.registerLinkMatcher(regex, handler, options);\r\n this.refresh(0, this.rows - 1);\r\n return matcherId;\r\n }\r\n return 0;\r\n };\r\n Terminal.prototype.deregisterLinkMatcher = function (matcherId) {\r\n if (this.linkifier) {\r\n if (this.linkifier.deregisterLinkMatcher(matcherId)) {\r\n this.refresh(0, this.rows - 1);\r\n }\r\n }\r\n };\r\n Terminal.prototype.hasSelection = function () {\r\n return this.selectionManager ? this.selectionManager.hasSelection : false;\r\n };\r\n Terminal.prototype.getSelection = function () {\r\n return this.selectionManager ? this.selectionManager.selectionText : '';\r\n };\r\n Terminal.prototype.clearSelection = function () {\r\n if (this.selectionManager) {\r\n this.selectionManager.clearSelection();\r\n }\r\n };\r\n Terminal.prototype.selectAll = function () {\r\n if (this.selectionManager) {\r\n this.selectionManager.selectAll();\r\n }\r\n };\r\n Terminal.prototype._keyDown = function (ev) {\r\n if (this.customKeyEventHandler && this.customKeyEventHandler(ev) === false) {\r\n return false;\r\n }\r\n if (!this.compositionHelper.keydown(ev)) {\r\n if (this.buffer.ybase !== this.buffer.ydisp) {\r\n this.scrollToBottom();\r\n }\r\n return false;\r\n }\r\n var result = this._evaluateKeyEscapeSequence(ev);\r\n if (result.key === EscapeSequences_1.C0.DC3) {\r\n this.writeStopped = true;\r\n }\r\n else if (result.key === EscapeSequences_1.C0.DC1) {\r\n this.writeStopped = false;\r\n }\r\n if (result.scrollDisp) {\r\n this.scrollDisp(result.scrollDisp);\r\n return this.cancel(ev, true);\r\n }\r\n if (isThirdLevelShift(this.browser, ev)) {\r\n return true;\r\n }\r\n if (result.cancel) {\r\n this.cancel(ev, true);\r\n }\r\n if (!result.key) {\r\n return true;\r\n }\r\n this.emit('keydown', ev);\r\n this.emit('key', result.key, ev);\r\n this.showCursor();\r\n this.handler(result.key);\r\n return this.cancel(ev, true);\r\n };\r\n Terminal.prototype._evaluateKeyEscapeSequence = function (ev) {\r\n var result = {\r\n cancel: false,\r\n key: undefined,\r\n scrollDisp: undefined\r\n };\r\n var modifiers = (ev.shiftKey ? 1 : 0) | (ev.altKey ? 2 : 0) | (ev.ctrlKey ? 4 : 0) | (ev.metaKey ? 8 : 0);\r\n switch (ev.keyCode) {\r\n case 0:\r\n if (ev.key === 'UIKeyInputUpArrow') {\r\n if (this.applicationCursor) {\r\n result.key = EscapeSequences_1.C0.ESC + 'OA';\r\n }\r\n else {\r\n result.key = EscapeSequences_1.C0.ESC + '[A';\r\n }\r\n }\r\n else if (ev.key === 'UIKeyInputLeftArrow') {\r\n if (this.applicationCursor) {\r\n result.key = EscapeSequences_1.C0.ESC + 'OD';\r\n }\r\n else {\r\n result.key = EscapeSequences_1.C0.ESC + '[D';\r\n }\r\n }\r\n else if (ev.key === 'UIKeyInputRightArrow') {\r\n if (this.applicationCursor) {\r\n result.key = EscapeSequences_1.C0.ESC + 'OC';\r\n }\r\n else {\r\n result.key = EscapeSequences_1.C0.ESC + '[C';\r\n }\r\n }\r\n else if (ev.key === 'UIKeyInputDownArrow') {\r\n if (this.applicationCursor) {\r\n result.key = EscapeSequences_1.C0.ESC + 'OB';\r\n }\r\n else {\r\n result.key = EscapeSequences_1.C0.ESC + '[B';\r\n }\r\n }\r\n break;\r\n case 8:\r\n if (ev.shiftKey) {\r\n result.key = EscapeSequences_1.C0.BS;\r\n break;\r\n }\r\n result.key = EscapeSequences_1.C0.DEL;\r\n break;\r\n case 9:\r\n if (ev.shiftKey) {\r\n result.key = EscapeSequences_1.C0.ESC + '[Z';\r\n break;\r\n }\r\n result.key = EscapeSequences_1.C0.HT;\r\n result.cancel = true;\r\n break;\r\n case 13:\r\n result.key = EscapeSequences_1.C0.CR;\r\n result.cancel = true;\r\n break;\r\n case 27:\r\n result.key = EscapeSequences_1.C0.ESC;\r\n result.cancel = true;\r\n break;\r\n case 37:\r\n if (modifiers) {\r\n result.key = EscapeSequences_1.C0.ESC + '[1;' + (modifiers + 1) + 'D';\r\n if (result.key === EscapeSequences_1.C0.ESC + '[1;3D') {\r\n result.key = (this.browser.isMac) ? EscapeSequences_1.C0.ESC + 'b' : EscapeSequences_1.C0.ESC + '[1;5D';\r\n }\r\n }\r\n else if (this.applicationCursor) {\r\n result.key = EscapeSequences_1.C0.ESC + 'OD';\r\n }\r\n else {\r\n result.key = EscapeSequences_1.C0.ESC + '[D';\r\n }\r\n break;\r\n case 39:\r\n if (modifiers) {\r\n result.key = EscapeSequences_1.C0.ESC + '[1;' + (modifiers + 1) + 'C';\r\n if (result.key === EscapeSequences_1.C0.ESC + '[1;3C') {\r\n result.key = (this.browser.isMac) ? EscapeSequences_1.C0.ESC + 'f' : EscapeSequences_1.C0.ESC + '[1;5C';\r\n }\r\n }\r\n else if (this.applicationCursor) {\r\n result.key = EscapeSequences_1.C0.ESC + 'OC';\r\n }\r\n else {\r\n result.key = EscapeSequences_1.C0.ESC + '[C';\r\n }\r\n break;\r\n case 38:\r\n if (modifiers) {\r\n result.key = EscapeSequences_1.C0.ESC + '[1;' + (modifiers + 1) + 'A';\r\n if (result.key === EscapeSequences_1.C0.ESC + '[1;3A') {\r\n result.key = EscapeSequences_1.C0.ESC + '[1;5A';\r\n }\r\n }\r\n else if (this.applicationCursor) {\r\n result.key = EscapeSequences_1.C0.ESC + 'OA';\r\n }\r\n else {\r\n result.key = EscapeSequences_1.C0.ESC + '[A';\r\n }\r\n break;\r\n case 40:\r\n if (modifiers) {\r\n result.key = EscapeSequences_1.C0.ESC + '[1;' + (modifiers + 1) + 'B';\r\n if (result.key === EscapeSequences_1.C0.ESC + '[1;3B') {\r\n result.key = EscapeSequences_1.C0.ESC + '[1;5B';\r\n }\r\n }\r\n else if (this.applicationCursor) {\r\n result.key = EscapeSequences_1.C0.ESC + 'OB';\r\n }\r\n else {\r\n result.key = EscapeSequences_1.C0.ESC + '[B';\r\n }\r\n break;\r\n case 45:\r\n if (!ev.shiftKey && !ev.ctrlKey) {\r\n result.key = EscapeSequences_1.C0.ESC + '[2~';\r\n }\r\n break;\r\n case 46:\r\n if (modifiers) {\r\n result.key = EscapeSequences_1.C0.ESC + '[3;' + (modifiers + 1) + '~';\r\n }\r\n else {\r\n result.key = EscapeSequences_1.C0.ESC + '[3~';\r\n }\r\n break;\r\n case 36:\r\n if (modifiers)\r\n result.key = EscapeSequences_1.C0.ESC + '[1;' + (modifiers + 1) + 'H';\r\n else if (this.applicationCursor)\r\n result.key = EscapeSequences_1.C0.ESC + 'OH';\r\n else\r\n result.key = EscapeSequences_1.C0.ESC + '[H';\r\n break;\r\n case 35:\r\n if (modifiers)\r\n result.key = EscapeSequences_1.C0.ESC + '[1;' + (modifiers + 1) + 'F';\r\n else if (this.applicationCursor)\r\n result.key = EscapeSequences_1.C0.ESC + 'OF';\r\n else\r\n result.key = EscapeSequences_1.C0.ESC + '[F';\r\n break;\r\n case 33:\r\n if (ev.shiftKey) {\r\n result.scrollDisp = -(this.rows - 1);\r\n }\r\n else {\r\n result.key = EscapeSequences_1.C0.ESC + '[5~';\r\n }\r\n break;\r\n case 34:\r\n if (ev.shiftKey) {\r\n result.scrollDisp = this.rows - 1;\r\n }\r\n else {\r\n result.key = EscapeSequences_1.C0.ESC + '[6~';\r\n }\r\n break;\r\n case 112:\r\n if (modifiers) {\r\n result.key = EscapeSequences_1.C0.ESC + '[1;' + (modifiers + 1) + 'P';\r\n }\r\n else {\r\n result.key = EscapeSequences_1.C0.ESC + 'OP';\r\n }\r\n break;\r\n case 113:\r\n if (modifiers) {\r\n result.key = EscapeSequences_1.C0.ESC + '[1;' + (modifiers + 1) + 'Q';\r\n }\r\n else {\r\n result.key = EscapeSequences_1.C0.ESC + 'OQ';\r\n }\r\n break;\r\n case 114:\r\n if (modifiers) {\r\n result.key = EscapeSequences_1.C0.ESC + '[1;' + (modifiers + 1) + 'R';\r\n }\r\n else {\r\n result.key = EscapeSequences_1.C0.ESC + 'OR';\r\n }\r\n break;\r\n case 115:\r\n if (modifiers) {\r\n result.key = EscapeSequences_1.C0.ESC + '[1;' + (modifiers + 1) + 'S';\r\n }\r\n else {\r\n result.key = EscapeSequences_1.C0.ESC + 'OS';\r\n }\r\n break;\r\n case 116:\r\n if (modifiers) {\r\n result.key = EscapeSequences_1.C0.ESC + '[15;' + (modifiers + 1) + '~';\r\n }\r\n else {\r\n result.key = EscapeSequences_1.C0.ESC + '[15~';\r\n }\r\n break;\r\n case 117:\r\n if (modifiers) {\r\n result.key = EscapeSequences_1.C0.ESC + '[17;' + (modifiers + 1) + '~';\r\n }\r\n else {\r\n result.key = EscapeSequences_1.C0.ESC + '[17~';\r\n }\r\n break;\r\n case 118:\r\n if (modifiers) {\r\n result.key = EscapeSequences_1.C0.ESC + '[18;' + (modifiers + 1) + '~';\r\n }\r\n else {\r\n result.key = EscapeSequences_1.C0.ESC + '[18~';\r\n }\r\n break;\r\n case 119:\r\n if (modifiers) {\r\n result.key = EscapeSequences_1.C0.ESC + '[19;' + (modifiers + 1) + '~';\r\n }\r\n else {\r\n result.key = EscapeSequences_1.C0.ESC + '[19~';\r\n }\r\n break;\r\n case 120:\r\n if (modifiers) {\r\n result.key = EscapeSequences_1.C0.ESC + '[20;' + (modifiers + 1) + '~';\r\n }\r\n else {\r\n result.key = EscapeSequences_1.C0.ESC + '[20~';\r\n }\r\n break;\r\n case 121:\r\n if (modifiers) {\r\n result.key = EscapeSequences_1.C0.ESC + '[21;' + (modifiers + 1) + '~';\r\n }\r\n else {\r\n result.key = EscapeSequences_1.C0.ESC + '[21~';\r\n }\r\n break;\r\n case 122:\r\n if (modifiers) {\r\n result.key = EscapeSequences_1.C0.ESC + '[23;' + (modifiers + 1) + '~';\r\n }\r\n else {\r\n result.key = EscapeSequences_1.C0.ESC + '[23~';\r\n }\r\n break;\r\n case 123:\r\n if (modifiers) {\r\n result.key = EscapeSequences_1.C0.ESC + '[24;' + (modifiers + 1) + '~';\r\n }\r\n else {\r\n result.key = EscapeSequences_1.C0.ESC + '[24~';\r\n }\r\n break;\r\n default:\r\n if (ev.ctrlKey && !ev.shiftKey && !ev.altKey && !ev.metaKey) {\r\n if (ev.keyCode >= 65 && ev.keyCode <= 90) {\r\n result.key = String.fromCharCode(ev.keyCode - 64);\r\n }\r\n else if (ev.keyCode === 32) {\r\n result.key = String.fromCharCode(0);\r\n }\r\n else if (ev.keyCode >= 51 && ev.keyCode <= 55) {\r\n result.key = String.fromCharCode(ev.keyCode - 51 + 27);\r\n }\r\n else if (ev.keyCode === 56) {\r\n result.key = String.fromCharCode(127);\r\n }\r\n else if (ev.keyCode === 219) {\r\n result.key = String.fromCharCode(27);\r\n }\r\n else if (ev.keyCode === 220) {\r\n result.key = String.fromCharCode(28);\r\n }\r\n else if (ev.keyCode === 221) {\r\n result.key = String.fromCharCode(29);\r\n }\r\n }\r\n else if (!this.browser.isMac && ev.altKey && !ev.ctrlKey && !ev.metaKey) {\r\n if (ev.keyCode >= 65 && ev.keyCode <= 90) {\r\n result.key = EscapeSequences_1.C0.ESC + String.fromCharCode(ev.keyCode + 32);\r\n }\r\n else if (ev.keyCode === 192) {\r\n result.key = EscapeSequences_1.C0.ESC + '`';\r\n }\r\n else if (ev.keyCode >= 48 && ev.keyCode <= 57) {\r\n result.key = EscapeSequences_1.C0.ESC + (ev.keyCode - 48);\r\n }\r\n }\r\n else if (this.browser.isMac && !ev.altKey && !ev.ctrlKey && ev.metaKey) {\r\n if (ev.keyCode === 65) {\r\n this.selectAll();\r\n }\r\n }\r\n break;\r\n }\r\n return result;\r\n };\r\n Terminal.prototype.setgLevel = function (g) {\r\n this.glevel = g;\r\n this.charset = this.charsets[g];\r\n };\r\n Terminal.prototype.setgCharset = function (g, charset) {\r\n this.charsets[g] = charset;\r\n if (this.glevel === g) {\r\n this.charset = charset;\r\n }\r\n };\r\n Terminal.prototype._keyPress = function (ev) {\r\n var key;\r\n if (this.customKeyEventHandler && this.customKeyEventHandler(ev) === false) {\r\n return false;\r\n }\r\n this.cancel(ev);\r\n if (ev.charCode) {\r\n key = ev.charCode;\r\n }\r\n else if (ev.which == null) {\r\n key = ev.keyCode;\r\n }\r\n else if (ev.which !== 0 && ev.charCode !== 0) {\r\n key = ev.which;\r\n }\r\n else {\r\n return false;\r\n }\r\n if (!key || ((ev.altKey || ev.ctrlKey || ev.metaKey) && !isThirdLevelShift(this.browser, ev))) {\r\n return false;\r\n }\r\n key = String.fromCharCode(key);\r\n this.emit('keypress', key, ev);\r\n this.emit('key', key, ev);\r\n this.showCursor();\r\n this.handler(key);\r\n return true;\r\n };\r\n Terminal.prototype.send = function (data) {\r\n var _this = this;\r\n if (!this.sendDataQueue) {\r\n setTimeout(function () {\r\n _this.handler(_this.sendDataQueue);\r\n _this.sendDataQueue = '';\r\n }, 1);\r\n }\r\n this.sendDataQueue += data;\r\n };\r\n Terminal.prototype.bell = function () {\r\n var _this = this;\r\n this.emit('bell');\r\n if (this.soundBell())\r\n this.bellAudioElement.play();\r\n if (this.visualBell()) {\r\n this.element.classList.add('visual-bell-active');\r\n clearTimeout(this.visualBellTimer);\r\n this.visualBellTimer = window.setTimeout(function () {\r\n _this.element.classList.remove('visual-bell-active');\r\n }, 200);\r\n }\r\n };\r\n Terminal.prototype.log = function (text, data) {\r\n if (!this.options.debug)\r\n return;\r\n if (!this.context.console || !this.context.console.log)\r\n return;\r\n this.context.console.log(text, data);\r\n };\r\n Terminal.prototype.error = function (text, data) {\r\n if (!this.options.debug)\r\n return;\r\n if (!this.context.console || !this.context.console.error)\r\n return;\r\n this.context.console.error(text, data);\r\n };\r\n Terminal.prototype.resize = function (x, y) {\r\n if (isNaN(x) || isNaN(y)) {\r\n return;\r\n }\r\n if (x === this.cols && y === this.rows) {\r\n if (!this.charMeasure.width || !this.charMeasure.height) {\r\n this.charMeasure.measure(this.options);\r\n }\r\n return;\r\n }\r\n if (x < 1)\r\n x = 1;\r\n if (y < 1)\r\n y = 1;\r\n this.buffers.resize(x, y);\r\n this.cols = x;\r\n this.rows = y;\r\n this.buffers.setupTabStops(this.cols);\r\n this.charMeasure.measure(this.options);\r\n this.refresh(0, this.rows - 1);\r\n this.geometry = [this.cols, this.rows];\r\n this.emit('resize', { cols: x, rows: y });\r\n };\r\n Terminal.prototype.updateRange = function (y) {\r\n if (y < this.refreshStart)\r\n this.refreshStart = y;\r\n if (y > this.refreshEnd)\r\n this.refreshEnd = y;\r\n };\r\n Terminal.prototype.maxRange = function () {\r\n this.refreshStart = 0;\r\n this.refreshEnd = this.rows - 1;\r\n };\r\n Terminal.prototype.eraseRight = function (x, y) {\r\n var line = this.buffer.lines.get(this.buffer.ybase + y);\r\n if (!line) {\r\n return;\r\n }\r\n var ch = [this.eraseAttr(), ' ', 1, 32];\r\n for (; x < this.cols; x++) {\r\n line[x] = ch;\r\n }\r\n this.updateRange(y);\r\n };\r\n Terminal.prototype.eraseLeft = function (x, y) {\r\n var line = this.buffer.lines.get(this.buffer.ybase + y);\r\n if (!line) {\r\n return;\r\n }\r\n var ch = [this.eraseAttr(), ' ', 1, 32];\r\n x++;\r\n while (x--) {\r\n line[x] = ch;\r\n }\r\n this.updateRange(y);\r\n };\r\n Terminal.prototype.clear = function () {\r\n if (this.buffer.ybase === 0 && this.buffer.y === 0) {\r\n return;\r\n }\r\n this.buffer.lines.set(0, this.buffer.lines.get(this.buffer.ybase + this.buffer.y));\r\n this.buffer.lines.length = 1;\r\n this.buffer.ydisp = 0;\r\n this.buffer.ybase = 0;\r\n this.buffer.y = 0;\r\n for (var i = 1; i < this.rows; i++) {\r\n this.buffer.lines.push(this.blankLine());\r\n }\r\n this.refresh(0, this.rows - 1);\r\n this.emit('scroll', this.buffer.ydisp);\r\n };\r\n Terminal.prototype.eraseLine = function (y) {\r\n this.eraseRight(0, y);\r\n };\r\n Terminal.prototype.blankLine = function (cur, isWrapped, cols) {\r\n var attr = cur ? this.eraseAttr() : this.defAttr;\r\n var ch = [attr, ' ', 1, 32];\r\n var line = [];\r\n if (isWrapped) {\r\n line.isWrapped = isWrapped;\r\n }\r\n cols = cols || this.cols;\r\n for (var i = 0; i < cols; i++) {\r\n line[i] = ch;\r\n }\r\n return line;\r\n };\r\n Terminal.prototype.ch = function (cur) {\r\n if (cur) {\r\n return [this.eraseAttr(), ' ', 1, 32];\r\n }\r\n return [this.defAttr, ' ', 1, 32];\r\n };\r\n Terminal.prototype.is = function (term) {\r\n return (this.options.termName + '').indexOf(term) === 0;\r\n };\r\n Terminal.prototype.handler = function (data) {\r\n if (this.options.disableStdin) {\r\n return;\r\n }\r\n if (this.selectionManager && this.selectionManager.hasSelection) {\r\n this.selectionManager.clearSelection();\r\n }\r\n if (this.buffer.ybase !== this.buffer.ydisp) {\r\n this.scrollToBottom();\r\n }\r\n this.emit('data', data);\r\n };\r\n Terminal.prototype.handleTitle = function (title) {\r\n this.emit('title', title);\r\n };\r\n Terminal.prototype.index = function () {\r\n this.buffer.y++;\r\n if (this.buffer.y > this.buffer.scrollBottom) {\r\n this.buffer.y--;\r\n this.scroll();\r\n }\r\n if (this.buffer.x >= this.cols) {\r\n this.buffer.x--;\r\n }\r\n };\r\n Terminal.prototype.reverseIndex = function () {\r\n if (this.buffer.y === this.buffer.scrollTop) {\r\n var scrollRegionHeight = this.buffer.scrollBottom - this.buffer.scrollTop;\r\n this.buffer.lines.shiftElements(this.buffer.y + this.buffer.ybase, scrollRegionHeight, 1);\r\n this.buffer.lines.set(this.buffer.y + this.buffer.ybase, this.blankLine(true));\r\n this.updateRange(this.buffer.scrollTop);\r\n this.updateRange(this.buffer.scrollBottom);\r\n }\r\n else {\r\n this.buffer.y--;\r\n }\r\n };\r\n Terminal.prototype.reset = function () {\r\n this.options.rows = this.rows;\r\n this.options.cols = this.cols;\r\n var customKeyEventHandler = this.customKeyEventHandler;\r\n var inputHandler = this.inputHandler;\r\n var buffers = this.buffers;\r\n this.setup();\r\n this.customKeyEventHandler = customKeyEventHandler;\r\n this.inputHandler = inputHandler;\r\n this.buffers = buffers;\r\n this.refresh(0, this.rows - 1);\r\n this.viewport.syncScrollArea();\r\n };\r\n Terminal.prototype.tabSet = function () {\r\n this.buffer.tabs[this.buffer.x] = true;\r\n };\r\n Terminal.prototype.cancel = function (ev, force) {\r\n if (!this.options.cancelEvents && !force) {\r\n return;\r\n }\r\n ev.preventDefault();\r\n ev.stopPropagation();\r\n return false;\r\n };\r\n Terminal.prototype.matchColor = function (r1, g1, b1) {\r\n return matchColor_(r1, g1, b1);\r\n };\r\n Terminal.prototype.visualBell = function () {\r\n return this.options.bellStyle === 'visual' ||\r\n this.options.bellStyle === 'both';\r\n };\r\n Terminal.prototype.soundBell = function () {\r\n return this.options.bellStyle === 'sound' ||\r\n this.options.bellStyle === 'both';\r\n };\r\n Terminal.prototype.syncBellSound = function () {\r\n if (this.soundBell() && this.bellAudioElement) {\r\n this.bellAudioElement.setAttribute('src', this.options.bellSound);\r\n }\r\n else if (this.soundBell()) {\r\n this.bellAudioElement = document.createElement('audio');\r\n this.bellAudioElement.setAttribute('preload', 'auto');\r\n this.bellAudioElement.setAttribute('src', this.options.bellSound);\r\n this.helperContainer.appendChild(this.bellAudioElement);\r\n }\r\n else if (this.bellAudioElement) {\r\n this.helperContainer.removeChild(this.bellAudioElement);\r\n }\r\n };\r\n return Terminal;\r\n}(EventEmitter_1.EventEmitter));\r\nexports.Terminal = Terminal;\r\nfunction globalOn(el, type, handler, capture) {\r\n if (!Array.isArray(el)) {\r\n el = [el];\r\n }\r\n el.forEach(function (element) {\r\n element.addEventListener(type, handler, capture || false);\r\n });\r\n}\r\nvar on = globalOn;\r\nfunction off(el, type, handler, capture) {\r\n if (capture === void 0) { capture = false; }\r\n el.removeEventListener(type, handler, capture);\r\n}\r\nfunction isThirdLevelShift(browser, ev) {\r\n var thirdLevelKey = (browser.isMac && ev.altKey && !ev.ctrlKey && !ev.metaKey) ||\r\n (browser.isMSWindows && ev.altKey && ev.ctrlKey && !ev.metaKey);\r\n if (ev.type === 'keypress') {\r\n return thirdLevelKey;\r\n }\r\n return thirdLevelKey && (!ev.keyCode || ev.keyCode > 47);\r\n}\r\nfunction wasMondifierKeyOnlyEvent(ev) {\r\n return ev.keyCode === 16 ||\r\n ev.keyCode === 17 ||\r\n ev.keyCode === 18;\r\n}\r\nvar vcolors = (function () {\r\n var result = ColorManager_1.DEFAULT_ANSI_COLORS.map(function (c) {\r\n c = c.substring(1);\r\n return [\r\n parseInt(c.substring(0, 2), 16),\r\n parseInt(c.substring(2, 4), 16),\r\n parseInt(c.substring(4, 6), 16)\r\n ];\r\n });\r\n var r = [0x00, 0x5f, 0x87, 0xaf, 0xd7, 0xff];\r\n for (var i = 0; i < 216; i++) {\r\n result.push([\r\n r[(i / 36) % 6 | 0],\r\n r[(i / 6) % 6 | 0],\r\n r[i % 6]\r\n ]);\r\n }\r\n var c;\r\n for (var i = 0; i < 24; i++) {\r\n c = 8 + i * 10;\r\n result.push([c, c, c]);\r\n }\r\n return result;\r\n})();\r\nvar matchColorCache = {};\r\nfunction matchColorDistance(r1, g1, b1, r2, g2, b2) {\r\n return Math.pow(30 * (r1 - r2), 2)\r\n + Math.pow(59 * (g1 - g2), 2)\r\n + Math.pow(11 * (b1 - b2), 2);\r\n}\r\n;\r\nfunction matchColor_(r1, g1, b1) {\r\n var hash = (r1 << 16) | (g1 << 8) | b1;\r\n if (matchColorCache[hash] != null) {\r\n return matchColorCache[hash];\r\n }\r\n var ldiff = Infinity;\r\n var li = -1;\r\n var i = 0;\r\n var c;\r\n var r2;\r\n var g2;\r\n var b2;\r\n var diff;\r\n for (; i < vcolors.length; i++) {\r\n c = vcolors[i];\r\n r2 = c[0];\r\n g2 = c[1];\r\n b2 = c[2];\r\n diff = matchColorDistance(r1, g1, b1, r2, g2, b2);\r\n if (diff === 0) {\r\n li = i;\r\n break;\r\n }\r\n if (diff < ldiff) {\r\n ldiff = diff;\r\n li = i;\r\n }\r\n }\r\n return matchColorCache[hash] = li;\r\n}\r\n\r\n\r\n\r\n},{\"./BufferSet\":2,\"./CompositionHelper\":4,\"./EscapeSequences\":5,\"./EventEmitter\":6,\"./InputHandler\":7,\"./Linkifier\":8,\"./Parser\":9,\"./SelectionManager\":10,\"./Viewport\":14,\"./handlers/Clipboard\":15,\"./input/MouseZoneManager\":16,\"./renderer/CharAtlas\":18,\"./renderer/ColorManager\":19,\"./renderer/Renderer\":23,\"./utils/Browser\":27,\"./utils/CharMeasure\":28,\"./utils/MouseHelper\":31,\"./utils/Sounds\":32}],13:[function(require,module,exports){\r\n\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nvar LinkHoverEventTypes;\r\n(function (LinkHoverEventTypes) {\r\n LinkHoverEventTypes[\"HOVER\"] = \"linkhover\";\r\n LinkHoverEventTypes[\"TOOLTIP\"] = \"linktooltip\";\r\n LinkHoverEventTypes[\"LEAVE\"] = \"linkleave\";\r\n})(LinkHoverEventTypes = exports.LinkHoverEventTypes || (exports.LinkHoverEventTypes = {}));\r\n;\r\n\r\n\r\n\r\n},{}],14:[function(require,module,exports){\r\n\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nvar Viewport = (function () {\r\n function Viewport(terminal, viewportElement, scrollArea, charMeasure) {\r\n var _this = this;\r\n this.terminal = terminal;\r\n this.viewportElement = viewportElement;\r\n this.scrollArea = scrollArea;\r\n this.charMeasure = charMeasure;\r\n this.currentRowHeight = 0;\r\n this.lastRecordedBufferLength = 0;\r\n this.lastRecordedViewportHeight = 0;\r\n this.lastRecordedBufferHeight = 0;\r\n this.viewportElement.addEventListener('scroll', this.onScroll.bind(this));\r\n setTimeout(function () { return _this.syncScrollArea(); }, 0);\r\n }\r\n Viewport.prototype.onThemeChanged = function (colors) {\r\n this.viewportElement.style.backgroundColor = colors.background;\r\n };\r\n Viewport.prototype.refresh = function () {\r\n if (this.charMeasure.height > 0) {\r\n this.currentRowHeight = this.terminal.renderer.dimensions.scaledCellHeight / window.devicePixelRatio;\r\n if (this.lastRecordedViewportHeight !== this.terminal.renderer.dimensions.canvasHeight) {\r\n this.lastRecordedViewportHeight = this.terminal.renderer.dimensions.canvasHeight;\r\n this.viewportElement.style.height = this.lastRecordedViewportHeight + 'px';\r\n }\r\n var newBufferHeight = Math.round(this.currentRowHeight * this.lastRecordedBufferLength);\r\n if (this.lastRecordedBufferHeight !== newBufferHeight) {\r\n this.lastRecordedBufferHeight = newBufferHeight;\r\n this.scrollArea.style.height = this.lastRecordedBufferHeight + 'px';\r\n }\r\n }\r\n };\r\n Viewport.prototype.syncScrollArea = function () {\r\n if (this.lastRecordedBufferLength !== this.terminal.buffer.lines.length) {\r\n this.lastRecordedBufferLength = this.terminal.buffer.lines.length;\r\n this.refresh();\r\n }\r\n else if (this.lastRecordedViewportHeight !== this.terminal.renderer.dimensions.canvasHeight) {\r\n this.refresh();\r\n }\r\n else {\r\n if (this.terminal.renderer.dimensions.scaledCellHeight / window.devicePixelRatio !== this.currentRowHeight) {\r\n this.refresh();\r\n }\r\n }\r\n var scrollTop = this.terminal.buffer.ydisp * this.currentRowHeight;\r\n if (this.viewportElement.scrollTop !== scrollTop) {\r\n this.viewportElement.scrollTop = scrollTop;\r\n }\r\n };\r\n Viewport.prototype.onScroll = function (ev) {\r\n var newRow = Math.round(this.viewportElement.scrollTop / this.currentRowHeight);\r\n var diff = newRow - this.terminal.buffer.ydisp;\r\n this.terminal.scrollDisp(diff, true);\r\n };\r\n Viewport.prototype.onWheel = function (ev) {\r\n if (ev.deltaY === 0) {\r\n return;\r\n }\r\n var multiplier = 1;\r\n if (ev.deltaMode === WheelEvent.DOM_DELTA_LINE) {\r\n multiplier = this.currentRowHeight;\r\n }\r\n else if (ev.deltaMode === WheelEvent.DOM_DELTA_PAGE) {\r\n multiplier = this.currentRowHeight * this.terminal.rows;\r\n }\r\n this.viewportElement.scrollTop += ev.deltaY * multiplier;\r\n ev.preventDefault();\r\n };\r\n ;\r\n Viewport.prototype.onTouchStart = function (ev) {\r\n this.lastTouchY = ev.touches[0].pageY;\r\n };\r\n ;\r\n Viewport.prototype.onTouchMove = function (ev) {\r\n var deltaY = this.lastTouchY - ev.touches[0].pageY;\r\n this.lastTouchY = ev.touches[0].pageY;\r\n if (deltaY === 0) {\r\n return;\r\n }\r\n this.viewportElement.scrollTop += deltaY;\r\n ev.preventDefault();\r\n };\r\n ;\r\n return Viewport;\r\n}());\r\nexports.Viewport = Viewport;\r\n\r\n\r\n\r\n},{}],15:[function(require,module,exports){\r\n\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nfunction prepareTextForTerminal(text, isMSWindows) {\r\n if (isMSWindows) {\r\n return text.replace(/\\r?\\n/g, '\\r');\r\n }\r\n return text;\r\n}\r\nexports.prepareTextForTerminal = prepareTextForTerminal;\r\nfunction copyHandler(ev, term, selectionManager) {\r\n if (term.browser.isMSIE) {\r\n window.clipboardData.setData('Text', selectionManager.selectionText);\r\n }\r\n else {\r\n ev.clipboardData.setData('text/plain', selectionManager.selectionText);\r\n }\r\n ev.preventDefault();\r\n}\r\nexports.copyHandler = copyHandler;\r\nfunction pasteHandler(ev, term) {\r\n ev.stopPropagation();\r\n var text;\r\n var dispatchPaste = function (text) {\r\n text = prepareTextForTerminal(text, term.browser.isMSWindows);\r\n term.handler(text);\r\n term.textarea.value = '';\r\n term.emit('paste', text);\r\n term.cancel(ev);\r\n };\r\n if (term.browser.isMSIE) {\r\n if (window.clipboardData) {\r\n text = window.clipboardData.getData('Text');\r\n dispatchPaste(text);\r\n }\r\n }\r\n else {\r\n if (ev.clipboardData) {\r\n text = ev.clipboardData.getData('text/plain');\r\n dispatchPaste(text);\r\n }\r\n }\r\n}\r\nexports.pasteHandler = pasteHandler;\r\nfunction moveTextAreaUnderMouseCursor(ev, textarea) {\r\n textarea.style.position = 'fixed';\r\n textarea.style.width = '20px';\r\n textarea.style.height = '20px';\r\n textarea.style.left = (ev.clientX - 10) + 'px';\r\n textarea.style.top = (ev.clientY - 10) + 'px';\r\n textarea.style.zIndex = '1000';\r\n textarea.focus();\r\n setTimeout(function () {\r\n textarea.style.position = null;\r\n textarea.style.width = null;\r\n textarea.style.height = null;\r\n textarea.style.left = null;\r\n textarea.style.top = null;\r\n textarea.style.zIndex = null;\r\n }, 4);\r\n}\r\nexports.moveTextAreaUnderMouseCursor = moveTextAreaUnderMouseCursor;\r\nfunction rightClickHandler(ev, textarea, selectionManager) {\r\n moveTextAreaUnderMouseCursor(ev, textarea);\r\n textarea.value = selectionManager.selectionText;\r\n textarea.select();\r\n}\r\nexports.rightClickHandler = rightClickHandler;\r\n\r\n\r\n\r\n},{}],16:[function(require,module,exports){\r\n\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nvar HOVER_DURATION = 500;\r\nvar MouseZoneManager = (function () {\r\n function MouseZoneManager(_terminal) {\r\n var _this = this;\r\n this._terminal = _terminal;\r\n this._zones = [];\r\n this._areZonesActive = false;\r\n this._tooltipTimeout = null;\r\n this._currentZone = null;\r\n this._lastHoverCoords = [null, null];\r\n this._terminal.element.addEventListener('mousedown', function (e) { return _this._onMouseDown(e); });\r\n this._mouseMoveListener = function (e) { return _this._onMouseMove(e); };\r\n this._clickListener = function (e) { return _this._onClick(e); };\r\n }\r\n MouseZoneManager.prototype.add = function (zone) {\r\n this._zones.push(zone);\r\n if (this._zones.length === 1) {\r\n this._activate();\r\n }\r\n };\r\n MouseZoneManager.prototype.clearAll = function (start, end) {\r\n if (this._zones.length === 0) {\r\n return;\r\n }\r\n if (!end) {\r\n start = 0;\r\n end = this._terminal.rows - 1;\r\n }\r\n for (var i = 0; i < this._zones.length; i++) {\r\n var zone = this._zones[i];\r\n if (zone.y > start && zone.y <= end + 1) {\r\n if (this._currentZone && this._currentZone === zone) {\r\n this._currentZone.leaveCallback();\r\n this._currentZone = null;\r\n }\r\n this._zones.splice(i--, 1);\r\n }\r\n }\r\n if (this._zones.length === 0) {\r\n this._deactivate();\r\n }\r\n };\r\n MouseZoneManager.prototype._activate = function () {\r\n if (!this._areZonesActive) {\r\n this._areZonesActive = true;\r\n this._terminal.element.addEventListener('mousemove', this._mouseMoveListener);\r\n this._terminal.element.addEventListener('click', this._clickListener);\r\n }\r\n };\r\n MouseZoneManager.prototype._deactivate = function () {\r\n if (this._areZonesActive) {\r\n this._areZonesActive = false;\r\n this._terminal.element.removeEventListener('mousemove', this._mouseMoveListener);\r\n this._terminal.element.removeEventListener('click', this._clickListener);\r\n }\r\n };\r\n MouseZoneManager.prototype._onMouseMove = function (e) {\r\n if (this._lastHoverCoords[0] !== e.pageX || this._lastHoverCoords[1] !== e.pageY) {\r\n this._onHover(e);\r\n this._lastHoverCoords = [e.pageX, e.pageY];\r\n }\r\n };\r\n MouseZoneManager.prototype._onHover = function (e) {\r\n var _this = this;\r\n var zone = this._findZoneEventAt(e);\r\n if (zone === this._currentZone) {\r\n return;\r\n }\r\n if (this._currentZone) {\r\n this._currentZone.leaveCallback();\r\n this._currentZone = null;\r\n if (this._tooltipTimeout) {\r\n clearTimeout(this._tooltipTimeout);\r\n }\r\n }\r\n if (!zone) {\r\n return;\r\n }\r\n this._currentZone = zone;\r\n if (zone.hoverCallback) {\r\n zone.hoverCallback(e);\r\n }\r\n this._tooltipTimeout = setTimeout(function () { return _this._onTooltip(e); }, HOVER_DURATION);\r\n };\r\n MouseZoneManager.prototype._onTooltip = function (e) {\r\n this._tooltipTimeout = null;\r\n var zone = this._findZoneEventAt(e);\r\n if (zone && zone.tooltipCallback) {\r\n zone.tooltipCallback(e);\r\n }\r\n };\r\n MouseZoneManager.prototype._onMouseDown = function (e) {\r\n if (!this._areZonesActive) {\r\n return;\r\n }\r\n var zone = this._findZoneEventAt(e);\r\n if (zone) {\r\n e.preventDefault();\r\n e.stopImmediatePropagation();\r\n }\r\n };\r\n MouseZoneManager.prototype._onClick = function (e) {\r\n var zone = this._findZoneEventAt(e);\r\n if (zone) {\r\n zone.clickCallback(e);\r\n e.preventDefault();\r\n e.stopImmediatePropagation();\r\n }\r\n };\r\n MouseZoneManager.prototype._findZoneEventAt = function (e) {\r\n var coords = this._terminal.mouseHelper.getCoords(e, this._terminal.element, this._terminal.charMeasure, this._terminal.options.lineHeight, this._terminal.cols, this._terminal.rows);\r\n if (!coords) {\r\n return null;\r\n }\r\n for (var i = 0; i < this._zones.length; i++) {\r\n var zone = this._zones[i];\r\n if (zone.y === coords[1] && zone.x1 <= coords[0] && zone.x2 > coords[0]) {\r\n return zone;\r\n }\r\n }\r\n ;\r\n return null;\r\n };\r\n return MouseZoneManager;\r\n}());\r\nexports.MouseZoneManager = MouseZoneManager;\r\nvar MouseZone = (function () {\r\n function MouseZone(x1, x2, y, clickCallback, hoverCallback, tooltipCallback, leaveCallback) {\r\n this.x1 = x1;\r\n this.x2 = x2;\r\n this.y = y;\r\n this.clickCallback = clickCallback;\r\n this.hoverCallback = hoverCallback;\r\n this.tooltipCallback = tooltipCallback;\r\n this.leaveCallback = leaveCallback;\r\n }\r\n return MouseZone;\r\n}());\r\nexports.MouseZone = MouseZone;\r\n\r\n\r\n\r\n},{}],17:[function(require,module,exports){\r\n\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nvar CharAtlas_1 = require(\"./CharAtlas\");\r\nvar Buffer_1 = require(\"../Buffer\");\r\nexports.INVERTED_DEFAULT_COLOR = -1;\r\nvar DIM_OPACITY = 0.5;\r\nvar BaseRenderLayer = (function () {\r\n function BaseRenderLayer(container, id, zIndex, _alpha, _colors) {\r\n this._alpha = _alpha;\r\n this._colors = _colors;\r\n this._scaledCharWidth = 0;\r\n this._scaledCharHeight = 0;\r\n this._scaledCellWidth = 0;\r\n this._scaledCellHeight = 0;\r\n this._scaledCharLeft = 0;\r\n this._scaledCharTop = 0;\r\n this._canvas = document.createElement('canvas');\r\n this._canvas.id = \"xterm-\" + id + \"-layer\";\r\n this._canvas.style.zIndex = zIndex.toString();\r\n this._ctx = this._canvas.getContext('2d', { alpha: _alpha });\r\n this._ctx.scale(window.devicePixelRatio, window.devicePixelRatio);\r\n if (!_alpha) {\r\n this.clearAll();\r\n }\r\n container.appendChild(this._canvas);\r\n }\r\n BaseRenderLayer.prototype.onOptionsChanged = function (terminal) { };\r\n BaseRenderLayer.prototype.onBlur = function (terminal) { };\r\n BaseRenderLayer.prototype.onFocus = function (terminal) { };\r\n BaseRenderLayer.prototype.onCursorMove = function (terminal) { };\r\n BaseRenderLayer.prototype.onGridChanged = function (terminal, startRow, endRow) { };\r\n BaseRenderLayer.prototype.onSelectionChanged = function (terminal, start, end) { };\r\n BaseRenderLayer.prototype.onThemeChanged = function (terminal, colorSet) {\r\n this._refreshCharAtlas(terminal, colorSet);\r\n };\r\n BaseRenderLayer.prototype._refreshCharAtlas = function (terminal, colorSet) {\r\n var _this = this;\r\n if (this._scaledCharWidth <= 0 && this._scaledCharHeight <= 0) {\r\n return;\r\n }\r\n this._charAtlas = null;\r\n var result = CharAtlas_1.acquireCharAtlas(terminal, this._colors, this._scaledCharWidth, this._scaledCharHeight);\r\n if (result instanceof HTMLCanvasElement) {\r\n this._charAtlas = result;\r\n }\r\n else {\r\n result.then(function (bitmap) { return _this._charAtlas = bitmap; });\r\n }\r\n };\r\n BaseRenderLayer.prototype.resize = function (terminal, dim, charSizeChanged) {\r\n this._scaledCellWidth = dim.scaledCellWidth;\r\n this._scaledCellHeight = dim.scaledCellHeight;\r\n this._scaledCharWidth = dim.scaledCharWidth;\r\n this._scaledCharHeight = dim.scaledCharHeight;\r\n this._scaledCharLeft = dim.scaledCharLeft;\r\n this._scaledCharTop = dim.scaledCharTop;\r\n this._canvas.width = dim.scaledCanvasWidth;\r\n this._canvas.height = dim.scaledCanvasHeight;\r\n this._canvas.style.width = dim.canvasWidth + \"px\";\r\n this._canvas.style.height = dim.canvasHeight + \"px\";\r\n if (!this._alpha) {\r\n this.clearAll();\r\n }\r\n if (charSizeChanged) {\r\n this._refreshCharAtlas(terminal, this._colors);\r\n }\r\n };\r\n BaseRenderLayer.prototype.fillCells = function (x, y, width, height) {\r\n this._ctx.fillRect(x * this._scaledCellWidth, y * this._scaledCellHeight, width * this._scaledCellWidth, height * this._scaledCellHeight);\r\n };\r\n BaseRenderLayer.prototype.fillBottomLineAtCells = function (x, y, width) {\r\n if (width === void 0) { width = 1; }\r\n this._ctx.fillRect(x * this._scaledCellWidth, (y + 1) * this._scaledCellHeight - window.devicePixelRatio - 1, width * this._scaledCellWidth, window.devicePixelRatio);\r\n };\r\n BaseRenderLayer.prototype.fillLeftLineAtCell = function (x, y) {\r\n this._ctx.fillRect(x * this._scaledCellWidth, y * this._scaledCellHeight, window.devicePixelRatio, this._scaledCellHeight);\r\n };\r\n BaseRenderLayer.prototype.strokeRectAtCell = function (x, y, width, height) {\r\n this._ctx.lineWidth = window.devicePixelRatio;\r\n this._ctx.strokeRect(x * this._scaledCellWidth + window.devicePixelRatio / 2, y * this._scaledCellHeight + (window.devicePixelRatio / 2), width * this._scaledCellWidth - window.devicePixelRatio, (height * this._scaledCellHeight) - window.devicePixelRatio);\r\n };\r\n BaseRenderLayer.prototype.clearAll = function () {\r\n if (this._alpha) {\r\n this._ctx.clearRect(0, 0, this._canvas.width, this._canvas.height);\r\n }\r\n else {\r\n this._ctx.fillStyle = this._colors.background;\r\n this._ctx.fillRect(0, 0, this._canvas.width, this._canvas.height);\r\n }\r\n };\r\n BaseRenderLayer.prototype.clearCells = function (x, y, width, height) {\r\n if (this._alpha) {\r\n this._ctx.clearRect(x * this._scaledCellWidth, y * this._scaledCellHeight, width * this._scaledCellWidth, height * this._scaledCellHeight);\r\n }\r\n else {\r\n this._ctx.fillStyle = this._colors.background;\r\n this._ctx.fillRect(x * this._scaledCellWidth, y * this._scaledCellHeight, width * this._scaledCellWidth, height * this._scaledCellHeight);\r\n }\r\n };\r\n BaseRenderLayer.prototype.fillCharTrueColor = function (terminal, charData, x, y) {\r\n this._ctx.font = terminal.options.fontSize * window.devicePixelRatio + \"px \" + terminal.options.fontFamily;\r\n this._ctx.textBaseline = 'top';\r\n this._clipRow(terminal, y);\r\n this._ctx.fillText(charData[Buffer_1.CHAR_DATA_CHAR_INDEX], x * this._scaledCellWidth + this._scaledCharLeft, y * this._scaledCellHeight + this._scaledCharTop);\r\n };\r\n BaseRenderLayer.prototype.drawChar = function (terminal, char, code, width, x, y, fg, bg, bold, dim) {\r\n var colorIndex = 0;\r\n if (fg < 256) {\r\n colorIndex = fg + 2;\r\n }\r\n else {\r\n if (bold && terminal.options.enableBold) {\r\n colorIndex = 1;\r\n }\r\n }\r\n var isAscii = code < 256;\r\n var isBasicColor = (colorIndex > 1 && fg < 16) && (fg < 8 || bold);\r\n var isDefaultColor = fg >= 256;\r\n var isDefaultBackground = bg >= 256;\r\n if (this._charAtlas && isAscii && (isBasicColor || isDefaultColor) && isDefaultBackground) {\r\n var charAtlasCellWidth = this._scaledCharWidth + CharAtlas_1.CHAR_ATLAS_CELL_SPACING;\r\n var charAtlasCellHeight = this._scaledCharHeight + CharAtlas_1.CHAR_ATLAS_CELL_SPACING;\r\n if (dim) {\r\n this._ctx.globalAlpha = DIM_OPACITY;\r\n }\r\n if (bold && !terminal.options.enableBold) {\r\n if (colorIndex > 1) {\r\n colorIndex -= 8;\r\n }\r\n }\r\n this._ctx.drawImage(this._charAtlas, code * charAtlasCellWidth, colorIndex * charAtlasCellHeight, charAtlasCellWidth, this._scaledCharHeight, x * this._scaledCellWidth + this._scaledCharLeft, y * this._scaledCellHeight + this._scaledCharTop, charAtlasCellWidth, this._scaledCharHeight);\r\n }\r\n else {\r\n this._drawUncachedChar(terminal, char, width, fg, x, y, bold, dim);\r\n }\r\n };\r\n BaseRenderLayer.prototype._drawUncachedChar = function (terminal, char, width, fg, x, y, bold, dim) {\r\n this._ctx.save();\r\n this._ctx.font = terminal.options.fontSize * window.devicePixelRatio + \"px \" + terminal.options.fontFamily;\r\n if (bold && terminal.options.enableBold) {\r\n this._ctx.font = \"bold \" + this._ctx.font;\r\n }\r\n this._ctx.textBaseline = 'top';\r\n if (fg === exports.INVERTED_DEFAULT_COLOR) {\r\n this._ctx.fillStyle = this._colors.background;\r\n }\r\n else if (fg < 256) {\r\n this._ctx.fillStyle = this._colors.ansi[fg];\r\n }\r\n else {\r\n this._ctx.fillStyle = this._colors.foreground;\r\n }\r\n this._clipRow(terminal, y);\r\n if (dim) {\r\n this._ctx.globalAlpha = DIM_OPACITY;\r\n }\r\n this._ctx.fillText(char, x * this._scaledCellWidth + this._scaledCharLeft, y * this._scaledCellHeight + this._scaledCharTop);\r\n this._ctx.restore();\r\n };\r\n BaseRenderLayer.prototype._clipRow = function (terminal, y) {\r\n this._ctx.beginPath();\r\n this._ctx.rect(0, y * this._scaledCellHeight, terminal.cols * this._scaledCellWidth, this._scaledCellHeight);\r\n this._ctx.clip();\r\n };\r\n return BaseRenderLayer;\r\n}());\r\nexports.BaseRenderLayer = BaseRenderLayer;\r\n\r\n\r\n\r\n},{\"../Buffer\":1,\"./CharAtlas\":18}],18:[function(require,module,exports){\r\n\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nvar Browser_1 = require(\"../utils/Browser\");\r\nexports.CHAR_ATLAS_CELL_SPACING = 1;\r\nvar charAtlasCache = [];\r\nfunction acquireCharAtlas(terminal, colors, scaledCharWidth, scaledCharHeight) {\r\n var newConfig = generateConfig(scaledCharWidth, scaledCharHeight, terminal, colors);\r\n for (var i = 0; i < charAtlasCache.length; i++) {\r\n var entry = charAtlasCache[i];\r\n var ownedByIndex = entry.ownedBy.indexOf(terminal);\r\n if (ownedByIndex >= 0) {\r\n if (configEquals(entry.config, newConfig)) {\r\n return entry.bitmap;\r\n }\r\n else {\r\n if (entry.ownedBy.length === 1) {\r\n charAtlasCache.splice(i, 1);\r\n }\r\n else {\r\n entry.ownedBy.splice(ownedByIndex, 1);\r\n }\r\n break;\r\n }\r\n }\r\n }\r\n for (var i = 0; i < charAtlasCache.length; i++) {\r\n var entry = charAtlasCache[i];\r\n if (configEquals(entry.config, newConfig)) {\r\n entry.ownedBy.push(terminal);\r\n return entry.bitmap;\r\n }\r\n }\r\n var newEntry = {\r\n bitmap: generator.generate(scaledCharWidth, scaledCharHeight, terminal.options.fontSize, terminal.options.fontFamily, colors.background, colors.foreground, colors.ansi),\r\n config: newConfig,\r\n ownedBy: [terminal]\r\n };\r\n charAtlasCache.push(newEntry);\r\n return newEntry.bitmap;\r\n}\r\nexports.acquireCharAtlas = acquireCharAtlas;\r\nfunction generateConfig(scaledCharWidth, scaledCharHeight, terminal, colors) {\r\n var clonedColors = {\r\n foreground: colors.foreground,\r\n background: colors.background,\r\n cursor: null,\r\n cursorAccent: null,\r\n selection: null,\r\n ansi: colors.ansi.slice(0, 16)\r\n };\r\n return {\r\n scaledCharWidth: scaledCharWidth,\r\n scaledCharHeight: scaledCharHeight,\r\n fontFamily: terminal.options.fontFamily,\r\n fontSize: terminal.options.fontSize,\r\n colors: clonedColors\r\n };\r\n}\r\nfunction configEquals(a, b) {\r\n for (var i = 0; i < a.colors.ansi.length; i++) {\r\n if (a.colors.ansi[i] !== b.colors.ansi[i]) {\r\n return false;\r\n }\r\n }\r\n return a.fontFamily === b.fontFamily &&\r\n a.fontSize === b.fontSize &&\r\n a.scaledCharWidth === b.scaledCharWidth &&\r\n a.scaledCharHeight === b.scaledCharHeight &&\r\n a.colors.foreground === b.colors.foreground &&\r\n a.colors.background === b.colors.background;\r\n}\r\nvar generator;\r\nfunction initialize(document) {\r\n if (!generator) {\r\n generator = new CharAtlasGenerator(document);\r\n }\r\n}\r\nexports.initialize = initialize;\r\nvar CharAtlasGenerator = (function () {\r\n function CharAtlasGenerator(_document) {\r\n this._document = _document;\r\n this._canvas = this._document.createElement('canvas');\r\n this._ctx = this._canvas.getContext('2d', { alpha: false });\r\n this._ctx.scale(window.devicePixelRatio, window.devicePixelRatio);\r\n }\r\n CharAtlasGenerator.prototype.generate = function (scaledCharWidth, scaledCharHeight, fontSize, fontFamily, background, foreground, ansiColors) {\r\n var cellWidth = scaledCharWidth + exports.CHAR_ATLAS_CELL_SPACING;\r\n var cellHeight = scaledCharHeight + exports.CHAR_ATLAS_CELL_SPACING;\r\n this._canvas.width = 255 * cellWidth;\r\n this._canvas.height = (2 + 16) * cellHeight;\r\n this._ctx.fillStyle = background;\r\n this._ctx.fillRect(0, 0, this._canvas.width, this._canvas.height);\r\n this._ctx.save();\r\n this._ctx.fillStyle = foreground;\r\n this._ctx.font = fontSize * window.devicePixelRatio + \"px \" + fontFamily;\r\n this._ctx.textBaseline = 'top';\r\n for (var i = 0; i < 256; i++) {\r\n this._ctx.save();\r\n this._ctx.beginPath();\r\n this._ctx.rect(i * cellWidth, 0, cellWidth, cellHeight);\r\n this._ctx.clip();\r\n this._ctx.fillText(String.fromCharCode(i), i * cellWidth, 0);\r\n this._ctx.restore();\r\n }\r\n this._ctx.save();\r\n this._ctx.font = \"bold \" + this._ctx.font;\r\n for (var i = 0; i < 256; i++) {\r\n this._ctx.save();\r\n this._ctx.beginPath();\r\n this._ctx.rect(i * cellWidth, cellHeight, cellWidth, cellHeight);\r\n this._ctx.clip();\r\n this._ctx.fillText(String.fromCharCode(i), i * cellWidth, cellHeight);\r\n this._ctx.restore();\r\n }\r\n this._ctx.restore();\r\n this._ctx.font = fontSize * window.devicePixelRatio + \"px \" + fontFamily;\r\n for (var colorIndex = 0; colorIndex < 16; colorIndex++) {\r\n if (colorIndex === 8) {\r\n this._ctx.font = \"bold \" + this._ctx.font;\r\n }\r\n var y = (colorIndex + 2) * cellHeight;\r\n for (var i = 0; i < 256; i++) {\r\n this._ctx.save();\r\n this._ctx.beginPath();\r\n this._ctx.rect(i * cellWidth, y, cellWidth, cellHeight);\r\n this._ctx.clip();\r\n this._ctx.fillStyle = ansiColors[colorIndex];\r\n this._ctx.fillText(String.fromCharCode(i), i * cellWidth, y);\r\n this._ctx.restore();\r\n }\r\n }\r\n this._ctx.restore();\r\n if (!('createImageBitmap' in window) || Browser_1.isFirefox) {\r\n var result = this._canvas;\r\n this._canvas = this._document.createElement('canvas');\r\n this._ctx = this._canvas.getContext('2d');\r\n this._ctx.scale(window.devicePixelRatio, window.devicePixelRatio);\r\n return result;\r\n }\r\n var charAtlasImageData = this._ctx.getImageData(0, 0, this._canvas.width, this._canvas.height);\r\n var r = parseInt(background.substr(1, 2), 16);\r\n var g = parseInt(background.substr(3, 2), 16);\r\n var b = parseInt(background.substr(5, 2), 16);\r\n this._clearColor(charAtlasImageData, r, g, b);\r\n var promise = window.createImageBitmap(charAtlasImageData);\r\n this._ctx.clearRect(0, 0, this._canvas.width, this._canvas.height);\r\n return promise;\r\n };\r\n CharAtlasGenerator.prototype._clearColor = function (imageData, r, g, b) {\r\n for (var offset = 0; offset < imageData.data.length; offset += 4) {\r\n if (imageData.data[offset] === r &&\r\n imageData.data[offset + 1] === g &&\r\n imageData.data[offset + 2] === b) {\r\n imageData.data[offset + 3] = 0;\r\n }\r\n }\r\n };\r\n return CharAtlasGenerator;\r\n}());\r\n\r\n\r\n\r\n},{\"../utils/Browser\":27}],19:[function(require,module,exports){\r\n\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nvar DEFAULT_FOREGROUND = '#ffffff';\r\nvar DEFAULT_BACKGROUND = '#000000';\r\nvar DEFAULT_CURSOR = '#ffffff';\r\nvar DEFAULT_CURSOR_ACCENT = '#000000';\r\nvar DEFAULT_SELECTION = 'rgba(255, 255, 255, 0.3)';\r\nexports.DEFAULT_ANSI_COLORS = [\r\n '#2e3436',\r\n '#cc0000',\r\n '#4e9a06',\r\n '#c4a000',\r\n '#3465a4',\r\n '#75507b',\r\n '#06989a',\r\n '#d3d7cf',\r\n '#555753',\r\n '#ef2929',\r\n '#8ae234',\r\n '#fce94f',\r\n '#729fcf',\r\n '#ad7fa8',\r\n '#34e2e2',\r\n '#eeeeec'\r\n];\r\nfunction generate256Colors(first16Colors) {\r\n var colors = first16Colors.slice();\r\n var v = [0x00, 0x5f, 0x87, 0xaf, 0xd7, 0xff];\r\n for (var i = 0; i < 216; i++) {\r\n var r = toPaddedHex(v[(i / 36) % 6 | 0]);\r\n var g = toPaddedHex(v[(i / 6) % 6 | 0]);\r\n var b = toPaddedHex(v[i % 6]);\r\n colors.push(\"#\" + r + g + b);\r\n }\r\n for (var i = 0; i < 24; i++) {\r\n var c = toPaddedHex(8 + i * 10);\r\n colors.push(\"#\" + c + c + c);\r\n }\r\n return colors;\r\n}\r\nfunction toPaddedHex(c) {\r\n var s = c.toString(16);\r\n return s.length < 2 ? '0' + s : s;\r\n}\r\nvar ColorManager = (function () {\r\n function ColorManager() {\r\n this.colors = {\r\n foreground: DEFAULT_FOREGROUND,\r\n background: DEFAULT_BACKGROUND,\r\n cursor: DEFAULT_CURSOR,\r\n cursorAccent: DEFAULT_CURSOR_ACCENT,\r\n selection: DEFAULT_SELECTION,\r\n ansi: generate256Colors(exports.DEFAULT_ANSI_COLORS)\r\n };\r\n }\r\n ColorManager.prototype.setTheme = function (theme) {\r\n this.colors.foreground = theme.foreground || DEFAULT_FOREGROUND;\r\n this.colors.background = this._validateColor(theme.background, DEFAULT_BACKGROUND);\r\n this.colors.cursor = theme.cursor || DEFAULT_CURSOR;\r\n this.colors.cursorAccent = theme.cursorAccent || DEFAULT_CURSOR_ACCENT;\r\n this.colors.selection = theme.selection || DEFAULT_SELECTION;\r\n this.colors.ansi[0] = theme.black || exports.DEFAULT_ANSI_COLORS[0];\r\n this.colors.ansi[1] = theme.red || exports.DEFAULT_ANSI_COLORS[1];\r\n this.colors.ansi[2] = theme.green || exports.DEFAULT_ANSI_COLORS[2];\r\n this.colors.ansi[3] = theme.yellow || exports.DEFAULT_ANSI_COLORS[3];\r\n this.colors.ansi[4] = theme.blue || exports.DEFAULT_ANSI_COLORS[4];\r\n this.colors.ansi[5] = theme.magenta || exports.DEFAULT_ANSI_COLORS[5];\r\n this.colors.ansi[6] = theme.cyan || exports.DEFAULT_ANSI_COLORS[6];\r\n this.colors.ansi[7] = theme.white || exports.DEFAULT_ANSI_COLORS[7];\r\n this.colors.ansi[8] = theme.brightBlack || exports.DEFAULT_ANSI_COLORS[8];\r\n this.colors.ansi[9] = theme.brightRed || exports.DEFAULT_ANSI_COLORS[9];\r\n this.colors.ansi[10] = theme.brightGreen || exports.DEFAULT_ANSI_COLORS[10];\r\n this.colors.ansi[11] = theme.brightYellow || exports.DEFAULT_ANSI_COLORS[11];\r\n this.colors.ansi[12] = theme.brightBlue || exports.DEFAULT_ANSI_COLORS[12];\r\n this.colors.ansi[13] = theme.brightMagenta || exports.DEFAULT_ANSI_COLORS[13];\r\n this.colors.ansi[14] = theme.brightCyan || exports.DEFAULT_ANSI_COLORS[14];\r\n this.colors.ansi[15] = theme.brightWhite || exports.DEFAULT_ANSI_COLORS[15];\r\n };\r\n ColorManager.prototype._validateColor = function (color, fallback) {\r\n if (!color) {\r\n return fallback;\r\n }\r\n if (color.length === 7 && color.charAt(0) === '#') {\r\n return color;\r\n }\r\n if (color.length === 4 && color.charAt(0) === '#') {\r\n var r = color.charAt(1);\r\n var g = color.charAt(2);\r\n var b = color.charAt(3);\r\n return \"#\" + r + r + g + g + b + b;\r\n }\r\n return fallback;\r\n };\r\n return ColorManager;\r\n}());\r\nexports.ColorManager = ColorManager;\r\n\r\n\r\n\r\n},{}],20:[function(require,module,exports){\r\n\"use strict\";\r\nvar __extends = (this && this.__extends) || (function () {\r\n var extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\r\n return function (d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n };\r\n})();\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nvar Buffer_1 = require(\"../Buffer\");\r\nvar BaseRenderLayer_1 = require(\"./BaseRenderLayer\");\r\nvar BLINK_INTERVAL = 600;\r\nvar CursorRenderLayer = (function (_super) {\r\n __extends(CursorRenderLayer, _super);\r\n function CursorRenderLayer(container, zIndex, colors) {\r\n var _this = _super.call(this, container, 'cursor', zIndex, true, colors) || this;\r\n _this._state = {\r\n x: null,\r\n y: null,\r\n isFocused: null,\r\n style: null,\r\n width: null,\r\n };\r\n _this._cursorRenderers = {\r\n 'bar': _this._renderBarCursor.bind(_this),\r\n 'block': _this._renderBlockCursor.bind(_this),\r\n 'underline': _this._renderUnderlineCursor.bind(_this)\r\n };\r\n return _this;\r\n }\r\n CursorRenderLayer.prototype.resize = function (terminal, dim, charSizeChanged) {\r\n _super.prototype.resize.call(this, terminal, dim, charSizeChanged);\r\n this._state = {\r\n x: null,\r\n y: null,\r\n isFocused: null,\r\n style: null,\r\n width: null,\r\n };\r\n };\r\n CursorRenderLayer.prototype.reset = function (terminal) {\r\n this._clearCursor();\r\n if (this._cursorBlinkStateManager) {\r\n this._cursorBlinkStateManager.dispose();\r\n this._cursorBlinkStateManager = null;\r\n this.onOptionsChanged(terminal);\r\n }\r\n };\r\n CursorRenderLayer.prototype.onBlur = function (terminal) {\r\n if (this._cursorBlinkStateManager) {\r\n this._cursorBlinkStateManager.pause();\r\n }\r\n terminal.refresh(terminal.buffer.y, terminal.buffer.y);\r\n };\r\n CursorRenderLayer.prototype.onFocus = function (terminal) {\r\n if (this._cursorBlinkStateManager) {\r\n this._cursorBlinkStateManager.resume(terminal);\r\n }\r\n else {\r\n terminal.refresh(terminal.buffer.y, terminal.buffer.y);\r\n }\r\n };\r\n CursorRenderLayer.prototype.onOptionsChanged = function (terminal) {\r\n var _this = this;\r\n if (terminal.options.cursorBlink) {\r\n if (!this._cursorBlinkStateManager) {\r\n this._cursorBlinkStateManager = new CursorBlinkStateManager(terminal, function () {\r\n _this._render(terminal, true);\r\n });\r\n }\r\n }\r\n else {\r\n if (this._cursorBlinkStateManager) {\r\n this._cursorBlinkStateManager.dispose();\r\n this._cursorBlinkStateManager = null;\r\n }\r\n terminal.refresh(terminal.buffer.y, terminal.buffer.y);\r\n }\r\n };\r\n CursorRenderLayer.prototype.onCursorMove = function (terminal) {\r\n if (this._cursorBlinkStateManager) {\r\n this._cursorBlinkStateManager.restartBlinkAnimation(terminal);\r\n }\r\n };\r\n CursorRenderLayer.prototype.onGridChanged = function (terminal, startRow, endRow) {\r\n if (!this._cursorBlinkStateManager || this._cursorBlinkStateManager.isPaused) {\r\n this._render(terminal, false);\r\n }\r\n };\r\n CursorRenderLayer.prototype._render = function (terminal, triggeredByAnimationFrame) {\r\n if (!terminal.cursorState || terminal.cursorHidden) {\r\n this._clearCursor();\r\n return;\r\n }\r\n var cursorY = terminal.buffer.ybase + terminal.buffer.y;\r\n var viewportRelativeCursorY = cursorY - terminal.buffer.ydisp;\r\n if (viewportRelativeCursorY < 0 || viewportRelativeCursorY >= terminal.rows) {\r\n this._clearCursor();\r\n return;\r\n }\r\n var charData = terminal.buffer.lines.get(cursorY)[terminal.buffer.x];\r\n if (!charData) {\r\n return;\r\n }\r\n if (!terminal.isFocused) {\r\n this._clearCursor();\r\n this._ctx.save();\r\n this._ctx.fillStyle = this._colors.cursor;\r\n this._renderBlurCursor(terminal, terminal.buffer.x, viewportRelativeCursorY, charData);\r\n this._ctx.restore();\r\n this._state.x = terminal.buffer.x;\r\n this._state.y = viewportRelativeCursorY;\r\n this._state.isFocused = false;\r\n this._state.style = terminal.options.cursorStyle;\r\n this._state.width = charData[Buffer_1.CHAR_DATA_WIDTH_INDEX];\r\n return;\r\n }\r\n if (this._cursorBlinkStateManager && !this._cursorBlinkStateManager.isCursorVisible) {\r\n this._clearCursor();\r\n return;\r\n }\r\n if (this._state) {\r\n if (this._state.x === terminal.buffer.x &&\r\n this._state.y === viewportRelativeCursorY &&\r\n this._state.isFocused === terminal.isFocused &&\r\n this._state.style === terminal.options.cursorStyle &&\r\n this._state.width === charData[Buffer_1.CHAR_DATA_WIDTH_INDEX]) {\r\n return;\r\n }\r\n this._clearCursor();\r\n }\r\n this._ctx.save();\r\n this._cursorRenderers[terminal.options.cursorStyle || 'block'](terminal, terminal.buffer.x, viewportRelativeCursorY, charData);\r\n this._ctx.restore();\r\n this._state.x = terminal.buffer.x;\r\n this._state.y = viewportRelativeCursorY;\r\n this._state.isFocused = false;\r\n this._state.style = terminal.options.cursorStyle;\r\n this._state.width = charData[Buffer_1.CHAR_DATA_WIDTH_INDEX];\r\n };\r\n CursorRenderLayer.prototype._clearCursor = function () {\r\n if (this._state) {\r\n this.clearCells(this._state.x, this._state.y, this._state.width, 1);\r\n this._state = {\r\n x: null,\r\n y: null,\r\n isFocused: null,\r\n style: null,\r\n width: null,\r\n };\r\n }\r\n };\r\n CursorRenderLayer.prototype._renderBarCursor = function (terminal, x, y, charData) {\r\n this._ctx.save();\r\n this._ctx.fillStyle = this._colors.cursor;\r\n this.fillLeftLineAtCell(x, y);\r\n this._ctx.restore();\r\n };\r\n CursorRenderLayer.prototype._renderBlockCursor = function (terminal, x, y, charData) {\r\n this._ctx.save();\r\n this._ctx.fillStyle = this._colors.cursor;\r\n this.fillCells(x, y, charData[Buffer_1.CHAR_DATA_WIDTH_INDEX], 1);\r\n this._ctx.fillStyle = this._colors.cursorAccent;\r\n this.fillCharTrueColor(terminal, charData, x, y);\r\n this._ctx.restore();\r\n };\r\n CursorRenderLayer.prototype._renderUnderlineCursor = function (terminal, x, y, charData) {\r\n this._ctx.save();\r\n this._ctx.fillStyle = this._colors.cursor;\r\n this.fillBottomLineAtCells(x, y);\r\n this._ctx.restore();\r\n };\r\n CursorRenderLayer.prototype._renderBlurCursor = function (terminal, x, y, charData) {\r\n this._ctx.save();\r\n this._ctx.strokeStyle = this._colors.cursor;\r\n this.strokeRectAtCell(x, y, charData[Buffer_1.CHAR_DATA_WIDTH_INDEX], 1);\r\n this._ctx.restore();\r\n };\r\n return CursorRenderLayer;\r\n}(BaseRenderLayer_1.BaseRenderLayer));\r\nexports.CursorRenderLayer = CursorRenderLayer;\r\nvar CursorBlinkStateManager = (function () {\r\n function CursorBlinkStateManager(terminal, renderCallback) {\r\n this.renderCallback = renderCallback;\r\n this.isCursorVisible = true;\r\n if (terminal.isFocused) {\r\n this._restartInterval();\r\n }\r\n }\r\n Object.defineProperty(CursorBlinkStateManager.prototype, \"isPaused\", {\r\n get: function () { return !(this._blinkStartTimeout || this._blinkInterval); },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n CursorBlinkStateManager.prototype.dispose = function () {\r\n if (this._blinkInterval) {\r\n window.clearInterval(this._blinkInterval);\r\n this._blinkInterval = null;\r\n }\r\n if (this._blinkStartTimeout) {\r\n window.clearTimeout(this._blinkStartTimeout);\r\n this._blinkStartTimeout = null;\r\n }\r\n if (this._animationFrame) {\r\n window.cancelAnimationFrame(this._animationFrame);\r\n this._animationFrame = null;\r\n }\r\n };\r\n CursorBlinkStateManager.prototype.restartBlinkAnimation = function (terminal) {\r\n var _this = this;\r\n if (this.isPaused) {\r\n return;\r\n }\r\n this._animationTimeRestarted = Date.now();\r\n this.isCursorVisible = true;\r\n if (!this._animationFrame) {\r\n this._animationFrame = window.requestAnimationFrame(function () {\r\n _this.renderCallback();\r\n _this._animationFrame = null;\r\n });\r\n }\r\n };\r\n CursorBlinkStateManager.prototype._restartInterval = function (timeToStart) {\r\n var _this = this;\r\n if (timeToStart === void 0) { timeToStart = BLINK_INTERVAL; }\r\n if (this._blinkInterval) {\r\n window.clearInterval(this._blinkInterval);\r\n }\r\n this._blinkStartTimeout = setTimeout(function () {\r\n if (_this._animationTimeRestarted) {\r\n var time = BLINK_INTERVAL - (Date.now() - _this._animationTimeRestarted);\r\n _this._animationTimeRestarted = null;\r\n if (time > 0) {\r\n _this._restartInterval(time);\r\n return;\r\n }\r\n }\r\n _this.isCursorVisible = false;\r\n _this._animationFrame = window.requestAnimationFrame(function () {\r\n _this.renderCallback();\r\n _this._animationFrame = null;\r\n });\r\n _this._blinkInterval = setInterval(function () {\r\n if (_this._animationTimeRestarted) {\r\n var time = BLINK_INTERVAL - (Date.now() - _this._animationTimeRestarted);\r\n _this._animationTimeRestarted = null;\r\n _this._restartInterval(time);\r\n return;\r\n }\r\n _this.isCursorVisible = !_this.isCursorVisible;\r\n _this._animationFrame = window.requestAnimationFrame(function () {\r\n _this.renderCallback();\r\n _this._animationFrame = null;\r\n });\r\n }, BLINK_INTERVAL);\r\n }, timeToStart);\r\n };\r\n CursorBlinkStateManager.prototype.pause = function () {\r\n this.isCursorVisible = true;\r\n if (this._blinkInterval) {\r\n window.clearInterval(this._blinkInterval);\r\n this._blinkInterval = null;\r\n }\r\n if (this._blinkStartTimeout) {\r\n window.clearTimeout(this._blinkStartTimeout);\r\n this._blinkStartTimeout = null;\r\n }\r\n if (this._animationFrame) {\r\n window.cancelAnimationFrame(this._animationFrame);\r\n this._animationFrame = null;\r\n }\r\n };\r\n CursorBlinkStateManager.prototype.resume = function (terminal) {\r\n this._animationTimeRestarted = null;\r\n this._restartInterval();\r\n this.restartBlinkAnimation(terminal);\r\n };\r\n return CursorBlinkStateManager;\r\n}());\r\n\r\n\r\n\r\n},{\"../Buffer\":1,\"./BaseRenderLayer\":17}],21:[function(require,module,exports){\r\n\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nvar GridCache = (function () {\r\n function GridCache() {\r\n this.cache = [];\r\n }\r\n GridCache.prototype.resize = function (width, height) {\r\n for (var x = 0; x < width; x++) {\r\n if (this.cache.length <= x) {\r\n this.cache.push([]);\r\n }\r\n for (var y = this.cache[x].length; y < height; y++) {\r\n this.cache[x].push(null);\r\n }\r\n this.cache[x].length = height;\r\n }\r\n this.cache.length = width;\r\n };\r\n GridCache.prototype.clear = function () {\r\n for (var x = 0; x < this.cache.length; x++) {\r\n for (var y = 0; y < this.cache[x].length; y++) {\r\n this.cache[x][y] = null;\r\n }\r\n }\r\n };\r\n return GridCache;\r\n}());\r\nexports.GridCache = GridCache;\r\n\r\n\r\n\r\n},{}],22:[function(require,module,exports){\r\n\"use strict\";\r\nvar __extends = (this && this.__extends) || (function () {\r\n var extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\r\n return function (d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n };\r\n})();\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nvar BaseRenderLayer_1 = require(\"./BaseRenderLayer\");\r\nvar Types_1 = require(\"../Types\");\r\nvar LinkRenderLayer = (function (_super) {\r\n __extends(LinkRenderLayer, _super);\r\n function LinkRenderLayer(container, zIndex, colors, terminal) {\r\n var _this = _super.call(this, container, 'link', zIndex, true, colors) || this;\r\n _this._state = null;\r\n terminal.linkifier.on(Types_1.LinkHoverEventTypes.HOVER, function (e) { return _this._onLinkHover(e); });\r\n terminal.linkifier.on(Types_1.LinkHoverEventTypes.LEAVE, function (e) { return _this._onLinkLeave(e); });\r\n return _this;\r\n }\r\n LinkRenderLayer.prototype.resize = function (terminal, dim, charSizeChanged) {\r\n _super.prototype.resize.call(this, terminal, dim, charSizeChanged);\r\n this._state = null;\r\n };\r\n LinkRenderLayer.prototype.reset = function (terminal) {\r\n this._clearCurrentLink();\r\n };\r\n LinkRenderLayer.prototype._clearCurrentLink = function () {\r\n if (this._state) {\r\n this.clearCells(this._state.x, this._state.y, this._state.length, 1);\r\n this._state = null;\r\n }\r\n };\r\n LinkRenderLayer.prototype._onLinkHover = function (e) {\r\n this._ctx.fillStyle = this._colors.foreground;\r\n this.fillBottomLineAtCells(e.x, e.y, e.length);\r\n this._state = e;\r\n };\r\n LinkRenderLayer.prototype._onLinkLeave = function (e) {\r\n this._clearCurrentLink();\r\n };\r\n return LinkRenderLayer;\r\n}(BaseRenderLayer_1.BaseRenderLayer));\r\nexports.LinkRenderLayer = LinkRenderLayer;\r\n\r\n\r\n\r\n},{\"../Types\":13,\"./BaseRenderLayer\":17}],23:[function(require,module,exports){\r\n\"use strict\";\r\nvar __extends = (this && this.__extends) || (function () {\r\n var extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\r\n return function (d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n };\r\n})();\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nvar TextRenderLayer_1 = require(\"./TextRenderLayer\");\r\nvar SelectionRenderLayer_1 = require(\"./SelectionRenderLayer\");\r\nvar CursorRenderLayer_1 = require(\"./CursorRenderLayer\");\r\nvar ColorManager_1 = require(\"./ColorManager\");\r\nvar LinkRenderLayer_1 = require(\"./LinkRenderLayer\");\r\nvar EventEmitter_1 = require(\"../EventEmitter\");\r\nvar Renderer = (function (_super) {\r\n __extends(Renderer, _super);\r\n function Renderer(_terminal, theme) {\r\n var _this = _super.call(this) || this;\r\n _this._terminal = _terminal;\r\n _this._refreshRowsQueue = [];\r\n _this._refreshAnimationFrame = null;\r\n _this.colorManager = new ColorManager_1.ColorManager();\r\n if (theme) {\r\n _this.colorManager.setTheme(theme);\r\n }\r\n _this._renderLayers = [\r\n new TextRenderLayer_1.TextRenderLayer(_this._terminal.element, 0, _this.colorManager.colors),\r\n new SelectionRenderLayer_1.SelectionRenderLayer(_this._terminal.element, 1, _this.colorManager.colors),\r\n new LinkRenderLayer_1.LinkRenderLayer(_this._terminal.element, 2, _this.colorManager.colors, _this._terminal),\r\n new CursorRenderLayer_1.CursorRenderLayer(_this._terminal.element, 3, _this.colorManager.colors)\r\n ];\r\n _this.dimensions = {\r\n scaledCharWidth: null,\r\n scaledCharHeight: null,\r\n scaledCellWidth: null,\r\n scaledCellHeight: null,\r\n scaledCharLeft: null,\r\n scaledCharTop: null,\r\n scaledCanvasWidth: null,\r\n scaledCanvasHeight: null,\r\n canvasWidth: null,\r\n canvasHeight: null,\r\n actualCellWidth: null,\r\n actualCellHeight: null\r\n };\r\n _this._devicePixelRatio = window.devicePixelRatio;\r\n return _this;\r\n }\r\n Renderer.prototype.onWindowResize = function (devicePixelRatio) {\r\n if (this._devicePixelRatio !== devicePixelRatio) {\r\n this._devicePixelRatio = devicePixelRatio;\r\n this.onResize(this._terminal.cols, this._terminal.rows, true);\r\n }\r\n };\r\n Renderer.prototype.setTheme = function (theme) {\r\n var _this = this;\r\n this.colorManager.setTheme(theme);\r\n this._renderLayers.forEach(function (l) {\r\n l.onThemeChanged(_this._terminal, _this.colorManager.colors);\r\n l.reset(_this._terminal);\r\n });\r\n this._terminal.refresh(0, this._terminal.rows - 1);\r\n return this.colorManager.colors;\r\n };\r\n Renderer.prototype.onResize = function (cols, rows, didCharSizeChange) {\r\n var _this = this;\r\n if (!this._terminal.charMeasure.width || !this._terminal.charMeasure.height) {\r\n return;\r\n }\r\n this.dimensions.scaledCharWidth = Math.floor(this._terminal.charMeasure.width * window.devicePixelRatio);\r\n this.dimensions.scaledCharHeight = Math.ceil(this._terminal.charMeasure.height * window.devicePixelRatio);\r\n this.dimensions.scaledCellHeight = Math.floor(this.dimensions.scaledCharHeight * this._terminal.options.lineHeight);\r\n this.dimensions.scaledCharTop = this._terminal.options.lineHeight === 1 ? 0 : Math.round((this.dimensions.scaledCellHeight - this.dimensions.scaledCharHeight) / 2);\r\n this.dimensions.scaledCellWidth = this.dimensions.scaledCharWidth + Math.round(this._terminal.options.letterSpacing);\r\n this.dimensions.scaledCharLeft = Math.floor(this._terminal.options.letterSpacing / 2);\r\n this.dimensions.scaledCanvasHeight = this._terminal.rows * this.dimensions.scaledCellHeight;\r\n this.dimensions.scaledCanvasWidth = this._terminal.cols * this.dimensions.scaledCellWidth;\r\n this.dimensions.canvasHeight = Math.round(this.dimensions.scaledCanvasHeight / window.devicePixelRatio);\r\n this.dimensions.canvasWidth = Math.round(this.dimensions.scaledCanvasWidth / window.devicePixelRatio);\r\n this.dimensions.actualCellHeight = this.dimensions.canvasHeight / this._terminal.rows;\r\n this.dimensions.actualCellWidth = this.dimensions.canvasWidth / this._terminal.cols;\r\n this._renderLayers.forEach(function (l) { return l.resize(_this._terminal, _this.dimensions, didCharSizeChange); });\r\n this._terminal.refresh(0, this._terminal.rows - 1);\r\n this.emit('resize', {\r\n width: this.dimensions.canvasWidth,\r\n height: this.dimensions.canvasHeight\r\n });\r\n };\r\n Renderer.prototype.onCharSizeChanged = function () {\r\n this.onResize(this._terminal.cols, this._terminal.rows, true);\r\n };\r\n Renderer.prototype.onBlur = function () {\r\n var _this = this;\r\n this._renderLayers.forEach(function (l) { return l.onBlur(_this._terminal); });\r\n };\r\n Renderer.prototype.onFocus = function () {\r\n var _this = this;\r\n this._renderLayers.forEach(function (l) { return l.onFocus(_this._terminal); });\r\n };\r\n Renderer.prototype.onSelectionChanged = function (start, end) {\r\n var _this = this;\r\n this._renderLayers.forEach(function (l) { return l.onSelectionChanged(_this._terminal, start, end); });\r\n };\r\n Renderer.prototype.onCursorMove = function () {\r\n var _this = this;\r\n this._renderLayers.forEach(function (l) { return l.onCursorMove(_this._terminal); });\r\n };\r\n Renderer.prototype.onOptionsChanged = function () {\r\n var _this = this;\r\n this._renderLayers.forEach(function (l) { return l.onOptionsChanged(_this._terminal); });\r\n };\r\n Renderer.prototype.clear = function () {\r\n var _this = this;\r\n this._renderLayers.forEach(function (l) { return l.reset(_this._terminal); });\r\n };\r\n Renderer.prototype.queueRefresh = function (start, end) {\r\n this._refreshRowsQueue.push({ start: start, end: end });\r\n if (!this._refreshAnimationFrame) {\r\n this._refreshAnimationFrame = window.requestAnimationFrame(this._refreshLoop.bind(this));\r\n }\r\n };\r\n Renderer.prototype._refreshLoop = function () {\r\n var _this = this;\r\n var start;\r\n var end;\r\n if (this._refreshRowsQueue.length > 4) {\r\n start = 0;\r\n end = this._terminal.rows - 1;\r\n }\r\n else {\r\n start = this._refreshRowsQueue[0].start;\r\n end = this._refreshRowsQueue[0].end;\r\n for (var i = 1; i < this._refreshRowsQueue.length; i++) {\r\n if (this._refreshRowsQueue[i].start < start) {\r\n start = this._refreshRowsQueue[i].start;\r\n }\r\n if (this._refreshRowsQueue[i].end > end) {\r\n end = this._refreshRowsQueue[i].end;\r\n }\r\n }\r\n }\r\n this._refreshRowsQueue = [];\r\n this._refreshAnimationFrame = null;\r\n start = Math.max(start, 0);\r\n end = Math.min(end, this._terminal.rows - 1);\r\n this._renderLayers.forEach(function (l) { return l.onGridChanged(_this._terminal, start, end); });\r\n this._terminal.emit('refresh', { start: start, end: end });\r\n };\r\n return Renderer;\r\n}(EventEmitter_1.EventEmitter));\r\nexports.Renderer = Renderer;\r\n\r\n\r\n\r\n},{\"../EventEmitter\":6,\"./ColorManager\":19,\"./CursorRenderLayer\":20,\"./LinkRenderLayer\":22,\"./SelectionRenderLayer\":24,\"./TextRenderLayer\":25}],24:[function(require,module,exports){\r\n\"use strict\";\r\nvar __extends = (this && this.__extends) || (function () {\r\n var extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\r\n return function (d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n };\r\n})();\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nvar BaseRenderLayer_1 = require(\"./BaseRenderLayer\");\r\nvar SelectionRenderLayer = (function (_super) {\r\n __extends(SelectionRenderLayer, _super);\r\n function SelectionRenderLayer(container, zIndex, colors) {\r\n var _this = _super.call(this, container, 'selection', zIndex, true, colors) || this;\r\n _this._state = {\r\n start: null,\r\n end: null\r\n };\r\n return _this;\r\n }\r\n SelectionRenderLayer.prototype.resize = function (terminal, dim, charSizeChanged) {\r\n _super.prototype.resize.call(this, terminal, dim, charSizeChanged);\r\n this._state = {\r\n start: null,\r\n end: null\r\n };\r\n };\r\n SelectionRenderLayer.prototype.reset = function (terminal) {\r\n if (this._state.start && this._state.end) {\r\n this._state = {\r\n start: null,\r\n end: null\r\n };\r\n this.clearAll();\r\n }\r\n };\r\n SelectionRenderLayer.prototype.onSelectionChanged = function (terminal, start, end) {\r\n if (this._state.start === start || this._state.end === end) {\r\n return;\r\n }\r\n this.clearAll();\r\n if (!start || !end) {\r\n return;\r\n }\r\n var viewportStartRow = start[1] - terminal.buffer.ydisp;\r\n var viewportEndRow = end[1] - terminal.buffer.ydisp;\r\n var viewportCappedStartRow = Math.max(viewportStartRow, 0);\r\n var viewportCappedEndRow = Math.min(viewportEndRow, terminal.rows - 1);\r\n if (viewportCappedStartRow >= terminal.rows || viewportCappedEndRow < 0) {\r\n return;\r\n }\r\n var startCol = viewportStartRow === viewportCappedStartRow ? start[0] : 0;\r\n var startRowEndCol = viewportCappedStartRow === viewportCappedEndRow ? end[0] : terminal.cols;\r\n this._ctx.fillStyle = this._colors.selection;\r\n this.fillCells(startCol, viewportCappedStartRow, startRowEndCol - startCol, 1);\r\n var middleRowsCount = Math.max(viewportCappedEndRow - viewportCappedStartRow - 1, 0);\r\n this.fillCells(0, viewportCappedStartRow + 1, terminal.cols, middleRowsCount);\r\n if (viewportCappedStartRow !== viewportCappedEndRow) {\r\n var endCol = viewportEndRow === viewportCappedEndRow ? end[0] : terminal.cols;\r\n this.fillCells(0, viewportCappedEndRow, endCol, 1);\r\n }\r\n this._state.start = [start[0], start[1]];\r\n this._state.end = [end[0], end[1]];\r\n };\r\n return SelectionRenderLayer;\r\n}(BaseRenderLayer_1.BaseRenderLayer));\r\nexports.SelectionRenderLayer = SelectionRenderLayer;\r\n\r\n\r\n\r\n},{\"./BaseRenderLayer\":17}],25:[function(require,module,exports){\r\n\"use strict\";\r\nvar __extends = (this && this.__extends) || (function () {\r\n var extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\r\n return function (d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n };\r\n})();\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nvar Buffer_1 = require(\"../Buffer\");\r\nvar Types_1 = require(\"./Types\");\r\nvar GridCache_1 = require(\"./GridCache\");\r\nvar BaseRenderLayer_1 = require(\"./BaseRenderLayer\");\r\nvar OVERLAP_OWNED_CHAR_DATA = [null, '', 0, -1];\r\nvar TextRenderLayer = (function (_super) {\r\n __extends(TextRenderLayer, _super);\r\n function TextRenderLayer(container, zIndex, colors) {\r\n var _this = _super.call(this, container, 'text', zIndex, false, colors) || this;\r\n _this._characterOverlapCache = {};\r\n _this._state = new GridCache_1.GridCache();\r\n return _this;\r\n }\r\n TextRenderLayer.prototype.resize = function (terminal, dim, charSizeChanged) {\r\n _super.prototype.resize.call(this, terminal, dim, charSizeChanged);\r\n var terminalFont = terminal.options.fontSize * window.devicePixelRatio + \"px \" + terminal.options.fontFamily;\r\n if (this._characterWidth !== dim.scaledCharWidth || this._characterFont !== terminalFont) {\r\n this._characterWidth = dim.scaledCharWidth;\r\n this._characterFont = terminalFont;\r\n this._characterOverlapCache = {};\r\n }\r\n this._state.clear();\r\n this._state.resize(terminal.cols, terminal.rows);\r\n };\r\n TextRenderLayer.prototype.reset = function (terminal) {\r\n this._state.clear();\r\n this.clearAll();\r\n };\r\n TextRenderLayer.prototype.onGridChanged = function (terminal, startRow, endRow) {\r\n if (this._state.cache.length === 0) {\r\n return;\r\n }\r\n for (var y = startRow; y <= endRow; y++) {\r\n var row = y + terminal.buffer.ydisp;\r\n var line = terminal.buffer.lines.get(row);\r\n this.clearCells(0, y, terminal.cols, 1);\r\n for (var x = 0; x < terminal.cols; x++) {\r\n var charData = line[x];\r\n var code = charData[Buffer_1.CHAR_DATA_CODE_INDEX];\r\n var char = charData[Buffer_1.CHAR_DATA_CHAR_INDEX];\r\n var attr = charData[Buffer_1.CHAR_DATA_ATTR_INDEX];\r\n var width = charData[Buffer_1.CHAR_DATA_WIDTH_INDEX];\r\n if (width === 0) {\r\n continue;\r\n }\r\n if (code === 32) {\r\n if (x > 0) {\r\n var previousChar = line[x - 1];\r\n if (this._isOverlapping(previousChar)) {\r\n continue;\r\n }\r\n }\r\n }\r\n var flags = attr >> 18;\r\n var bg = attr & 0x1ff;\r\n var isDefaultBackground = bg >= 256;\r\n var isInvisible = flags & Types_1.FLAGS.INVISIBLE;\r\n var isInverted = flags & Types_1.FLAGS.INVERSE;\r\n if (!code || (code === 32 && isDefaultBackground && !isInverted) || isInvisible) {\r\n continue;\r\n }\r\n if (width !== 0 && this._isOverlapping(charData)) {\r\n if (x < line.length - 1 && line[x + 1][Buffer_1.CHAR_DATA_CODE_INDEX] === 32) {\r\n width = 2;\r\n }\r\n }\r\n var fg = (attr >> 9) & 0x1ff;\r\n if (isInverted) {\r\n var temp = bg;\r\n bg = fg;\r\n fg = temp;\r\n if (fg === 256) {\r\n fg = BaseRenderLayer_1.INVERTED_DEFAULT_COLOR;\r\n }\r\n if (bg === 257) {\r\n bg = BaseRenderLayer_1.INVERTED_DEFAULT_COLOR;\r\n }\r\n }\r\n if (width === 2) {\r\n }\r\n if (bg < 256) {\r\n this._ctx.save();\r\n this._ctx.fillStyle = (bg === BaseRenderLayer_1.INVERTED_DEFAULT_COLOR ? this._colors.foreground : this._colors.ansi[bg]);\r\n this.fillCells(x, y, width, 1);\r\n this._ctx.restore();\r\n }\r\n this._ctx.save();\r\n if (flags & Types_1.FLAGS.BOLD) {\r\n this._ctx.font = \"bold \" + this._ctx.font;\r\n if (fg < 8) {\r\n fg += 8;\r\n }\r\n }\r\n if (flags & Types_1.FLAGS.UNDERLINE) {\r\n if (fg === BaseRenderLayer_1.INVERTED_DEFAULT_COLOR) {\r\n this._ctx.fillStyle = this._colors.background;\r\n }\r\n else if (fg < 256) {\r\n this._ctx.fillStyle = this._colors.ansi[fg];\r\n }\r\n else {\r\n this._ctx.fillStyle = this._colors.foreground;\r\n }\r\n this.fillBottomLineAtCells(x, y);\r\n }\r\n this.drawChar(terminal, char, code, width, x, y, fg, bg, !!(flags & Types_1.FLAGS.BOLD), !!(flags & Types_1.FLAGS.DIM));\r\n this._ctx.restore();\r\n }\r\n }\r\n };\r\n TextRenderLayer.prototype._isOverlapping = function (charData) {\r\n if (charData[Buffer_1.CHAR_DATA_WIDTH_INDEX] !== 1) {\r\n return false;\r\n }\r\n var code = charData[Buffer_1.CHAR_DATA_CODE_INDEX];\r\n if (code < 256) {\r\n return false;\r\n }\r\n var char = charData[Buffer_1.CHAR_DATA_CHAR_INDEX];\r\n if (this._characterOverlapCache.hasOwnProperty(char)) {\r\n return this._characterOverlapCache[char];\r\n }\r\n this._ctx.save();\r\n this._ctx.font = this._characterFont;\r\n var overlaps = Math.floor(this._ctx.measureText(char).width) > this._characterWidth;\r\n this._ctx.restore();\r\n this._characterOverlapCache[char] = overlaps;\r\n return overlaps;\r\n };\r\n TextRenderLayer.prototype._clearChar = function (x, y) {\r\n var colsToClear = 1;\r\n var state = this._state.cache[x][y];\r\n if (state && state[Buffer_1.CHAR_DATA_WIDTH_INDEX] === 2) {\r\n colsToClear = 2;\r\n }\r\n this.clearCells(x, y, colsToClear, 1);\r\n };\r\n return TextRenderLayer;\r\n}(BaseRenderLayer_1.BaseRenderLayer));\r\nexports.TextRenderLayer = TextRenderLayer;\r\n\r\n\r\n\r\n},{\"../Buffer\":1,\"./BaseRenderLayer\":17,\"./GridCache\":21,\"./Types\":26}],26:[function(require,module,exports){\r\n\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nvar FLAGS;\r\n(function (FLAGS) {\r\n FLAGS[FLAGS[\"BOLD\"] = 1] = \"BOLD\";\r\n FLAGS[FLAGS[\"UNDERLINE\"] = 2] = \"UNDERLINE\";\r\n FLAGS[FLAGS[\"BLINK\"] = 4] = \"BLINK\";\r\n FLAGS[FLAGS[\"INVERSE\"] = 8] = \"INVERSE\";\r\n FLAGS[FLAGS[\"INVISIBLE\"] = 16] = \"INVISIBLE\";\r\n FLAGS[FLAGS[\"DIM\"] = 32] = \"DIM\";\r\n})(FLAGS = exports.FLAGS || (exports.FLAGS = {}));\r\n;\r\n\r\n\r\n\r\n},{}],27:[function(require,module,exports){\r\n\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nvar Generic_1 = require(\"./Generic\");\r\nvar isNode = (typeof navigator === 'undefined') ? true : false;\r\nvar userAgent = (isNode) ? 'node' : navigator.userAgent;\r\nvar platform = (isNode) ? 'node' : navigator.platform;\r\nexports.isFirefox = !!~userAgent.indexOf('Firefox');\r\nexports.isMSIE = !!~userAgent.indexOf('MSIE') || !!~userAgent.indexOf('Trident');\r\nexports.isMac = Generic_1.contains(['Macintosh', 'MacIntel', 'MacPPC', 'Mac68K'], platform);\r\nexports.isIpad = platform === 'iPad';\r\nexports.isIphone = platform === 'iPhone';\r\nexports.isMSWindows = Generic_1.contains(['Windows', 'Win16', 'Win32', 'WinCE'], platform);\r\nexports.isLinux = platform.indexOf('Linux') >= 0;\r\n\r\n\r\n\r\n},{\"./Generic\":30}],28:[function(require,module,exports){\r\n\"use strict\";\r\nvar __extends = (this && this.__extends) || (function () {\r\n var extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\r\n return function (d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n };\r\n})();\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nvar EventEmitter_1 = require(\"../EventEmitter\");\r\nvar CharMeasure = (function (_super) {\r\n __extends(CharMeasure, _super);\r\n function CharMeasure(document, parentElement) {\r\n var _this = _super.call(this) || this;\r\n _this._document = document;\r\n _this._parentElement = parentElement;\r\n return _this;\r\n }\r\n Object.defineProperty(CharMeasure.prototype, \"width\", {\r\n get: function () {\r\n return this._width;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(CharMeasure.prototype, \"height\", {\r\n get: function () {\r\n return this._height;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n CharMeasure.prototype.measure = function (options) {\r\n var _this = this;\r\n if (!this._measureElement) {\r\n this._measureElement = this._document.createElement('span');\r\n this._measureElement.style.position = 'absolute';\r\n this._measureElement.style.top = '0';\r\n this._measureElement.style.left = '-9999em';\r\n this._measureElement.style.lineHeight = 'normal';\r\n this._measureElement.textContent = 'W';\r\n this._measureElement.setAttribute('aria-hidden', 'true');\r\n this._parentElement.appendChild(this._measureElement);\r\n setTimeout(function () { return _this._doMeasure(options); }, 0);\r\n }\r\n else {\r\n this._doMeasure(options);\r\n }\r\n };\r\n CharMeasure.prototype._doMeasure = function (options) {\r\n this._measureElement.style.fontFamily = options.fontFamily;\r\n this._measureElement.style.fontSize = options.fontSize + \"px\";\r\n var geometry = this._measureElement.getBoundingClientRect();\r\n if (geometry.width === 0 || geometry.height === 0) {\r\n return;\r\n }\r\n if (this._width !== geometry.width || this._height !== geometry.height) {\r\n this._width = geometry.width;\r\n this._height = Math.ceil(geometry.height);\r\n this.emit('charsizechanged');\r\n }\r\n };\r\n return CharMeasure;\r\n}(EventEmitter_1.EventEmitter));\r\nexports.CharMeasure = CharMeasure;\r\n\r\n\r\n\r\n},{\"../EventEmitter\":6}],29:[function(require,module,exports){\r\n\"use strict\";\r\nvar __extends = (this && this.__extends) || (function () {\r\n var extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\r\n return function (d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n };\r\n})();\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nvar EventEmitter_1 = require(\"../EventEmitter\");\r\nvar CircularList = (function (_super) {\r\n __extends(CircularList, _super);\r\n function CircularList(_maxLength) {\r\n var _this = _super.call(this) || this;\r\n _this._maxLength = _maxLength;\r\n _this._array = new Array(_this._maxLength);\r\n _this._startIndex = 0;\r\n _this._length = 0;\r\n return _this;\r\n }\r\n Object.defineProperty(CircularList.prototype, \"maxLength\", {\r\n get: function () {\r\n return this._maxLength;\r\n },\r\n set: function (newMaxLength) {\r\n if (this._maxLength === newMaxLength) {\r\n return;\r\n }\r\n var newArray = new Array(newMaxLength);\r\n for (var i = 0; i < Math.min(newMaxLength, this.length); i++) {\r\n newArray[i] = this._array[this._getCyclicIndex(i)];\r\n }\r\n this._array = newArray;\r\n this._maxLength = newMaxLength;\r\n this._startIndex = 0;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(CircularList.prototype, \"length\", {\r\n get: function () {\r\n return this._length;\r\n },\r\n set: function (newLength) {\r\n if (newLength > this._length) {\r\n for (var i = this._length; i < newLength; i++) {\r\n this._array[i] = undefined;\r\n }\r\n }\r\n this._length = newLength;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(CircularList.prototype, \"forEach\", {\r\n get: function () {\r\n var _this = this;\r\n return function (callbackfn) {\r\n var i = 0;\r\n var length = _this.length;\r\n for (var i_1 = 0; i_1 < length; i_1++) {\r\n callbackfn(_this.get(i_1), i_1);\r\n }\r\n };\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n CircularList.prototype.get = function (index) {\r\n return this._array[this._getCyclicIndex(index)];\r\n };\r\n CircularList.prototype.set = function (index, value) {\r\n this._array[this._getCyclicIndex(index)] = value;\r\n };\r\n CircularList.prototype.push = function (value) {\r\n this._array[this._getCyclicIndex(this._length)] = value;\r\n if (this._length === this._maxLength) {\r\n this._startIndex++;\r\n if (this._startIndex === this._maxLength) {\r\n this._startIndex = 0;\r\n }\r\n this.emit('trim', 1);\r\n }\r\n else {\r\n this._length++;\r\n }\r\n };\r\n CircularList.prototype.pop = function () {\r\n return this._array[this._getCyclicIndex(this._length-- - 1)];\r\n };\r\n CircularList.prototype.splice = function (start, deleteCount) {\r\n var items = [];\r\n for (var _i = 2; _i < arguments.length; _i++) {\r\n items[_i - 2] = arguments[_i];\r\n }\r\n if (deleteCount) {\r\n for (var i = start; i < this._length - deleteCount; i++) {\r\n this._array[this._getCyclicIndex(i)] = this._array[this._getCyclicIndex(i + deleteCount)];\r\n }\r\n this._length -= deleteCount;\r\n }\r\n if (items && items.length) {\r\n for (var i = this._length - 1; i >= start; i--) {\r\n this._array[this._getCyclicIndex(i + items.length)] = this._array[this._getCyclicIndex(i)];\r\n }\r\n for (var i = 0; i < items.length; i++) {\r\n this._array[this._getCyclicIndex(start + i)] = items[i];\r\n }\r\n if (this._length + items.length > this.maxLength) {\r\n var countToTrim = (this._length + items.length) - this.maxLength;\r\n this._startIndex += countToTrim;\r\n this._length = this.maxLength;\r\n this.emit('trim', countToTrim);\r\n }\r\n else {\r\n this._length += items.length;\r\n }\r\n }\r\n };\r\n CircularList.prototype.trimStart = function (count) {\r\n if (count > this._length) {\r\n count = this._length;\r\n }\r\n this._startIndex += count;\r\n this._length -= count;\r\n this.emit('trim', count);\r\n };\r\n CircularList.prototype.shiftElements = function (start, count, offset) {\r\n if (count <= 0) {\r\n return;\r\n }\r\n if (start < 0 || start >= this._length) {\r\n throw new Error('start argument out of range');\r\n }\r\n if (start + offset < 0) {\r\n throw new Error('Cannot shift elements in list beyond index 0');\r\n }\r\n if (offset > 0) {\r\n for (var i = count - 1; i >= 0; i--) {\r\n this.set(start + i + offset, this.get(start + i));\r\n }\r\n var expandListBy = (start + count + offset) - this._length;\r\n if (expandListBy > 0) {\r\n this._length += expandListBy;\r\n while (this._length > this.maxLength) {\r\n this._length--;\r\n this._startIndex++;\r\n this.emit('trim', 1);\r\n }\r\n }\r\n }\r\n else {\r\n for (var i = 0; i < count; i++) {\r\n this.set(start + i + offset, this.get(start + i));\r\n }\r\n }\r\n };\r\n CircularList.prototype._getCyclicIndex = function (index) {\r\n return (this._startIndex + index) % this.maxLength;\r\n };\r\n return CircularList;\r\n}(EventEmitter_1.EventEmitter));\r\nexports.CircularList = CircularList;\r\n\r\n\r\n\r\n},{\"../EventEmitter\":6}],30:[function(require,module,exports){\r\n\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nfunction contains(arr, el) {\r\n return arr.indexOf(el) >= 0;\r\n}\r\nexports.contains = contains;\r\n;\r\n\r\n\r\n\r\n},{}],31:[function(require,module,exports){\r\n\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nvar MouseHelper = (function () {\r\n function MouseHelper(_renderer) {\r\n this._renderer = _renderer;\r\n }\r\n MouseHelper.getCoordsRelativeToElement = function (event, element) {\r\n if (event.pageX == null) {\r\n return null;\r\n }\r\n var originalElement = element;\r\n var x = event.pageX;\r\n var y = event.pageY;\r\n while (element) {\r\n x -= element.offsetLeft;\r\n y -= element.offsetTop;\r\n element = 'offsetParent' in element ? element.offsetParent : element.parentElement;\r\n }\r\n element = originalElement;\r\n while (element && element !== element.ownerDocument.body) {\r\n x += element.scrollLeft;\r\n y += element.scrollTop;\r\n element = element.parentElement;\r\n }\r\n return [x, y];\r\n };\r\n MouseHelper.prototype.getCoords = function (event, element, charMeasure, lineHeight, colCount, rowCount, isSelection) {\r\n if (!charMeasure.width || !charMeasure.height) {\r\n return null;\r\n }\r\n var coords = MouseHelper.getCoordsRelativeToElement(event, element);\r\n if (!coords) {\r\n return null;\r\n }\r\n coords[0] = Math.ceil((coords[0] + (isSelection ? this._renderer.dimensions.actualCellWidth / 2 : 0)) / this._renderer.dimensions.actualCellWidth);\r\n coords[1] = Math.ceil(coords[1] / this._renderer.dimensions.actualCellHeight);\r\n coords[0] = Math.min(Math.max(coords[0], 1), colCount);\r\n coords[1] = Math.min(Math.max(coords[1], 1), rowCount);\r\n return coords;\r\n };\r\n MouseHelper.prototype.getRawByteCoords = function (event, element, charMeasure, lineHeight, colCount, rowCount) {\r\n var coords = this.getCoords(event, element, charMeasure, lineHeight, colCount, rowCount);\r\n var x = coords[0];\r\n var y = coords[1];\r\n x += 32;\r\n y += 32;\r\n return { x: x, y: y };\r\n };\r\n return MouseHelper;\r\n}());\r\nexports.MouseHelper = MouseHelper;\r\n\r\n\r\n\r\n},{}],32:[function(require,module,exports){\r\n\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.BellSound = 'data:audio/wav;base64,UklGRigBAABXQVZFZm10IBAAAAABAAEARKwAAIhYAQACABAAZGF0YQQBAADpAFgCwAMlBZoG/wdmCcoKRAypDQ8PbRDBEQQTOxRtFYcWlBePGIUZXhoiG88bcBz7HHIdzh0WHlMeZx51HmkeUx4WHs8dah0AHXwc3hs9G4saxRnyGBIYGBcQFv8U4RPAEoYRQBACD70NWwwHC6gJOwjWBloF7gOBAhABkf8b/qv8R/ve+Xf4Ife79W/0JfPZ8Z/wde9N7ijtE+wU6xvqM+lb6H7nw+YX5mrlxuQz5Mzje+Ma49fioeKD4nXiYeJy4pHitOL04j/jn+MN5IPkFOWs5U3mDefM55/ogOl36m7rdOyE7abuyu8D8Unyj/Pg9D/2qfcb+Yn6/vuK/Qj/lAAlAg==';\r\n\r\n\r\n\r\n},{}],33:[function(require,module,exports){\r\n\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nvar Terminal_1 = require(\"./Terminal\");\r\nmodule.exports = Terminal_1.Terminal;\r\n\r\n\r\n\r\n},{\"./Terminal\":12}]},{},[33])(33)\r\n});\r\n//# sourceMappingURL=xterm.js.map\r\n"),
}
fileq := &embedded.EmbeddedFile{
Filename: `xterm.js.map`,
FileModTime: time.Unix(1512991935, 0),
Content: string("{\"version\":3,\"file\":\"xterm.js\",\"sources\":[\"../src/xterm.ts\",\"../src/utils/Sounds.ts\",\"../src/utils/MouseHelper.ts\",\"../src/utils/Generic.ts\",\"../src/utils/CircularList.ts\",\"../src/utils/CharMeasure.ts\",\"../src/utils/Browser.ts\",\"../src/renderer/Types.ts\",\"../src/renderer/TextRenderLayer.ts\",\"../src/renderer/SelectionRenderLayer.ts\",\"../src/renderer/Renderer.ts\",\"../src/renderer/LinkRenderLayer.ts\",\"../src/renderer/GridCache.ts\",\"../src/renderer/CursorRenderLayer.ts\",\"../src/renderer/ColorManager.ts\",\"../src/renderer/CharAtlas.ts\",\"../src/renderer/BaseRenderLayer.ts\",\"../src/input/MouseZoneManager.ts\",\"../src/handlers/Clipboard.ts\",\"../src/Viewport.ts\",\"../src/Types.ts\",\"../src/Terminal.ts\",\"../src/SelectionModel.ts\",\"../src/SelectionManager.ts\",\"../src/Parser.ts\",\"../src/Linkifier.ts\",\"../src/InputHandler.ts\",\"../src/EventEmitter.ts\",\"../src/EscapeSequences.ts\",\"../src/CompositionHelper.ts\",\"../src/Charsets.ts\",\"../src/BufferSet.ts\",\"../src/Buffer.ts\",\"../node_modules/browser-pack/_prelude.js\"],\"sourcesContent\":[\"/**\\r\\n * Copyright (c) 2017 The xterm.js authors. All rights reserved.\\r\\n * @license MIT\\r\\n *\\r\\n * This file is the entry point for browserify.\\r\\n */\\r\\n\\r\\nimport { Terminal } from './Terminal';\\r\\n\\r\\nmodule.exports = Terminal;\\r\\n\",\"/**\\r\\n * Copyright (c) 2017 The xterm.js authors. All rights reserved.\\r\\n * @license MIT\\r\\n */\\r\\n\\r\\n// Source: https://freesound.org/people/altemark/sounds/45759/\\r\\n// This sound is released under the Creative Commons Attribution 3.0 Unported\\r\\n// (CC BY 3.0) license. It was created by 'altemark'. No modifications have been\\r\\n// made, apart from the conversion to base64.\\r\\nexport const BellSound = 'data:audio/wav;base64,UklGRigBAABXQVZFZm10IBAAAAABAAEARKwAAIhYAQACABAAZGF0YQQBAADpAFgCwAMlBZoG/wdmCcoKRAypDQ8PbRDBEQQTOxRtFYcWlBePGIUZXhoiG88bcBz7HHIdzh0WHlMeZx51HmkeUx4WHs8dah0AHXwc3hs9G4saxRnyGBIYGBcQFv8U4RPAEoYRQBACD70NWwwHC6gJOwjWBloF7gOBAhABkf8b/qv8R/ve+Xf4Ife79W/0JfPZ8Z/wde9N7ijtE+wU6xvqM+lb6H7nw+YX5mrlxuQz5Mzje+Ma49fioeKD4nXiYeJy4pHitOL04j/jn+MN5IPkFOWs5U3mDefM55/ogOl36m7rdOyE7abuyu8D8Unyj/Pg9D/2qfcb+Yn6/vuK/Qj/lAAlAg==';\\r\\n\",\"/**\\r\\n * Copyright (c) 2017 The xterm.js authors. All rights reserved.\\r\\n * @license MIT\\r\\n */\\r\\n\\r\\nimport { ICharMeasure } from '../Interfaces';\\r\\nimport { IRenderer } from '../renderer/Interfaces';\\r\\n\\r\\nexport class MouseHelper {\\r\\n constructor(private _renderer: IRenderer) {}\\r\\n\\r\\n public static getCoordsRelativeToElement(event: {pageX: number, pageY: number}, element: HTMLElement): [number, number] {\\r\\n // Ignore browsers that don't support MouseEvent.pageX\\r\\n if (event.pageX == null) {\\r\\n return null;\\r\\n }\\r\\n\\r\\n const originalElement = element;\\r\\n let x = event.pageX;\\r\\n let y = event.pageY;\\r\\n\\r\\n // Converts the coordinates from being relative to the document to being\\r\\n // relative to the terminal.\\r\\n while (element) {\\r\\n x -= element.offsetLeft;\\r\\n y -= element.offsetTop;\\r\\n element = 'offsetParent' in element ? <HTMLElement>element.offsetParent : <HTMLElement>element.parentElement;\\r\\n }\\r\\n element = originalElement;\\r\\n while (element && element !== element.ownerDocument.body) {\\r\\n x += element.scrollLeft;\\r\\n y += element.scrollTop;\\r\\n element = <HTMLElement>element.parentElement;\\r\\n }\\r\\n return [x, y];\\r\\n }\\r\\n\\r\\n /**\\r\\n * Gets coordinates within the terminal for a particular mouse event. The result\\r\\n * is returned as an array in the form [x, y] instead of an object as it's a\\r\\n * little faster and this function is used in some low level code.\\r\\n * @param event The mouse event.\\r\\n * @param element The terminal's container element.\\r\\n * @param charMeasure The char measure object used to determine character sizes.\\r\\n * @param colCount The number of columns in the terminal.\\r\\n * @param rowCount The number of rows n the terminal.\\r\\n * @param isSelection Whether the request is for the selection or not. This will\\r\\n * apply an offset to the x value such that the left half of the cell will\\r\\n * select that cell and the right half will select the next cell.\\r\\n */\\r\\n public getCoords(event: {pageX: number, pageY: number}, element: HTMLElement, charMeasure: ICharMeasure, lineHeight: number, colCount: number, rowCount: number, isSelection?: boolean): [number, number] {\\r\\n // Coordinates cannot be measured if charMeasure has not been initialized\\r\\n if (!charMeasure.width || !charMeasure.height) {\\r\\n return null;\\r\\n }\\r\\n\\r\\n const coords = MouseHelper.getCoordsRelativeToElement(event, element);\\r\\n if (!coords) {\\r\\n return null;\\r\\n }\\r\\n\\r\\n coords[0] = Math.ceil((coords[0] + (isSelection ? this._renderer.dimensions.actualCellWidth / 2 : 0)) / this._renderer.dimensions.actualCellWidth);\\r\\n coords[1] = Math.ceil(coords[1] / this._renderer.dimensions.actualCellHeight);\\r\\n\\r\\n // Ensure coordinates are within the terminal viewport.\\r\\n coords[0] = Math.min(Math.max(coords[0], 1), colCount);\\r\\n coords[1] = Math.min(Math.max(coords[1], 1), rowCount);\\r\\n\\r\\n return coords;\\r\\n }\\r\\n\\r\\n /**\\r\\n * Gets coordinates within the terminal for a particular mouse event, wrapping\\r\\n * them to the bounds of the terminal and adding 32 to both the x and y values\\r\\n * as expected by xterm.\\r\\n * @param event The mouse event.\\r\\n * @param element The terminal's container element.\\r\\n * @param charMeasure The char measure object used to determine character sizes.\\r\\n * @param colCount The number of columns in the terminal.\\r\\n * @param rowCount The number of rows in the terminal.\\r\\n */\\r\\n public getRawByteCoords(event: MouseEvent, element: HTMLElement, charMeasure: ICharMeasure, lineHeight: number, colCount: number, rowCount: number): { x: number, y: number } {\\r\\n const coords = this.getCoords(event, element, charMeasure, lineHeight, colCount, rowCount);\\r\\n let x = coords[0];\\r\\n let y = coords[1];\\r\\n\\r\\n // xterm sends raw bytes and starts at 32 (SP) for each.\\r\\n x += 32;\\r\\n y += 32;\\r\\n\\r\\n return { x, y };\\r\\n }\\r\\n}\\r\\n\",\"/**\\r\\n * Copyright (c) 2016 The xterm.js authors. All rights reserved.\\r\\n * @license MIT\\r\\n */\\r\\n\\r\\n/**\\r\\n * Return if the given array contains the given element\\r\\n * @param {Array} array The array to search for the given element.\\r\\n * @param {Object} el The element to look for into the array\\r\\n */\\r\\nexport function contains(arr: any[], el: any): boolean {\\r\\n return arr.indexOf(el) >= 0;\\r\\n};\\r\\n\",\"/**\\r\\n * Copyright (c) 2016 The xterm.js authors. All rights reserved.\\r\\n * @license MIT\\r\\n */\\r\\n\\r\\nimport { EventEmitter } from '../EventEmitter';\\r\\nimport { ICircularList } from '../Interfaces';\\r\\n\\r\\n/**\\r\\n * Represents a circular list; a list with a maximum size that wraps around when push is called,\\r\\n * overriding values at the start of the list.\\r\\n */\\r\\nexport class CircularList<T> extends EventEmitter implements ICircularList<T> {\\r\\n protected _array: T[];\\r\\n private _startIndex: number;\\r\\n private _length: number;\\r\\n\\r\\n constructor(\\r\\n private _maxLength: number\\r\\n ) {\\r\\n super();\\r\\n this._array = new Array<T>(this._maxLength);\\r\\n this._startIndex = 0;\\r\\n this._length = 0;\\r\\n }\\r\\n\\r\\n public get maxLength(): number {\\r\\n return this._maxLength;\\r\\n }\\r\\n\\r\\n public set maxLength(newMaxLength: number) {\\r\\n // There was no change in maxLength, return early.\\r\\n if (this._maxLength === newMaxLength) {\\r\\n return;\\r\\n }\\r\\n\\r\\n // Reconstruct array, starting at index 0. Only transfer values from the\\r\\n // indexes 0 to length.\\r\\n let newArray = new Array<T>(newMaxLength);\\r\\n for (let i = 0; i < Math.min(newMaxLength, this.length); i++) {\\r\\n newArray[i] = this._array[this._getCyclicIndex(i)];\\r\\n }\\r\\n this._array = newArray;\\r\\n this._maxLength = newMaxLength;\\r\\n this._startIndex = 0;\\r\\n }\\r\\n\\r\\n public get length(): number {\\r\\n return this._length;\\r\\n }\\r\\n\\r\\n public set length(newLength: number) {\\r\\n if (newLength > this._length) {\\r\\n for (let i = this._length; i < newLength; i++) {\\r\\n this._array[i] = undefined;\\r\\n }\\r\\n }\\r\\n this._length = newLength;\\r\\n }\\r\\n\\r\\n public get forEach(): (callbackfn: (value: T, index: number) => void) => void {\\r\\n return (callbackfn: (value: T, index: number) => void) => {\\r\\n let i = 0;\\r\\n let length = this.length;\\r\\n for (let i = 0; i < length; i++) {\\r\\n callbackfn(this.get(i), i);\\r\\n }\\r\\n };\\r\\n }\\r\\n\\r\\n /**\\r\\n * Gets the value at an index.\\r\\n *\\r\\n * Note that for performance reasons there is no bounds checking here, the index reference is\\r\\n * circular so this should always return a value and never throw.\\r\\n * @param index The index of the value to get.\\r\\n * @return The value corresponding to the index.\\r\\n */\\r\\n public get(index: number): T {\\r\\n return this._array[this._getCyclicIndex(index)];\\r\\n }\\r\\n\\r\\n /**\\r\\n * Sets the value at an index.\\r\\n *\\r\\n * Note that for performance reasons there is no bounds checking here, the index reference is\\r\\n * circular so this should always return a value and never throw.\\r\\n * @param index The index to set.\\r\\n * @param value The value to set.\\r\\n */\\r\\n public set(index: number, value: T): void {\\r\\n this._array[this._getCyclicIndex(index)] = value;\\r\\n }\\r\\n\\r\\n /**\\r\\n * Pushes a new value onto the list, wrapping around to the start of the array, overriding index 0\\r\\n * if the maximum length is reached.\\r\\n * @param value The value to push onto the list.\\r\\n */\\r\\n public push(value: T): void {\\r\\n this._array[this._getCyclicIndex(this._length)] = value;\\r\\n if (this._length === this._maxLength) {\\r\\n this._startIndex++;\\r\\n if (this._startIndex === this._maxLength) {\\r\\n this._startIndex = 0;\\r\\n }\\r\\n this.emit('trim', 1);\\r\\n } else {\\r\\n this._length++;\\r\\n }\\r\\n }\\r\\n\\r\\n /**\\r\\n * Removes and returns the last value on the list.\\r\\n * @return The popped value.\\r\\n */\\r\\n public pop(): T {\\r\\n return this._array[this._getCyclicIndex(this._length-- - 1)];\\r\\n }\\r\\n\\r\\n /**\\r\\n * Deletes and/or inserts items at a particular index (in that order). Unlike\\r\\n * Array.prototype.splice, this operation does not return the deleted items as a new array in\\r\\n * order to save creating a new array. Note that this operation may shift all values in the list\\r\\n * in the worst case.\\r\\n * @param start The index to delete and/or insert.\\r\\n * @param deleteCount The number of elements to delete.\\r\\n * @param items The items to insert.\\r\\n */\\r\\n public splice(start: number, deleteCount: number, ...items: T[]): void {\\r\\n // Delete items\\r\\n if (deleteCount) {\\r\\n for (let i = start; i < this._length - deleteCount; i++) {\\r\\n this._array[this._getCyclicIndex(i)] = this._array[this._getCyclicIndex(i + deleteCount)];\\r\\n }\\r\\n this._length -= deleteCount;\\r\\n }\\r\\n\\r\\n if (items && items.length) {\\r\\n // Add items\\r\\n for (let i = this._length - 1; i >= start; i--) {\\r\\n this._array[this._getCyclicIndex(i + items.length)] = this._array[this._getCyclicIndex(i)];\\r\\n }\\r\\n for (let i = 0; i < items.length; i++) {\\r\\n this._array[this._getCyclicIndex(start + i)] = items[i];\\r\\n }\\r\\n\\r\\n // Adjust length as needed\\r\\n if (this._length + items.length > this.maxLength) {\\r\\n const countToTrim = (this._length + items.length) - this.maxLength;\\r\\n this._startIndex += countToTrim;\\r\\n this._length = this.maxLength;\\r\\n this.emit('trim', countToTrim);\\r\\n } else {\\r\\n this._length += items.length;\\r\\n }\\r\\n }\\r\\n }\\r\\n\\r\\n /**\\r\\n * Trims a number of items from the start of the list.\\r\\n * @param count The number of items to remove.\\r\\n */\\r\\n public trimStart(count: number): void {\\r\\n if (count > this._length) {\\r\\n count = this._length;\\r\\n }\\r\\n this._startIndex += count;\\r\\n this._length -= count;\\r\\n this.emit('trim', count);\\r\\n }\\r\\n\\r\\n public shiftElements(start: number, count: number, offset: number): void {\\r\\n if (count <= 0) {\\r\\n return;\\r\\n }\\r\\n if (start < 0 || start >= this._length) {\\r\\n throw new Error('start argument out of range');\\r\\n }\\r\\n if (start + offset < 0) {\\r\\n throw new Error('Cannot shift elements in list beyond index 0');\\r\\n }\\r\\n\\r\\n if (offset > 0) {\\r\\n for (let i = count - 1; i >= 0; i--) {\\r\\n this.set(start + i + offset, this.get(start + i));\\r\\n }\\r\\n const expandListBy = (start + count + offset) - this._length;\\r\\n if (expandListBy > 0) {\\r\\n this._length += expandListBy;\\r\\n while (this._length > this.maxLength) {\\r\\n this._length--;\\r\\n this._startIndex++;\\r\\n this.emit('trim', 1);\\r\\n }\\r\\n }\\r\\n } else {\\r\\n for (let i = 0; i < count; i++) {\\r\\n this.set(start + i + offset, this.get(start + i));\\r\\n }\\r\\n }\\r\\n }\\r\\n\\r\\n /**\\r\\n * Gets the cyclic index for the specified regular index. The cyclic index can then be used on the\\r\\n * backing array to get the element associated with the regular index.\\r\\n * @param index The regular index.\\r\\n * @returns The cyclic index.\\r\\n */\\r\\n private _getCyclicIndex(index: number): number {\\r\\n return (this._startIndex + index) % this.maxLength;\\r\\n }\\r\\n}\\r\\n\",\"/**\\r\\n * Copyright (c) 2016 The xterm.js authors. All rights reserved.\\r\\n * @license MIT\\r\\n */\\r\\n\\r\\nimport { EventEmitter } from '../EventEmitter';\\r\\nimport { ICharMeasure, ITerminal, ITerminalOptions } from '../Interfaces';\\r\\n\\r\\n/**\\r\\n * Utility class that measures the size of a character. Measurements are done in\\r\\n * the DOM rather than with a canvas context because support for extracting the\\r\\n * height of characters is patchy across browsers.\\r\\n */\\r\\nexport class CharMeasure extends EventEmitter implements ICharMeasure {\\r\\n private _document: Document;\\r\\n private _parentElement: HTMLElement;\\r\\n private _measureElement: HTMLElement;\\r\\n private _width: number;\\r\\n private _height: number;\\r\\n\\r\\n constructor(document: Document, parentElement: HTMLElement) {\\r\\n super();\\r\\n this._document = document;\\r\\n this._parentElement = parentElement;\\r\\n }\\r\\n\\r\\n public get width(): number {\\r\\n return this._width;\\r\\n }\\r\\n\\r\\n public get height(): number {\\r\\n return this._height;\\r\\n }\\r\\n\\r\\n public measure(options: ITerminalOptions): void {\\r\\n if (!this._measureElement) {\\r\\n this._measureElement = this._document.createElement('span');\\r\\n this._measureElement.style.position = 'absolute';\\r\\n this._measureElement.style.top = '0';\\r\\n this._measureElement.style.left = '-9999em';\\r\\n this._measureElement.style.lineHeight = 'normal';\\r\\n this._measureElement.textContent = 'W';\\r\\n this._measureElement.setAttribute('aria-hidden', 'true');\\r\\n this._parentElement.appendChild(this._measureElement);\\r\\n // Perform _doMeasure async if the element was just attached as sometimes\\r\\n // getBoundingClientRect does not return accurate values without this.\\r\\n setTimeout(() => this._doMeasure(options), 0);\\r\\n } else {\\r\\n this._doMeasure(options);\\r\\n }\\r\\n }\\r\\n\\r\\n private _doMeasure(options: ITerminalOptions): void {\\r\\n this._measureElement.style.fontFamily = options.fontFamily;\\r\\n this._measureElement.style.fontSize = `${options.fontSize}px`;\\r\\n const geometry = this._measureElement.getBoundingClientRect();\\r\\n // The element is likely currently display:none, we should retain the\\r\\n // previous value.\\r\\n if (geometry.width === 0 || geometry.height === 0) {\\r\\n return;\\r\\n }\\r\\n if (this._width !== geometry.width || this._height !== geometry.height) {\\r\\n this._width = geometry.width;\\r\\n this._height = Math.ceil(geometry.height);\\r\\n this.emit('charsizechanged');\\r\\n }\\r\\n }\\r\\n}\\r\\n\",\"/**\\r\\n * Copyright (c) 2016 The xterm.js authors. All rights reserved.\\r\\n * @license MIT\\r\\n */\\r\\n\\r\\nimport { contains } from './Generic';\\r\\n\\r\\nconst isNode = (typeof navigator === 'undefined') ? true : false;\\r\\nconst userAgent = (isNode) ? 'node' : navigator.userAgent;\\r\\nconst platform = (isNode) ? 'node' : navigator.platform;\\r\\n\\r\\nexport const isFirefox = !!~userAgent.indexOf('Firefox');\\r\\nexport const isMSIE = !!~userAgent.indexOf('MSIE') || !!~userAgent.indexOf('Trident');\\r\\n\\r\\n// Find the users platform. We use this to interpret the meta key\\r\\n// and ISO third level shifts.\\r\\n// http://stackoverflow.com/q/19877924/577598\\r\\nexport const isMac = contains(['Macintosh', 'MacIntel', 'MacPPC', 'Mac68K'], platform);\\r\\nexport const isIpad = platform === 'iPad';\\r\\nexport const isIphone = platform === 'iPhone';\\r\\nexport const isMSWindows = contains(['Windows', 'Win16', 'Win32', 'WinCE'], platform);\\r\\nexport const isLinux = platform.indexOf('Linux') >= 0;\\r\\n\",\"/**\\r\\n * Copyright (c) 2017 The xterm.js authors. All rights reserved.\\r\\n * @license MIT\\r\\n */\\r\\n\\r\\n /**\\r\\n * Flags used to render terminal text properly.\\r\\n */\\r\\nexport enum FLAGS {\\r\\n BOLD = 1,\\r\\n UNDERLINE = 2,\\r\\n BLINK = 4,\\r\\n INVERSE = 8,\\r\\n INVISIBLE = 16,\\r\\n DIM = 32\\r\\n};\\r\\n\",\"/**\\r\\n * Copyright (c) 2017 The xterm.js authors. All rights reserved.\\r\\n * @license MIT\\r\\n */\\r\\n\\r\\nimport { IColorSet, IRenderDimensions } from './Interfaces';\\r\\nimport { IBuffer, ICharMeasure, ITerminal } from '../Interfaces';\\r\\nimport { CHAR_DATA_ATTR_INDEX, CHAR_DATA_CODE_INDEX, CHAR_DATA_CHAR_INDEX, CHAR_DATA_WIDTH_INDEX } from '../Buffer';\\r\\nimport { FLAGS } from './Types';\\r\\nimport { GridCache } from './GridCache';\\r\\nimport { CharData } from '../Types';\\r\\nimport { BaseRenderLayer, INVERTED_DEFAULT_COLOR } from './BaseRenderLayer';\\r\\n\\r\\n/**\\r\\n * This CharData looks like a null character, which will forc a clear and render\\r\\n * when the character changes (a regular space ' ' character may not as it's\\r\\n * drawn state is a cleared cell).\\r\\n */\\r\\nconst OVERLAP_OWNED_CHAR_DATA: CharData = [null, '', 0, -1];\\r\\n\\r\\nexport class TextRenderLayer extends BaseRenderLayer {\\r\\n private _state: GridCache<CharData>;\\r\\n private _characterWidth: number;\\r\\n private _characterFont: string;\\r\\n private _characterOverlapCache: { [key: string]: boolean } = {};\\r\\n\\r\\n constructor(container: HTMLElement, zIndex: number, colors: IColorSet) {\\r\\n super(container, 'text', zIndex, false, colors);\\r\\n this._state = new GridCache<CharData>();\\r\\n }\\r\\n\\r\\n public resize(terminal: ITerminal, dim: IRenderDimensions, charSizeChanged: boolean): void {\\r\\n super.resize(terminal, dim, charSizeChanged);\\r\\n\\r\\n // Clear the character width cache if the font or width has changed\\r\\n const terminalFont = `${terminal.options.fontSize * window.devicePixelRatio}px ${terminal.options.fontFamily}`;\\r\\n if (this._characterWidth !== dim.scaledCharWidth || this._characterFont !== terminalFont) {\\r\\n this._characterWidth = dim.scaledCharWidth;\\r\\n this._characterFont = terminalFont;\\r\\n this._characterOverlapCache = {};\\r\\n }\\r\\n // Resizing the canvas discards the contents of the canvas so clear state\\r\\n this._state.clear();\\r\\n this._state.resize(terminal.cols, terminal.rows);\\r\\n }\\r\\n\\r\\n public reset(terminal: ITerminal): void {\\r\\n this._state.clear();\\r\\n this.clearAll();\\r\\n }\\r\\n\\r\\n public onGridChanged(terminal: ITerminal, startRow: number, endRow: number): void {\\r\\n // Resize has not been called yet\\r\\n if (this._state.cache.length === 0) {\\r\\n return;\\r\\n }\\r\\n\\r\\n for (let y = startRow; y <= endRow; y++) {\\r\\n const row = y + terminal.buffer.ydisp;\\r\\n const line = terminal.buffer.lines.get(row);\\r\\n\\r\\n this.clearCells(0, y, terminal.cols, 1);\\r\\n // for (let x = 0; x < terminal.cols; x++) {\\r\\n // this._state.cache[x][y] = null;\\r\\n // }\\r\\n\\r\\n for (let x = 0; x < terminal.cols; x++) {\\r\\n const charData = line[x];\\r\\n const code: number = <number>charData[CHAR_DATA_CODE_INDEX];\\r\\n const char: string = charData[CHAR_DATA_CHAR_INDEX];\\r\\n const attr: number = charData[CHAR_DATA_ATTR_INDEX];\\r\\n let width: number = charData[CHAR_DATA_WIDTH_INDEX];\\r\\n\\r\\n // The character to the left is a wide character, drawing is owned by\\r\\n // the char at x-1\\r\\n if (width === 0) {\\r\\n // this._state.cache[x][y] = null;\\r\\n continue;\\r\\n }\\r\\n\\r\\n // If the character is a space and the character to the left is an\\r\\n // overlapping character, skip the character and allow the overlapping\\r\\n // char to take full control over this character's cell.\\r\\n if (code === 32 /*' '*/) {\\r\\n if (x > 0) {\\r\\n const previousChar: CharData = line[x - 1];\\r\\n if (this._isOverlapping(previousChar)) {\\r\\n continue;\\r\\n }\\r\\n }\\r\\n }\\r\\n\\r\\n // Skip rendering if the character is identical\\r\\n // const state = this._state.cache[x][y];\\r\\n // if (state && state[CHAR_DATA_CHAR_INDEX] === char && state[CHAR_DATA_ATTR_INDEX] === attr) {\\r\\n // // Skip render, contents are identical\\r\\n // this._state.cache[x][y] = charData;\\r\\n // continue;\\r\\n // }\\r\\n\\r\\n // Clear the old character was not a space with the default background\\r\\n // const wasInverted = !!(state && state[CHAR_DATA_ATTR_INDEX] && state[CHAR_DATA_ATTR_INDEX] >> 18 & FLAGS.INVERSE);\\r\\n // if (state && !(state[CHAR_DATA_CODE_INDEX] === 32 /*' '*/ && (state[CHAR_DATA_ATTR_INDEX] & 0x1ff) >= 256 && !wasInverted)) {\\r\\n // this._clearChar(x, y);\\r\\n // }\\r\\n // this._state.cache[x][y] = charData;\\r\\n\\r\\n const flags = attr >> 18;\\r\\n let bg = attr & 0x1ff;\\r\\n\\r\\n // Skip rendering if the character is invisible\\r\\n const isDefaultBackground = bg >= 256;\\r\\n const isInvisible = flags & FLAGS.INVISIBLE;\\r\\n const isInverted = flags & FLAGS.INVERSE;\\r\\n if (!code || (code === 32 /*' '*/ && isDefaultBackground && !isInverted) || isInvisible) {\\r\\n continue;\\r\\n }\\r\\n\\r\\n // If the character is an overlapping char and the character to the right is a\\r\\n // space, take ownership of the cell to the right.\\r\\n if (width !== 0 && this._isOverlapping(charData)) {\\r\\n // If the character is overlapping, we want to force a re-render on every\\r\\n // frame. This is specifically to work around the case where two\\r\\n // overlaping chars `a` and `b` are adjacent, the cursor is moved to b and a\\r\\n // space is added. Without this, the first half of `b` would never\\r\\n // get removed, and `a` would not re-render because it thinks it's\\r\\n // already in the correct state.\\r\\n // this._state.cache[x][y] = OVERLAP_OWNED_CHAR_DATA;\\r\\n if (x < line.length - 1 && line[x + 1][CHAR_DATA_CODE_INDEX] === 32 /*' '*/) {\\r\\n width = 2;\\r\\n // this._clearChar(x + 1, y);\\r\\n // The overlapping char's char data will force a clear and render when the\\r\\n // overlapping char is no longer to the left of the character and also when\\r\\n // the space changes to another character.\\r\\n // this._state.cache[x + 1][y] = OVERLAP_OWNED_CHAR_DATA;\\r\\n }\\r\\n }\\r\\n\\r\\n let fg = (attr >> 9) & 0x1ff;\\r\\n\\r\\n // If inverse flag is on, the foreground should become the background.\\r\\n if (isInverted) {\\r\\n const temp = bg;\\r\\n bg = fg;\\r\\n fg = temp;\\r\\n if (fg === 256) {\\r\\n fg = INVERTED_DEFAULT_COLOR;\\r\\n }\\r\\n if (bg === 257) {\\r\\n bg = INVERTED_DEFAULT_COLOR;\\r\\n }\\r\\n }\\r\\n\\r\\n // Clear the cell next to this character if it's wide\\r\\n if (width === 2) {\\r\\n // this.clearCells(x + 1, y, 1, 1);\\r\\n }\\r\\n\\r\\n // Draw background\\r\\n if (bg < 256) {\\r\\n this._ctx.save();\\r\\n this._ctx.fillStyle = (bg === INVERTED_DEFAULT_COLOR ? this._colors.foreground : this._colors.ansi[bg]);\\r\\n this.fillCells(x, y, width, 1);\\r\\n this._ctx.restore();\\r\\n }\\r\\n\\r\\n this._ctx.save();\\r\\n if (flags & FLAGS.BOLD) {\\r\\n this._ctx.font = `bold ${this._ctx.font}`;\\r\\n // Convert the FG color to the bold variant\\r\\n if (fg < 8) {\\r\\n fg += 8;\\r\\n }\\r\\n }\\r\\n\\r\\n if (flags & FLAGS.UNDERLINE) {\\r\\n if (fg === INVERTED_DEFAULT_COLOR) {\\r\\n this._ctx.fillStyle = this._colors.background;\\r\\n } else if (fg < 256) {\\r\\n // 256 color support\\r\\n this._ctx.fillStyle = this._colors.ansi[fg];\\r\\n } else {\\r\\n this._ctx.fillStyle = this._colors.foreground;\\r\\n }\\r\\n this.fillBottomLineAtCells(x, y);\\r\\n }\\r\\n\\r\\n this.drawChar(terminal, char, code, width, x, y, fg, bg, !!(flags & FLAGS.BOLD), !!(flags & FLAGS.DIM));\\r\\n\\r\\n this._ctx.restore();\\r\\n }\\r\\n }\\r\\n }\\r\\n\\r\\n\\t/**\\r\\n\\t * Whether a character is overlapping to the next cell.\\r\\n\\t */\\r\\n private _isOverlapping(charData: CharData): boolean {\\r\\n // Only single cell characters can be overlapping, rendering issues can\\r\\n // occur without this check\\r\\n if (charData[CHAR_DATA_WIDTH_INDEX] !== 1) {\\r\\n return false;\\r\\n }\\r\\n\\r\\n // We assume that any ascii character will not overlap\\r\\n const code = charData[CHAR_DATA_CODE_INDEX];\\r\\n if (code < 256) {\\r\\n return false;\\r\\n }\\r\\n\\r\\n // Deliver from cache if available\\r\\n const char = charData[CHAR_DATA_CHAR_INDEX];\\r\\n if (this._characterOverlapCache.hasOwnProperty(char)) {\\r\\n return this._characterOverlapCache[char];\\r\\n }\\r\\n\\r\\n // Setup the font\\r\\n this._ctx.save();\\r\\n this._ctx.font = this._characterFont;\\r\\n\\r\\n // Measure the width of the character, but Math.floor it\\r\\n // because that is what the renderer does when it calculates\\r\\n // the character dimensions we are comparing against\\r\\n const overlaps = Math.floor(this._ctx.measureText(char).width) > this._characterWidth;\\r\\n\\r\\n // Restore the original context\\r\\n this._ctx.restore();\\r\\n\\r\\n // Cache and return\\r\\n this._characterOverlapCache[char] = overlaps;\\r\\n return overlaps;\\r\\n }\\r\\n\\r\\n /**\\r\\n * Clear the charcater at the cell specified.\\r\\n * @param x The column of the char.\\r\\n * @param y The row of the char.\\r\\n */\\r\\n private _clearChar(x: number, y: number): void {\\r\\n let colsToClear = 1;\\r\\n // Clear the adjacent character if it was wide\\r\\n const state = this._state.cache[x][y];\\r\\n if (state && state[CHAR_DATA_WIDTH_INDEX] === 2) {\\r\\n colsToClear = 2;\\r\\n }\\r\\n this.clearCells(x, y, colsToClear, 1);\\r\\n }\\r\\n}\\r\\n\",\"/**\\r\\n * Copyright (c) 2017 The xterm.js authors. All rights reserved.\\r\\n * @license MIT\\r\\n */\\r\\n\\r\\nimport { IColorSet, IRenderDimensions } from './Interfaces';\\r\\nimport { IBuffer, ICharMeasure, ITerminal } from '../Interfaces';\\r\\nimport { CHAR_DATA_ATTR_INDEX } from '../Buffer';\\r\\nimport { GridCache } from './GridCache';\\r\\nimport { FLAGS } from './Types';\\r\\nimport { BaseRenderLayer } from './BaseRenderLayer';\\r\\n\\r\\nexport class SelectionRenderLayer extends BaseRenderLayer {\\r\\n private _state: {start: [number, number], end: [number, number]};\\r\\n\\r\\n constructor(container: HTMLElement, zIndex: number, colors: IColorSet) {\\r\\n super(container, 'selection', zIndex, true, colors);\\r\\n this._state = {\\r\\n start: null,\\r\\n end: null\\r\\n };\\r\\n }\\r\\n\\r\\n public resize(terminal: ITerminal, dim: IRenderDimensions, charSizeChanged: boolean): void {\\r\\n super.resize(terminal, dim, charSizeChanged);\\r\\n // Resizing the canvas discards the contents of the canvas so clear state\\r\\n this._state = {\\r\\n start: null,\\r\\n end: null\\r\\n };\\r\\n }\\r\\n\\r\\n public reset(terminal: ITerminal): void {\\r\\n if (this._state.start && this._state.end) {\\r\\n this._state = {\\r\\n start: null,\\r\\n end: null\\r\\n };\\r\\n this.clearAll();\\r\\n }\\r\\n }\\r\\n\\r\\n public onSelectionChanged(terminal: ITerminal, start: [number, number], end: [number, number]): void {\\r\\n // Selection has not changed\\r\\n if (this._state.start === start || this._state.end === end) {\\r\\n return;\\r\\n }\\r\\n\\r\\n // Remove all selections\\r\\n this.clearAll();\\r\\n\\r\\n // Selection does not exist\\r\\n if (!start || !end) {\\r\\n return;\\r\\n }\\r\\n\\r\\n // Translate from buffer position to viewport position\\r\\n const viewportStartRow = start[1] - terminal.buffer.ydisp;\\r\\n const viewportEndRow = end[1] - terminal.buffer.ydisp;\\r\\n const viewportCappedStartRow = Math.max(viewportStartRow, 0);\\r\\n const viewportCappedEndRow = Math.min(viewportEndRow, terminal.rows - 1);\\r\\n\\r\\n // No need to draw the selection\\r\\n if (viewportCappedStartRow >= terminal.rows || viewportCappedEndRow < 0) {\\r\\n return;\\r\\n }\\r\\n\\r\\n // Draw first row\\r\\n const startCol = viewportStartRow === viewportCappedStartRow ? start[0] : 0;\\r\\n const startRowEndCol = viewportCappedStartRow === viewportCappedEndRow ? end[0] : terminal.cols;\\r\\n this._ctx.fillStyle = this._colors.selection;\\r\\n this.fillCells(startCol, viewportCappedStartRow, startRowEndCol - startCol, 1);\\r\\n\\r\\n // Draw middle rows\\r\\n const middleRowsCount = Math.max(viewportCappedEndRow - viewportCappedStartRow - 1, 0);\\r\\n this.fillCells(0, viewportCappedStartRow + 1, terminal.cols, middleRowsCount);\\r\\n\\r\\n // Draw final row\\r\\n if (viewportCappedStartRow !== viewportCappedEndRow) {\\r\\n // Only draw viewportEndRow if it's not the same as viewporttartRow\\r\\n const endCol = viewportEndRow === viewportCappedEndRow ? end[0] : terminal.cols;\\r\\n this.fillCells(0, viewportCappedEndRow, endCol, 1);\\r\\n }\\r\\n\\r\\n // Save state for next render\\r\\n this._state.start = [start[0], start[1]];\\r\\n this._state.end = [end[0], end[1]];\\r\\n }\\r\\n}\\r\\n\",\"/**\\r\\n * Copyright (c) 2017 The xterm.js authors. All rights reserved.\\r\\n * @license MIT\\r\\n */\\r\\n\\r\\nimport { ITerminal, ITheme } from '../Interfaces';\\r\\nimport { CHAR_DATA_WIDTH_INDEX, CHAR_DATA_CHAR_INDEX } from '../Buffer';\\r\\nimport { TextRenderLayer } from './TextRenderLayer';\\r\\nimport { SelectionRenderLayer } from './SelectionRenderLayer';\\r\\nimport { CursorRenderLayer } from './CursorRenderLayer';\\r\\nimport { ColorManager } from './ColorManager';\\r\\nimport { BaseRenderLayer } from './BaseRenderLayer';\\r\\nimport { IRenderLayer, IColorSet, IRenderer, IRenderDimensions } from './Interfaces';\\r\\nimport { LinkRenderLayer } from './LinkRenderLayer';\\r\\nimport { EventEmitter } from '../EventEmitter';\\r\\n\\r\\nexport class Renderer extends EventEmitter implements IRenderer {\\r\\n /** A queue of the rows to be refreshed */\\r\\n private _refreshRowsQueue: {start: number, end: number}[] = [];\\r\\n private _refreshAnimationFrame = null;\\r\\n\\r\\n private _renderLayers: IRenderLayer[];\\r\\n private _devicePixelRatio: number;\\r\\n\\r\\n public colorManager: ColorManager;\\r\\n public dimensions: IRenderDimensions;\\r\\n\\r\\n constructor(private _terminal: ITerminal, theme: ITheme) {\\r\\n super();\\r\\n this.colorManager = new ColorManager();\\r\\n if (theme) {\\r\\n this.colorManager.setTheme(theme);\\r\\n }\\r\\n this._renderLayers = [\\r\\n new TextRenderLayer(this._terminal.element, 0, this.colorManager.colors),\\r\\n new SelectionRenderLayer(this._terminal.element, 1, this.colorManager.colors),\\r\\n new LinkRenderLayer(this._terminal.element, 2, this.colorManager.colors, this._terminal),\\r\\n new CursorRenderLayer(this._terminal.element, 3, this.colorManager.colors)\\r\\n ];\\r\\n this.dimensions = {\\r\\n scaledCharWidth: null,\\r\\n scaledCharHeight: null,\\r\\n scaledCellWidth: null,\\r\\n scaledCellHeight: null,\\r\\n scaledCharLeft: null,\\r\\n scaledCharTop: null,\\r\\n scaledCanvasWidth: null,\\r\\n scaledCanvasHeight: null,\\r\\n canvasWidth: null,\\r\\n canvasHeight: null,\\r\\n actualCellWidth: null,\\r\\n actualCellHeight: null\\r\\n };\\r\\n this._devicePixelRatio = window.devicePixelRatio;\\r\\n }\\r\\n\\r\\n public onWindowResize(devicePixelRatio: number): void {\\r\\n // If the device pixel ratio changed, the char atlas needs to be regenerated\\r\\n // and the terminal needs to refreshed\\r\\n if (this._devicePixelRatio !== devicePixelRatio) {\\r\\n this._devicePixelRatio = devicePixelRatio;\\r\\n this.onResize(this._terminal.cols, this._terminal.rows, true);\\r\\n }\\r\\n }\\r\\n\\r\\n public setTheme(theme: ITheme): IColorSet {\\r\\n this.colorManager.setTheme(theme);\\r\\n\\r\\n // Clear layers and force a full render\\r\\n this._renderLayers.forEach(l => {\\r\\n l.onThemeChanged(this._terminal, this.colorManager.colors);\\r\\n l.reset(this._terminal);\\r\\n });\\r\\n\\r\\n this._terminal.refresh(0, this._terminal.rows - 1);\\r\\n\\r\\n return this.colorManager.colors;\\r\\n }\\r\\n\\r\\n public onResize(cols: number, rows: number, didCharSizeChange: boolean): void {\\r\\n if (!this._terminal.charMeasure.width || !this._terminal.charMeasure.height) {\\r\\n return;\\r\\n }\\r\\n\\r\\n // Calculate the scaled character width. Width is floored as it must be\\r\\n // drawn to an integer grid in order for the CharAtlas \\\"stamps\\\" to not be\\r\\n // blurry. When text is drawn to the grid not using the CharAtlas, it is\\r\\n // clipped to ensure there is no overlap with the next cell.\\r\\n this.dimensions.scaledCharWidth = Math.floor(this._terminal.charMeasure.width * window.devicePixelRatio);\\r\\n\\r\\n // Calculate the scaled character height. Height is ceiled in case\\r\\n // devicePixelRatio is a floating point number in order to ensure there is\\r\\n // enough space to draw the character to the cell.\\r\\n this.dimensions.scaledCharHeight = Math.ceil(this._terminal.charMeasure.height * window.devicePixelRatio);\\r\\n\\r\\n // Calculate the scaled cell height, if lineHeight is not 1 then the value\\r\\n // will be floored because since lineHeight can never be lower then 1, there\\r\\n // is a guarentee that the scaled line height will always be larger than\\r\\n // scaled char height.\\r\\n this.dimensions.scaledCellHeight = Math.floor(this.dimensions.scaledCharHeight * this._terminal.options.lineHeight);\\r\\n\\r\\n // Calculate the y coordinate within a cell that text should draw from in\\r\\n // order to draw in the center of a cell.\\r\\n this.dimensions.scaledCharTop = this._terminal.options.lineHeight === 1 ? 0 : Math.round((this.dimensions.scaledCellHeight - this.dimensions.scaledCharHeight) / 2);\\r\\n\\r\\n // Calculate the scaled cell width, taking the letterSpacing into account.\\r\\n this.dimensions.scaledCellWidth = this.dimensions.scaledCharWidth + Math.round(this._terminal.options.letterSpacing);\\r\\n\\r\\n // Calculate the x coordinate with a cell that text should draw from in\\r\\n // order to draw in the center of a cell.\\r\\n this.dimensions.scaledCharLeft = Math.floor(this._terminal.options.letterSpacing / 2);\\r\\n\\r\\n // Recalculate the canvas dimensions; scaled* define the actual number of\\r\\n // pixel in the canvas\\r\\n this.dimensions.scaledCanvasHeight = this._terminal.rows * this.dimensions.scaledCellHeight;\\r\\n this.dimensions.scaledCanvasWidth = this._terminal.cols * this.dimensions.scaledCellWidth;\\r\\n\\r\\n // The the size of the canvas on the page. It's very important that this\\r\\n // rounds to nearest integer and not ceils as browsers often set\\r\\n // window.devicePixelRatio as something like 1.100000023841858, when it's\\r\\n // actually 1.1. Ceiling causes blurriness as the backing canvas image is 1\\r\\n // pixel too large for the canvas element size.\\r\\n this.dimensions.canvasHeight = Math.round(this.dimensions.scaledCanvasHeight / window.devicePixelRatio);\\r\\n this.dimensions.canvasWidth = Math.round(this.dimensions.scaledCanvasWidth / window.devicePixelRatio);\\r\\n\\r\\n // Get the _actual_ dimensions of an individual cell. This needs to be\\r\\n // derived from the canvasWidth/Height calculated above which takes into\\r\\n // account window.devicePixelRatio. CharMeasure.width/height by itself is\\r\\n // insufficient when the page is not at 100% zoom level as CharMeasure is\\r\\n // measured in CSS pixels, but the actual char size on the canvas can\\r\\n // differ.\\r\\n this.dimensions.actualCellHeight = this.dimensions.canvasHeight / this._terminal.rows;\\r\\n this.dimensions.actualCellWidth = this.dimensions.canvasWidth / this._terminal.cols;\\r\\n\\r\\n // Resize all render layers\\r\\n this._renderLayers.forEach(l => l.resize(this._terminal, this.dimensions, didCharSizeChange));\\r\\n\\r\\n // Force a refresh\\r\\n this._terminal.refresh(0, this._terminal.rows - 1);\\r\\n\\r\\n this.emit('resize', {\\r\\n width: this.dimensions.canvasWidth,\\r\\n height: this.dimensions.canvasHeight\\r\\n });\\r\\n }\\r\\n\\r\\n public onCharSizeChanged(): void {\\r\\n this.onResize(this._terminal.cols, this._terminal.rows, true);\\r\\n }\\r\\n\\r\\n public onBlur(): void {\\r\\n this._renderLayers.forEach(l => l.onBlur(this._terminal));\\r\\n }\\r\\n\\r\\n public onFocus(): void {\\r\\n this._renderLayers.forEach(l => l.onFocus(this._terminal));\\r\\n }\\r\\n\\r\\n public onSelectionChanged(start: [number, number], end: [number, number]): void {\\r\\n this._renderLayers.forEach(l => l.onSelectionChanged(this._terminal, start, end));\\r\\n }\\r\\n\\r\\n public onCursorMove(): void {\\r\\n this._renderLayers.forEach(l => l.onCursorMove(this._terminal));\\r\\n }\\r\\n\\r\\n public onOptionsChanged(): void {\\r\\n this._renderLayers.forEach(l => l.onOptionsChanged(this._terminal));\\r\\n }\\r\\n\\r\\n public clear(): void {\\r\\n this._renderLayers.forEach(l => l.reset(this._terminal));\\r\\n }\\r\\n\\r\\n /**\\r\\n * Queues a refresh between two rows (inclusive), to be done on next animation\\r\\n * frame.\\r\\n * @param {number} start The start row.\\r\\n * @param {number} end The end row.\\r\\n */\\r\\n public queueRefresh(start: number, end: number): void {\\r\\n this._refreshRowsQueue.push({ start: start, end: end });\\r\\n if (!this._refreshAnimationFrame) {\\r\\n this._refreshAnimationFrame = window.requestAnimationFrame(this._refreshLoop.bind(this));\\r\\n }\\r\\n }\\r\\n\\r\\n /**\\r\\n * Performs the refresh loop callback, calling refresh only if a refresh is\\r\\n * necessary before queueing up the next one.\\r\\n */\\r\\n private _refreshLoop(): void {\\r\\n let start;\\r\\n let end;\\r\\n if (this._refreshRowsQueue.length > 4) {\\r\\n // Just do a full refresh when 5+ refreshes are queued\\r\\n start = 0;\\r\\n end = this._terminal.rows - 1;\\r\\n } else {\\r\\n // Get start and end rows that need refreshing\\r\\n start = this._refreshRowsQueue[0].start;\\r\\n end = this._refreshRowsQueue[0].end;\\r\\n for (let i = 1; i < this._refreshRowsQueue.length; i++) {\\r\\n if (this._refreshRowsQueue[i].start < start) {\\r\\n start = this._refreshRowsQueue[i].start;\\r\\n }\\r\\n if (this._refreshRowsQueue[i].end > end) {\\r\\n end = this._refreshRowsQueue[i].end;\\r\\n }\\r\\n }\\r\\n }\\r\\n this._refreshRowsQueue = [];\\r\\n this._refreshAnimationFrame = null;\\r\\n\\r\\n // Render\\r\\n start = Math.max(start, 0);\\r\\n end = Math.min(end, this._terminal.rows - 1);\\r\\n this._renderLayers.forEach(l => l.onGridChanged(this._terminal, start, end));\\r\\n this._terminal.emit('refresh', {start, end});\\r\\n }\\r\\n}\\r\\n\",\"/**\\r\\n * Copyright (c) 2017 The xterm.js authors. All rights reserved.\\r\\n * @license MIT\\r\\n */\\r\\n\\r\\nimport { IColorSet, IRenderDimensions } from './Interfaces';\\r\\nimport { IBuffer, ICharMeasure, ITerminal, ILinkifierAccessor } from '../Interfaces';\\r\\nimport { CHAR_DATA_ATTR_INDEX } from '../Buffer';\\r\\nimport { GridCache } from './GridCache';\\r\\nimport { FLAGS } from './Types';\\r\\nimport { BaseRenderLayer, INVERTED_DEFAULT_COLOR } from './BaseRenderLayer';\\r\\nimport { LinkHoverEvent, LinkHoverEventTypes } from '../Types';\\r\\n\\r\\nexport class LinkRenderLayer extends BaseRenderLayer {\\r\\n private _state: LinkHoverEvent = null;\\r\\n\\r\\n constructor(container: HTMLElement, zIndex: number, colors: IColorSet, terminal: ILinkifierAccessor) {\\r\\n super(container, 'link', zIndex, true, colors);\\r\\n terminal.linkifier.on(LinkHoverEventTypes.HOVER, (e: LinkHoverEvent) => this._onLinkHover(e));\\r\\n terminal.linkifier.on(LinkHoverEventTypes.LEAVE, (e: LinkHoverEvent) => this._onLinkLeave(e));\\r\\n }\\r\\n\\r\\n public resize(terminal: ITerminal, dim: IRenderDimensions, charSizeChanged: boolean): void {\\r\\n super.resize(terminal, dim, charSizeChanged);\\r\\n // Resizing the canvas discards the contents of the canvas so clear state\\r\\n this._state = null;\\r\\n }\\r\\n\\r\\n public reset(terminal: ITerminal): void {\\r\\n this._clearCurrentLink();\\r\\n }\\r\\n\\r\\n private _clearCurrentLink(): void {\\r\\n if (this._state) {\\r\\n this.clearCells(this._state.x, this._state.y, this._state.length, 1);\\r\\n this._state = null;\\r\\n }\\r\\n }\\r\\n\\r\\n private _onLinkHover(e: LinkHoverEvent): void {\\r\\n this._ctx.fillStyle = this._colors.foreground;\\r\\n this.fillBottomLineAtCells(e.x, e.y, e.length);\\r\\n this._state = e;\\r\\n }\\r\\n\\r\\n private _onLinkLeave(e: LinkHoverEvent): void {\\r\\n this._clearCurrentLink();\\r\\n }\\r\\n}\\r\\n\",\"/**\\r\\n * Copyright (c) 2017 The xterm.js authors. All rights reserved.\\r\\n * @license MIT\\r\\n */\\r\\n\\r\\nexport class GridCache<T> {\\r\\n public cache: T[][];\\r\\n\\r\\n public constructor() {\\r\\n this.cache = [];\\r\\n }\\r\\n\\r\\n public resize(width: number, height: number): void {\\r\\n for (let x = 0; x < width; x++) {\\r\\n if (this.cache.length <= x) {\\r\\n this.cache.push([]);\\r\\n }\\r\\n for (let y = this.cache[x].length; y < height; y++) {\\r\\n this.cache[x].push(null);\\r\\n }\\r\\n this.cache[x].length = height;\\r\\n }\\r\\n this.cache.length = width;\\r\\n }\\r\\n\\r\\n public clear(): void {\\r\\n for (let x = 0; x < this.cache.length; x++) {\\r\\n for (let y = 0; y < this.cache[x].length; y++) {\\r\\n this.cache[x][y] = null;\\r\\n }\\r\\n }\\r\\n }\\r\\n}\\r\\n\",\"/**\\r\\n * Copyright (c) 2017 The xterm.js authors. All rights reserved.\\r\\n * @license MIT\\r\\n */\\r\\n\\r\\nimport { IColorSet, IRenderDimensions } from './Interfaces';\\r\\nimport { IBuffer, ICharMeasure, ITerminal, ITerminalOptions } from '../Interfaces';\\r\\nimport { CHAR_DATA_WIDTH_INDEX, CHAR_DATA_CODE_INDEX, CHAR_DATA_CHAR_INDEX } from '../Buffer';\\r\\nimport { GridCache } from './GridCache';\\r\\nimport { FLAGS } from './Types';\\r\\nimport { BaseRenderLayer } from './BaseRenderLayer';\\r\\nimport { CharData } from '../Types';\\r\\n\\r\\ninterface CursorState {\\r\\n x: number;\\r\\n y: number;\\r\\n isFocused: boolean;\\r\\n style: string;\\r\\n width: number;\\r\\n}\\r\\n\\r\\n/**\\r\\n * The time between cursor blinks.\\r\\n */\\r\\nconst BLINK_INTERVAL = 600;\\r\\n\\r\\nexport class CursorRenderLayer extends BaseRenderLayer {\\r\\n private _state: CursorState;\\r\\n private _cursorRenderers: {[key: string]: (terminal: ITerminal, x: number, y: number, charData: CharData) => void};\\r\\n private _cursorBlinkStateManager: CursorBlinkStateManager;\\r\\n private _isFocused: boolean;\\r\\n\\r\\n constructor(container: HTMLElement, zIndex: number, colors: IColorSet) {\\r\\n super(container, 'cursor', zIndex, true, colors);\\r\\n this._state = {\\r\\n x: null,\\r\\n y: null,\\r\\n isFocused: null,\\r\\n style: null,\\r\\n width: null,\\r\\n };\\r\\n this._cursorRenderers = {\\r\\n 'bar': this._renderBarCursor.bind(this),\\r\\n 'block': this._renderBlockCursor.bind(this),\\r\\n 'underline': this._renderUnderlineCursor.bind(this)\\r\\n };\\r\\n // TODO: Consider initial options? Maybe onOptionsChanged should be called at the end of open?\\r\\n }\\r\\n\\r\\n public resize(terminal: ITerminal, dim: IRenderDimensions, charSizeChanged: boolean): void {\\r\\n super.resize(terminal, dim, charSizeChanged);\\r\\n // Resizing the canvas discards the contents of the canvas so clear state\\r\\n this._state = {\\r\\n x: null,\\r\\n y: null,\\r\\n isFocused: null,\\r\\n style: null,\\r\\n width: null,\\r\\n };\\r\\n }\\r\\n\\r\\n public reset(terminal: ITerminal): void {\\r\\n this._clearCursor();\\r\\n if (this._cursorBlinkStateManager) {\\r\\n this._cursorBlinkStateManager.dispose();\\r\\n this._cursorBlinkStateManager = null;\\r\\n this.onOptionsChanged(terminal);\\r\\n }\\r\\n }\\r\\n\\r\\n public onBlur(terminal: ITerminal): void {\\r\\n if (this._cursorBlinkStateManager) {\\r\\n this._cursorBlinkStateManager.pause();\\r\\n }\\r\\n terminal.refresh(terminal.buffer.y, terminal.buffer.y);\\r\\n }\\r\\n\\r\\n public onFocus(terminal: ITerminal): void {\\r\\n if (this._cursorBlinkStateManager) {\\r\\n this._cursorBlinkStateManager.resume(terminal);\\r\\n } else {\\r\\n terminal.refresh(terminal.buffer.y, terminal.buffer.y);\\r\\n }\\r\\n }\\r\\n\\r\\n public onOptionsChanged(terminal: ITerminal): void {\\r\\n if (terminal.options.cursorBlink) {\\r\\n if (!this._cursorBlinkStateManager) {\\r\\n this._cursorBlinkStateManager = new CursorBlinkStateManager(terminal, () => {\\r\\n this._render(terminal, true);\\r\\n });\\r\\n }\\r\\n } else {\\r\\n if (this._cursorBlinkStateManager) {\\r\\n this._cursorBlinkStateManager.dispose();\\r\\n this._cursorBlinkStateManager = null;\\r\\n }\\r\\n // Request a refresh from the terminal as management of rendering is being\\r\\n // moved back to the terminal\\r\\n terminal.refresh(terminal.buffer.y, terminal.buffer.y);\\r\\n }\\r\\n }\\r\\n\\r\\n public onCursorMove(terminal: ITerminal): void {\\r\\n if (this._cursorBlinkStateManager) {\\r\\n this._cursorBlinkStateManager.restartBlinkAnimation(terminal);\\r\\n }\\r\\n }\\r\\n\\r\\n public onGridChanged(terminal: ITerminal, startRow: number, endRow: number): void {\\r\\n // Only render if the animation frame is not active\\r\\n if (!this._cursorBlinkStateManager || this._cursorBlinkStateManager.isPaused) {\\r\\n this._render(terminal, false);\\r\\n }\\r\\n }\\r\\n\\r\\n private _render(terminal: ITerminal, triggeredByAnimationFrame: boolean): void {\\r\\n // Don't draw the cursor if it's hidden\\r\\n if (!terminal.cursorState || terminal.cursorHidden) {\\r\\n this._clearCursor();\\r\\n return;\\r\\n }\\r\\n\\r\\n const cursorY = terminal.buffer.ybase + terminal.buffer.y;\\r\\n const viewportRelativeCursorY = cursorY - terminal.buffer.ydisp;\\r\\n\\r\\n // Don't draw the cursor if it's off-screen\\r\\n if (viewportRelativeCursorY < 0 || viewportRelativeCursorY >= terminal.rows) {\\r\\n this._clearCursor();\\r\\n return;\\r\\n }\\r\\n\\r\\n const charData = terminal.buffer.lines.get(cursorY)[terminal.buffer.x];\\r\\n if (!charData) {\\r\\n return;\\r\\n }\\r\\n\\r\\n if (!terminal.isFocused) {\\r\\n this._clearCursor();\\r\\n this._ctx.save();\\r\\n this._ctx.fillStyle = this._colors.cursor;\\r\\n this._renderBlurCursor(terminal, terminal.buffer.x, viewportRelativeCursorY, charData);\\r\\n this._ctx.restore();\\r\\n this._state.x = terminal.buffer.x;\\r\\n this._state.y = viewportRelativeCursorY;\\r\\n this._state.isFocused = false;\\r\\n this._state.style = terminal.options.cursorStyle;\\r\\n this._state.width = charData[CHAR_DATA_WIDTH_INDEX];\\r\\n return;\\r\\n }\\r\\n\\r\\n // Don't draw the cursor if it's blinking\\r\\n if (this._cursorBlinkStateManager && !this._cursorBlinkStateManager.isCursorVisible) {\\r\\n this._clearCursor();\\r\\n return;\\r\\n }\\r\\n\\r\\n if (this._state) {\\r\\n // The cursor is already in the correct spot, don't redraw\\r\\n if (this._state.x === terminal.buffer.x &&\\r\\n this._state.y === viewportRelativeCursorY &&\\r\\n this._state.isFocused === terminal.isFocused &&\\r\\n this._state.style === terminal.options.cursorStyle &&\\r\\n this._state.width === charData[CHAR_DATA_WIDTH_INDEX]) {\\r\\n return;\\r\\n }\\r\\n this._clearCursor();\\r\\n }\\r\\n\\r\\n this._ctx.save();\\r\\n this._cursorRenderers[terminal.options.cursorStyle || 'block'](terminal, terminal.buffer.x, viewportRelativeCursorY, charData);\\r\\n this._ctx.restore();\\r\\n\\r\\n this._state.x = terminal.buffer.x;\\r\\n this._state.y = viewportRelativeCursorY;\\r\\n this._state.isFocused = false;\\r\\n this._state.style = terminal.options.cursorStyle;\\r\\n this._state.width = charData[CHAR_DATA_WIDTH_INDEX];\\r\\n }\\r\\n\\r\\n private _clearCursor(): void {\\r\\n if (this._state) {\\r\\n this.clearCells(this._state.x, this._state.y, this._state.width, 1);\\r\\n this._state = {\\r\\n x: null,\\r\\n y: null,\\r\\n isFocused: null,\\r\\n style: null,\\r\\n width: null,\\r\\n };\\r\\n }\\r\\n }\\r\\n\\r\\n private _renderBarCursor(terminal: ITerminal, x: number, y: number, charData: CharData): void {\\r\\n this._ctx.save();\\r\\n this._ctx.fillStyle = this._colors.cursor;\\r\\n this.fillLeftLineAtCell(x, y);\\r\\n this._ctx.restore();\\r\\n }\\r\\n\\r\\n private _renderBlockCursor(terminal: ITerminal, x: number, y: number, charData: CharData): void {\\r\\n this._ctx.save();\\r\\n this._ctx.fillStyle = this._colors.cursor;\\r\\n this.fillCells(x, y, charData[CHAR_DATA_WIDTH_INDEX], 1);\\r\\n this._ctx.fillStyle = this._colors.cursorAccent;\\r\\n this.fillCharTrueColor(terminal, charData, x, y);\\r\\n this._ctx.restore();\\r\\n }\\r\\n\\r\\n private _renderUnderlineCursor(terminal: ITerminal, x: number, y: number, charData: CharData): void {\\r\\n this._ctx.save();\\r\\n this._ctx.fillStyle = this._colors.cursor;\\r\\n this.fillBottomLineAtCells(x, y);\\r\\n this._ctx.restore();\\r\\n }\\r\\n\\r\\n private _renderBlurCursor(terminal: ITerminal, x: number, y: number, charData: CharData): void {\\r\\n this._ctx.save();\\r\\n this._ctx.strokeStyle = this._colors.cursor;\\r\\n this.strokeRectAtCell(x, y, charData[CHAR_DATA_WIDTH_INDEX], 1);\\r\\n this._ctx.restore();\\r\\n }\\r\\n}\\r\\n\\r\\nclass CursorBlinkStateManager {\\r\\n public isCursorVisible: boolean;\\r\\n\\r\\n private _animationFrame: number;\\r\\n private _blinkStartTimeout: number;\\r\\n private _blinkInterval: number;\\r\\n\\r\\n /**\\r\\n * The time at which the animation frame was restarted, this is used on the\\r\\n * next render to restart the timers so they don't need to restart the timers\\r\\n * multiple times over a short period.\\r\\n */\\r\\n private _animationTimeRestarted: number;\\r\\n\\r\\n constructor(\\r\\n terminal: ITerminal,\\r\\n private renderCallback: () => void\\r\\n ) {\\r\\n this.isCursorVisible = true;\\r\\n if (terminal.isFocused) {\\r\\n this._restartInterval();\\r\\n }\\r\\n }\\r\\n\\r\\n public get isPaused(): boolean { return !(this._blinkStartTimeout || this._blinkInterval); }\\r\\n\\r\\n public dispose(): void {\\r\\n if (this._blinkInterval) {\\r\\n window.clearInterval(this._blinkInterval);\\r\\n this._blinkInterval = null;\\r\\n }\\r\\n if (this._blinkStartTimeout) {\\r\\n window.clearTimeout(this._blinkStartTimeout);\\r\\n this._blinkStartTimeout = null;\\r\\n }\\r\\n if (this._animationFrame) {\\r\\n window.cancelAnimationFrame(this._animationFrame);\\r\\n this._animationFrame = null;\\r\\n }\\r\\n }\\r\\n\\r\\n public restartBlinkAnimation(terminal: ITerminal): void {\\r\\n if (this.isPaused) {\\r\\n return;\\r\\n }\\r\\n // Save a timestamp so that the restart can be done on the next interval\\r\\n this._animationTimeRestarted = Date.now();\\r\\n // Force a cursor render to ensure it's visible and in the correct position\\r\\n this.isCursorVisible = true;\\r\\n if (!this._animationFrame) {\\r\\n this._animationFrame = window.requestAnimationFrame(() => {\\r\\n this.renderCallback();\\r\\n this._animationFrame = null;\\r\\n });\\r\\n }\\r\\n }\\r\\n\\r\\n private _restartInterval(timeToStart: number = BLINK_INTERVAL): void {\\r\\n // Clear any existing interval\\r\\n if (this._blinkInterval) {\\r\\n window.clearInterval(this._blinkInterval);\\r\\n }\\r\\n\\r\\n // Setup the initial timeout which will hide the cursor, this is done before\\r\\n // the regular interval is setup in order to support restarting the blink\\r\\n // animation in a lightweight way (without thrashing clearInterval and\\r\\n // setInterval).\\r\\n this._blinkStartTimeout = <number><any>setTimeout(() => {\\r\\n // Check if another animation restart was requested while this was being\\r\\n // started\\r\\n if (this._animationTimeRestarted) {\\r\\n const time = BLINK_INTERVAL - (Date.now() - this._animationTimeRestarted);\\r\\n this._animationTimeRestarted = null;\\r\\n if (time > 0) {\\r\\n this._restartInterval(time);\\r\\n return;\\r\\n }\\r\\n }\\r\\n\\r\\n // Hide the cursor\\r\\n this.isCursorVisible = false;\\r\\n this._animationFrame = window.requestAnimationFrame(() => {\\r\\n this.renderCallback();\\r\\n this._animationFrame = null;\\r\\n });\\r\\n\\r\\n // Setup the blink interval\\r\\n this._blinkInterval = <number><any>setInterval(() => {\\r\\n // Adjust the animation time if it was restarted\\r\\n if (this._animationTimeRestarted) {\\r\\n // calc time diff\\r\\n // Make restart interval do a setTimeout initially?\\r\\n const time = BLINK_INTERVAL - (Date.now() - this._animationTimeRestarted);\\r\\n this._animationTimeRestarted = null;\\r\\n this._restartInterval(time);\\r\\n return;\\r\\n }\\r\\n\\r\\n // Invert visibility and render\\r\\n this.isCursorVisible = !this.isCursorVisible;\\r\\n this._animationFrame = window.requestAnimationFrame(() => {\\r\\n this.renderCallback();\\r\\n this._animationFrame = null;\\r\\n });\\r\\n }, BLINK_INTERVAL);\\r\\n }, timeToStart);\\r\\n }\\r\\n\\r\\n public pause(): void {\\r\\n this.isCursorVisible = true;\\r\\n if (this._blinkInterval) {\\r\\n window.clearInterval(this._blinkInterval);\\r\\n this._blinkInterval = null;\\r\\n }\\r\\n if (this._blinkStartTimeout) {\\r\\n window.clearTimeout(this._blinkStartTimeout);\\r\\n this._blinkStartTimeout = null;\\r\\n }\\r\\n if (this._animationFrame) {\\r\\n window.cancelAnimationFrame(this._animationFrame);\\r\\n this._animationFrame = null;\\r\\n }\\r\\n }\\r\\n\\r\\n public resume(terminal: ITerminal): void {\\r\\n this._animationTimeRestarted = null;\\r\\n this._restartInterval();\\r\\n this.restartBlinkAnimation(terminal);\\r\\n }\\r\\n}\\r\\n\",\"/**\\r\\n * Copyright (c) 2017 The xterm.js authors. All rights reserved.\\r\\n * @license MIT\\r\\n */\\r\\n\\r\\nimport { IColorSet, IColorManager } from './Interfaces';\\r\\nimport { ITheme } from '../Interfaces';\\r\\n\\r\\nconst DEFAULT_FOREGROUND = '#ffffff';\\r\\nconst DEFAULT_BACKGROUND = '#000000';\\r\\nconst DEFAULT_CURSOR = '#ffffff';\\r\\nconst DEFAULT_CURSOR_ACCENT = '#000000';\\r\\nconst DEFAULT_SELECTION = 'rgba(255, 255, 255, 0.3)';\\r\\nexport const DEFAULT_ANSI_COLORS = [\\r\\n // dark:\\r\\n '#2e3436',\\r\\n '#cc0000',\\r\\n '#4e9a06',\\r\\n '#c4a000',\\r\\n '#3465a4',\\r\\n '#75507b',\\r\\n '#06989a',\\r\\n '#d3d7cf',\\r\\n // bright:\\r\\n '#555753',\\r\\n '#ef2929',\\r\\n '#8ae234',\\r\\n '#fce94f',\\r\\n '#729fcf',\\r\\n '#ad7fa8',\\r\\n '#34e2e2',\\r\\n '#eeeeec'\\r\\n];\\r\\n\\r\\n/**\\r\\n * Fills an existing 16 length string with the remaining 240 ANSI colors.\\r\\n * @param first16Colors The first 16 ANSI colors.\\r\\n */\\r\\nfunction generate256Colors(first16Colors: string[]): string[] {\\r\\n let colors = first16Colors.slice();\\r\\n\\r\\n // Generate colors (16-231)\\r\\n let v = [0x00, 0x5f, 0x87, 0xaf, 0xd7, 0xff];\\r\\n for (let i = 0; i < 216; i++) {\\r\\n const r = toPaddedHex(v[(i / 36) % 6 | 0]);\\r\\n const g = toPaddedHex(v[(i / 6) % 6 | 0]);\\r\\n const b = toPaddedHex(v[i % 6]);\\r\\n colors.push(`#${r}${g}${b}`);\\r\\n }\\r\\n\\r\\n // Generate greys (232-255)\\r\\n for (let i = 0; i < 24; i++) {\\r\\n const c = toPaddedHex(8 + i * 10);\\r\\n colors.push(`#${c}${c}${c}`);\\r\\n }\\r\\n\\r\\n return colors;\\r\\n}\\r\\n\\r\\nfunction toPaddedHex(c: number): string {\\r\\n let s = c.toString(16);\\r\\n return s.length < 2 ? '0' + s : s;\\r\\n}\\r\\n\\r\\n/**\\r\\n * Manages the source of truth for a terminal's colors.\\r\\n */\\r\\nexport class ColorManager implements IColorManager {\\r\\n public colors: IColorSet;\\r\\n\\r\\n constructor() {\\r\\n this.colors = {\\r\\n foreground: DEFAULT_FOREGROUND,\\r\\n background: DEFAULT_BACKGROUND,\\r\\n cursor: DEFAULT_CURSOR,\\r\\n cursorAccent: DEFAULT_CURSOR_ACCENT,\\r\\n selection: DEFAULT_SELECTION,\\r\\n ansi: generate256Colors(DEFAULT_ANSI_COLORS)\\r\\n };\\r\\n }\\r\\n\\r\\n /**\\r\\n * Sets the terminal's theme.\\r\\n * @param theme The theme to use. If a partial theme is provided then default\\r\\n * colors will be used where colors are not defined.\\r\\n */\\r\\n public setTheme(theme: ITheme): void {\\r\\n this.colors.foreground = theme.foreground || DEFAULT_FOREGROUND;\\r\\n this.colors.background = this._validateColor(theme.background, DEFAULT_BACKGROUND);\\r\\n this.colors.cursor = theme.cursor || DEFAULT_CURSOR;\\r\\n this.colors.cursorAccent = theme.cursorAccent || DEFAULT_CURSOR_ACCENT;\\r\\n this.colors.selection = theme.selection || DEFAULT_SELECTION;\\r\\n this.colors.ansi[0] = theme.black || DEFAULT_ANSI_COLORS[0];\\r\\n this.colors.ansi[1] = theme.red || DEFAULT_ANSI_COLORS[1];\\r\\n this.colors.ansi[2] = theme.green || DEFAULT_ANSI_COLORS[2];\\r\\n this.colors.ansi[3] = theme.yellow || DEFAULT_ANSI_COLORS[3];\\r\\n this.colors.ansi[4] = theme.blue || DEFAULT_ANSI_COLORS[4];\\r\\n this.colors.ansi[5] = theme.magenta || DEFAULT_ANSI_COLORS[5];\\r\\n this.colors.ansi[6] = theme.cyan || DEFAULT_ANSI_COLORS[6];\\r\\n this.colors.ansi[7] = theme.white || DEFAULT_ANSI_COLORS[7];\\r\\n this.colors.ansi[8] = theme.brightBlack || DEFAULT_ANSI_COLORS[8];\\r\\n this.colors.ansi[9] = theme.brightRed || DEFAULT_ANSI_COLORS[9];\\r\\n this.colors.ansi[10] = theme.brightGreen || DEFAULT_ANSI_COLORS[10];\\r\\n this.colors.ansi[11] = theme.brightYellow || DEFAULT_ANSI_COLORS[11];\\r\\n this.colors.ansi[12] = theme.brightBlue || DEFAULT_ANSI_COLORS[12];\\r\\n this.colors.ansi[13] = theme.brightMagenta || DEFAULT_ANSI_COLORS[13];\\r\\n this.colors.ansi[14] = theme.brightCyan || DEFAULT_ANSI_COLORS[14];\\r\\n this.colors.ansi[15] = theme.brightWhite || DEFAULT_ANSI_COLORS[15];\\r\\n }\\r\\n\\r\\n private _validateColor(color: string, fallback: string): string {\\r\\n if (!color) {\\r\\n return fallback;\\r\\n }\\r\\n if (color.length === 7 && color.charAt(0) === '#') {\\r\\n return color;\\r\\n }\\r\\n if (color.length === 4 && color.charAt(0) === '#') {\\r\\n const r = color.charAt(1);\\r\\n const g = color.charAt(2);\\r\\n const b = color.charAt(3);\\r\\n return `#${r}${r}${g}${g}${b}${b}`;\\r\\n }\\r\\n return fallback;\\r\\n }\\r\\n}\\r\\n\",\"/**\\r\\n * Copyright (c) 2017 The xterm.js authors. All rights reserved.\\r\\n * @license MIT\\r\\n */\\r\\n\\r\\nimport { ITerminal, ITheme } from '../Interfaces';\\r\\nimport { IColorSet } from '../renderer/Interfaces';\\r\\nimport { isFirefox } from '../utils/Browser';\\r\\n\\r\\nexport const CHAR_ATLAS_CELL_SPACING = 1;\\r\\n\\r\\ninterface ICharAtlasConfig {\\r\\n fontSize: number;\\r\\n fontFamily: string;\\r\\n scaledCharWidth: number;\\r\\n scaledCharHeight: number;\\r\\n colors: IColorSet;\\r\\n}\\r\\n\\r\\ninterface ICharAtlasCacheEntry {\\r\\n bitmap: HTMLCanvasElement | Promise<ImageBitmap>;\\r\\n config: ICharAtlasConfig;\\r\\n ownedBy: ITerminal[];\\r\\n}\\r\\n\\r\\nlet charAtlasCache: ICharAtlasCacheEntry[] = [];\\r\\n\\r\\n/**\\r\\n * Acquires a char atlas, either generating a new one or returning an existing\\r\\n * one that is in use by another terminal.\\r\\n * @param terminal The terminal.\\r\\n * @param colors The colors to use.\\r\\n */\\r\\nexport function acquireCharAtlas(terminal: ITerminal, colors: IColorSet, scaledCharWidth: number, scaledCharHeight: number): HTMLCanvasElement | Promise<ImageBitmap> {\\r\\n const newConfig = generateConfig(scaledCharWidth, scaledCharHeight, terminal, colors);\\r\\n\\r\\n // Check to see if the terminal already owns this config\\r\\n for (let i = 0; i < charAtlasCache.length; i++) {\\r\\n const entry = charAtlasCache[i];\\r\\n const ownedByIndex = entry.ownedBy.indexOf(terminal);\\r\\n if (ownedByIndex >= 0) {\\r\\n if (configEquals(entry.config, newConfig)) {\\r\\n return entry.bitmap;\\r\\n } else {\\r\\n // The configs differ, release the terminal from the entry\\r\\n if (entry.ownedBy.length === 1) {\\r\\n charAtlasCache.splice(i, 1);\\r\\n } else {\\r\\n entry.ownedBy.splice(ownedByIndex, 1);\\r\\n }\\r\\n break;\\r\\n }\\r\\n }\\r\\n }\\r\\n\\r\\n // Try match a char atlas from the cache\\r\\n for (let i = 0; i < charAtlasCache.length; i++) {\\r\\n const entry = charAtlasCache[i];\\r\\n if (configEquals(entry.config, newConfig)) {\\r\\n // Add the terminal to the cache entry and return\\r\\n entry.ownedBy.push(terminal);\\r\\n return entry.bitmap;\\r\\n }\\r\\n }\\r\\n\\r\\n const newEntry: ICharAtlasCacheEntry = {\\r\\n bitmap: generator.generate(scaledCharWidth, scaledCharHeight, terminal.options.fontSize, terminal.options.fontFamily, colors.background, colors.foreground, colors.ansi),\\r\\n config: newConfig,\\r\\n ownedBy: [terminal]\\r\\n };\\r\\n charAtlasCache.push(newEntry);\\r\\n return newEntry.bitmap;\\r\\n}\\r\\n\\r\\nfunction generateConfig(scaledCharWidth: number, scaledCharHeight: number, terminal: ITerminal, colors: IColorSet): ICharAtlasConfig {\\r\\n const clonedColors = {\\r\\n foreground: colors.foreground,\\r\\n background: colors.background,\\r\\n cursor: null,\\r\\n cursorAccent: null,\\r\\n selection: null,\\r\\n ansi: colors.ansi.slice(0, 16)\\r\\n };\\r\\n return {\\r\\n scaledCharWidth,\\r\\n scaledCharHeight,\\r\\n fontFamily: terminal.options.fontFamily,\\r\\n fontSize: terminal.options.fontSize,\\r\\n colors: clonedColors\\r\\n };\\r\\n}\\r\\n\\r\\nfunction configEquals(a: ICharAtlasConfig, b: ICharAtlasConfig): boolean {\\r\\n for (let i = 0; i < a.colors.ansi.length; i++) {\\r\\n if (a.colors.ansi[i] !== b.colors.ansi[i]) {\\r\\n return false;\\r\\n }\\r\\n }\\r\\n return a.fontFamily === b.fontFamily &&\\r\\n a.fontSize === b.fontSize &&\\r\\n a.scaledCharWidth === b.scaledCharWidth &&\\r\\n a.scaledCharHeight === b.scaledCharHeight &&\\r\\n a.colors.foreground === b.colors.foreground &&\\r\\n a.colors.background === b.colors.background;\\r\\n}\\r\\n\\r\\nlet generator: CharAtlasGenerator;\\r\\n\\r\\n/**\\r\\n * Initializes the char atlas generator.\\r\\n * @param document The document.\\r\\n */\\r\\nexport function initialize(document: Document): void {\\r\\n if (!generator) {\\r\\n generator = new CharAtlasGenerator(document);\\r\\n }\\r\\n}\\r\\n\\r\\nclass CharAtlasGenerator {\\r\\n private _canvas: HTMLCanvasElement;\\r\\n private _ctx: CanvasRenderingContext2D;\\r\\n\\r\\n constructor(private _document: Document) {\\r\\n this._canvas = this._document.createElement('canvas');\\r\\n this._ctx = this._canvas.getContext('2d', {alpha: false});\\r\\n this._ctx.scale(window.devicePixelRatio, window.devicePixelRatio);\\r\\n }\\r\\n\\r\\n public generate(scaledCharWidth: number, scaledCharHeight: number, fontSize: number, fontFamily: string, background: string, foreground: string, ansiColors: string[]): HTMLCanvasElement | Promise<ImageBitmap> {\\r\\n const cellWidth = scaledCharWidth + CHAR_ATLAS_CELL_SPACING;\\r\\n const cellHeight = scaledCharHeight + CHAR_ATLAS_CELL_SPACING;\\r\\n this._canvas.width = 255 * cellWidth;\\r\\n this._canvas.height = (/*default+default bold*/2 + /*0-15*/16) * cellHeight;\\r\\n\\r\\n this._ctx.fillStyle = background;\\r\\n this._ctx.fillRect(0, 0, this._canvas.width, this._canvas.height);\\r\\n\\r\\n this._ctx.save();\\r\\n this._ctx.fillStyle = foreground;\\r\\n this._ctx.font = `${fontSize * window.devicePixelRatio}px ${fontFamily}`;\\r\\n this._ctx.textBaseline = 'top';\\r\\n\\r\\n // Default color\\r\\n for (let i = 0; i < 256; i++) {\\r\\n this._ctx.save();\\r\\n this._ctx.beginPath();\\r\\n this._ctx.rect(i * cellWidth, 0, cellWidth, cellHeight);\\r\\n this._ctx.clip();\\r\\n this._ctx.fillText(String.fromCharCode(i), i * cellWidth, 0);\\r\\n this._ctx.restore();\\r\\n }\\r\\n // Default color bold\\r\\n this._ctx.save();\\r\\n this._ctx.font = `bold ${this._ctx.font}`;\\r\\n for (let i = 0; i < 256; i++) {\\r\\n this._ctx.save();\\r\\n this._ctx.beginPath();\\r\\n this._ctx.rect(i * cellWidth, cellHeight, cellWidth, cellHeight);\\r\\n this._ctx.clip();\\r\\n this._ctx.fillText(String.fromCharCode(i), i * cellWidth, cellHeight);\\r\\n this._ctx.restore();\\r\\n }\\r\\n this._ctx.restore();\\r\\n\\r\\n // Colors 0-15\\r\\n this._ctx.font = `${fontSize * window.devicePixelRatio}px ${fontFamily}`;\\r\\n for (let colorIndex = 0; colorIndex < 16; colorIndex++) {\\r\\n // colors 8-15 are bold\\r\\n if (colorIndex === 8) {\\r\\n this._ctx.font = `bold ${this._ctx.font}`;\\r\\n }\\r\\n const y = (colorIndex + 2) * cellHeight;\\r\\n // Draw ascii characters\\r\\n for (let i = 0; i < 256; i++) {\\r\\n this._ctx.save();\\r\\n this._ctx.beginPath();\\r\\n this._ctx.rect(i * cellWidth, y, cellWidth, cellHeight);\\r\\n this._ctx.clip();\\r\\n this._ctx.fillStyle = ansiColors[colorIndex];\\r\\n this._ctx.fillText(String.fromCharCode(i), i * cellWidth, y);\\r\\n this._ctx.restore();\\r\\n }\\r\\n }\\r\\n this._ctx.restore();\\r\\n\\r\\n // Support is patchy for createImageBitmap at the moment, pass a canvas back\\r\\n // if support is lacking as drawImage works there too. Firefox is also\\r\\n // included here as ImageBitmap appears both buggy and has horrible\\r\\n // performance (tested on v55).\\r\\n if (!('createImageBitmap' in window) || isFirefox) {\\r\\n // Regenerate canvas and context as they are now owned by the char atlas\\r\\n const result = this._canvas;\\r\\n this._canvas = this._document.createElement('canvas');\\r\\n this._ctx = this._canvas.getContext('2d');\\r\\n this._ctx.scale(window.devicePixelRatio, window.devicePixelRatio);\\r\\n return result;\\r\\n }\\r\\n\\r\\n const charAtlasImageData = this._ctx.getImageData(0, 0, this._canvas.width, this._canvas.height);\\r\\n\\r\\n // Remove the background color from the image so characters may overlap\\r\\n const r = parseInt(background.substr(1, 2), 16);\\r\\n const g = parseInt(background.substr(3, 2), 16);\\r\\n const b = parseInt(background.substr(5, 2), 16);\\r\\n this._clearColor(charAtlasImageData, r, g, b);\\r\\n\\r\\n const promise = window.createImageBitmap(charAtlasImageData);\\r\\n // Clear the rect while the promise is in progress\\r\\n this._ctx.clearRect(0, 0, this._canvas.width, this._canvas.height);\\r\\n return promise;\\r\\n }\\r\\n\\r\\n private _clearColor(imageData: ImageData, r: number, g: number, b: number): void {\\r\\n for (let offset = 0; offset < imageData.data.length; offset += 4) {\\r\\n if (imageData.data[offset] === r &&\\r\\n imageData.data[offset + 1] === g &&\\r\\n imageData.data[offset + 2] === b) {\\r\\n imageData.data[offset + 3] = 0;\\r\\n }\\r\\n }\\r\\n }\\r\\n}\\r\\n\",\"/**\\r\\n * Copyright (c) 2017 The xterm.js authors. All rights reserved.\\r\\n * @license MIT\\r\\n */\\r\\n\\r\\nimport { IRenderLayer, IColorSet, IRenderDimensions } from './Interfaces';\\r\\nimport { ITerminal, ITerminalOptions } from '../Interfaces';\\r\\nimport { acquireCharAtlas, CHAR_ATLAS_CELL_SPACING } from './CharAtlas';\\r\\nimport { CharData } from '../Types';\\r\\nimport { CHAR_DATA_WIDTH_INDEX, CHAR_DATA_CHAR_INDEX } from '../Buffer';\\r\\n\\r\\nexport const INVERTED_DEFAULT_COLOR = -1;\\r\\nconst DIM_OPACITY = 0.5;\\r\\n\\r\\nexport abstract class BaseRenderLayer implements IRenderLayer {\\r\\n private _canvas: HTMLCanvasElement;\\r\\n protected _ctx: CanvasRenderingContext2D;\\r\\n private _scaledCharWidth: number = 0;\\r\\n private _scaledCharHeight: number = 0;\\r\\n private _scaledCellWidth: number = 0;\\r\\n private _scaledCellHeight: number = 0;\\r\\n private _scaledCharLeft: number = 0;\\r\\n private _scaledCharTop: number = 0;\\r\\n\\r\\n private _charAtlas: HTMLCanvasElement | ImageBitmap;\\r\\n\\r\\n constructor(\\r\\n container: HTMLElement,\\r\\n id: string,\\r\\n zIndex: number,\\r\\n private _alpha: boolean,\\r\\n protected _colors: IColorSet\\r\\n ) {\\r\\n this._canvas = document.createElement('canvas');\\r\\n this._canvas.id = `xterm-${id}-layer`;\\r\\n this._canvas.style.zIndex = zIndex.toString();\\r\\n this._ctx = this._canvas.getContext('2d', {alpha: _alpha});\\r\\n this._ctx.scale(window.devicePixelRatio, window.devicePixelRatio);\\r\\n // Draw the background if this is an opaque layer\\r\\n if (!_alpha) {\\r\\n this.clearAll();\\r\\n }\\r\\n container.appendChild(this._canvas);\\r\\n }\\r\\n\\r\\n public onOptionsChanged(terminal: ITerminal): void {}\\r\\n public onBlur(terminal: ITerminal): void {}\\r\\n public onFocus(terminal: ITerminal): void {}\\r\\n public onCursorMove(terminal: ITerminal): void {}\\r\\n public onGridChanged(terminal: ITerminal, startRow: number, endRow: number): void {}\\r\\n public onSelectionChanged(terminal: ITerminal, start: [number, number], end: [number, number]): void {}\\r\\n\\r\\n public onThemeChanged(terminal: ITerminal, colorSet: IColorSet): void {\\r\\n this._refreshCharAtlas(terminal, colorSet);\\r\\n }\\r\\n\\r\\n /**\\r\\n * Refreshes the char atlas, aquiring a new one if necessary.\\r\\n * @param terminal The terminal.\\r\\n * @param colorSet The color set to use for the char atlas.\\r\\n */\\r\\n private _refreshCharAtlas(terminal: ITerminal, colorSet: IColorSet): void {\\r\\n if (this._scaledCharWidth <= 0 && this._scaledCharHeight <= 0) {\\r\\n return;\\r\\n }\\r\\n this._charAtlas = null;\\r\\n const result = acquireCharAtlas(terminal, this._colors, this._scaledCharWidth, this._scaledCharHeight);\\r\\n if (result instanceof HTMLCanvasElement) {\\r\\n this._charAtlas = result;\\r\\n } else {\\r\\n result.then(bitmap => this._charAtlas = bitmap);\\r\\n }\\r\\n }\\r\\n\\r\\n public resize(terminal: ITerminal, dim: IRenderDimensions, charSizeChanged: boolean): void {\\r\\n this._scaledCellWidth = dim.scaledCellWidth;\\r\\n this._scaledCellHeight = dim.scaledCellHeight;\\r\\n this._scaledCharWidth = dim.scaledCharWidth;\\r\\n this._scaledCharHeight = dim.scaledCharHeight;\\r\\n this._scaledCharLeft = dim.scaledCharLeft;\\r\\n this._scaledCharTop = dim.scaledCharTop;\\r\\n this._canvas.width = dim.scaledCanvasWidth;\\r\\n this._canvas.height = dim.scaledCanvasHeight;\\r\\n this._canvas.style.width = `${dim.canvasWidth}px`;\\r\\n this._canvas.style.height = `${dim.canvasHeight}px`;\\r\\n\\r\\n // Draw the background if this is an opaque layer\\r\\n if (!this._alpha) {\\r\\n this.clearAll();\\r\\n }\\r\\n\\r\\n if (charSizeChanged) {\\r\\n this._refreshCharAtlas(terminal, this._colors);\\r\\n }\\r\\n }\\r\\n\\r\\n public abstract reset(terminal: ITerminal): void;\\r\\n\\r\\n /**\\r\\n * Fills 1+ cells completely. This uses the existing fillStyle on the context.\\r\\n * @param x The column to start at.\\r\\n * @param y The row to start at\\r\\n * @param width The number of columns to fill.\\r\\n * @param height The number of rows to fill.\\r\\n */\\r\\n protected fillCells(x: number, y: number, width: number, height: number): void {\\r\\n this._ctx.fillRect(\\r\\n x * this._scaledCellWidth,\\r\\n y * this._scaledCellHeight,\\r\\n width * this._scaledCellWidth,\\r\\n height * this._scaledCellHeight);\\r\\n }\\r\\n\\r\\n /**\\r\\n * Fills a 1px line (2px on HDPI) at the bottom of the cell. This uses the\\r\\n * existing fillStyle on the context.\\r\\n * @param x The column to fill.\\r\\n * @param y The row to fill.\\r\\n */\\r\\n protected fillBottomLineAtCells(x: number, y: number, width: number = 1): void {\\r\\n this._ctx.fillRect(\\r\\n x * this._scaledCellWidth,\\r\\n (y + 1) * this._scaledCellHeight - window.devicePixelRatio - 1 /* Ensure it's drawn within the cell */,\\r\\n width * this._scaledCellWidth,\\r\\n window.devicePixelRatio);\\r\\n }\\r\\n\\r\\n /**\\r\\n * Fills a 1px line (2px on HDPI) at the left of the cell. This uses the\\r\\n * existing fillStyle on the context.\\r\\n * @param x The column to fill.\\r\\n * @param y The row to fill.\\r\\n */\\r\\n protected fillLeftLineAtCell(x: number, y: number): void {\\r\\n this._ctx.fillRect(\\r\\n x * this._scaledCellWidth,\\r\\n y * this._scaledCellHeight,\\r\\n window.devicePixelRatio,\\r\\n this._scaledCellHeight);\\r\\n }\\r\\n\\r\\n /**\\r\\n * Strokes a 1px rectangle (2px on HDPI) around a cell. This uses the existing\\r\\n * strokeStyle on the context.\\r\\n * @param x The column to fill.\\r\\n * @param y The row to fill.\\r\\n */\\r\\n protected strokeRectAtCell(x: number, y: number, width: number, height: number): void {\\r\\n this._ctx.lineWidth = window.devicePixelRatio;\\r\\n this._ctx.strokeRect(\\r\\n x * this._scaledCellWidth + window.devicePixelRatio / 2,\\r\\n y * this._scaledCellHeight + (window.devicePixelRatio / 2),\\r\\n width * this._scaledCellWidth - window.devicePixelRatio,\\r\\n (height * this._scaledCellHeight) - window.devicePixelRatio);\\r\\n }\\r\\n\\r\\n /**\\r\\n * Clears the entire canvas.\\r\\n */\\r\\n protected clearAll(): void {\\r\\n if (this._alpha) {\\r\\n this._ctx.clearRect(0, 0, this._canvas.width, this._canvas.height);\\r\\n } else {\\r\\n this._ctx.fillStyle = this._colors.background;\\r\\n this._ctx.fillRect(0, 0, this._canvas.width, this._canvas.height);\\r\\n }\\r\\n }\\r\\n\\r\\n /**\\r\\n * Clears 1+ cells completely.\\r\\n * @param x The column to start at.\\r\\n * @param y The row to start at.\\r\\n * @param width The number of columns to clear.\\r\\n * @param height The number of rows to clear.\\r\\n */\\r\\n protected clearCells(x: number, y: number, width: number, height: number): void {\\r\\n if (this._alpha) {\\r\\n this._ctx.clearRect(\\r\\n x * this._scaledCellWidth,\\r\\n y * this._scaledCellHeight,\\r\\n width * this._scaledCellWidth,\\r\\n height * this._scaledCellHeight);\\r\\n } else {\\r\\n this._ctx.fillStyle = this._colors.background;\\r\\n this._ctx.fillRect(\\r\\n x * this._scaledCellWidth,\\r\\n y * this._scaledCellHeight,\\r\\n width * this._scaledCellWidth,\\r\\n height * this._scaledCellHeight);\\r\\n }\\r\\n }\\r\\n\\r\\n /**\\r\\n * Draws a truecolor character at the cell. The character will be clipped to\\r\\n * ensure that it fits with the cell, including the cell to the right if it's\\r\\n * a wide character. This uses the existing fillStyle on the context.\\r\\n * @param terminal The terminal.\\r\\n * @param charData The char data for the character to draw.\\r\\n * @param x The column to draw at.\\r\\n * @param y The row to draw at.\\r\\n * @param color The color of the character.\\r\\n */\\r\\n protected fillCharTrueColor(terminal: ITerminal, charData: CharData, x: number, y: number): void {\\r\\n this._ctx.font = `${terminal.options.fontSize * window.devicePixelRatio}px ${terminal.options.fontFamily}`;\\r\\n this._ctx.textBaseline = 'top';\\r\\n this._clipRow(terminal, y);\\r\\n this._ctx.fillText(\\r\\n charData[CHAR_DATA_CHAR_INDEX],\\r\\n x * this._scaledCellWidth + this._scaledCharLeft,\\r\\n y * this._scaledCellHeight + this._scaledCharTop);\\r\\n }\\r\\n\\r\\n /**\\r\\n * Draws a character at a cell. If possible this will draw using the character\\r\\n * atlas to reduce draw time.\\r\\n * @param terminal The terminal.\\r\\n * @param char The character.\\r\\n * @param code The character code.\\r\\n * @param width The width of the character.\\r\\n * @param x The column to draw at.\\r\\n * @param y The row to draw at.\\r\\n * @param fg The foreground color, in the format stored within the attributes.\\r\\n * @param bg The background color, in the format stored within the attributes.\\r\\n * This is used to validate whether a cached image can be used.\\r\\n * @param bold Whether the text is bold.\\r\\n */\\r\\n protected drawChar(terminal: ITerminal, char: string, code: number, width: number, x: number, y: number, fg: number, bg: number, bold: boolean, dim: boolean): void {\\r\\n let colorIndex = 0;\\r\\n if (fg < 256) {\\r\\n colorIndex = fg + 2;\\r\\n } else {\\r\\n // If default color and bold\\r\\n if (bold && terminal.options.enableBold) {\\r\\n colorIndex = 1;\\r\\n }\\r\\n }\\r\\n const isAscii = code < 256;\\r\\n // A color is basic if it is one of the standard normal or bold weight\\r\\n // colors of the characters held in the char atlas. Note that this excludes\\r\\n // the normal weight _light_ color characters.\\r\\n const isBasicColor = (colorIndex > 1 && fg < 16) && (fg < 8 || bold);\\r\\n const isDefaultColor = fg >= 256;\\r\\n const isDefaultBackground = bg >= 256;\\r\\n if (this._charAtlas && isAscii && (isBasicColor || isDefaultColor) && isDefaultBackground) {\\r\\n // ImageBitmap's draw about twice as fast as from a canvas\\r\\n const charAtlasCellWidth = this._scaledCharWidth + CHAR_ATLAS_CELL_SPACING;\\r\\n const charAtlasCellHeight = this._scaledCharHeight + CHAR_ATLAS_CELL_SPACING;\\r\\n\\r\\n // Apply alpha to dim the character\\r\\n if (dim) {\\r\\n this._ctx.globalAlpha = DIM_OPACITY;\\r\\n }\\r\\n\\r\\n // Draw the non-bold version of the same color if bold is not enabled\\r\\n if (bold && !terminal.options.enableBold) {\\r\\n // Ignore default color as it's not touched above\\r\\n if (colorIndex > 1) {\\r\\n colorIndex -= 8;\\r\\n }\\r\\n }\\r\\n\\r\\n this._ctx.drawImage(this._charAtlas,\\r\\n code * charAtlasCellWidth,\\r\\n colorIndex * charAtlasCellHeight,\\r\\n charAtlasCellWidth,\\r\\n this._scaledCharHeight,\\r\\n x * this._scaledCellWidth + this._scaledCharLeft,\\r\\n y * this._scaledCellHeight + this._scaledCharTop,\\r\\n charAtlasCellWidth,\\r\\n this._scaledCharHeight);\\r\\n } else {\\r\\n this._drawUncachedChar(terminal, char, width, fg, x, y, bold, dim);\\r\\n }\\r\\n // This draws the atlas (for debugging purposes)\\r\\n // this._ctx.clearRect(0, 0, this._canvas.width, this._canvas.height);\\r\\n // this._ctx.drawImage(this._charAtlas, 0, 0);\\r\\n }\\r\\n\\r\\n /**\\r\\n * Draws a character at a cell. The character will be clipped to\\r\\n * ensure that it fits with the cell, including the cell to the right if it's\\r\\n * a wide character.\\r\\n * @param terminal The terminal.\\r\\n * @param char The character.\\r\\n * @param width The width of the character.\\r\\n * @param fg The foreground color, in the format stored within the attributes.\\r\\n * @param x The column to draw at.\\r\\n * @param y The row to draw at.\\r\\n */\\r\\n private _drawUncachedChar(terminal: ITerminal, char: string, width: number, fg: number, x: number, y: number, bold: boolean, dim: boolean): void {\\r\\n this._ctx.save();\\r\\n this._ctx.font = `${terminal.options.fontSize * window.devicePixelRatio}px ${terminal.options.fontFamily}`;\\r\\n if (bold && terminal.options.enableBold) {\\r\\n this._ctx.font = `bold ${this._ctx.font}`;\\r\\n }\\r\\n this._ctx.textBaseline = 'top';\\r\\n\\r\\n if (fg === INVERTED_DEFAULT_COLOR) {\\r\\n this._ctx.fillStyle = this._colors.background;\\r\\n } else if (fg < 256) {\\r\\n // 256 color support\\r\\n this._ctx.fillStyle = this._colors.ansi[fg];\\r\\n } else {\\r\\n this._ctx.fillStyle = this._colors.foreground;\\r\\n }\\r\\n\\r\\n this._clipRow(terminal, y);\\r\\n\\r\\n // Apply alpha to dim the character\\r\\n if (dim) {\\r\\n this._ctx.globalAlpha = DIM_OPACITY;\\r\\n }\\r\\n // Draw the character\\r\\n this._ctx.fillText(\\r\\n char,\\r\\n x * this._scaledCellWidth + this._scaledCharLeft,\\r\\n y * this._scaledCellHeight + this._scaledCharTop);\\r\\n this._ctx.restore();\\r\\n }\\r\\n\\r\\n /**\\r\\n * Clips a row to ensure no pixels will be drawn outside the cells in the row.\\r\\n * @param terminal The terminal.\\r\\n * @param y The row to clip.\\r\\n */\\r\\n private _clipRow(terminal: ITerminal, y: number): void {\\r\\n this._ctx.beginPath();\\r\\n this._ctx.rect(\\r\\n 0,\\r\\n y * this._scaledCellHeight,\\r\\n terminal.cols * this._scaledCellWidth,\\r\\n this._scaledCellHeight);\\r\\n this._ctx.clip();\\r\\n }\\r\\n}\\r\\n\\r\\n\",\"/**\\r\\n * Copyright (c) 2017 The xterm.js authors. All rights reserved.\\r\\n * @license MIT\\r\\n */\\r\\n\\r\\nimport { IMouseZoneManager, IMouseZone } from './Interfaces';\\r\\nimport { ITerminal } from '../Interfaces';\\r\\n\\r\\nconst HOVER_DURATION = 500;\\r\\n\\r\\n/**\\r\\n * The MouseZoneManager allows components to register zones within the terminal\\r\\n * that trigger hover and click callbacks.\\r\\n *\\r\\n * This class was intentionally made not so robust initially as the only case it\\r\\n * needed to support was single-line links which never overlap. Improvements can\\r\\n * be made in the future.\\r\\n */\\r\\nexport class MouseZoneManager implements IMouseZoneManager {\\r\\n private _zones: IMouseZone[] = [];\\r\\n\\r\\n private _areZonesActive: boolean = false;\\r\\n private _mouseMoveListener: (e: MouseEvent) => any;\\r\\n private _clickListener: (e: MouseEvent) => any;\\r\\n\\r\\n private _tooltipTimeout: number = null;\\r\\n private _currentZone: IMouseZone = null;\\r\\n private _lastHoverCoords: [number, number] = [null, null];\\r\\n\\r\\n constructor(\\r\\n private _terminal: ITerminal\\r\\n ) {\\r\\n this._terminal.element.addEventListener('mousedown', e => this._onMouseDown(e));\\r\\n\\r\\n // These events are expensive, only listen to it when mouse zones are active\\r\\n this._mouseMoveListener = e => this._onMouseMove(e);\\r\\n this._clickListener = e => this._onClick(e);\\r\\n }\\r\\n\\r\\n public add(zone: IMouseZone): void {\\r\\n this._zones.push(zone);\\r\\n if (this._zones.length === 1) {\\r\\n this._activate();\\r\\n }\\r\\n }\\r\\n\\r\\n public clearAll(start?: number, end?: number): void {\\r\\n // Exit if there's nothing to clear\\r\\n if (this._zones.length === 0) {\\r\\n return;\\r\\n }\\r\\n\\r\\n // Clear all if start/end weren't set\\r\\n if (!end) {\\r\\n start = 0;\\r\\n end = this._terminal.rows - 1;\\r\\n }\\r\\n\\r\\n // Iterate through zones and clear them out if they're within the range\\r\\n for (let i = 0; i < this._zones.length; i++) {\\r\\n const zone = this._zones[i];\\r\\n if (zone.y > start && zone.y <= end + 1) {\\r\\n if (this._currentZone && this._currentZone === zone) {\\r\\n this._currentZone.leaveCallback();\\r\\n this._currentZone = null;\\r\\n }\\r\\n this._zones.splice(i--, 1);\\r\\n }\\r\\n }\\r\\n\\r\\n // Deactivate the mouse zone manager if all the zones have been removed\\r\\n if (this._zones.length === 0) {\\r\\n this._deactivate();\\r\\n }\\r\\n }\\r\\n\\r\\n private _activate(): void {\\r\\n if (!this._areZonesActive) {\\r\\n this._areZonesActive = true;\\r\\n this._terminal.element.addEventListener('mousemove', this._mouseMoveListener);\\r\\n this._terminal.element.addEventListener('click', this._clickListener);\\r\\n }\\r\\n }\\r\\n\\r\\n private _deactivate(): void {\\r\\n if (this._areZonesActive) {\\r\\n this._areZonesActive = false;\\r\\n this._terminal.element.removeEventListener('mousemove', this._mouseMoveListener);\\r\\n this._terminal.element.removeEventListener('click', this._clickListener);\\r\\n }\\r\\n }\\r\\n\\r\\n private _onMouseMove(e: MouseEvent): void {\\r\\n // TODO: Ideally this would only clear the hover state when the mouse moves\\r\\n // outside of the mouse zone\\r\\n if (this._lastHoverCoords[0] !== e.pageX || this._lastHoverCoords[1] !== e.pageY) {\\r\\n this._onHover(e);\\r\\n // Record the current coordinates\\r\\n this._lastHoverCoords = [e.pageX, e.pageY];\\r\\n }\\r\\n }\\r\\n\\r\\n private _onHover(e: MouseEvent): void {\\r\\n const zone = this._findZoneEventAt(e);\\r\\n\\r\\n // Do nothing if the zone is the same\\r\\n if (zone === this._currentZone) {\\r\\n return;\\r\\n }\\r\\n\\r\\n // Fire the hover end callback and cancel any existing timer if a new zone\\r\\n // is being hovered\\r\\n if (this._currentZone) {\\r\\n this._currentZone.leaveCallback();\\r\\n this._currentZone = null;\\r\\n if (this._tooltipTimeout) {\\r\\n clearTimeout(this._tooltipTimeout);\\r\\n }\\r\\n }\\r\\n\\r\\n // Exit if there is not zone\\r\\n if (!zone) {\\r\\n return;\\r\\n }\\r\\n this._currentZone = zone;\\r\\n\\r\\n // Trigger the hover callback\\r\\n if (zone.hoverCallback) {\\r\\n zone.hoverCallback(e);\\r\\n }\\r\\n\\r\\n // Restart the tooltip timeout\\r\\n this._tooltipTimeout = <number><any>setTimeout(() => this._onTooltip(e), HOVER_DURATION);\\r\\n }\\r\\n\\r\\n private _onTooltip(e: MouseEvent): void {\\r\\n this._tooltipTimeout = null;\\r\\n const zone = this._findZoneEventAt(e);\\r\\n if (zone && zone.tooltipCallback) {\\r\\n zone.tooltipCallback(e);\\r\\n }\\r\\n }\\r\\n\\r\\n private _onMouseDown(e: MouseEvent): void {\\r\\n // Ignore the event if there are no zones active\\r\\n if (!this._areZonesActive) {\\r\\n return;\\r\\n }\\r\\n\\r\\n // Find the active zone, prevent event propagation if found to prevent other\\r\\n // components from handling the mouse event.\\r\\n const zone = this._findZoneEventAt(e);\\r\\n if (zone) {\\r\\n // TODO: When link modifier support is added, the event should only be\\r\\n // cancelled when the modifier is held (see #1021)\\r\\n e.preventDefault();\\r\\n e.stopImmediatePropagation();\\r\\n }\\r\\n }\\r\\n\\r\\n private _onClick(e: MouseEvent): void {\\r\\n // Find the active zone and click it if found\\r\\n const zone = this._findZoneEventAt(e);\\r\\n if (zone) {\\r\\n zone.clickCallback(e);\\r\\n e.preventDefault();\\r\\n e.stopImmediatePropagation();\\r\\n }\\r\\n }\\r\\n\\r\\n private _findZoneEventAt(e: MouseEvent): IMouseZone {\\r\\n const coords = this._terminal.mouseHelper.getCoords(e, this._terminal.element, this._terminal.charMeasure, this._terminal.options.lineHeight, this._terminal.cols, this._terminal.rows);\\r\\n if (!coords) {\\r\\n return null;\\r\\n }\\r\\n for (let i = 0; i < this._zones.length; i++) {\\r\\n const zone = this._zones[i];\\r\\n if (zone.y === coords[1] && zone.x1 <= coords[0] && zone.x2 > coords[0]) {\\r\\n return zone;\\r\\n }\\r\\n };\\r\\n return null;\\r\\n }\\r\\n}\\r\\n\\r\\nexport class MouseZone implements IMouseZone {\\r\\n constructor(\\r\\n public x1: number,\\r\\n public x2: number,\\r\\n public y: number,\\r\\n public clickCallback: (e: MouseEvent) => any,\\r\\n public hoverCallback?: (e: MouseEvent) => any,\\r\\n public tooltipCallback?: (e: MouseEvent) => any,\\r\\n public leaveCallback?: () => void\\r\\n ) {\\r\\n }\\r\\n}\\r\\n\",\"/**\\r\\n * Copyright (c) 2016 The xterm.js authors. All rights reserved.\\r\\n * @license MIT\\r\\n */\\r\\n\\r\\nimport { ITerminal, ISelectionManager } from '../Interfaces';\\r\\n\\r\\ninterface IWindow extends Window {\\r\\n clipboardData?: {\\r\\n getData(format: string): string;\\r\\n setData(format: string, data: string): void;\\r\\n };\\r\\n}\\r\\n\\r\\ndeclare var window: IWindow;\\r\\n\\r\\n/**\\r\\n * Prepares text to be pasted into the terminal by normalizing the line endings\\r\\n * @param text The pasted text that needs processing before inserting into the terminal\\r\\n */\\r\\nexport function prepareTextForTerminal(text: string, isMSWindows: boolean): string {\\r\\n if (isMSWindows) {\\r\\n return text.replace(/\\\\r?\\\\n/g, '\\\\r');\\r\\n }\\r\\n return text;\\r\\n}\\r\\n\\r\\n/**\\r\\n * Binds copy functionality to the given terminal.\\r\\n * @param {ClipboardEvent} ev The original copy event to be handled\\r\\n */\\r\\nexport function copyHandler(ev: ClipboardEvent, term: ITerminal, selectionManager: ISelectionManager): void {\\r\\n if (term.browser.isMSIE) {\\r\\n window.clipboardData.setData('Text', selectionManager.selectionText);\\r\\n } else {\\r\\n ev.clipboardData.setData('text/plain', selectionManager.selectionText);\\r\\n }\\r\\n\\r\\n // Prevent or the original text will be copied.\\r\\n ev.preventDefault();\\r\\n}\\r\\n\\r\\n/**\\r\\n * Redirect the clipboard's data to the terminal's input handler.\\r\\n * @param {ClipboardEvent} ev The original paste event to be handled\\r\\n * @param {Terminal} term The terminal on which to apply the handled paste event\\r\\n */\\r\\nexport function pasteHandler(ev: ClipboardEvent, term: ITerminal): void {\\r\\n ev.stopPropagation();\\r\\n\\r\\n let text: string;\\r\\n\\r\\n let dispatchPaste = function(text: string): void {\\r\\n text = prepareTextForTerminal(text, term.browser.isMSWindows);\\r\\n term.handler(text);\\r\\n term.textarea.value = '';\\r\\n term.emit('paste', text);\\r\\n term.cancel(ev);\\r\\n };\\r\\n\\r\\n if (term.browser.isMSIE) {\\r\\n if (window.clipboardData) {\\r\\n text = window.clipboardData.getData('Text');\\r\\n dispatchPaste(text);\\r\\n }\\r\\n } else {\\r\\n if (ev.clipboardData) {\\r\\n text = ev.clipboardData.getData('text/plain');\\r\\n dispatchPaste(text);\\r\\n }\\r\\n }\\r\\n}\\r\\n\\r\\n/**\\r\\n * Moves the textarea under the mouse cursor and focuses it.\\r\\n * @param ev The original right click event to be handled.\\r\\n * @param textarea The terminal's textarea.\\r\\n */\\r\\nexport function moveTextAreaUnderMouseCursor(ev: MouseEvent, textarea: HTMLTextAreaElement): void {\\r\\n // Bring textarea at the cursor position\\r\\n textarea.style.position = 'fixed';\\r\\n textarea.style.width = '20px';\\r\\n textarea.style.height = '20px';\\r\\n textarea.style.left = (ev.clientX - 10) + 'px';\\r\\n textarea.style.top = (ev.clientY - 10) + 'px';\\r\\n textarea.style.zIndex = '1000';\\r\\n\\r\\n textarea.focus();\\r\\n\\r\\n // Reset the terminal textarea's styling\\r\\n setTimeout(() => {\\r\\n textarea.style.position = null;\\r\\n textarea.style.width = null;\\r\\n textarea.style.height = null;\\r\\n textarea.style.left = null;\\r\\n textarea.style.top = null;\\r\\n textarea.style.zIndex = null;\\r\\n }, 4);\\r\\n}\\r\\n\\r\\n/**\\r\\n * Bind to right-click event and allow right-click copy and paste.\\r\\n * @param ev The original right click event to be handled.\\r\\n * @param textarea The terminal's textarea.\\r\\n * @param selectionManager The terminal's selection manager.\\r\\n */\\r\\nexport function rightClickHandler(ev: MouseEvent, textarea: HTMLTextAreaElement, selectionManager: ISelectionManager): void {\\r\\n moveTextAreaUnderMouseCursor(ev, textarea);\\r\\n\\r\\n // Get textarea ready to copy from the context menu\\r\\n textarea.value = selectionManager.selectionText;\\r\\n textarea.select();\\r\\n}\\r\\n\",\"/**\\r\\n * Copyright (c) 2016 The xterm.js authors. All rights reserved.\\r\\n * @license MIT\\r\\n */\\r\\n\\r\\nimport { ITerminal, IViewport } from './Interfaces';\\r\\nimport { CharMeasure } from './utils/CharMeasure';\\r\\nimport { IColorSet } from './renderer/Interfaces';\\r\\n\\r\\n/**\\r\\n * Represents the viewport of a terminal, the visible area within the larger buffer of output.\\r\\n * Logic for the virtual scroll bar is included in this object.\\r\\n */\\r\\nexport class Viewport implements IViewport {\\r\\n private currentRowHeight: number = 0;\\r\\n private lastRecordedBufferLength: number = 0;\\r\\n private lastRecordedViewportHeight: number = 0;\\r\\n private lastRecordedBufferHeight: number = 0;\\r\\n private lastTouchY: number;\\r\\n\\r\\n /**\\r\\n * Creates a new Viewport.\\r\\n * @param terminal The terminal this viewport belongs to.\\r\\n * @param viewportElement The DOM element acting as the viewport.\\r\\n * @param scrollArea The DOM element acting as the scroll area.\\r\\n * @param charMeasure A DOM element used to measure the character size of. the terminal.\\r\\n */\\r\\n constructor(\\r\\n private terminal: ITerminal,\\r\\n private viewportElement: HTMLElement,\\r\\n private scrollArea: HTMLElement,\\r\\n private charMeasure: CharMeasure\\r\\n ) {\\r\\n this.viewportElement.addEventListener('scroll', this.onScroll.bind(this));\\r\\n\\r\\n // Perform this async to ensure the CharMeasure is ready.\\r\\n setTimeout(() => this.syncScrollArea(), 0);\\r\\n }\\r\\n\\r\\n public onThemeChanged(colors: IColorSet): void {\\r\\n this.viewportElement.style.backgroundColor = colors.background;\\r\\n }\\r\\n\\r\\n /**\\r\\n * Refreshes row height, setting line-height, viewport height and scroll area height if\\r\\n * necessary.\\r\\n */\\r\\n private refresh(): void {\\r\\n if (this.charMeasure.height > 0) {\\r\\n this.currentRowHeight = this.terminal.renderer.dimensions.scaledCellHeight / window.devicePixelRatio;\\r\\n\\r\\n if (this.lastRecordedViewportHeight !== this.terminal.renderer.dimensions.canvasHeight) {\\r\\n this.lastRecordedViewportHeight = this.terminal.renderer.dimensions.canvasHeight;\\r\\n this.viewportElement.style.height = this.lastRecordedViewportHeight + 'px';\\r\\n }\\r\\n\\r\\n const newBufferHeight = Math.round(this.currentRowHeight * this.lastRecordedBufferLength);\\r\\n if (this.lastRecordedBufferHeight !== newBufferHeight) {\\r\\n this.lastRecordedBufferHeight = newBufferHeight;\\r\\n this.scrollArea.style.height = this.lastRecordedBufferHeight + 'px';\\r\\n }\\r\\n }\\r\\n }\\r\\n\\r\\n /**\\r\\n * Updates dimensions and synchronizes the scroll area if necessary.\\r\\n */\\r\\n public syncScrollArea(): void {\\r\\n if (this.lastRecordedBufferLength !== this.terminal.buffer.lines.length) {\\r\\n // If buffer height changed\\r\\n this.lastRecordedBufferLength = this.terminal.buffer.lines.length;\\r\\n this.refresh();\\r\\n } else if (this.lastRecordedViewportHeight !== (<any>this.terminal).renderer.dimensions.canvasHeight) {\\r\\n // If viewport height changed\\r\\n this.refresh();\\r\\n } else {\\r\\n // If size has changed, refresh viewport\\r\\n if (this.terminal.renderer.dimensions.scaledCellHeight / window.devicePixelRatio !== this.currentRowHeight) {\\r\\n this.refresh();\\r\\n }\\r\\n }\\r\\n\\r\\n // Sync scrollTop\\r\\n const scrollTop = this.terminal.buffer.ydisp * this.currentRowHeight;\\r\\n if (this.viewportElement.scrollTop !== scrollTop) {\\r\\n this.viewportElement.scrollTop = scrollTop;\\r\\n }\\r\\n }\\r\\n\\r\\n /**\\r\\n * Handles scroll events on the viewport, calculating the new viewport and requesting the\\r\\n * terminal to scroll to it.\\r\\n * @param ev The scroll event.\\r\\n */\\r\\n private onScroll(ev: Event): void {\\r\\n const newRow = Math.round(this.viewportElement.scrollTop / this.currentRowHeight);\\r\\n const diff = newRow - this.terminal.buffer.ydisp;\\r\\n this.terminal.scrollDisp(diff, true);\\r\\n }\\r\\n\\r\\n /**\\r\\n * Handles mouse wheel events by adjusting the viewport's scrollTop and delegating the actual\\r\\n * scrolling to `onScroll`, this event needs to be attached manually by the consumer of\\r\\n * `Viewport`.\\r\\n * @param ev The mouse wheel event.\\r\\n */\\r\\n public onWheel(ev: WheelEvent): void {\\r\\n if (ev.deltaY === 0) {\\r\\n // Do nothing if it's not a vertical scroll event\\r\\n return;\\r\\n }\\r\\n // Fallback to WheelEvent.DOM_DELTA_PIXEL\\r\\n let multiplier = 1;\\r\\n if (ev.deltaMode === WheelEvent.DOM_DELTA_LINE) {\\r\\n multiplier = this.currentRowHeight;\\r\\n } else if (ev.deltaMode === WheelEvent.DOM_DELTA_PAGE) {\\r\\n multiplier = this.currentRowHeight * this.terminal.rows;\\r\\n }\\r\\n this.viewportElement.scrollTop += ev.deltaY * multiplier;\\r\\n // Prevent the page from scrolling when the terminal scrolls\\r\\n ev.preventDefault();\\r\\n };\\r\\n\\r\\n /**\\r\\n * Handles the touchstart event, recording the touch occurred.\\r\\n * @param ev The touch event.\\r\\n */\\r\\n public onTouchStart(ev: TouchEvent): void {\\r\\n this.lastTouchY = ev.touches[0].pageY;\\r\\n };\\r\\n\\r\\n /**\\r\\n * Handles the touchmove event, scrolling the viewport if the position shifted.\\r\\n * @param ev The touch event.\\r\\n */\\r\\n public onTouchMove(ev: TouchEvent): void {\\r\\n let deltaY = this.lastTouchY - ev.touches[0].pageY;\\r\\n this.lastTouchY = ev.touches[0].pageY;\\r\\n if (deltaY === 0) {\\r\\n return;\\r\\n }\\r\\n this.viewportElement.scrollTop += deltaY;\\r\\n ev.preventDefault();\\r\\n };\\r\\n}\\r\\n\",\"/**\\r\\n * Copyright (c) 2017 The xterm.js authors. All rights reserved.\\r\\n * @license MIT\\r\\n */\\r\\n\\r\\nexport type LinkMatcher = {\\r\\n id: number,\\r\\n regex: RegExp,\\r\\n handler: LinkMatcherHandler,\\r\\n hoverTooltipCallback?: LinkMatcherHandler,\\r\\n hoverLeaveCallback?: () => void,\\r\\n matchIndex?: number,\\r\\n validationCallback?: LinkMatcherValidationCallback,\\r\\n priority?: number\\r\\n};\\r\\nexport type LinkMatcherHandler = (event: MouseEvent, uri: string) => boolean | void;\\r\\nexport type LinkMatcherValidationCallback = (uri: string, callback: (isValid: boolean) => void) => void;\\r\\n\\r\\nexport type CustomKeyEventHandler = (event: KeyboardEvent) => boolean;\\r\\nexport type Charset = {[key: string]: string};\\r\\n\\r\\nexport type CharData = [number, string, number, number];\\r\\nexport type LineData = CharData[];\\r\\n\\r\\nexport type LinkHoverEvent = {\\r\\n x: number,\\r\\n y: number,\\r\\n length: number\\r\\n};\\r\\n\\r\\nexport enum LinkHoverEventTypes {\\r\\n HOVER = 'linkhover',\\r\\n TOOLTIP = 'linktooltip',\\r\\n LEAVE = 'linkleave'\\r\\n};\\r\\n\",\"/**\\r\\n * Copyright (c) 2014 The xterm.js authors. All rights reserved.\\r\\n * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)\\r\\n * @license MIT\\r\\n *\\r\\n * Originally forked from (with the author's permission):\\r\\n * Fabrice Bellard's javascript vt100 for jslinux:\\r\\n * http://bellard.org/jslinux/\\r\\n * Copyright (c) 2011 Fabrice Bellard\\r\\n * The original design remains. The terminal itself\\r\\n * has been extended to include xterm CSI codes, among\\r\\n * other features.\\r\\n *\\r\\n * Terminal Emulation References:\\r\\n * http://vt100.net/\\r\\n * http://invisible-island.net/xterm/ctlseqs/ctlseqs.txt\\r\\n * http://invisible-island.net/xterm/ctlseqs/ctlseqs.html\\r\\n * http://invisible-island.net/vttest/\\r\\n * http://www.inwap.com/pdp10/ansicode.txt\\r\\n * http://linux.die.net/man/4/console_codes\\r\\n * http://linux.die.net/man/7/urxvt\\r\\n */\\r\\n\\r\\nimport { BufferSet } from './BufferSet';\\r\\nimport { Buffer } from './Buffer';\\r\\nimport { CompositionHelper } from './CompositionHelper';\\r\\nimport { EventEmitter } from './EventEmitter';\\r\\nimport { Viewport } from './Viewport';\\r\\nimport { rightClickHandler, moveTextAreaUnderMouseCursor, pasteHandler, copyHandler } from './handlers/Clipboard';\\r\\nimport { CircularList } from './utils/CircularList';\\r\\nimport { C0 } from './EscapeSequences';\\r\\nimport { InputHandler } from './InputHandler';\\r\\nimport { Parser } from './Parser';\\r\\nimport { Renderer } from './renderer/Renderer';\\r\\nimport { Linkifier } from './Linkifier';\\r\\nimport { SelectionManager } from './SelectionManager';\\r\\nimport { CharMeasure } from './utils/CharMeasure';\\r\\nimport * as Browser from './utils/Browser';\\r\\nimport { MouseHelper } from './utils/MouseHelper';\\r\\nimport { CHARSETS } from './Charsets';\\r\\nimport { CustomKeyEventHandler, Charset, LinkMatcherHandler, LinkMatcherValidationCallback, CharData, LineData } from './Types';\\r\\nimport { ITerminal, IBrowser, ITerminalOptions, IInputHandlingTerminal, ILinkMatcherOptions, IViewport, ICompositionHelper, ITheme, ILinkifier } from './Interfaces';\\r\\nimport { BellSound } from './utils/Sounds';\\r\\nimport { DEFAULT_ANSI_COLORS } from './renderer/ColorManager';\\r\\nimport { IMouseZoneManager } from './input/Interfaces';\\r\\nimport { MouseZoneManager } from './input/MouseZoneManager';\\r\\nimport { initialize as initializeCharAtlas } from './renderer/CharAtlas';\\r\\nimport { IRenderer } from './renderer/Interfaces';\\r\\n\\r\\n// Declares required for loadAddon\\r\\ndeclare var exports: any;\\r\\ndeclare var module: any;\\r\\ndeclare var define: any;\\r\\ndeclare var require: any;\\r\\n\\r\\n// Let it work inside Node.js for automated testing purposes.\\r\\nconst document = (typeof window !== 'undefined') ? window.document : null;\\r\\n\\r\\n/**\\r\\n * The amount of write requests to queue before sending an XOFF signal to the\\r\\n * pty process. This number must be small in order for ^C and similar sequences\\r\\n * to be responsive.\\r\\n */\\r\\nconst WRITE_BUFFER_PAUSE_THRESHOLD = 5;\\r\\n\\r\\n/**\\r\\n * The number of writes to perform in a single batch before allowing the\\r\\n * renderer to catch up with a 0ms setTimeout.\\r\\n */\\r\\nconst WRITE_BATCH_SIZE = 300;\\r\\n\\r\\nconst DEFAULT_OPTIONS: ITerminalOptions = {\\r\\n convertEol: false,\\r\\n termName: 'xterm',\\r\\n geometry: [80, 24],\\r\\n cursorBlink: false,\\r\\n cursorStyle: 'block',\\r\\n bellSound: BellSound,\\r\\n bellStyle: 'none',\\r\\n enableBold: true,\\r\\n fontFamily: 'courier-new, courier, monospace',\\r\\n fontSize: 15,\\r\\n lineHeight: 1.0,\\r\\n letterSpacing: 0,\\r\\n scrollback: 1000,\\r\\n screenKeys: false,\\r\\n debug: false,\\r\\n cancelEvents: false,\\r\\n disableStdin: false,\\r\\n useFlowControl: false,\\r\\n tabStopWidth: 8,\\r\\n theme: null\\r\\n // programFeatures: false,\\r\\n // focusKeys: false,\\r\\n};\\r\\n\\r\\nexport class Terminal extends EventEmitter implements ITerminal, IInputHandlingTerminal {\\r\\n public textarea: HTMLTextAreaElement;\\r\\n public element: HTMLElement;\\r\\n\\r\\n /**\\r\\n * The HTMLElement that the terminal is created in, set by Terminal.open.\\r\\n */\\r\\n private parent: HTMLElement;\\r\\n private context: Window;\\r\\n private document: Document;\\r\\n private body: HTMLBodyElement;\\r\\n private viewportScrollArea: HTMLElement;\\r\\n private viewportElement: HTMLElement;\\r\\n private helperContainer: HTMLElement;\\r\\n private compositionView: HTMLElement;\\r\\n private charSizeStyleElement: HTMLStyleElement;\\r\\n private bellAudioElement: HTMLAudioElement;\\r\\n private visualBellTimer: number;\\r\\n\\r\\n public browser: IBrowser = <any>Browser;\\r\\n\\r\\n public options: ITerminalOptions;\\r\\n private colors: any;\\r\\n\\r\\n // TODO: This can be changed to an enum or boolean, 0 and 1 seem to be the only options\\r\\n public cursorState: number;\\r\\n public cursorHidden: boolean;\\r\\n public convertEol: boolean;\\r\\n\\r\\n private sendDataQueue: string;\\r\\n private customKeyEventHandler: CustomKeyEventHandler;\\r\\n\\r\\n // modes\\r\\n public applicationKeypad: boolean;\\r\\n public applicationCursor: boolean;\\r\\n public originMode: boolean;\\r\\n public insertMode: boolean;\\r\\n public wraparoundMode: boolean; // defaults: xterm - true, vt100 - false\\r\\n\\r\\n // charset\\r\\n // The current charset\\r\\n public charset: Charset;\\r\\n public gcharset: number;\\r\\n public glevel: number;\\r\\n public charsets: Charset[];\\r\\n\\r\\n // mouse properties\\r\\n private decLocator: boolean; // This is unstable and never set\\r\\n public x10Mouse: boolean;\\r\\n public vt200Mouse: boolean;\\r\\n private vt300Mouse: boolean; // This is unstable and never set\\r\\n public normalMouse: boolean;\\r\\n public mouseEvents: boolean;\\r\\n public sendFocus: boolean;\\r\\n public utfMouse: boolean;\\r\\n public sgrMouse: boolean;\\r\\n public urxvtMouse: boolean;\\r\\n\\r\\n // misc\\r\\n private refreshStart: number;\\r\\n private refreshEnd: number;\\r\\n public savedCols: number;\\r\\n\\r\\n // stream\\r\\n private readable: boolean;\\r\\n private writable: boolean;\\r\\n\\r\\n public defAttr: number;\\r\\n public curAttr: number;\\r\\n\\r\\n public params: (string | number)[];\\r\\n public currentParam: string | number;\\r\\n public prefix: string;\\r\\n public postfix: string;\\r\\n\\r\\n // user input states\\r\\n public writeBuffer: string[];\\r\\n private writeInProgress: boolean;\\r\\n\\r\\n /**\\r\\n * Whether _xterm.js_ sent XOFF in order to catch up with the pty process.\\r\\n * This is a distinct state from writeStopped so that if the user requested\\r\\n * XOFF via ^S that it will not automatically resume when the writeBuffer goes\\r\\n * below threshold.\\r\\n */\\r\\n private xoffSentToCatchUp: boolean;\\r\\n\\r\\n /** Whether writing has been stopped as a result of XOFF */\\r\\n private writeStopped: boolean;\\r\\n\\r\\n // leftover surrogate high from previous write invocation\\r\\n private surrogate_high: string;\\r\\n\\r\\n // Store if user went browsing history in scrollback\\r\\n private userScrolling: boolean;\\r\\n\\r\\n private inputHandler: InputHandler;\\r\\n private parser: Parser;\\r\\n public renderer: IRenderer;\\r\\n public selectionManager: SelectionManager;\\r\\n public linkifier: ILinkifier;\\r\\n public buffers: BufferSet;\\r\\n public buffer: Buffer;\\r\\n public viewport: IViewport;\\r\\n private compositionHelper: ICompositionHelper;\\r\\n public charMeasure: CharMeasure;\\r\\n private _mouseZoneManager: IMouseZoneManager;\\r\\n public mouseHelper: MouseHelper;\\r\\n\\r\\n public cols: number;\\r\\n public rows: number;\\r\\n public geometry: [/*cols*/number, /*rows*/number];\\r\\n\\r\\n /**\\r\\n * Creates a new `Terminal` object.\\r\\n *\\r\\n * @param {object} options An object containing a set of options, the available options are:\\r\\n * - `cursorBlink` (boolean): Whether the terminal cursor blinks\\r\\n * - `cols` (number): The number of columns of the terminal (horizontal size)\\r\\n * - `rows` (number): The number of rows of the terminal (vertical size)\\r\\n *\\r\\n * @public\\r\\n * @class Xterm Xterm\\r\\n * @alias module:xterm/src/xterm\\r\\n */\\r\\n constructor(\\r\\n options: ITerminalOptions = {}\\r\\n ) {\\r\\n super();\\r\\n this.options = options;\\r\\n this.setup();\\r\\n }\\r\\n\\r\\n private setup(): void {\\r\\n Object.keys(DEFAULT_OPTIONS).forEach((key) => {\\r\\n if (this.options[key] == null) {\\r\\n this.options[key] = DEFAULT_OPTIONS[key];\\r\\n }\\r\\n // TODO: We should move away from duplicate options on the Terminal object\\r\\n this[key] = this.options[key];\\r\\n });\\r\\n\\r\\n // this.context = options.context || window;\\r\\n // this.document = options.document || document;\\r\\n // TODO: WHy not document.body?\\r\\n this.parent = document ? document.body : null;\\r\\n\\r\\n this.cols = this.options.cols || this.options.geometry[0];\\r\\n this.rows = this.options.rows || this.options.geometry[1];\\r\\n this.geometry = [this.cols, this.rows];\\r\\n\\r\\n if (this.options.handler) {\\r\\n this.on('data', this.options.handler);\\r\\n }\\r\\n\\r\\n this.cursorState = 0;\\r\\n this.cursorHidden = false;\\r\\n this.sendDataQueue = '';\\r\\n this.customKeyEventHandler = null;\\r\\n\\r\\n // modes\\r\\n this.applicationKeypad = false;\\r\\n this.applicationCursor = false;\\r\\n this.originMode = false;\\r\\n this.insertMode = false;\\r\\n this.wraparoundMode = true; // defaults: xterm - true, vt100 - false\\r\\n\\r\\n // charset\\r\\n this.charset = null;\\r\\n this.gcharset = null;\\r\\n this.glevel = 0;\\r\\n // TODO: Can this be just []?\\r\\n this.charsets = [null];\\r\\n\\r\\n this.readable = true;\\r\\n this.writable = true;\\r\\n\\r\\n this.defAttr = (0 << 18) | (257 << 9) | (256 << 0);\\r\\n this.curAttr = (0 << 18) | (257 << 9) | (256 << 0);\\r\\n\\r\\n this.params = [];\\r\\n this.currentParam = 0;\\r\\n this.prefix = '';\\r\\n this.postfix = '';\\r\\n\\r\\n // user input states\\r\\n this.writeBuffer = [];\\r\\n this.writeInProgress = false;\\r\\n\\r\\n this.xoffSentToCatchUp = false;\\r\\n this.writeStopped = false;\\r\\n this.surrogate_high = '';\\r\\n this.userScrolling = false;\\r\\n\\r\\n this.inputHandler = new InputHandler(this);\\r\\n this.parser = new Parser(this.inputHandler, this);\\r\\n // Reuse renderer if the Terminal is being recreated via a reset call.\\r\\n this.renderer = this.renderer || null;\\r\\n this.selectionManager = this.selectionManager || null;\\r\\n this.linkifier = this.linkifier || new Linkifier(this);\\r\\n this._mouseZoneManager = this._mouseZoneManager || null;\\r\\n\\r\\n // Create the terminal's buffers and set the current buffer\\r\\n this.buffers = new BufferSet(this);\\r\\n this.buffer = this.buffers.active; // Convenience shortcut;\\r\\n this.buffers.on('activate', (buffer: Buffer) => {\\r\\n this.buffer = buffer;\\r\\n });\\r\\n\\r\\n // Ensure the selection manager has the correct buffer\\r\\n if (this.selectionManager) {\\r\\n this.selectionManager.setBuffer(this.buffer);\\r\\n }\\r\\n }\\r\\n\\r\\n /**\\r\\n * back_color_erase feature for xterm.\\r\\n */\\r\\n public eraseAttr(): number {\\r\\n // if (this.is('screen')) return this.defAttr;\\r\\n return (this.defAttr & ~0x1ff) | (this.curAttr & 0x1ff);\\r\\n }\\r\\n\\r\\n /**\\r\\n * Focus the terminal. Delegates focus handling to the terminal's DOM element.\\r\\n */\\r\\n public focus(): void {\\r\\n this.textarea.focus();\\r\\n }\\r\\n\\r\\n public get isFocused(): boolean {\\r\\n return document.activeElement === this.textarea;\\r\\n }\\r\\n\\r\\n /**\\r\\n * Retrieves an option's value from the terminal.\\r\\n * @param {string} key The option key.\\r\\n */\\r\\n public getOption(key: string): any {\\r\\n if (!(key in DEFAULT_OPTIONS)) {\\r\\n throw new Error('No option with key \\\"' + key + '\\\"');\\r\\n }\\r\\n\\r\\n if (typeof this.options[key] !== 'undefined') {\\r\\n return this.options[key];\\r\\n }\\r\\n\\r\\n return this[key];\\r\\n }\\r\\n\\r\\n /**\\r\\n * Sets an option on the terminal.\\r\\n * @param {string} key The option key.\\r\\n * @param {any} value The option value.\\r\\n */\\r\\n public setOption(key: string, value: any): void {\\r\\n if (!(key in DEFAULT_OPTIONS)) {\\r\\n throw new Error('No option with key \\\"' + key + '\\\"');\\r\\n }\\r\\n switch (key) {\\r\\n case 'bellStyle':\\r\\n if (!value) {\\r\\n value = 'none';\\r\\n }\\r\\n break;\\r\\n case 'cursorStyle':\\r\\n if (!value) {\\r\\n value = 'block';\\r\\n }\\r\\n break;\\r\\n case 'lineHeight':\\r\\n if (value < 1) {\\r\\n console.warn(`${key} cannot be less than 1, value: ${value}`);\\r\\n return;\\r\\n }\\r\\n case 'tabStopWidth':\\r\\n if (value < 1) {\\r\\n console.warn(`${key} cannot be less than 1, value: ${value}`);\\r\\n return;\\r\\n }\\r\\n break;\\r\\n case 'theme':\\r\\n // If open has been called we do not want to set options.theme as the\\r\\n // source of truth is owned by the renderer.\\r\\n if (this.renderer) {\\r\\n this._setTheme(<ITheme>value);\\r\\n return;\\r\\n }\\r\\n break;\\r\\n case 'scrollback':\\r\\n if (value < 0) {\\r\\n console.warn(`${key} cannot be less than 0, value: ${value}`);\\r\\n return;\\r\\n }\\r\\n if (this.options[key] !== value) {\\r\\n const newBufferLength = this.rows + value;\\r\\n if (this.buffer.lines.length > newBufferLength) {\\r\\n const amountToTrim = this.buffer.lines.length - newBufferLength;\\r\\n const needsRefresh = (this.buffer.ydisp - amountToTrim < 0);\\r\\n this.buffer.lines.trimStart(amountToTrim);\\r\\n this.buffer.ybase = Math.max(this.buffer.ybase - amountToTrim, 0);\\r\\n this.buffer.ydisp = Math.max(this.buffer.ydisp - amountToTrim, 0);\\r\\n if (needsRefresh) {\\r\\n this.refresh(0, this.rows - 1);\\r\\n }\\r\\n }\\r\\n }\\r\\n break;\\r\\n }\\r\\n this[key] = value;\\r\\n this.options[key] = value;\\r\\n switch (key) {\\r\\n case 'fontFamily':\\r\\n case 'fontSize':\\r\\n // When the font changes the size of the cells may change which requires a renderer clear\\r\\n this.renderer.clear();\\r\\n this.charMeasure.measure(this.options);\\r\\n break;\\r\\n case 'enableBold':\\r\\n case 'letterSpacing':\\r\\n case 'lineHeight':\\r\\n // When the font changes the size of the cells may change which requires a renderer clear\\r\\n this.renderer.clear();\\r\\n this.renderer.onResize(this.cols, this.rows, false);\\r\\n this.refresh(0, this.rows - 1);\\r\\n // this.charMeasure.measure(this.options);\\r\\n case 'scrollback':\\r\\n this.buffers.resize(this.cols, this.rows);\\r\\n this.viewport.syncScrollArea();\\r\\n break;\\r\\n case 'tabStopWidth': this.buffers.setupTabStops(); break;\\r\\n case 'bellSound':\\r\\n case 'bellStyle': this.syncBellSound(); break;\\r\\n }\\r\\n // Inform renderer of changes\\r\\n if (this.renderer) {\\r\\n this.renderer.onOptionsChanged();\\r\\n }\\r\\n }\\r\\n\\r\\n /**\\r\\n * Binds the desired focus behavior on a given terminal object.\\r\\n */\\r\\n private _onTextAreaFocus(): void {\\r\\n if (this.sendFocus) {\\r\\n this.send(C0.ESC + '[I');\\r\\n }\\r\\n this.element.classList.add('focus');\\r\\n this.showCursor();\\r\\n this.emit('focus');\\r\\n };\\r\\n\\r\\n /**\\r\\n * Blur the terminal, calling the blur function on the terminal's underlying\\r\\n * textarea.\\r\\n */\\r\\n public blur(): void {\\r\\n return this.textarea.blur();\\r\\n }\\r\\n\\r\\n /**\\r\\n * Binds the desired blur behavior on a given terminal object.\\r\\n */\\r\\n private _onTextAreaBlur(): void {\\r\\n this.refresh(this.buffer.y, this.buffer.y);\\r\\n if (this.sendFocus) {\\r\\n this.send(C0.ESC + '[O');\\r\\n }\\r\\n this.element.classList.remove('focus');\\r\\n this.emit('blur');\\r\\n }\\r\\n\\r\\n /**\\r\\n * Initialize default behavior\\r\\n */\\r\\n private initGlobal(): void {\\r\\n this.bindKeys();\\r\\n\\r\\n // Bind clipboard functionality\\r\\n on(this.element, 'copy', (event: ClipboardEvent) => {\\r\\n // If mouse events are active it means the selection manager is disabled and\\r\\n // copy should be handled by the host program.\\r\\n if (!this.hasSelection()) {\\r\\n return;\\r\\n }\\r\\n copyHandler(event, this, this.selectionManager);\\r\\n });\\r\\n const pasteHandlerWrapper = event => pasteHandler(event, this);\\r\\n on(this.textarea, 'paste', pasteHandlerWrapper);\\r\\n on(this.element, 'paste', pasteHandlerWrapper);\\r\\n\\r\\n // Handle right click context menus\\r\\n if (Browser.isFirefox) {\\r\\n // Firefox doesn't appear to fire the contextmenu event on right click\\r\\n on(this.element, 'mousedown', (event: MouseEvent) => {\\r\\n if (event.button === 2) {\\r\\n rightClickHandler(event, this.textarea, this.selectionManager);\\r\\n }\\r\\n });\\r\\n } else {\\r\\n on(this.element, 'contextmenu', (event: MouseEvent) => {\\r\\n rightClickHandler(event, this.textarea, this.selectionManager);\\r\\n });\\r\\n }\\r\\n\\r\\n // Move the textarea under the cursor when middle clicking on Linux to ensure\\r\\n // middle click to paste selection works. This only appears to work in Chrome\\r\\n // at the time is writing.\\r\\n if (Browser.isLinux) {\\r\\n // Use auxclick event over mousedown the latter doesn't seem to work. Note\\r\\n // that the regular click event doesn't fire for the middle mouse button.\\r\\n on(this.element, 'auxclick', (event: MouseEvent) => {\\r\\n if (event.button === 1) {\\r\\n moveTextAreaUnderMouseCursor(event, this.textarea);\\r\\n }\\r\\n });\\r\\n }\\r\\n }\\r\\n\\r\\n /**\\r\\n * Apply key handling to the terminal\\r\\n */\\r\\n private bindKeys(): void {\\r\\n const self = this;\\r\\n on(this.element, 'keydown', function (ev: KeyboardEvent): void {\\r\\n if (document.activeElement !== this) {\\r\\n return;\\r\\n }\\r\\n self._keyDown(ev);\\r\\n }, true);\\r\\n\\r\\n on(this.element, 'keypress', function (ev: KeyboardEvent): void {\\r\\n if (document.activeElement !== this) {\\r\\n return;\\r\\n }\\r\\n self._keyPress(ev);\\r\\n }, true);\\r\\n\\r\\n on(this.element, 'keyup', (ev: KeyboardEvent) => {\\r\\n if (!wasMondifierKeyOnlyEvent(ev)) {\\r\\n this.focus();\\r\\n }\\r\\n }, true);\\r\\n\\r\\n on(this.textarea, 'keydown', (ev: KeyboardEvent) => {\\r\\n this._keyDown(ev);\\r\\n }, true);\\r\\n\\r\\n on(this.textarea, 'keypress', (ev: KeyboardEvent) => {\\r\\n this._keyPress(ev);\\r\\n // Truncate the textarea's value, since it is not needed\\r\\n this.textarea.value = '';\\r\\n }, true);\\r\\n\\r\\n on(this.textarea, 'compositionstart', () => this.compositionHelper.compositionstart());\\r\\n on(this.textarea, 'compositionupdate', (e: CompositionEvent) => this.compositionHelper.compositionupdate(e));\\r\\n on(this.textarea, 'compositionend', () => this.compositionHelper.compositionend());\\r\\n this.on('refresh', () => this.compositionHelper.updateCompositionElements());\\r\\n this.on('refresh', (data) => this.queueLinkification(data.start, data.end));\\r\\n }\\r\\n\\r\\n /**\\r\\n * Opens the terminal within an element.\\r\\n *\\r\\n * @param {HTMLElement} parent The element to create the terminal within.\\r\\n */\\r\\n public open(parent: HTMLElement): void {\\r\\n let i = 0;\\r\\n let div;\\r\\n\\r\\n this.parent = parent || this.parent;\\r\\n\\r\\n if (!this.parent) {\\r\\n throw new Error('Terminal requires a parent element.');\\r\\n }\\r\\n\\r\\n // Grab global elements\\r\\n this.context = this.parent.ownerDocument.defaultView;\\r\\n this.document = this.parent.ownerDocument;\\r\\n this.body = <HTMLBodyElement>this.document.body;\\r\\n\\r\\n initializeCharAtlas(this.document);\\r\\n\\r\\n // Create main element container\\r\\n this.element = this.document.createElement('div');\\r\\n this.element.classList.add('terminal');\\r\\n this.element.classList.add('xterm');\\r\\n\\r\\n this.element.setAttribute('tabindex', '0');\\r\\n\\r\\n this.viewportElement = document.createElement('div');\\r\\n this.viewportElement.classList.add('xterm-viewport');\\r\\n this.element.appendChild(this.viewportElement);\\r\\n this.viewportScrollArea = document.createElement('div');\\r\\n this.viewportScrollArea.classList.add('xterm-scroll-area');\\r\\n this.viewportElement.appendChild(this.viewportScrollArea);\\r\\n\\r\\n // preload audio\\r\\n this.syncBellSound();\\r\\n\\r\\n this._mouseZoneManager = new MouseZoneManager(this);\\r\\n this.on('scroll', () => this._mouseZoneManager.clearAll());\\r\\n this.linkifier.attachToDom(this._mouseZoneManager);\\r\\n\\r\\n // Create the container that will hold helpers like the textarea for\\r\\n // capturing DOM Events. Then produce the helpers.\\r\\n this.helperContainer = document.createElement('div');\\r\\n this.helperContainer.classList.add('xterm-helpers');\\r\\n // TODO: This should probably be inserted once it's filled to prevent an additional layout\\r\\n this.element.appendChild(this.helperContainer);\\r\\n this.textarea = document.createElement('textarea');\\r\\n this.textarea.classList.add('xterm-helper-textarea');\\r\\n this.textarea.setAttribute('autocorrect', 'off');\\r\\n this.textarea.setAttribute('autocapitalize', 'off');\\r\\n this.textarea.setAttribute('spellcheck', 'false');\\r\\n this.textarea.tabIndex = 0;\\r\\n this.textarea.addEventListener('focus', () => this._onTextAreaFocus());\\r\\n this.textarea.addEventListener('blur', () => this._onTextAreaBlur());\\r\\n this.helperContainer.appendChild(this.textarea);\\r\\n\\r\\n this.compositionView = document.createElement('div');\\r\\n this.compositionView.classList.add('composition-view');\\r\\n this.compositionHelper = new CompositionHelper(this.textarea, this.compositionView, this);\\r\\n this.helperContainer.appendChild(this.compositionView);\\r\\n\\r\\n this.charSizeStyleElement = document.createElement('style');\\r\\n this.helperContainer.appendChild(this.charSizeStyleElement);\\r\\n\\r\\n this.parent.appendChild(this.element);\\r\\n\\r\\n this.charMeasure = new CharMeasure(document, this.helperContainer);\\r\\n\\r\\n this.renderer = new Renderer(this, this.options.theme);\\r\\n this.options.theme = null;\\r\\n this.viewport = new Viewport(this, this.viewportElement, this.viewportScrollArea, this.charMeasure);\\r\\n this.viewport.onThemeChanged(this.renderer.colorManager.colors);\\r\\n\\r\\n this.on('cursormove', () => this.renderer.onCursorMove());\\r\\n this.on('resize', () => this.renderer.onResize(this.cols, this.rows, false));\\r\\n this.on('blur', () => this.renderer.onBlur());\\r\\n this.on('focus', () => this.renderer.onFocus());\\r\\n window.addEventListener('resize', () => this.renderer.onWindowResize(window.devicePixelRatio));\\r\\n this.charMeasure.on('charsizechanged', () => this.renderer.onResize(this.cols, this.rows, true));\\r\\n this.renderer.on('resize', (dimensions) => this.viewport.syncScrollArea());\\r\\n\\r\\n this.selectionManager = new SelectionManager(this, this.buffer, this.charMeasure);\\r\\n this.element.addEventListener('mousedown', (e: MouseEvent) => this.selectionManager.onMouseDown(e));\\r\\n this.selectionManager.on('refresh', data => this.renderer.onSelectionChanged(data.start, data.end));\\r\\n this.selectionManager.on('newselection', text => {\\r\\n // If there's a new selection, put it into the textarea, focus and select it\\r\\n // in order to register it as a selection on the OS. This event is fired\\r\\n // only on Linux to enable middle click to paste selection.\\r\\n this.textarea.value = text;\\r\\n this.textarea.focus();\\r\\n this.textarea.select();\\r\\n });\\r\\n this.on('scroll', () => {\\r\\n this.viewport.syncScrollArea();\\r\\n this.selectionManager.refresh();\\r\\n });\\r\\n this.viewportElement.addEventListener('scroll', () => this.selectionManager.refresh());\\r\\n\\r\\n this.mouseHelper = new MouseHelper(this.renderer);\\r\\n\\r\\n // Measure the character size\\r\\n this.charMeasure.measure(this.options);\\r\\n\\r\\n // Setup loop that draws to screen\\r\\n this.refresh(0, this.rows - 1);\\r\\n\\r\\n // Initialize global actions that need to be taken on the document.\\r\\n this.initGlobal();\\r\\n\\r\\n // Listen for mouse events and translate\\r\\n // them into terminal mouse protocols.\\r\\n this.bindMouse();\\r\\n }\\r\\n\\r\\n /**\\r\\n * Sets the theme on the renderer. The renderer must have been initialized.\\r\\n * @param theme The theme to ste.\\r\\n */\\r\\n private _setTheme(theme: ITheme): void {\\r\\n const colors = this.renderer.setTheme(theme);\\r\\n if (this.viewport) {\\r\\n this.viewport.onThemeChanged(colors);\\r\\n }\\r\\n }\\r\\n\\r\\n /**\\r\\n * Attempts to load an add-on using CommonJS or RequireJS (whichever is available).\\r\\n * @param {string} addon The name of the addon to load\\r\\n * @static\\r\\n */\\r\\n public static loadAddon(addon: string, callback?: Function): boolean | any {\\r\\n // TODO: Improve return type and documentation\\r\\n if (typeof exports === 'object' && typeof module === 'object') {\\r\\n // CommonJS\\r\\n return require('./addons/' + addon + '/' + addon);\\r\\n } else if (typeof define === 'function') {\\r\\n // RequireJS\\r\\n return (<any>require)(['./addons/' + addon + '/' + addon], callback);\\r\\n } else {\\r\\n console.error('Cannot load a module without a CommonJS or RequireJS environment.');\\r\\n return false;\\r\\n }\\r\\n }\\r\\n\\r\\n /**\\r\\n * XTerm mouse events\\r\\n * http://invisible-island.net/xterm/ctlseqs/ctlseqs.html#Mouse%20Tracking\\r\\n * To better understand these\\r\\n * the xterm code is very helpful:\\r\\n * Relevant files:\\r\\n * button.c, charproc.c, misc.c\\r\\n * Relevant functions in xterm/button.c:\\r\\n * BtnCode, EmitButtonCode, EditorButton, SendMousePosition\\r\\n */\\r\\n public bindMouse(): void {\\r\\n const el = this.element;\\r\\n const self = this;\\r\\n let pressed = 32;\\r\\n\\r\\n // mouseup, mousedown, wheel\\r\\n // left click: ^[[M 3<^[[M#3<\\r\\n // wheel up: ^[[M`3>\\r\\n function sendButton(ev: MouseEvent | WheelEvent): void {\\r\\n let button;\\r\\n let pos;\\r\\n\\r\\n // get the xterm-style button\\r\\n button = getButton(ev);\\r\\n\\r\\n // get mouse coordinates\\r\\n pos = self.mouseHelper.getRawByteCoords(ev, self.element, self.charMeasure, self.options.lineHeight, self.cols, self.rows);\\r\\n if (!pos) return;\\r\\n\\r\\n sendEvent(button, pos);\\r\\n\\r\\n switch ((<any>ev).overrideType || ev.type) {\\r\\n case 'mousedown':\\r\\n pressed = button;\\r\\n break;\\r\\n case 'mouseup':\\r\\n // keep it at the left\\r\\n // button, just in case.\\r\\n pressed = 32;\\r\\n break;\\r\\n case 'wheel':\\r\\n // nothing. don't\\r\\n // interfere with\\r\\n // `pressed`.\\r\\n break;\\r\\n }\\r\\n }\\r\\n\\r\\n // motion example of a left click:\\r\\n // ^[[M 3<^[[M@4<^[[M@5<^[[M@6<^[[M@7<^[[M#7<\\r\\n function sendMove(ev: MouseEvent): void {\\r\\n let button = pressed;\\r\\n let pos = self.mouseHelper.getRawByteCoords(ev, self.element, self.charMeasure, self.options.lineHeight, self.cols, self.rows);\\r\\n if (!pos) return;\\r\\n\\r\\n // buttons marked as motions\\r\\n // are incremented by 32\\r\\n button += 32;\\r\\n\\r\\n sendEvent(button, pos);\\r\\n }\\r\\n\\r\\n // encode button and\\r\\n // position to characters\\r\\n function encode(data: number[], ch: number): void {\\r\\n if (!self.utfMouse) {\\r\\n if (ch === 255) {\\r\\n data.push(0);\\r\\n return;\\r\\n }\\r\\n if (ch > 127) ch = 127;\\r\\n data.push(ch);\\r\\n } else {\\r\\n if (ch === 2047) {\\r\\n data.push(0);\\r\\n return;\\r\\n }\\r\\n if (ch < 127) {\\r\\n data.push(ch);\\r\\n } else {\\r\\n if (ch > 2047) ch = 2047;\\r\\n data.push(0xC0 | (ch >> 6));\\r\\n data.push(0x80 | (ch & 0x3F));\\r\\n }\\r\\n }\\r\\n }\\r\\n\\r\\n // send a mouse event:\\r\\n // regular/utf8: ^[[M Cb Cx Cy\\r\\n // urxvt: ^[[ Cb ; Cx ; Cy M\\r\\n // sgr: ^[[ Cb ; Cx ; Cy M/m\\r\\n // vt300: ^[[ 24(1/3/5)~ [ Cx , Cy ] \\\\r\\r\\n // locator: CSI P e ; P b ; P r ; P c ; P p & w\\r\\n function sendEvent(button: number, pos: {x: number, y: number}): void {\\r\\n // self.emit('mouse', {\\r\\n // x: pos.x - 32,\\r\\n // y: pos.x - 32,\\r\\n // button: button\\r\\n // });\\r\\n\\r\\n if (self.vt300Mouse) {\\r\\n // NOTE: Unstable.\\r\\n // http://www.vt100.net/docs/vt3xx-gp/chapter15.html\\r\\n button &= 3;\\r\\n pos.x -= 32;\\r\\n pos.y -= 32;\\r\\n let data = C0.ESC + '[24';\\r\\n if (button === 0) data += '1';\\r\\n else if (button === 1) data += '3';\\r\\n else if (button === 2) data += '5';\\r\\n else if (button === 3) return;\\r\\n else data += '0';\\r\\n data += '~[' + pos.x + ',' + pos.y + ']\\\\r';\\r\\n self.send(data);\\r\\n return;\\r\\n }\\r\\n\\r\\n if (self.decLocator) {\\r\\n // NOTE: Unstable.\\r\\n button &= 3;\\r\\n pos.x -= 32;\\r\\n pos.y -= 32;\\r\\n if (button === 0) button = 2;\\r\\n else if (button === 1) button = 4;\\r\\n else if (button === 2) button = 6;\\r\\n else if (button === 3) button = 3;\\r\\n self.send(C0.ESC + '['\\r\\n + button\\r\\n + ';'\\r\\n + (button === 3 ? 4 : 0)\\r\\n + ';'\\r\\n + pos.y\\r\\n + ';'\\r\\n + pos.x\\r\\n + ';'\\r\\n // Not sure what page is meant to be\\r\\n + (<any>pos).page || 0\\r\\n + '&w');\\r\\n return;\\r\\n }\\r\\n\\r\\n if (self.urxvtMouse) {\\r\\n pos.x -= 32;\\r\\n pos.y -= 32;\\r\\n pos.x++;\\r\\n pos.y++;\\r\\n self.send(C0.ESC + '[' + button + ';' + pos.x + ';' + pos.y + 'M');\\r\\n return;\\r\\n }\\r\\n\\r\\n if (self.sgrMouse) {\\r\\n pos.x -= 32;\\r\\n pos.y -= 32;\\r\\n self.send(C0.ESC + '[<'\\r\\n + (((button & 3) === 3 ? button & ~3 : button) - 32)\\r\\n + ';'\\r\\n + pos.x\\r\\n + ';'\\r\\n + pos.y\\r\\n + ((button & 3) === 3 ? 'm' : 'M'));\\r\\n return;\\r\\n }\\r\\n\\r\\n let data: number[] = [];\\r\\n\\r\\n encode(data, button);\\r\\n encode(data, pos.x);\\r\\n encode(data, pos.y);\\r\\n\\r\\n self.send(C0.ESC + '[M' + String.fromCharCode.apply(String, data));\\r\\n }\\r\\n\\r\\n function getButton(ev: MouseEvent): number {\\r\\n let button;\\r\\n let shift;\\r\\n let meta;\\r\\n let ctrl;\\r\\n let mod;\\r\\n\\r\\n // two low bits:\\r\\n // 0 = left\\r\\n // 1 = middle\\r\\n // 2 = right\\r\\n // 3 = release\\r\\n // wheel up/down:\\r\\n // 1, and 2 - with 64 added\\r\\n switch ((<any>ev).overrideType || ev.type) {\\r\\n case 'mousedown':\\r\\n button = ev.button != null\\r\\n ? +ev.button\\r\\n : ev.which != null\\r\\n ? ev.which - 1\\r\\n : null;\\r\\n\\r\\n if (Browser.isMSIE) {\\r\\n button = button === 1 ? 0 : button === 4 ? 1 : button;\\r\\n }\\r\\n break;\\r\\n case 'mouseup':\\r\\n button = 3;\\r\\n break;\\r\\n case 'DOMMouseScroll':\\r\\n button = ev.detail < 0\\r\\n ? 64\\r\\n : 65;\\r\\n break;\\r\\n case 'wheel':\\r\\n button = (<WheelEvent>ev).wheelDeltaY > 0\\r\\n ? 64\\r\\n : 65;\\r\\n break;\\r\\n }\\r\\n\\r\\n // next three bits are the modifiers:\\r\\n // 4 = shift, 8 = meta, 16 = control\\r\\n shift = ev.shiftKey ? 4 : 0;\\r\\n meta = ev.metaKey ? 8 : 0;\\r\\n ctrl = ev.ctrlKey ? 16 : 0;\\r\\n mod = shift | meta | ctrl;\\r\\n\\r\\n // no mods\\r\\n if (self.vt200Mouse) {\\r\\n // ctrl only\\r\\n mod &= ctrl;\\r\\n } else if (!self.normalMouse) {\\r\\n mod = 0;\\r\\n }\\r\\n\\r\\n // increment to SP\\r\\n button = (32 + (mod << 2)) + button;\\r\\n\\r\\n return button;\\r\\n }\\r\\n\\r\\n on(el, 'mousedown', (ev: MouseEvent) => {\\r\\n\\r\\n // Prevent the focus on the textarea from getting lost\\r\\n // and make sure we get focused on mousedown\\r\\n ev.preventDefault();\\r\\n this.focus();\\r\\n\\r\\n if (!this.mouseEvents) return;\\r\\n\\r\\n // send the button\\r\\n sendButton(ev);\\r\\n\\r\\n // fix for odd bug\\r\\n // if (this.vt200Mouse && !this.normalMouse) {\\r\\n if (this.vt200Mouse) {\\r\\n (<any>ev).overrideType = 'mouseup';\\r\\n sendButton(ev);\\r\\n return this.cancel(ev);\\r\\n }\\r\\n\\r\\n // bind events\\r\\n if (this.normalMouse) on(this.document, 'mousemove', sendMove);\\r\\n\\r\\n // x10 compatibility mode can't send button releases\\r\\n if (!this.x10Mouse) {\\r\\n const handler = (ev: MouseEvent) => {\\r\\n sendButton(ev);\\r\\n // TODO: Seems dangerous calling this on document?\\r\\n if (this.normalMouse) off(this.document, 'mousemove', sendMove);\\r\\n off(this.document, 'mouseup', handler);\\r\\n return this.cancel(ev);\\r\\n };\\r\\n // TODO: Seems dangerous calling this on document?\\r\\n on(this.document, 'mouseup', handler);\\r\\n }\\r\\n\\r\\n return this.cancel(ev);\\r\\n });\\r\\n\\r\\n // if (this.normalMouse) {\\r\\n // on(this.document, 'mousemove', sendMove);\\r\\n // }\\r\\n\\r\\n on(el, 'wheel', (ev: WheelEvent) => {\\r\\n if (!this.mouseEvents) return;\\r\\n if (this.x10Mouse || this.vt300Mouse || this.decLocator) return;\\r\\n sendButton(ev);\\r\\n ev.preventDefault();\\r\\n });\\r\\n\\r\\n // allow wheel scrolling in\\r\\n // the shell for example\\r\\n on(el, 'wheel', (ev: WheelEvent) => {\\r\\n if (this.mouseEvents) return;\\r\\n this.viewport.onWheel(ev);\\r\\n return this.cancel(ev);\\r\\n });\\r\\n\\r\\n on(el, 'touchstart', (ev: TouchEvent) => {\\r\\n if (this.mouseEvents) return;\\r\\n this.viewport.onTouchStart(ev);\\r\\n return this.cancel(ev);\\r\\n });\\r\\n\\r\\n on(el, 'touchmove', (ev: TouchEvent) => {\\r\\n if (this.mouseEvents) return;\\r\\n this.viewport.onTouchMove(ev);\\r\\n return this.cancel(ev);\\r\\n });\\r\\n }\\r\\n\\r\\n /**\\r\\n * Destroys the terminal.\\r\\n */\\r\\n public destroy(): void {\\r\\n super.destroy();\\r\\n this.readable = false;\\r\\n this.writable = false;\\r\\n this.handler = () => {};\\r\\n this.write = () => {};\\r\\n if (this.element && this.element.parentNode) {\\r\\n this.element.parentNode.removeChild(this.element);\\r\\n }\\r\\n // this.emit('close');\\r\\n }\\r\\n\\r\\n /**\\r\\n * Tells the renderer to refresh terminal content between two rows (inclusive) at the next\\r\\n * opportunity.\\r\\n * @param {number} start The row to start from (between 0 and this.rows - 1).\\r\\n * @param {number} end The row to end at (between start and this.rows - 1).\\r\\n */\\r\\n public refresh(start: number, end: number): void {\\r\\n if (this.renderer) {\\r\\n this.renderer.queueRefresh(start, end);\\r\\n }\\r\\n }\\r\\n\\r\\n /**\\r\\n * Queues linkification for the specified rows.\\r\\n * @param {number} start The row to start from (between 0 and this.rows - 1).\\r\\n * @param {number} end The row to end at (between start and this.rows - 1).\\r\\n */\\r\\n private queueLinkification(start: number, end: number): void {\\r\\n if (this.linkifier) {\\r\\n this.linkifier.linkifyRows(start, end);\\r\\n }\\r\\n }\\r\\n\\r\\n /**\\r\\n * Display the cursor element\\r\\n */\\r\\n public showCursor(): void {\\r\\n if (!this.cursorState) {\\r\\n this.cursorState = 1;\\r\\n this.refresh(this.buffer.y, this.buffer.y);\\r\\n }\\r\\n }\\r\\n\\r\\n /**\\r\\n * Scroll the terminal down 1 row, creating a blank line.\\r\\n * @param isWrapped Whether the new line is wrapped from the previous line.\\r\\n */\\r\\n public scroll(isWrapped?: boolean): void {\\r\\n const newLine = this.blankLine(undefined, isWrapped);\\r\\n const topRow = this.buffer.ybase + this.buffer.scrollTop;\\r\\n let bottomRow = this.buffer.ybase + this.buffer.scrollBottom;\\r\\n\\r\\n if (this.buffer.scrollTop === 0) {\\r\\n // Determine whether the buffer is going to be trimmed after insertion.\\r\\n const willBufferBeTrimmed = this.buffer.lines.length === this.buffer.lines.maxLength;\\r\\n\\r\\n // Insert the line using the fastest method\\r\\n if (bottomRow === this.buffer.lines.length - 1) {\\r\\n this.buffer.lines.push(newLine);\\r\\n } else {\\r\\n this.buffer.lines.splice(bottomRow + 1, 0, newLine);\\r\\n }\\r\\n\\r\\n // Only adjust ybase and ydisp when the buffer is not trimmed\\r\\n if (!willBufferBeTrimmed) {\\r\\n this.buffer.ybase++;\\r\\n // Only scroll the ydisp with ybase if the user has not scrolled up\\r\\n if (!this.userScrolling) {\\r\\n this.buffer.ydisp++;\\r\\n }\\r\\n } else {\\r\\n // When the buffer is full and the user has scrolled up, keep the text\\r\\n // stable unless ydisp is right at the top\\r\\n if (this.userScrolling) {\\r\\n this.buffer.ydisp = Math.max(this.buffer.ydisp - 1, 0);\\r\\n }\\r\\n }\\r\\n } else {\\r\\n // scrollTop is non-zero which means no line will be going to the\\r\\n // scrollback, instead we can just shift them in-place.\\r\\n const scrollRegionHeight = bottomRow - topRow + 1/*as it's zero-based*/;\\r\\n this.buffer.lines.shiftElements(topRow + 1, scrollRegionHeight - 1, -1);\\r\\n this.buffer.lines.set(bottomRow, newLine);\\r\\n }\\r\\n\\r\\n // Move the viewport to the bottom of the buffer unless the user is\\r\\n // scrolling.\\r\\n if (!this.userScrolling) {\\r\\n this.buffer.ydisp = this.buffer.ybase;\\r\\n }\\r\\n\\r\\n // Flag rows that need updating\\r\\n this.updateRange(this.buffer.scrollTop);\\r\\n this.updateRange(this.buffer.scrollBottom);\\r\\n\\r\\n /**\\r\\n * This event is emitted whenever the terminal is scrolled.\\r\\n * The one parameter passed is the new y display position.\\r\\n *\\r\\n * @event scroll\\r\\n */\\r\\n this.emit('scroll', this.buffer.ydisp);\\r\\n }\\r\\n\\r\\n /**\\r\\n * Scroll the display of the terminal\\r\\n * @param {number} disp The number of lines to scroll down (negative scroll up).\\r\\n * @param {boolean} suppressScrollEvent Don't emit the scroll event as scrollDisp. This is used\\r\\n * to avoid unwanted events being handled by the viewport when the event was triggered from the\\r\\n * viewport originally.\\r\\n */\\r\\n public scrollDisp(disp: number, suppressScrollEvent?: boolean): void {\\r\\n if (disp < 0) {\\r\\n if (this.buffer.ydisp === 0) {\\r\\n return;\\r\\n }\\r\\n this.userScrolling = true;\\r\\n } else if (disp + this.buffer.ydisp >= this.buffer.ybase) {\\r\\n this.userScrolling = false;\\r\\n }\\r\\n\\r\\n const oldYdisp = this.buffer.ydisp;\\r\\n this.buffer.ydisp = Math.max(Math.min(this.buffer.ydisp + disp, this.buffer.ybase), 0);\\r\\n\\r\\n // No change occurred, don't trigger scroll/refresh\\r\\n if (oldYdisp === this.buffer.ydisp) {\\r\\n return;\\r\\n }\\r\\n\\r\\n if (!suppressScrollEvent) {\\r\\n this.emit('scroll', this.buffer.ydisp);\\r\\n }\\r\\n\\r\\n this.refresh(0, this.rows - 1);\\r\\n }\\r\\n\\r\\n /**\\r\\n * Scroll the display of the terminal by a number of pages.\\r\\n * @param {number} pageCount The number of pages to scroll (negative scrolls up).\\r\\n */\\r\\n public scrollPages(pageCount: number): void {\\r\\n this.scrollDisp(pageCount * (this.rows - 1));\\r\\n }\\r\\n\\r\\n /**\\r\\n * Scrolls the display of the terminal to the top.\\r\\n */\\r\\n public scrollToTop(): void {\\r\\n this.scrollDisp(-this.buffer.ydisp);\\r\\n }\\r\\n\\r\\n /**\\r\\n * Scrolls the display of the terminal to the bottom.\\r\\n */\\r\\n public scrollToBottom(): void {\\r\\n this.scrollDisp(this.buffer.ybase - this.buffer.ydisp);\\r\\n }\\r\\n\\r\\n /**\\r\\n * Writes text to the terminal.\\r\\n * @param {string} data The text to write to the terminal.\\r\\n */\\r\\n public write(data: string): void {\\r\\n this.writeBuffer.push(data);\\r\\n\\r\\n // Send XOFF to pause the pty process if the write buffer becomes too large so\\r\\n // xterm.js can catch up before more data is sent. This is necessary in order\\r\\n // to keep signals such as ^C responsive.\\r\\n if (this.options.useFlowControl && !this.xoffSentToCatchUp && this.writeBuffer.length >= WRITE_BUFFER_PAUSE_THRESHOLD) {\\r\\n // XOFF - stop pty pipe\\r\\n // XON will be triggered by emulator before processing data chunk\\r\\n this.send(C0.DC3);\\r\\n this.xoffSentToCatchUp = true;\\r\\n }\\r\\n\\r\\n if (!this.writeInProgress && this.writeBuffer.length > 0) {\\r\\n // Kick off a write which will write all data in sequence recursively\\r\\n this.writeInProgress = true;\\r\\n // Kick off an async innerWrite so more writes can come in while processing data\\r\\n setTimeout(() => {\\r\\n this.innerWrite();\\r\\n });\\r\\n }\\r\\n }\\r\\n\\r\\n private innerWrite(): void {\\r\\n const writeBatch = this.writeBuffer.splice(0, WRITE_BATCH_SIZE);\\r\\n while (writeBatch.length > 0) {\\r\\n const data = writeBatch.shift();\\r\\n\\r\\n // If XOFF was sent in order to catch up with the pty process, resume it if\\r\\n // the writeBuffer is empty to allow more data to come in.\\r\\n if (this.xoffSentToCatchUp && writeBatch.length === 0 && this.writeBuffer.length === 0) {\\r\\n this.send(C0.DC1);\\r\\n this.xoffSentToCatchUp = false;\\r\\n }\\r\\n\\r\\n this.refreshStart = this.buffer.y;\\r\\n this.refreshEnd = this.buffer.y;\\r\\n\\r\\n // HACK: Set the parser state based on it's state at the time of return.\\r\\n // This works around the bug #662 which saw the parser state reset in the\\r\\n // middle of parsing escape sequence in two chunks. For some reason the\\r\\n // state of the parser resets to 0 after exiting parser.parse. This change\\r\\n // just sets the state back based on the correct return statement.\\r\\n const state = this.parser.parse(data);\\r\\n this.parser.setState(state);\\r\\n\\r\\n this.updateRange(this.buffer.y);\\r\\n this.refresh(this.refreshStart, this.refreshEnd);\\r\\n }\\r\\n if (this.writeBuffer.length > 0) {\\r\\n // Allow renderer to catch up before processing the next batch\\r\\n setTimeout(() => this.innerWrite(), 0);\\r\\n } else {\\r\\n this.writeInProgress = false;\\r\\n }\\r\\n }\\r\\n\\r\\n /**\\r\\n * Writes text to the terminal, followed by a break line character (\\\\n).\\r\\n * @param {string} data The text to write to the terminal.\\r\\n */\\r\\n public writeln(data: string): void {\\r\\n this.write(data + '\\\\r\\\\n');\\r\\n }\\r\\n\\r\\n /**\\r\\n * Attaches a custom key event handler which is run before keys are processed,\\r\\n * giving consumers of xterm.js ultimate control as to what keys should be\\r\\n * processed by the terminal and what keys should not.\\r\\n * @param customKeyEventHandler The custom KeyboardEvent handler to attach.\\r\\n * This is a function that takes a KeyboardEvent, allowing consumers to stop\\r\\n * propogation and/or prevent the default action. The function returns whether\\r\\n * the event should be processed by xterm.js.\\r\\n */\\r\\n public attachCustomKeyEventHandler(customKeyEventHandler: CustomKeyEventHandler): void {\\r\\n this.customKeyEventHandler = customKeyEventHandler;\\r\\n }\\r\\n\\r\\n /**\\r\\n * Attaches a http(s) link handler, forcing web links to behave differently to\\r\\n * regular <a> tags. This will trigger a refresh as links potentially need to be\\r\\n * reconstructed. Calling this with null will remove the handler.\\r\\n * @param handler The handler callback function.\\r\\n */\\r\\n public setHypertextLinkHandler(handler: LinkMatcherHandler): void {\\r\\n if (!this.linkifier) {\\r\\n throw new Error('Cannot attach a hypertext link handler before Terminal.open is called');\\r\\n }\\r\\n this.linkifier.setHypertextLinkHandler(handler);\\r\\n // Refresh to force links to refresh\\r\\n this.refresh(0, this.rows - 1);\\r\\n }\\r\\n\\r\\n /**\\r\\n * Attaches a validation callback for hypertext links. This is useful to use\\r\\n * validation logic or to do something with the link's element and url.\\r\\n * @param callback The callback to use, this can\\r\\n * be cleared with null.\\r\\n */\\r\\n public setHypertextValidationCallback(callback: LinkMatcherValidationCallback): void {\\r\\n if (!this.linkifier) {\\r\\n throw new Error('Cannot attach a hypertext validation callback before Terminal.open is called');\\r\\n }\\r\\n this.linkifier.setHypertextValidationCallback(callback);\\r\\n // // Refresh to force links to refresh\\r\\n this.refresh(0, this.rows - 1);\\r\\n }\\r\\n\\r\\n /**\\r\\n * Registers a link matcher, allowing custom link patterns to be matched and\\r\\n * handled.\\r\\n * @param regex The regular expression to search for, specifically\\r\\n * this searches the textContent of the rows. You will want to use \\\\s to match\\r\\n * a space ' ' character for example.\\r\\n * @param handler The callback when the link is called.\\r\\n * @param options Options for the link matcher.\\r\\n * @return The ID of the new matcher, this can be used to deregister.\\r\\n */\\r\\n public registerLinkMatcher(regex: RegExp, handler: LinkMatcherHandler, options?: ILinkMatcherOptions): number {\\r\\n if (this.linkifier) {\\r\\n const matcherId = this.linkifier.registerLinkMatcher(regex, handler, options);\\r\\n this.refresh(0, this.rows - 1);\\r\\n return matcherId;\\r\\n }\\r\\n return 0;\\r\\n }\\r\\n\\r\\n /**\\r\\n * Deregisters a link matcher if it has been registered.\\r\\n * @param matcherId The link matcher's ID (returned after register)\\r\\n */\\r\\n public deregisterLinkMatcher(matcherId: number): void {\\r\\n if (this.linkifier) {\\r\\n if (this.linkifier.deregisterLinkMatcher(matcherId)) {\\r\\n this.refresh(0, this.rows - 1);\\r\\n }\\r\\n }\\r\\n }\\r\\n\\r\\n /**\\r\\n * Gets whether the terminal has an active selection.\\r\\n */\\r\\n public hasSelection(): boolean {\\r\\n return this.selectionManager ? this.selectionManager.hasSelection : false;\\r\\n }\\r\\n\\r\\n /**\\r\\n * Gets the terminal's current selection, this is useful for implementing copy\\r\\n * behavior outside of xterm.js.\\r\\n */\\r\\n public getSelection(): string {\\r\\n return this.selectionManager ? this.selectionManager.selectionText : '';\\r\\n }\\r\\n\\r\\n /**\\r\\n * Clears the current terminal selection.\\r\\n */\\r\\n public clearSelection(): void {\\r\\n if (this.selectionManager) {\\r\\n this.selectionManager.clearSelection();\\r\\n }\\r\\n }\\r\\n\\r\\n /**\\r\\n * Selects all text within the terminal.\\r\\n */\\r\\n public selectAll(): void {\\r\\n if (this.selectionManager) {\\r\\n this.selectionManager.selectAll();\\r\\n }\\r\\n }\\r\\n\\r\\n /**\\r\\n * Handle a keydown event\\r\\n * Key Resources:\\r\\n * - https://developer.mozilla.org/en-US/docs/DOM/KeyboardEvent\\r\\n * @param {KeyboardEvent} ev The keydown event to be handled.\\r\\n */\\r\\n protected _keyDown(ev: KeyboardEvent): boolean {\\r\\n if (this.customKeyEventHandler && this.customKeyEventHandler(ev) === false) {\\r\\n return false;\\r\\n }\\r\\n\\r\\n if (!this.compositionHelper.keydown(ev)) {\\r\\n if (this.buffer.ybase !== this.buffer.ydisp) {\\r\\n this.scrollToBottom();\\r\\n }\\r\\n return false;\\r\\n }\\r\\n\\r\\n const result = this._evaluateKeyEscapeSequence(ev);\\r\\n\\r\\n if (result.key === C0.DC3) { // XOFF\\r\\n this.writeStopped = true;\\r\\n } else if (result.key === C0.DC1) { // XON\\r\\n this.writeStopped = false;\\r\\n }\\r\\n\\r\\n if (result.scrollDisp) {\\r\\n this.scrollDisp(result.scrollDisp);\\r\\n return this.cancel(ev, true);\\r\\n }\\r\\n\\r\\n if (isThirdLevelShift(this.browser, ev)) {\\r\\n return true;\\r\\n }\\r\\n\\r\\n if (result.cancel) {\\r\\n // The event is canceled at the end already, is this necessary?\\r\\n this.cancel(ev, true);\\r\\n }\\r\\n\\r\\n if (!result.key) {\\r\\n return true;\\r\\n }\\r\\n\\r\\n this.emit('keydown', ev);\\r\\n this.emit('key', result.key, ev);\\r\\n this.showCursor();\\r\\n this.handler(result.key);\\r\\n\\r\\n return this.cancel(ev, true);\\r\\n }\\r\\n\\r\\n /**\\r\\n * Returns an object that determines how a KeyboardEvent should be handled. The key of the\\r\\n * returned value is the new key code to pass to the PTY.\\r\\n *\\r\\n * Reference: http://invisible-island.net/xterm/ctlseqs/ctlseqs.html\\r\\n * @param ev The keyboard event to be translated to key escape sequence.\\r\\n */\\r\\n protected _evaluateKeyEscapeSequence(ev: KeyboardEvent): {cancel: boolean, key: string, scrollDisp: number} {\\r\\n const result: {cancel: boolean, key: string, scrollDisp: number} = {\\r\\n // Whether to cancel event propogation (NOTE: this may not be needed since the event is\\r\\n // canceled at the end of keyDown\\r\\n cancel: false,\\r\\n // The new key even to emit\\r\\n key: undefined,\\r\\n // The number of characters to scroll, if this is defined it will cancel the event\\r\\n scrollDisp: undefined\\r\\n };\\r\\n const modifiers = (ev.shiftKey ? 1 : 0) | (ev.altKey ? 2 : 0) | (ev.ctrlKey ? 4 : 0) | (ev.metaKey ? 8 : 0);\\r\\n switch (ev.keyCode) {\\r\\n case 0:\\r\\n if (ev.key === 'UIKeyInputUpArrow') {\\r\\n if (this.applicationCursor) {\\r\\n result.key = C0.ESC + 'OA';\\r\\n } else {\\r\\n result.key = C0.ESC + '[A';\\r\\n }\\r\\n }\\r\\n else if (ev.key === 'UIKeyInputLeftArrow') {\\r\\n if (this.applicationCursor) {\\r\\n result.key = C0.ESC + 'OD';\\r\\n } else {\\r\\n result.key = C0.ESC + '[D';\\r\\n }\\r\\n }\\r\\n else if (ev.key === 'UIKeyInputRightArrow') {\\r\\n if (this.applicationCursor) {\\r\\n result.key = C0.ESC + 'OC';\\r\\n } else {\\r\\n result.key = C0.ESC + '[C';\\r\\n }\\r\\n }\\r\\n else if (ev.key === 'UIKeyInputDownArrow') {\\r\\n if (this.applicationCursor) {\\r\\n result.key = C0.ESC + 'OB';\\r\\n } else {\\r\\n result.key = C0.ESC + '[B';\\r\\n }\\r\\n }\\r\\n break;\\r\\n case 8:\\r\\n // backspace\\r\\n if (ev.shiftKey) {\\r\\n result.key = C0.BS; // ^H\\r\\n break;\\r\\n }\\r\\n result.key = C0.DEL; // ^?\\r\\n break;\\r\\n case 9:\\r\\n // tab\\r\\n if (ev.shiftKey) {\\r\\n result.key = C0.ESC + '[Z';\\r\\n break;\\r\\n }\\r\\n result.key = C0.HT;\\r\\n result.cancel = true;\\r\\n break;\\r\\n case 13:\\r\\n // return/enter\\r\\n result.key = C0.CR;\\r\\n result.cancel = true;\\r\\n break;\\r\\n case 27:\\r\\n // escape\\r\\n result.key = C0.ESC;\\r\\n result.cancel = true;\\r\\n break;\\r\\n case 37:\\r\\n // left-arrow\\r\\n if (modifiers) {\\r\\n result.key = C0.ESC + '[1;' + (modifiers + 1) + 'D';\\r\\n // HACK: Make Alt + left-arrow behave like Ctrl + left-arrow: move one word backwards\\r\\n // http://unix.stackexchange.com/a/108106\\r\\n // macOS uses different escape sequences than linux\\r\\n if (result.key === C0.ESC + '[1;3D') {\\r\\n result.key = (this.browser.isMac) ? C0.ESC + 'b' : C0.ESC + '[1;5D';\\r\\n }\\r\\n } else if (this.applicationCursor) {\\r\\n result.key = C0.ESC + 'OD';\\r\\n } else {\\r\\n result.key = C0.ESC + '[D';\\r\\n }\\r\\n break;\\r\\n case 39:\\r\\n // right-arrow\\r\\n if (modifiers) {\\r\\n result.key = C0.ESC + '[1;' + (modifiers + 1) + 'C';\\r\\n // HACK: Make Alt + right-arrow behave like Ctrl + right-arrow: move one word forward\\r\\n // http://unix.stackexchange.com/a/108106\\r\\n // macOS uses different escape sequences than linux\\r\\n if (result.key === C0.ESC + '[1;3C') {\\r\\n result.key = (this.browser.isMac) ? C0.ESC + 'f' : C0.ESC + '[1;5C';\\r\\n }\\r\\n } else if (this.applicationCursor) {\\r\\n result.key = C0.ESC + 'OC';\\r\\n } else {\\r\\n result.key = C0.ESC + '[C';\\r\\n }\\r\\n break;\\r\\n case 38:\\r\\n // up-arrow\\r\\n if (modifiers) {\\r\\n result.key = C0.ESC + '[1;' + (modifiers + 1) + 'A';\\r\\n // HACK: Make Alt + up-arrow behave like Ctrl + up-arrow\\r\\n // http://unix.stackexchange.com/a/108106\\r\\n if (result.key === C0.ESC + '[1;3A') {\\r\\n result.key = C0.ESC + '[1;5A';\\r\\n }\\r\\n } else if (this.applicationCursor) {\\r\\n result.key = C0.ESC + 'OA';\\r\\n } else {\\r\\n result.key = C0.ESC + '[A';\\r\\n }\\r\\n break;\\r\\n case 40:\\r\\n // down-arrow\\r\\n if (modifiers) {\\r\\n result.key = C0.ESC + '[1;' + (modifiers + 1) + 'B';\\r\\n // HACK: Make Alt + down-arrow behave like Ctrl + down-arrow\\r\\n // http://unix.stackexchange.com/a/108106\\r\\n if (result.key === C0.ESC + '[1;3B') {\\r\\n result.key = C0.ESC + '[1;5B';\\r\\n }\\r\\n } else if (this.applicationCursor) {\\r\\n result.key = C0.ESC + 'OB';\\r\\n } else {\\r\\n result.key = C0.ESC + '[B';\\r\\n }\\r\\n break;\\r\\n case 45:\\r\\n // insert\\r\\n if (!ev.shiftKey && !ev.ctrlKey) {\\r\\n // <Ctrl> or <Shift> + <Insert> are used to\\r\\n // copy-paste on some systems.\\r\\n result.key = C0.ESC + '[2~';\\r\\n }\\r\\n break;\\r\\n case 46:\\r\\n // delete\\r\\n if (modifiers) {\\r\\n result.key = C0.ESC + '[3;' + (modifiers + 1) + '~';\\r\\n } else {\\r\\n result.key = C0.ESC + '[3~';\\r\\n }\\r\\n break;\\r\\n case 36:\\r\\n // home\\r\\n if (modifiers)\\r\\n result.key = C0.ESC + '[1;' + (modifiers + 1) + 'H';\\r\\n else if (this.applicationCursor)\\r\\n result.key = C0.ESC + 'OH';\\r\\n else\\r\\n result.key = C0.ESC + '[H';\\r\\n break;\\r\\n case 35:\\r\\n // end\\r\\n if (modifiers)\\r\\n result.key = C0.ESC + '[1;' + (modifiers + 1) + 'F';\\r\\n else if (this.applicationCursor)\\r\\n result.key = C0.ESC + 'OF';\\r\\n else\\r\\n result.key = C0.ESC + '[F';\\r\\n break;\\r\\n case 33:\\r\\n // page up\\r\\n if (ev.shiftKey) {\\r\\n result.scrollDisp = -(this.rows - 1);\\r\\n } else {\\r\\n result.key = C0.ESC + '[5~';\\r\\n }\\r\\n break;\\r\\n case 34:\\r\\n // page down\\r\\n if (ev.shiftKey) {\\r\\n result.scrollDisp = this.rows - 1;\\r\\n } else {\\r\\n result.key = C0.ESC + '[6~';\\r\\n }\\r\\n break;\\r\\n case 112:\\r\\n // F1-F12\\r\\n if (modifiers) {\\r\\n result.key = C0.ESC + '[1;' + (modifiers + 1) + 'P';\\r\\n } else {\\r\\n result.key = C0.ESC + 'OP';\\r\\n }\\r\\n break;\\r\\n case 113:\\r\\n if (modifiers) {\\r\\n result.key = C0.ESC + '[1;' + (modifiers + 1) + 'Q';\\r\\n } else {\\r\\n result.key = C0.ESC + 'OQ';\\r\\n }\\r\\n break;\\r\\n case 114:\\r\\n if (modifiers) {\\r\\n result.key = C0.ESC + '[1;' + (modifiers + 1) + 'R';\\r\\n } else {\\r\\n result.key = C0.ESC + 'OR';\\r\\n }\\r\\n break;\\r\\n case 115:\\r\\n if (modifiers) {\\r\\n result.key = C0.ESC + '[1;' + (modifiers + 1) + 'S';\\r\\n } else {\\r\\n result.key = C0.ESC + 'OS';\\r\\n }\\r\\n break;\\r\\n case 116:\\r\\n if (modifiers) {\\r\\n result.key = C0.ESC + '[15;' + (modifiers + 1) + '~';\\r\\n } else {\\r\\n result.key = C0.ESC + '[15~';\\r\\n }\\r\\n break;\\r\\n case 117:\\r\\n if (modifiers) {\\r\\n result.key = C0.ESC + '[17;' + (modifiers + 1) + '~';\\r\\n } else {\\r\\n result.key = C0.ESC + '[17~';\\r\\n }\\r\\n break;\\r\\n case 118:\\r\\n if (modifiers) {\\r\\n result.key = C0.ESC + '[18;' + (modifiers + 1) + '~';\\r\\n } else {\\r\\n result.key = C0.ESC + '[18~';\\r\\n }\\r\\n break;\\r\\n case 119:\\r\\n if (modifiers) {\\r\\n result.key = C0.ESC + '[19;' + (modifiers + 1) + '~';\\r\\n } else {\\r\\n result.key = C0.ESC + '[19~';\\r\\n }\\r\\n break;\\r\\n case 120:\\r\\n if (modifiers) {\\r\\n result.key = C0.ESC + '[20;' + (modifiers + 1) + '~';\\r\\n } else {\\r\\n result.key = C0.ESC + '[20~';\\r\\n }\\r\\n break;\\r\\n case 121:\\r\\n if (modifiers) {\\r\\n result.key = C0.ESC + '[21;' + (modifiers + 1) + '~';\\r\\n } else {\\r\\n result.key = C0.ESC + '[21~';\\r\\n }\\r\\n break;\\r\\n case 122:\\r\\n if (modifiers) {\\r\\n result.key = C0.ESC + '[23;' + (modifiers + 1) + '~';\\r\\n } else {\\r\\n result.key = C0.ESC + '[23~';\\r\\n }\\r\\n break;\\r\\n case 123:\\r\\n if (modifiers) {\\r\\n result.key = C0.ESC + '[24;' + (modifiers + 1) + '~';\\r\\n } else {\\r\\n result.key = C0.ESC + '[24~';\\r\\n }\\r\\n break;\\r\\n default:\\r\\n // a-z and space\\r\\n if (ev.ctrlKey && !ev.shiftKey && !ev.altKey && !ev.metaKey) {\\r\\n if (ev.keyCode >= 65 && ev.keyCode <= 90) {\\r\\n result.key = String.fromCharCode(ev.keyCode - 64);\\r\\n } else if (ev.keyCode === 32) {\\r\\n // NUL\\r\\n result.key = String.fromCharCode(0);\\r\\n } else if (ev.keyCode >= 51 && ev.keyCode <= 55) {\\r\\n // escape, file sep, group sep, record sep, unit sep\\r\\n result.key = String.fromCharCode(ev.keyCode - 51 + 27);\\r\\n } else if (ev.keyCode === 56) {\\r\\n // delete\\r\\n result.key = String.fromCharCode(127);\\r\\n } else if (ev.keyCode === 219) {\\r\\n // ^[ - Control Sequence Introducer (CSI)\\r\\n result.key = String.fromCharCode(27);\\r\\n } else if (ev.keyCode === 220) {\\r\\n // ^\\\\ - String Terminator (ST)\\r\\n result.key = String.fromCharCode(28);\\r\\n } else if (ev.keyCode === 221) {\\r\\n // ^] - Operating System Command (OSC)\\r\\n result.key = String.fromCharCode(29);\\r\\n }\\r\\n } else if (!this.browser.isMac && ev.altKey && !ev.ctrlKey && !ev.metaKey) {\\r\\n // On Mac this is a third level shift. Use <Esc> instead.\\r\\n if (ev.keyCode >= 65 && ev.keyCode <= 90) {\\r\\n result.key = C0.ESC + String.fromCharCode(ev.keyCode + 32);\\r\\n } else if (ev.keyCode === 192) {\\r\\n result.key = C0.ESC + '`';\\r\\n } else if (ev.keyCode >= 48 && ev.keyCode <= 57) {\\r\\n result.key = C0.ESC + (ev.keyCode - 48);\\r\\n }\\r\\n } else if (this.browser.isMac && !ev.altKey && !ev.ctrlKey && ev.metaKey) {\\r\\n if (ev.keyCode === 65) { // cmd + a\\r\\n this.selectAll();\\r\\n }\\r\\n }\\r\\n break;\\r\\n }\\r\\n\\r\\n return result;\\r\\n }\\r\\n\\r\\n /**\\r\\n * Set the G level of the terminal\\r\\n * @param g\\r\\n */\\r\\n public setgLevel(g: number): void {\\r\\n this.glevel = g;\\r\\n this.charset = this.charsets[g];\\r\\n }\\r\\n\\r\\n /**\\r\\n * Set the charset for the given G level of the terminal\\r\\n * @param g\\r\\n * @param charset\\r\\n */\\r\\n public setgCharset(g: number, charset: Charset): void {\\r\\n this.charsets[g] = charset;\\r\\n if (this.glevel === g) {\\r\\n this.charset = charset;\\r\\n }\\r\\n }\\r\\n\\r\\n /**\\r\\n * Handle a keypress event.\\r\\n * Key Resources:\\r\\n * - https://developer.mozilla.org/en-US/docs/DOM/KeyboardEvent\\r\\n * @param {KeyboardEvent} ev The keypress event to be handled.\\r\\n */\\r\\n protected _keyPress(ev: KeyboardEvent): boolean {\\r\\n let key;\\r\\n\\r\\n if (this.customKeyEventHandler && this.customKeyEventHandler(ev) === false) {\\r\\n return false;\\r\\n }\\r\\n\\r\\n this.cancel(ev);\\r\\n\\r\\n if (ev.charCode) {\\r\\n key = ev.charCode;\\r\\n } else if (ev.which == null) {\\r\\n key = ev.keyCode;\\r\\n } else if (ev.which !== 0 && ev.charCode !== 0) {\\r\\n key = ev.which;\\r\\n } else {\\r\\n return false;\\r\\n }\\r\\n\\r\\n if (!key || (\\r\\n (ev.altKey || ev.ctrlKey || ev.metaKey) && !isThirdLevelShift(this.browser, ev)\\r\\n )) {\\r\\n return false;\\r\\n }\\r\\n\\r\\n key = String.fromCharCode(key);\\r\\n\\r\\n this.emit('keypress', key, ev);\\r\\n this.emit('key', key, ev);\\r\\n this.showCursor();\\r\\n this.handler(key);\\r\\n\\r\\n return true;\\r\\n }\\r\\n\\r\\n /**\\r\\n * Send data for handling to the terminal\\r\\n * @param {string} data\\r\\n */\\r\\n public send(data: string): void {\\r\\n if (!this.sendDataQueue) {\\r\\n setTimeout(() => {\\r\\n this.handler(this.sendDataQueue);\\r\\n this.sendDataQueue = '';\\r\\n }, 1);\\r\\n }\\r\\n\\r\\n this.sendDataQueue += data;\\r\\n }\\r\\n\\r\\n /**\\r\\n * Ring the bell.\\r\\n * Note: We could do sweet things with webaudio here\\r\\n */\\r\\n public bell(): void {\\r\\n this.emit('bell');\\r\\n if (this.soundBell()) this.bellAudioElement.play();\\r\\n\\r\\n if (this.visualBell()) {\\r\\n this.element.classList.add('visual-bell-active');\\r\\n clearTimeout(this.visualBellTimer);\\r\\n this.visualBellTimer = window.setTimeout(() => {\\r\\n this.element.classList.remove('visual-bell-active');\\r\\n }, 200);\\r\\n }\\r\\n }\\r\\n\\r\\n /**\\r\\n * Log the current state to the console.\\r\\n */\\r\\n public log(text: string, data?: any): void {\\r\\n if (!this.options.debug) return;\\r\\n if (!this.context.console || !this.context.console.log) return;\\r\\n this.context.console.log(text, data);\\r\\n }\\r\\n\\r\\n /**\\r\\n * Log the current state as error to the console.\\r\\n */\\r\\n public error(text: string, data?: any): void {\\r\\n if (!this.options.debug) return;\\r\\n if (!this.context.console || !this.context.console.error) return;\\r\\n this.context.console.error(text, data);\\r\\n }\\r\\n\\r\\n /**\\r\\n * Resizes the terminal.\\r\\n *\\r\\n * @param {number} x The number of columns to resize to.\\r\\n * @param {number} y The number of rows to resize to.\\r\\n */\\r\\n public resize(x: number, y: number): void {\\r\\n if (isNaN(x) || isNaN(y)) {\\r\\n return;\\r\\n }\\r\\n\\r\\n if (x === this.cols && y === this.rows) {\\r\\n // Check if we still need to measure the char size (fixes #785).\\r\\n if (!this.charMeasure.width || !this.charMeasure.height) {\\r\\n this.charMeasure.measure(this.options);\\r\\n }\\r\\n return;\\r\\n }\\r\\n\\r\\n if (x < 1) x = 1;\\r\\n if (y < 1) y = 1;\\r\\n\\r\\n this.buffers.resize(x, y);\\r\\n\\r\\n this.cols = x;\\r\\n this.rows = y;\\r\\n this.buffers.setupTabStops(this.cols);\\r\\n\\r\\n this.charMeasure.measure(this.options);\\r\\n\\r\\n this.refresh(0, this.rows - 1);\\r\\n\\r\\n this.geometry = [this.cols, this.rows];\\r\\n this.emit('resize', {cols: x, rows: y});\\r\\n }\\r\\n\\r\\n /**\\r\\n * Updates the range of rows to refresh\\r\\n * @param {number} y The number of rows to refresh next.\\r\\n */\\r\\n public updateRange(y: number): void {\\r\\n if (y < this.refreshStart) this.refreshStart = y;\\r\\n if (y > this.refreshEnd) this.refreshEnd = y;\\r\\n // if (y > this.refreshEnd) {\\r\\n // this.refreshEnd = y;\\r\\n // if (y > this.rows - 1) {\\r\\n // this.refreshEnd = this.rows - 1;\\r\\n // }\\r\\n // }\\r\\n }\\r\\n\\r\\n /**\\r\\n * Set the range of refreshing to the maximum value\\r\\n */\\r\\n public maxRange(): void {\\r\\n this.refreshStart = 0;\\r\\n this.refreshEnd = this.rows - 1;\\r\\n }\\r\\n\\r\\n /**\\r\\n * Erase in the identified line everything from \\\"x\\\" to the end of the line (right).\\r\\n * @param {number} x The column from which to start erasing to the end of the line.\\r\\n * @param {number} y The line in which to operate.\\r\\n */\\r\\n public eraseRight(x: number, y: number): void {\\r\\n const line = this.buffer.lines.get(this.buffer.ybase + y);\\r\\n if (!line) {\\r\\n return;\\r\\n }\\r\\n const ch: CharData = [this.eraseAttr(), ' ', 1, 32 /* ' '.charCodeAt(0) */]; // xterm\\r\\n for (; x < this.cols; x++) {\\r\\n line[x] = ch;\\r\\n }\\r\\n this.updateRange(y);\\r\\n }\\r\\n\\r\\n /**\\r\\n * Erase in the identified line everything from \\\"x\\\" to the start of the line (left).\\r\\n * @param {number} x The column from which to start erasing to the start of the line.\\r\\n * @param {number} y The line in which to operate.\\r\\n */\\r\\n public eraseLeft(x: number, y: number): void {\\r\\n const line = this.buffer.lines.get(this.buffer.ybase + y);\\r\\n if (!line) {\\r\\n return;\\r\\n }\\r\\n const ch: CharData = [this.eraseAttr(), ' ', 1, 32 /* ' '.charCodeAt(0) */]; // xterm\\r\\n x++;\\r\\n while (x--) {\\r\\n line[x] = ch;\\r\\n }\\r\\n this.updateRange(y);\\r\\n }\\r\\n\\r\\n /**\\r\\n * Clear the entire buffer, making the prompt line the new first line.\\r\\n */\\r\\n public clear(): void {\\r\\n if (this.buffer.ybase === 0 && this.buffer.y === 0) {\\r\\n // Don't clear if it's already clear\\r\\n return;\\r\\n }\\r\\n this.buffer.lines.set(0, this.buffer.lines.get(this.buffer.ybase + this.buffer.y));\\r\\n this.buffer.lines.length = 1;\\r\\n this.buffer.ydisp = 0;\\r\\n this.buffer.ybase = 0;\\r\\n this.buffer.y = 0;\\r\\n for (let i = 1; i < this.rows; i++) {\\r\\n this.buffer.lines.push(this.blankLine());\\r\\n }\\r\\n this.refresh(0, this.rows - 1);\\r\\n this.emit('scroll', this.buffer.ydisp);\\r\\n }\\r\\n\\r\\n /**\\r\\n * Erase all content in the given line\\r\\n * @param {number} y The line to erase all of its contents.\\r\\n */\\r\\n public eraseLine(y: number): void {\\r\\n this.eraseRight(0, y);\\r\\n }\\r\\n\\r\\n /**\\r\\n * Return the data array of a blank line\\r\\n * @param {boolean} cur First bunch of data for each \\\"blank\\\" character.\\r\\n * @param {boolean} isWrapped Whether the new line is wrapped from the previous line.\\r\\n * @param {boolean} cols The number of columns in the terminal, if this is not\\r\\n * set, the terminal's current column count would be used.\\r\\n */\\r\\n public blankLine(cur?: boolean, isWrapped?: boolean, cols?: number): LineData {\\r\\n const attr = cur ? this.eraseAttr() : this.defAttr;\\r\\n\\r\\n const ch: CharData = [attr, ' ', 1, 32 /* ' '.charCodeAt(0) */]; // width defaults to 1 halfwidth character\\r\\n const line: LineData = [];\\r\\n\\r\\n // TODO: It is not ideal that this is a property on an array, a buffer line\\r\\n // class should be added that will hold this data and other useful functions.\\r\\n if (isWrapped) {\\r\\n (<any>line).isWrapped = isWrapped;\\r\\n }\\r\\n\\r\\n cols = cols || this.cols;\\r\\n for (let i = 0; i < cols; i++) {\\r\\n line[i] = ch;\\r\\n }\\r\\n\\r\\n return line;\\r\\n }\\r\\n\\r\\n /**\\r\\n * If cur return the back color xterm feature attribute. Else return defAttr.\\r\\n * @param cur\\r\\n */\\r\\n public ch(cur?: boolean): CharData {\\r\\n if (cur) {\\r\\n return [this.eraseAttr(), ' ', 1, 32 /* ' '.charCodeAt(0) */];\\r\\n }\\r\\n return [this.defAttr, ' ', 1, 32 /* ' '.charCodeAt(0) */];\\r\\n }\\r\\n\\r\\n /**\\r\\n * Evaluate if the current terminal is the given argument.\\r\\n * @param term The terminal name to evaluate\\r\\n */\\r\\n public is(term: string): boolean {\\r\\n return (this.options.termName + '').indexOf(term) === 0;\\r\\n }\\r\\n\\r\\n /**\\r\\n * Emit the 'data' event and populate the given data.\\r\\n * @param {string} data The data to populate in the event.\\r\\n */\\r\\n public handler(data: string): void {\\r\\n // Prevents all events to pty process if stdin is disabled\\r\\n if (this.options.disableStdin) {\\r\\n return;\\r\\n }\\r\\n\\r\\n // Clear the selection if the selection manager is available and has an active selection\\r\\n if (this.selectionManager && this.selectionManager.hasSelection) {\\r\\n this.selectionManager.clearSelection();\\r\\n }\\r\\n\\r\\n // Input is being sent to the terminal, the terminal should focus the prompt.\\r\\n if (this.buffer.ybase !== this.buffer.ydisp) {\\r\\n this.scrollToBottom();\\r\\n }\\r\\n this.emit('data', data);\\r\\n }\\r\\n\\r\\n /**\\r\\n * Emit the 'title' event and populate the given title.\\r\\n * @param {string} title The title to populate in the event.\\r\\n */\\r\\n private handleTitle(title: string): void {\\r\\n /**\\r\\n * This event is emitted when the title of the terminal is changed\\r\\n * from inside the terminal. The parameter is the new title.\\r\\n *\\r\\n * @event title\\r\\n */\\r\\n this.emit('title', title);\\r\\n }\\r\\n\\r\\n /**\\r\\n * ESC\\r\\n */\\r\\n\\r\\n /**\\r\\n * ESC D Index (IND is 0x84).\\r\\n */\\r\\n public index(): void {\\r\\n this.buffer.y++;\\r\\n if (this.buffer.y > this.buffer.scrollBottom) {\\r\\n this.buffer.y--;\\r\\n this.scroll();\\r\\n }\\r\\n // If the end of the line is hit, prevent this action from wrapping around to the next line.\\r\\n if (this.buffer.x >= this.cols) {\\r\\n this.buffer.x--;\\r\\n }\\r\\n }\\r\\n\\r\\n /**\\r\\n * ESC M Reverse Index (RI is 0x8d).\\r\\n *\\r\\n * Move the cursor up one row, inserting a new blank line if necessary.\\r\\n */\\r\\n public reverseIndex(): void {\\r\\n if (this.buffer.y === this.buffer.scrollTop) {\\r\\n // possibly move the code below to term.reverseScroll();\\r\\n // test: echo -ne '\\\\e[1;1H\\\\e[44m\\\\eM\\\\e[0m'\\r\\n // blankLine(true) is xterm/linux behavior\\r\\n const scrollRegionHeight = this.buffer.scrollBottom - this.buffer.scrollTop;\\r\\n this.buffer.lines.shiftElements(this.buffer.y + this.buffer.ybase, scrollRegionHeight, 1);\\r\\n this.buffer.lines.set(this.buffer.y + this.buffer.ybase, this.blankLine(true));\\r\\n this.updateRange(this.buffer.scrollTop);\\r\\n this.updateRange(this.buffer.scrollBottom);\\r\\n } else {\\r\\n this.buffer.y--;\\r\\n }\\r\\n }\\r\\n\\r\\n /**\\r\\n * ESC c Full Reset (RIS).\\r\\n */\\r\\n public reset(): void {\\r\\n this.options.rows = this.rows;\\r\\n this.options.cols = this.cols;\\r\\n const customKeyEventHandler = this.customKeyEventHandler;\\r\\n const inputHandler = this.inputHandler;\\r\\n const buffers = this.buffers;\\r\\n this.setup();\\r\\n this.customKeyEventHandler = customKeyEventHandler;\\r\\n this.inputHandler = inputHandler;\\r\\n this.buffers = buffers;\\r\\n this.refresh(0, this.rows - 1);\\r\\n this.viewport.syncScrollArea();\\r\\n }\\r\\n\\r\\n\\r\\n /**\\r\\n * ESC H Tab Set (HTS is 0x88).\\r\\n */\\r\\n private tabSet(): void {\\r\\n this.buffer.tabs[this.buffer.x] = true;\\r\\n }\\r\\n\\r\\n // TODO: Remove cancel function and cancelEvents option\\r\\n public cancel(ev: Event, force?: boolean): boolean {\\r\\n if (!this.options.cancelEvents && !force) {\\r\\n return;\\r\\n }\\r\\n ev.preventDefault();\\r\\n ev.stopPropagation();\\r\\n return false;\\r\\n }\\r\\n\\r\\n // TODO: Remove when true color is implemented\\r\\n public matchColor(r1: number, g1: number, b1: number): number {\\r\\n return matchColor_(r1, g1, b1);\\r\\n }\\r\\n\\r\\n private visualBell(): boolean {\\r\\n return this.options.bellStyle === 'visual' ||\\r\\n this.options.bellStyle === 'both';\\r\\n }\\r\\n\\r\\n private soundBell(): boolean {\\r\\n return this.options.bellStyle === 'sound' ||\\r\\n this.options.bellStyle === 'both';\\r\\n }\\r\\n\\r\\n private syncBellSound(): void {\\r\\n if (this.soundBell() && this.bellAudioElement) {\\r\\n this.bellAudioElement.setAttribute('src', this.options.bellSound);\\r\\n } else if (this.soundBell()) {\\r\\n this.bellAudioElement = document.createElement('audio');\\r\\n this.bellAudioElement.setAttribute('preload', 'auto');\\r\\n this.bellAudioElement.setAttribute('src', this.options.bellSound);\\r\\n this.helperContainer.appendChild(this.bellAudioElement);\\r\\n } else if (this.bellAudioElement) {\\r\\n this.helperContainer.removeChild(this.bellAudioElement);\\r\\n }\\r\\n }\\r\\n}\\r\\n\\r\\n/**\\r\\n * Helpers\\r\\n */\\r\\n\\r\\nfunction globalOn(el: any, type: string, handler: (event: Event) => any, capture?: boolean): void {\\r\\n if (!Array.isArray(el)) {\\r\\n el = [el];\\r\\n }\\r\\n el.forEach((element: HTMLElement) => {\\r\\n element.addEventListener(type, handler, capture || false);\\r\\n });\\r\\n}\\r\\n// TODO: Remove once everything is typed\\r\\nconst on = globalOn;\\r\\n\\r\\nfunction off(el: any, type: string, handler: (event: Event) => any, capture: boolean = false): void {\\r\\n el.removeEventListener(type, handler, capture);\\r\\n}\\r\\n\\r\\nfunction isThirdLevelShift(browser: IBrowser, ev: KeyboardEvent): boolean {\\r\\n const thirdLevelKey =\\r\\n (browser.isMac && ev.altKey && !ev.ctrlKey && !ev.metaKey) ||\\r\\n (browser.isMSWindows && ev.altKey && ev.ctrlKey && !ev.metaKey);\\r\\n\\r\\n if (ev.type === 'keypress') {\\r\\n return thirdLevelKey;\\r\\n }\\r\\n\\r\\n // Don't invoke for arrows, pageDown, home, backspace, etc. (on non-keypress events)\\r\\n return thirdLevelKey && (!ev.keyCode || ev.keyCode > 47);\\r\\n}\\r\\n\\r\\nfunction wasMondifierKeyOnlyEvent(ev: KeyboardEvent): boolean {\\r\\n return ev.keyCode === 16 || // Shift\\r\\n ev.keyCode === 17 || // Ctrl\\r\\n ev.keyCode === 18; // Alt\\r\\n}\\r\\n\\r\\n/**\\r\\n * TODO:\\r\\n * The below color-related code can be removed when true color is implemented.\\r\\n * It's only purpose is to match true color requests with the closest matching\\r\\n * ANSI color code.\\r\\n */\\r\\n\\r\\n// Colors 0-15 + 16-255\\r\\n// Much thanks to TooTallNate for writing this.\\r\\nconst vcolors: number[][] = (function(): number[][] {\\r\\n const result = DEFAULT_ANSI_COLORS.map(c => {\\r\\n c = c.substring(1);\\r\\n return [\\r\\n parseInt(c.substring(0, 2), 16),\\r\\n parseInt(c.substring(2, 4), 16),\\r\\n parseInt(c.substring(4, 6), 16)\\r\\n ];\\r\\n });\\r\\n const r = [0x00, 0x5f, 0x87, 0xaf, 0xd7, 0xff];\\r\\n\\r\\n // 16-231\\r\\n for (let i = 0; i < 216; i++) {\\r\\n result.push([\\r\\n r[(i / 36) % 6 | 0],\\r\\n r[(i / 6) % 6 | 0],\\r\\n r[i % 6]\\r\\n ]);\\r\\n }\\r\\n\\r\\n // 232-255 (grey)\\r\\n let c: number;\\r\\n for (let i = 0; i < 24; i++) {\\r\\n c = 8 + i * 10;\\r\\n result.push([c, c, c]);\\r\\n }\\r\\n\\r\\n return result;\\r\\n})();\\r\\n\\r\\nconst matchColorCache: {[colorRGBHash: number]: number} = {};\\r\\n\\r\\n// http://stackoverflow.com/questions/1633828\\r\\nfunction matchColorDistance(r1: number, g1: number, b1: number, r2: number, g2: number, b2: number): number {\\r\\n return Math.pow(30 * (r1 - r2), 2)\\r\\n + Math.pow(59 * (g1 - g2), 2)\\r\\n + Math.pow(11 * (b1 - b2), 2);\\r\\n};\\r\\n\\r\\n\\r\\nfunction matchColor_(r1: number, g1: number, b1: number): number {\\r\\n const hash = (r1 << 16) | (g1 << 8) | b1;\\r\\n\\r\\n if (matchColorCache[hash] != null) {\\r\\n return matchColorCache[hash];\\r\\n }\\r\\n\\r\\n let ldiff = Infinity;\\r\\n let li = -1;\\r\\n let i = 0;\\r\\n let c: number[];\\r\\n let r2: number;\\r\\n let g2: number;\\r\\n let b2: number;\\r\\n let diff: number;\\r\\n\\r\\n for (; i < vcolors.length; i++) {\\r\\n c = vcolors[i];\\r\\n r2 = c[0];\\r\\n g2 = c[1];\\r\\n b2 = c[2];\\r\\n\\r\\n diff = matchColorDistance(r1, g1, b1, r2, g2, b2);\\r\\n\\r\\n if (diff === 0) {\\r\\n li = i;\\r\\n break;\\r\\n }\\r\\n\\r\\n if (diff < ldiff) {\\r\\n ldiff = diff;\\r\\n li = i;\\r\\n }\\r\\n }\\r\\n\\r\\n return matchColorCache[hash] = li;\\r\\n}\\r\\n\",\"/**\\r\\n * Copyright (c) 2017 The xterm.js authors. All rights reserved.\\r\\n * @license MIT\\r\\n */\\r\\n\\r\\nimport { ITerminal } from './Interfaces';\\r\\n\\r\\n/**\\r\\n * Represents a selection within the buffer. This model only cares about column\\r\\n * and row coordinates, not wide characters.\\r\\n */\\r\\nexport class SelectionModel {\\r\\n /**\\r\\n * Whether select all is currently active.\\r\\n */\\r\\n public isSelectAllActive: boolean;\\r\\n\\r\\n /**\\r\\n * The [x, y] position the selection starts at.\\r\\n */\\r\\n public selectionStart: [number, number];\\r\\n\\r\\n /**\\r\\n * The minimal length of the selection from the start position. When double\\r\\n * clicking on a word, the word will be selected which makes the selection\\r\\n * start at the start of the word and makes this variable the length.\\r\\n */\\r\\n public selectionStartLength: number;\\r\\n\\r\\n /**\\r\\n * The [x, y] position the selection ends at.\\r\\n */\\r\\n public selectionEnd: [number, number];\\r\\n\\r\\n constructor(\\r\\n private _terminal: ITerminal\\r\\n ) {\\r\\n this.clearSelection();\\r\\n }\\r\\n\\r\\n /**\\r\\n * Clears the current selection.\\r\\n */\\r\\n public clearSelection(): void {\\r\\n this.selectionStart = null;\\r\\n this.selectionEnd = null;\\r\\n this.isSelectAllActive = false;\\r\\n this.selectionStartLength = 0;\\r\\n }\\r\\n\\r\\n /**\\r\\n * The final selection start, taking into consideration select all.\\r\\n */\\r\\n public get finalSelectionStart(): [number, number] {\\r\\n if (this.isSelectAllActive) {\\r\\n return [0, 0];\\r\\n }\\r\\n\\r\\n if (!this.selectionEnd || !this.selectionStart) {\\r\\n return this.selectionStart;\\r\\n }\\r\\n\\r\\n return this.areSelectionValuesReversed() ? this.selectionEnd : this.selectionStart;\\r\\n }\\r\\n\\r\\n /**\\r\\n * The final selection end, taking into consideration select all, double click\\r\\n * word selection and triple click line selection.\\r\\n */\\r\\n public get finalSelectionEnd(): [number, number] {\\r\\n if (this.isSelectAllActive) {\\r\\n return [this._terminal.cols, this._terminal.buffer.ybase + this._terminal.rows - 1];\\r\\n }\\r\\n\\r\\n if (!this.selectionStart) {\\r\\n return null;\\r\\n }\\r\\n\\r\\n // Use the selection start if the end doesn't exist or they're reversed\\r\\n if (!this.selectionEnd || this.areSelectionValuesReversed()) {\\r\\n return [this.selectionStart[0] + this.selectionStartLength, this.selectionStart[1]];\\r\\n }\\r\\n\\r\\n // Ensure the the word/line is selected after a double/triple click\\r\\n if (this.selectionStartLength) {\\r\\n // Select the larger of the two when start and end are on the same line\\r\\n if (this.selectionEnd[1] === this.selectionStart[1]) {\\r\\n return [Math.max(this.selectionStart[0] + this.selectionStartLength, this.selectionEnd[0]), this.selectionEnd[1]];\\r\\n }\\r\\n }\\r\\n return this.selectionEnd;\\r\\n }\\r\\n\\r\\n /**\\r\\n * Returns whether the selection start and end are reversed.\\r\\n */\\r\\n public areSelectionValuesReversed(): boolean {\\r\\n const start = this.selectionStart;\\r\\n const end = this.selectionEnd;\\r\\n if (!start || !end) {\\r\\n return false;\\r\\n }\\r\\n return start[1] > end[1] || (start[1] === end[1] && start[0] > end[0]);\\r\\n }\\r\\n\\r\\n /**\\r\\n * Handle the buffer being trimmed, adjust the selection position.\\r\\n * @param amount The amount the buffer is being trimmed.\\r\\n * @return Whether a refresh is necessary.\\r\\n */\\r\\n public onTrim(amount: number): boolean {\\r\\n // Adjust the selection position based on the trimmed amount.\\r\\n if (this.selectionStart) {\\r\\n this.selectionStart[1] -= amount;\\r\\n }\\r\\n if (this.selectionEnd) {\\r\\n this.selectionEnd[1] -= amount;\\r\\n }\\r\\n\\r\\n // The selection has moved off the buffer, clear it.\\r\\n if (this.selectionEnd && this.selectionEnd[1] < 0) {\\r\\n this.clearSelection();\\r\\n return true;\\r\\n }\\r\\n\\r\\n // If the selection start is trimmed, ensure the start column is 0.\\r\\n if (this.selectionStart && this.selectionStart[1] < 0) {\\r\\n this.selectionStart[1] = 0;\\r\\n }\\r\\n return false;\\r\\n }\\r\\n}\\r\\n\",\"/**\\r\\n * Copyright (c) 2017 The xterm.js authors. All rights reserved.\\r\\n * @license MIT\\r\\n */\\r\\n\\r\\nimport { MouseHelper } from './utils/MouseHelper';\\r\\nimport * as Browser from './utils/Browser';\\r\\nimport { CharMeasure } from './utils/CharMeasure';\\r\\nimport { CircularList } from './utils/CircularList';\\r\\nimport { EventEmitter } from './EventEmitter';\\r\\nimport { ITerminal, ICircularList, ISelectionManager, IBuffer } from './Interfaces';\\r\\nimport { SelectionModel } from './SelectionModel';\\r\\nimport { LineData, CharData } from './Types';\\r\\nimport { CHAR_DATA_WIDTH_INDEX, CHAR_DATA_CHAR_INDEX } from './Buffer';\\r\\n\\r\\n/**\\r\\n * The number of pixels the mouse needs to be above or below the viewport in\\r\\n * order to scroll at the maximum speed.\\r\\n */\\r\\nconst DRAG_SCROLL_MAX_THRESHOLD = 50;\\r\\n\\r\\n/**\\r\\n * The maximum scrolling speed\\r\\n */\\r\\nconst DRAG_SCROLL_MAX_SPEED = 15;\\r\\n\\r\\n/**\\r\\n * The number of milliseconds between drag scroll updates.\\r\\n */\\r\\nconst DRAG_SCROLL_INTERVAL = 50;\\r\\n\\r\\n/**\\r\\n * A string containing all characters that are considered word separated by the\\r\\n * double click to select work logic.\\r\\n */\\r\\nconst WORD_SEPARATORS = ' ()[]{}\\\\'\\\"';\\r\\n\\r\\nconst NON_BREAKING_SPACE_CHAR = String.fromCharCode(160);\\r\\nconst ALL_NON_BREAKING_SPACE_REGEX = new RegExp(NON_BREAKING_SPACE_CHAR, 'g');\\r\\n\\r\\n/**\\r\\n * Represents a position of a word on a line.\\r\\n */\\r\\ninterface IWordPosition {\\r\\n start: number;\\r\\n length: number;\\r\\n}\\r\\n\\r\\n/**\\r\\n * A selection mode, this drives how the selection behaves on mouse move.\\r\\n */\\r\\nenum SelectionMode {\\r\\n NORMAL,\\r\\n WORD,\\r\\n LINE\\r\\n}\\r\\n\\r\\n/**\\r\\n * A class that manages the selection of the terminal. With help from\\r\\n * SelectionModel, SelectionManager handles with all logic associated with\\r\\n * dealing with the selection, including handling mouse interaction, wide\\r\\n * characters and fetching the actual text within the selection. Rendering is\\r\\n * not handled by the SelectionManager but a 'refresh' event is fired when the\\r\\n * selection is ready to be redrawn.\\r\\n */\\r\\nexport class SelectionManager extends EventEmitter implements ISelectionManager {\\r\\n protected _model: SelectionModel;\\r\\n\\r\\n /**\\r\\n * The amount to scroll every drag scroll update (depends on how far the mouse\\r\\n * drag is above or below the terminal).\\r\\n */\\r\\n private _dragScrollAmount: number;\\r\\n\\r\\n /**\\r\\n * The current selection mode.\\r\\n */\\r\\n private _activeSelectionMode: SelectionMode;\\r\\n\\r\\n /**\\r\\n * A setInterval timer that is active while the mouse is down whose callback\\r\\n * scrolls the viewport when necessary.\\r\\n */\\r\\n private _dragScrollIntervalTimer: NodeJS.Timer;\\r\\n\\r\\n /**\\r\\n * The animation frame ID used for refreshing the selection.\\r\\n */\\r\\n private _refreshAnimationFrame: number;\\r\\n\\r\\n /**\\r\\n * Whether selection is enabled.\\r\\n */\\r\\n private _enabled = true;\\r\\n\\r\\n private _mouseMoveListener: EventListener;\\r\\n private _mouseUpListener: EventListener;\\r\\n\\r\\n constructor(\\r\\n private _terminal: ITerminal,\\r\\n private _buffer: IBuffer,\\r\\n private _charMeasure: CharMeasure\\r\\n ) {\\r\\n super();\\r\\n this._initListeners();\\r\\n this.enable();\\r\\n\\r\\n this._model = new SelectionModel(_terminal);\\r\\n this._activeSelectionMode = SelectionMode.NORMAL;\\r\\n }\\r\\n\\r\\n /**\\r\\n * Initializes listener variables.\\r\\n */\\r\\n private _initListeners(): void {\\r\\n this._mouseMoveListener = event => this._onMouseMove(<MouseEvent>event);\\r\\n this._mouseUpListener = event => this._onMouseUp(<MouseEvent>event);\\r\\n\\r\\n // Only adjust the selection on trim, shiftElements is rarely used (only in\\r\\n // reverseIndex) and delete in a splice is only ever used when the same\\r\\n // number of elements was just added. Given this is could actually be\\r\\n // beneficial to leave the selection as is for these cases.\\r\\n this._buffer.lines.on('trim', (amount: number) => this._onTrim(amount));\\r\\n }\\r\\n\\r\\n /**\\r\\n * Disables the selection manager. This is useful for when terminal mouse\\r\\n * are enabled.\\r\\n */\\r\\n public disable(): void {\\r\\n this.clearSelection();\\r\\n this._enabled = false;\\r\\n }\\r\\n\\r\\n /**\\r\\n * Enable the selection manager.\\r\\n */\\r\\n public enable(): void {\\r\\n this._enabled = true;\\r\\n }\\r\\n\\r\\n /**\\r\\n * Sets the active buffer, this should be called when the alt buffer is\\r\\n * switched in or out.\\r\\n * @param buffer The active buffer.\\r\\n */\\r\\n public setBuffer(buffer: IBuffer): void {\\r\\n this._buffer = buffer;\\r\\n this.clearSelection();\\r\\n }\\r\\n\\r\\n public get selectionStart(): [number, number] { return this._model.finalSelectionStart; }\\r\\n public get selectionEnd(): [number, number] { return this._model.finalSelectionEnd; }\\r\\n\\r\\n /**\\r\\n * Gets whether there is an active text selection.\\r\\n */\\r\\n public get hasSelection(): boolean {\\r\\n const start = this._model.finalSelectionStart;\\r\\n const end = this._model.finalSelectionEnd;\\r\\n if (!start || !end) {\\r\\n return false;\\r\\n }\\r\\n return start[0] !== end[0] || start[1] !== end[1];\\r\\n }\\r\\n\\r\\n /**\\r\\n * Gets the text currently selected.\\r\\n */\\r\\n public get selectionText(): string {\\r\\n const start = this._model.finalSelectionStart;\\r\\n const end = this._model.finalSelectionEnd;\\r\\n if (!start || !end) {\\r\\n return '';\\r\\n }\\r\\n\\r\\n // Get first row\\r\\n const startRowEndCol = start[1] === end[1] ? end[0] : null;\\r\\n let result: string[] = [];\\r\\n result.push(this._buffer.translateBufferLineToString(start[1], true, start[0], startRowEndCol));\\r\\n\\r\\n // Get middle rows\\r\\n for (let i = start[1] + 1; i <= end[1] - 1; i++) {\\r\\n const bufferLine = this._buffer.lines.get(i);\\r\\n const lineText = this._buffer.translateBufferLineToString(i, true);\\r\\n if ((<any>bufferLine).isWrapped) {\\r\\n result[result.length - 1] += lineText;\\r\\n } else {\\r\\n result.push(lineText);\\r\\n }\\r\\n }\\r\\n\\r\\n // Get final row\\r\\n if (start[1] !== end[1]) {\\r\\n const bufferLine = this._buffer.lines.get(end[1]);\\r\\n const lineText = this._buffer.translateBufferLineToString(end[1], true, 0, end[0]);\\r\\n if ((<any>bufferLine).isWrapped) {\\r\\n result[result.length - 1] += lineText;\\r\\n } else {\\r\\n result.push(lineText);\\r\\n }\\r\\n }\\r\\n\\r\\n // Format string by replacing non-breaking space chars with regular spaces\\r\\n // and joining the array into a multi-line string.\\r\\n const formattedResult = result.map(line => {\\r\\n return line.replace(ALL_NON_BREAKING_SPACE_REGEX, ' ');\\r\\n }).join(Browser.isMSWindows ? '\\\\r\\\\n' : '\\\\n');\\r\\n\\r\\n return formattedResult;\\r\\n }\\r\\n\\r\\n /**\\r\\n * Clears the current terminal selection.\\r\\n */\\r\\n public clearSelection(): void {\\r\\n this._model.clearSelection();\\r\\n this._removeMouseDownListeners();\\r\\n this.refresh();\\r\\n }\\r\\n\\r\\n /**\\r\\n * Queues a refresh, redrawing the selection on the next opportunity.\\r\\n * @param isNewSelection Whether the selection should be registered as a new\\r\\n * selection on Linux.\\r\\n */\\r\\n public refresh(isNewSelection?: boolean): void {\\r\\n // Queue the refresh for the renderer\\r\\n if (!this._refreshAnimationFrame) {\\r\\n this._refreshAnimationFrame = window.requestAnimationFrame(() => this._refresh());\\r\\n }\\r\\n\\r\\n // If the platform is Linux and the refresh call comes from a mouse event,\\r\\n // we need to update the selection for middle click to paste selection.\\r\\n if (Browser.isLinux && isNewSelection) {\\r\\n const selectionText = this.selectionText;\\r\\n if (selectionText.length) {\\r\\n this.emit('newselection', this.selectionText);\\r\\n }\\r\\n }\\r\\n }\\r\\n\\r\\n /**\\r\\n * Fires the refresh event, causing consumers to pick it up and redraw the\\r\\n * selection state.\\r\\n */\\r\\n private _refresh(): void {\\r\\n this._refreshAnimationFrame = null;\\r\\n this.emit('refresh', { start: this._model.finalSelectionStart, end: this._model.finalSelectionEnd });\\r\\n }\\r\\n\\r\\n /**\\r\\n * Selects all text within the terminal.\\r\\n */\\r\\n public selectAll(): void {\\r\\n this._model.isSelectAllActive = true;\\r\\n this.refresh();\\r\\n }\\r\\n\\r\\n /**\\r\\n * Handle the buffer being trimmed, adjust the selection position.\\r\\n * @param amount The amount the buffer is being trimmed.\\r\\n */\\r\\n private _onTrim(amount: number): void {\\r\\n const needsRefresh = this._model.onTrim(amount);\\r\\n if (needsRefresh) {\\r\\n this.refresh();\\r\\n }\\r\\n }\\r\\n\\r\\n /**\\r\\n * Gets the 0-based [x, y] buffer coordinates of the current mouse event.\\r\\n * @param event The mouse event.\\r\\n */\\r\\n private _getMouseBufferCoords(event: MouseEvent): [number, number] {\\r\\n const coords = this._terminal.mouseHelper.getCoords(event, this._terminal.element, this._charMeasure, this._terminal.options.lineHeight, this._terminal.cols, this._terminal.rows, true);\\r\\n if (!coords) {\\r\\n return null;\\r\\n }\\r\\n\\r\\n // Convert to 0-based\\r\\n coords[0]--;\\r\\n coords[1]--;\\r\\n\\r\\n // Convert viewport coords to buffer coords\\r\\n coords[1] += this._terminal.buffer.ydisp;\\r\\n return coords;\\r\\n }\\r\\n\\r\\n /**\\r\\n * Gets the amount the viewport should be scrolled based on how far out of the\\r\\n * terminal the mouse is.\\r\\n * @param event The mouse event.\\r\\n */\\r\\n private _getMouseEventScrollAmount(event: MouseEvent): number {\\r\\n let offset = MouseHelper.getCoordsRelativeToElement(event, this._terminal.element)[1];\\r\\n const terminalHeight = this._terminal.rows * Math.ceil(this._charMeasure.height * this._terminal.options.lineHeight);\\r\\n if (offset >= 0 && offset <= terminalHeight) {\\r\\n return 0;\\r\\n }\\r\\n if (offset > terminalHeight) {\\r\\n offset -= terminalHeight;\\r\\n }\\r\\n\\r\\n offset = Math.min(Math.max(offset, -DRAG_SCROLL_MAX_THRESHOLD), DRAG_SCROLL_MAX_THRESHOLD);\\r\\n offset /= DRAG_SCROLL_MAX_THRESHOLD;\\r\\n return (offset / Math.abs(offset)) + Math.round(offset * (DRAG_SCROLL_MAX_SPEED - 1));\\r\\n }\\r\\n\\r\\n /**\\r\\n * Handles te mousedown event, setting up for a new selection.\\r\\n * @param event The mousedown event.\\r\\n */\\r\\n public onMouseDown(event: MouseEvent): void {\\r\\n // If we have selection, we want the context menu on right click even if the\\r\\n // terminal is in mouse mode.\\r\\n if (event.button === 2 && this.hasSelection) {\\r\\n return;\\r\\n }\\r\\n\\r\\n // Only action the primary button\\r\\n if (event.button !== 0) {\\r\\n return;\\r\\n }\\r\\n\\r\\n // Allow selection when using a specific modifier key, even when disabled\\r\\n if (!this._enabled) {\\r\\n const shouldForceSelection = Browser.isMac ? event.altKey : event.shiftKey;\\r\\n\\r\\n if (!shouldForceSelection) {\\r\\n return;\\r\\n }\\r\\n\\r\\n // Don't send the mouse down event to the current process, we want to select\\r\\n event.stopPropagation();\\r\\n }\\r\\n\\r\\n // Tell the browser not to start a regular selection\\r\\n event.preventDefault();\\r\\n\\r\\n // Reset drag scroll state\\r\\n this._dragScrollAmount = 0;\\r\\n\\r\\n if (this._enabled && event.shiftKey) {\\r\\n this._onIncrementalClick(event);\\r\\n } else {\\r\\n if (event.detail === 1) {\\r\\n this._onSingleClick(event);\\r\\n } else if (event.detail === 2) {\\r\\n this._onDoubleClick(event);\\r\\n } else if (event.detail === 3) {\\r\\n this._onTripleClick(event);\\r\\n }\\r\\n }\\r\\n\\r\\n this._addMouseDownListeners();\\r\\n this.refresh(true);\\r\\n }\\r\\n\\r\\n /**\\r\\n * Adds listeners when mousedown is triggered.\\r\\n */\\r\\n private _addMouseDownListeners(): void {\\r\\n // Listen on the document so that dragging outside of viewport works\\r\\n this._terminal.element.ownerDocument.addEventListener('mousemove', this._mouseMoveListener);\\r\\n this._terminal.element.ownerDocument.addEventListener('mouseup', this._mouseUpListener);\\r\\n this._dragScrollIntervalTimer = setInterval(() => this._dragScroll(), DRAG_SCROLL_INTERVAL);\\r\\n }\\r\\n\\r\\n /**\\r\\n * Removes the listeners that are registered when mousedown is triggered.\\r\\n */\\r\\n private _removeMouseDownListeners(): void {\\r\\n this._terminal.element.ownerDocument.removeEventListener('mousemove', this._mouseMoveListener);\\r\\n this._terminal.element.ownerDocument.removeEventListener('mouseup', this._mouseUpListener);\\r\\n clearInterval(this._dragScrollIntervalTimer);\\r\\n this._dragScrollIntervalTimer = null;\\r\\n }\\r\\n\\r\\n /**\\r\\n * Performs an incremental click, setting the selection end position to the mouse\\r\\n * position.\\r\\n * @param event The mouse event.\\r\\n */\\r\\n private _onIncrementalClick(event: MouseEvent): void {\\r\\n if (this._model.selectionStart) {\\r\\n this._model.selectionEnd = this._getMouseBufferCoords(event);\\r\\n }\\r\\n }\\r\\n\\r\\n /**\\r\\n * Performs a single click, resetting relevant state and setting the selection\\r\\n * start position.\\r\\n * @param event The mouse event.\\r\\n */\\r\\n private _onSingleClick(event: MouseEvent): void {\\r\\n this._model.selectionStartLength = 0;\\r\\n this._model.isSelectAllActive = false;\\r\\n this._activeSelectionMode = SelectionMode.NORMAL;\\r\\n\\r\\n // Initialize the new selection\\r\\n this._model.selectionStart = this._getMouseBufferCoords(event);\\r\\n if (!this._model.selectionStart) {\\r\\n return;\\r\\n }\\r\\n this._model.selectionEnd = null;\\r\\n\\r\\n // Ensure the line exists\\r\\n const line = this._buffer.lines.get(this._model.selectionStart[1]);\\r\\n if (!line) {\\r\\n return;\\r\\n }\\r\\n\\r\\n // Return early if the click event is not in the buffer (eg. in scroll bar)\\r\\n if (line.length >= this._model.selectionStart[0]) {\\r\\n return;\\r\\n }\\r\\n\\r\\n // If the mouse is over the second half of a wide character, adjust the\\r\\n // selection to cover the whole character\\r\\n const char = line[this._model.selectionStart[0]];\\r\\n if (char[CHAR_DATA_WIDTH_INDEX] === 0) {\\r\\n this._model.selectionStart[0]++;\\r\\n }\\r\\n }\\r\\n\\r\\n /**\\r\\n * Performs a double click, selecting the current work.\\r\\n * @param event The mouse event.\\r\\n */\\r\\n private _onDoubleClick(event: MouseEvent): void {\\r\\n const coords = this._getMouseBufferCoords(event);\\r\\n if (coords) {\\r\\n this._activeSelectionMode = SelectionMode.WORD;\\r\\n this._selectWordAt(coords);\\r\\n }\\r\\n }\\r\\n\\r\\n /**\\r\\n * Performs a triple click, selecting the current line and activating line\\r\\n * select mode.\\r\\n * @param event The mouse event.\\r\\n */\\r\\n private _onTripleClick(event: MouseEvent): void {\\r\\n const coords = this._getMouseBufferCoords(event);\\r\\n if (coords) {\\r\\n this._activeSelectionMode = SelectionMode.LINE;\\r\\n this._selectLineAt(coords[1]);\\r\\n }\\r\\n }\\r\\n\\r\\n /**\\r\\n * Handles the mousemove event when the mouse button is down, recording the\\r\\n * end of the selection and refreshing the selection.\\r\\n * @param event The mousemove event.\\r\\n */\\r\\n private _onMouseMove(event: MouseEvent): void {\\r\\n // If the mousemove listener is active it means that a selection is\\r\\n // currently being made, we should stop propogation to prevent mouse events\\r\\n // to be sent to the pty.\\r\\n event.stopImmediatePropagation();\\r\\n\\r\\n // Record the previous position so we know whether to redraw the selection\\r\\n // at the end.\\r\\n const previousSelectionEnd = this._model.selectionEnd ? [this._model.selectionEnd[0], this._model.selectionEnd[1]] : null;\\r\\n\\r\\n // Set the initial selection end based on the mouse coordinates\\r\\n this._model.selectionEnd = this._getMouseBufferCoords(event);\\r\\n if (!this._model.selectionEnd) {\\r\\n this.refresh(true);\\r\\n return;\\r\\n }\\r\\n\\r\\n // Select the entire line if line select mode is active.\\r\\n if (this._activeSelectionMode === SelectionMode.LINE) {\\r\\n if (this._model.selectionEnd[1] < this._model.selectionStart[1]) {\\r\\n this._model.selectionEnd[0] = 0;\\r\\n } else {\\r\\n this._model.selectionEnd[0] = this._terminal.cols;\\r\\n }\\r\\n } else if (this._activeSelectionMode === SelectionMode.WORD) {\\r\\n this._selectToWordAt(this._model.selectionEnd);\\r\\n }\\r\\n\\r\\n // Determine the amount of scrolling that will happen.\\r\\n this._dragScrollAmount = this._getMouseEventScrollAmount(event);\\r\\n\\r\\n // If the cursor was above or below the viewport, make sure it's at the\\r\\n // start or end of the viewport respectively.\\r\\n if (this._dragScrollAmount > 0) {\\r\\n this._model.selectionEnd[0] = this._terminal.cols - 1;\\r\\n } else if (this._dragScrollAmount < 0) {\\r\\n this._model.selectionEnd[0] = 0;\\r\\n }\\r\\n\\r\\n // If the character is a wide character include the cell to the right in the\\r\\n // selection. Note that selections at the very end of the line will never\\r\\n // have a character.\\r\\n if (this._model.selectionEnd[1] < this._buffer.lines.length) {\\r\\n const char = this._buffer.lines.get(this._model.selectionEnd[1])[this._model.selectionEnd[0]];\\r\\n if (char && char[CHAR_DATA_WIDTH_INDEX] === 0) {\\r\\n this._model.selectionEnd[0]++;\\r\\n }\\r\\n }\\r\\n\\r\\n // Only draw here if the selection changes.\\r\\n if (!previousSelectionEnd ||\\r\\n previousSelectionEnd[0] !== this._model.selectionEnd[0] ||\\r\\n previousSelectionEnd[1] !== this._model.selectionEnd[1]) {\\r\\n this.refresh(true);\\r\\n }\\r\\n }\\r\\n\\r\\n /**\\r\\n * The callback that occurs every DRAG_SCROLL_INTERVAL ms that does the\\r\\n * scrolling of the viewport.\\r\\n */\\r\\n private _dragScroll(): void {\\r\\n if (this._dragScrollAmount) {\\r\\n this._terminal.scrollDisp(this._dragScrollAmount, false);\\r\\n // Re-evaluate selection\\r\\n if (this._dragScrollAmount > 0) {\\r\\n this._model.selectionEnd = [this._terminal.cols - 1, this._terminal.buffer.ydisp + this._terminal.rows];\\r\\n } else {\\r\\n this._model.selectionEnd = [0, this._terminal.buffer.ydisp];\\r\\n }\\r\\n this.refresh();\\r\\n }\\r\\n }\\r\\n\\r\\n /**\\r\\n * Handles the mouseup event, removing the mousedown listeners.\\r\\n * @param event The mouseup event.\\r\\n */\\r\\n private _onMouseUp(event: MouseEvent): void {\\r\\n this._removeMouseDownListeners();\\r\\n }\\r\\n\\r\\n /**\\r\\n * Converts a viewport column to the character index on the buffer line, the\\r\\n * latter takes into account wide characters.\\r\\n * @param coords The coordinates to find the 2 index for.\\r\\n */\\r\\n private _convertViewportColToCharacterIndex(bufferLine: any, coords: [number, number]): number {\\r\\n let charIndex = coords[0];\\r\\n for (let i = 0; coords[0] >= i; i++) {\\r\\n const char = bufferLine[i];\\r\\n if (char[CHAR_DATA_WIDTH_INDEX] === 0) {\\r\\n // Wide characters aren't included in the line string so decrement the\\r\\n // index so the index is back on the wide character.\\r\\n charIndex--;\\r\\n } else if (char[CHAR_DATA_CHAR_INDEX].length > 1 && coords[0] !== i) {\\r\\n // Emojis take up multiple characters, so adjust accordingly. For these\\r\\n // we don't want ot include the character at the column as we're\\r\\n // returning the start index in the string, not the end index.\\r\\n charIndex += char[CHAR_DATA_CHAR_INDEX].length - 1;\\r\\n }\\r\\n }\\r\\n return charIndex;\\r\\n }\\r\\n\\r\\n public setSelection(col: number, row: number, length: number): void {\\r\\n this._model.clearSelection();\\r\\n this._removeMouseDownListeners();\\r\\n this._model.selectionStart = [col, row];\\r\\n this._model.selectionStartLength = length;\\r\\n this.refresh();\\r\\n }\\r\\n\\r\\n /**\\r\\n * Gets positional information for the word at the coordinated specified.\\r\\n * @param coords The coordinates to get the word at.\\r\\n */\\r\\n private _getWordAt(coords: [number, number]): IWordPosition {\\r\\n const bufferLine = this._buffer.lines.get(coords[1]);\\r\\n if (!bufferLine) {\\r\\n return null;\\r\\n }\\r\\n\\r\\n const line = this._buffer.translateBufferLineToString(coords[1], false);\\r\\n\\r\\n // Get actual index, taking into consideration wide characters\\r\\n let startIndex = this._convertViewportColToCharacterIndex(bufferLine, coords);\\r\\n let endIndex = startIndex;\\r\\n\\r\\n // Record offset to be used later\\r\\n const charOffset = coords[0] - startIndex;\\r\\n let leftWideCharCount = 0;\\r\\n let rightWideCharCount = 0;\\r\\n let leftLongCharOffset = 0;\\r\\n let rightLongCharOffset = 0;\\r\\n\\r\\n if (line.charAt(startIndex) === ' ') {\\r\\n // Expand until non-whitespace is hit\\r\\n while (startIndex > 0 && line.charAt(startIndex - 1) === ' ') {\\r\\n startIndex--;\\r\\n }\\r\\n while (endIndex < line.length && line.charAt(endIndex + 1) === ' ') {\\r\\n endIndex++;\\r\\n }\\r\\n } else {\\r\\n // Expand until whitespace is hit. This algorithm works by scanning left\\r\\n // and right from the starting position, keeping both the index format\\r\\n // (line) and the column format (bufferLine) in sync. When a wide\\r\\n // character is hit, it is recorded and the column index is adjusted.\\r\\n let startCol = coords[0];\\r\\n let endCol = coords[0];\\r\\n\\r\\n // Consider the initial position, skip it and increment the wide char\\r\\n // variable\\r\\n if (bufferLine[startCol][CHAR_DATA_WIDTH_INDEX] === 0) {\\r\\n leftWideCharCount++;\\r\\n startCol--;\\r\\n }\\r\\n if (bufferLine[endCol][CHAR_DATA_WIDTH_INDEX] === 2) {\\r\\n rightWideCharCount++;\\r\\n endCol++;\\r\\n }\\r\\n\\r\\n // Adjust the end index for characters whose length are > 1 (emojis)\\r\\n if (bufferLine[endCol][CHAR_DATA_CHAR_INDEX].length > 1) {\\r\\n rightLongCharOffset += bufferLine[endCol][CHAR_DATA_CHAR_INDEX].length - 1;\\r\\n endIndex += bufferLine[endCol][CHAR_DATA_CHAR_INDEX].length - 1;\\r\\n }\\r\\n\\r\\n // Expand the string in both directions until a space is hit\\r\\n while (startCol > 0 && startIndex > 0 && !this._isCharWordSeparator(bufferLine[startCol - 1])) {\\r\\n const char = bufferLine[startCol - 1];\\r\\n if (char[CHAR_DATA_WIDTH_INDEX] === 0) {\\r\\n // If the next character is a wide char, record it and skip the column\\r\\n leftWideCharCount++;\\r\\n startCol--;\\r\\n } else if (char[CHAR_DATA_CHAR_INDEX].length > 1) {\\r\\n // If the next character's string is longer than 1 char (eg. emoji),\\r\\n // adjust the index\\r\\n leftLongCharOffset += char[CHAR_DATA_CHAR_INDEX].length - 1;\\r\\n startIndex -= char[CHAR_DATA_CHAR_INDEX].length - 1;\\r\\n }\\r\\n startIndex--;\\r\\n startCol--;\\r\\n }\\r\\n while (endCol < bufferLine.length && endIndex + 1 < line.length && !this._isCharWordSeparator(bufferLine[endCol + 1])) {\\r\\n const char = bufferLine[endCol + 1];\\r\\n if (char[CHAR_DATA_WIDTH_INDEX] === 2) {\\r\\n // If the next character is a wide char, record it and skip the column\\r\\n rightWideCharCount++;\\r\\n endCol++;\\r\\n } else if (char[CHAR_DATA_CHAR_INDEX].length > 1) {\\r\\n // If the next character's string is longer than 1 char (eg. emoji),\\r\\n // adjust the index\\r\\n rightLongCharOffset += char[CHAR_DATA_CHAR_INDEX].length - 1;\\r\\n endIndex += char[CHAR_DATA_CHAR_INDEX].length - 1;\\r\\n }\\r\\n endIndex++;\\r\\n endCol++;\\r\\n }\\r\\n }\\r\\n\\r\\n // Incremenet the end index so it is at the start of the next character\\r\\n endIndex++;\\r\\n\\r\\n // Calculate the start _column_, converting the the string indexes back to\\r\\n // column coordinates.\\r\\n const start =\\r\\n startIndex // The index of the selection's start char in the line string\\r\\n + charOffset // The difference between the initial char's column and index\\r\\n - leftWideCharCount // The number of wide chars left of the initial char\\r\\n + leftLongCharOffset; // The number of additional chars left of the initial char added by columns with strings longer than 1 (emojis)\\r\\n\\r\\n // Calculate the length in _columns_, converting the the string indexes back\\r\\n // to column coordinates.\\r\\n const length = Math.min(this._terminal.cols, // Disallow lengths larger than the terminal cols\\r\\n endIndex // The index of the selection's end char in the line string\\r\\n - startIndex // The index of the selection's start char in the line string\\r\\n + leftWideCharCount // The number of wide chars left of the initial char\\r\\n + rightWideCharCount // The number of wide chars right of the initial char (inclusive)\\r\\n - leftLongCharOffset // The number of additional chars left of the initial char added by columns with strings longer than 1 (emojis)\\r\\n - rightLongCharOffset); // The number of additional chars right of the initial char (inclusive) added by columns with strings longer than 1 (emojis)\\r\\n\\r\\n return { start, length };\\r\\n }\\r\\n\\r\\n /**\\r\\n * Selects the word at the coordinates specified.\\r\\n * @param coords The coordinates to get the word at.\\r\\n */\\r\\n protected _selectWordAt(coords: [number, number]): void {\\r\\n const wordPosition = this._getWordAt(coords);\\r\\n if (wordPosition) {\\r\\n this._model.selectionStart = [wordPosition.start, coords[1]];\\r\\n this._model.selectionStartLength = wordPosition.length;\\r\\n }\\r\\n }\\r\\n\\r\\n /**\\r\\n * Sets the selection end to the word at the coordinated specified.\\r\\n * @param coords The coordinates to get the word at.\\r\\n */\\r\\n private _selectToWordAt(coords: [number, number]): void {\\r\\n const wordPosition = this._getWordAt(coords);\\r\\n if (wordPosition) {\\r\\n this._model.selectionEnd = [this._model.areSelectionValuesReversed() ? wordPosition.start : (wordPosition.start + wordPosition.length), coords[1]];\\r\\n }\\r\\n }\\r\\n\\r\\n /**\\r\\n * Gets whether the character is considered a word separator by the select\\r\\n * word logic.\\r\\n * @param char The character to check.\\r\\n */\\r\\n private _isCharWordSeparator(charData: CharData): boolean {\\r\\n // Zero width characters are never separators as they are always to the\\r\\n // right of wide characters\\r\\n if (charData[CHAR_DATA_WIDTH_INDEX] === 0) {\\r\\n return false;\\r\\n }\\r\\n return WORD_SEPARATORS.indexOf(charData[CHAR_DATA_CHAR_INDEX]) >= 0;\\r\\n }\\r\\n\\r\\n /**\\r\\n * Selects the line specified.\\r\\n * @param line The line index.\\r\\n */\\r\\n protected _selectLineAt(line: number): void {\\r\\n this._model.selectionStart = [0, line];\\r\\n this._model.selectionStartLength = this._terminal.cols;\\r\\n }\\r\\n}\\r\\n\",\"/**\\r\\n * Copyright (c) 2014 The xterm.js authors. All rights reserved.\\r\\n * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)\\r\\n * @license MIT\\r\\n */\\r\\n\\r\\nimport { C0 } from './EscapeSequences';\\r\\nimport { IInputHandler } from './Interfaces';\\r\\nimport { CHARSETS, DEFAULT_CHARSET } from './Charsets';\\r\\n\\r\\nconst normalStateHandler: {[key: string]: (parser: Parser, handler: IInputHandler) => void} = {};\\r\\nnormalStateHandler[C0.BEL] = (parser, handler) => handler.bell();\\r\\nnormalStateHandler[C0.LF] = (parser, handler) => handler.lineFeed();\\r\\nnormalStateHandler[C0.VT] = normalStateHandler[C0.LF];\\r\\nnormalStateHandler[C0.FF] = normalStateHandler[C0.LF];\\r\\nnormalStateHandler[C0.CR] = (parser, handler) => handler.carriageReturn();\\r\\nnormalStateHandler[C0.BS] = (parser, handler) => handler.backspace();\\r\\nnormalStateHandler[C0.HT] = (parser, handler) => handler.tab();\\r\\nnormalStateHandler[C0.SO] = (parser, handler) => handler.shiftOut();\\r\\nnormalStateHandler[C0.SI] = (parser, handler) => handler.shiftIn();\\r\\nnormalStateHandler[C0.ESC] = (parser, handler) => parser.setState(ParserState.ESCAPED);\\r\\n\\r\\n// TODO: Remove terminal when parser owns params and currentParam\\r\\nconst escapedStateHandler: {[key: string]: (parser: Parser, terminal: any) => void} = {};\\r\\nescapedStateHandler['['] = (parser, terminal) => {\\r\\n // ESC [ Control Sequence Introducer (CSI is 0x9b)\\r\\n terminal.params = [];\\r\\n terminal.currentParam = 0;\\r\\n parser.setState(ParserState.CSI_PARAM);\\r\\n};\\r\\nescapedStateHandler[']'] = (parser, terminal) => {\\r\\n // ESC ] Operating System Command (OSC is 0x9d)\\r\\n terminal.params = [];\\r\\n terminal.currentParam = 0;\\r\\n parser.setState(ParserState.OSC);\\r\\n};\\r\\nescapedStateHandler['P'] = (parser, terminal) => {\\r\\n // ESC P Device Control String (DCS is 0x90)\\r\\n terminal.params = [];\\r\\n terminal.currentParam = 0;\\r\\n parser.setState(ParserState.DCS);\\r\\n};\\r\\nescapedStateHandler['_'] = (parser, terminal) => {\\r\\n // ESC _ Application Program Command ( APC is 0x9f).\\r\\n parser.setState(ParserState.IGNORE);\\r\\n};\\r\\nescapedStateHandler['^'] = (parser, terminal) => {\\r\\n // ESC ^ Privacy Message ( PM is 0x9e).\\r\\n parser.setState(ParserState.IGNORE);\\r\\n};\\r\\nescapedStateHandler['c'] = (parser, terminal) => {\\r\\n // ESC c Full Reset (RIS).\\r\\n terminal.reset();\\r\\n};\\r\\nescapedStateHandler['E'] = (parser, terminal) => {\\r\\n // ESC E Next Line ( NEL is 0x85).\\r\\n terminal.buffer.x = 0;\\r\\n terminal.index();\\r\\n parser.setState(ParserState.NORMAL);\\r\\n};\\r\\nescapedStateHandler['D'] = (parser, terminal) => {\\r\\n // ESC D Index ( IND is 0x84).\\r\\n terminal.index();\\r\\n parser.setState(ParserState.NORMAL);\\r\\n};\\r\\nescapedStateHandler['M'] = (parser, terminal) => {\\r\\n // ESC M Reverse Index ( RI is 0x8d).\\r\\n terminal.reverseIndex();\\r\\n parser.setState(ParserState.NORMAL);\\r\\n};\\r\\nescapedStateHandler['%'] = (parser, terminal) => {\\r\\n // ESC % Select default/utf-8 character set.\\r\\n // @ = default, G = utf-8\\r\\n terminal.setgLevel(0);\\r\\n terminal.setgCharset(0, DEFAULT_CHARSET); // US (default)\\r\\n parser.setState(ParserState.NORMAL);\\r\\n parser.skipNextChar();\\r\\n};\\r\\nescapedStateHandler[C0.CAN] = (parser) => parser.setState(ParserState.NORMAL);\\r\\n\\r\\nconst csiParamStateHandler: {[key: string]: (parser: Parser) => void} = {};\\r\\ncsiParamStateHandler['?'] = (parser) => parser.setPrefix('?');\\r\\ncsiParamStateHandler['>'] = (parser) => parser.setPrefix('>');\\r\\ncsiParamStateHandler['!'] = (parser) => parser.setPrefix('!');\\r\\ncsiParamStateHandler['0'] = (parser) => parser.setParam(parser.getParam() * 10);\\r\\ncsiParamStateHandler['1'] = (parser) => parser.setParam(parser.getParam() * 10 + 1);\\r\\ncsiParamStateHandler['2'] = (parser) => parser.setParam(parser.getParam() * 10 + 2);\\r\\ncsiParamStateHandler['3'] = (parser) => parser.setParam(parser.getParam() * 10 + 3);\\r\\ncsiParamStateHandler['4'] = (parser) => parser.setParam(parser.getParam() * 10 + 4);\\r\\ncsiParamStateHandler['5'] = (parser) => parser.setParam(parser.getParam() * 10 + 5);\\r\\ncsiParamStateHandler['6'] = (parser) => parser.setParam(parser.getParam() * 10 + 6);\\r\\ncsiParamStateHandler['7'] = (parser) => parser.setParam(parser.getParam() * 10 + 7);\\r\\ncsiParamStateHandler['8'] = (parser) => parser.setParam(parser.getParam() * 10 + 8);\\r\\ncsiParamStateHandler['9'] = (parser) => parser.setParam(parser.getParam() * 10 + 9);\\r\\ncsiParamStateHandler['$'] = (parser) => parser.setPostfix('$');\\r\\ncsiParamStateHandler['\\\"'] = (parser) => parser.setPostfix('\\\"');\\r\\ncsiParamStateHandler[' '] = (parser) => parser.setPostfix(' ');\\r\\ncsiParamStateHandler['\\\\''] = (parser) => parser.setPostfix('\\\\'');\\r\\ncsiParamStateHandler[';'] = (parser) => parser.finalizeParam();\\r\\ncsiParamStateHandler[C0.CAN] = (parser) => parser.setState(ParserState.NORMAL);\\r\\n\\r\\nconst csiStateHandler: {[key: string]: (handler: IInputHandler, params: number[], prefix: string, postfix: string, parser: Parser) => void} = {};\\r\\ncsiStateHandler['@'] = (handler, params, prefix) => handler.insertChars(params);\\r\\ncsiStateHandler['A'] = (handler, params, prefix) => handler.cursorUp(params);\\r\\ncsiStateHandler['B'] = (handler, params, prefix) => handler.cursorDown(params);\\r\\ncsiStateHandler['C'] = (handler, params, prefix) => handler.cursorForward(params);\\r\\ncsiStateHandler['D'] = (handler, params, prefix) => handler.cursorBackward(params);\\r\\ncsiStateHandler['E'] = (handler, params, prefix) => handler.cursorNextLine(params);\\r\\ncsiStateHandler['F'] = (handler, params, prefix) => handler.cursorPrecedingLine(params);\\r\\ncsiStateHandler['G'] = (handler, params, prefix) => handler.cursorCharAbsolute(params);\\r\\ncsiStateHandler['H'] = (handler, params, prefix) => handler.cursorPosition(params);\\r\\ncsiStateHandler['I'] = (handler, params, prefix) => handler.cursorForwardTab(params);\\r\\ncsiStateHandler['J'] = (handler, params, prefix) => handler.eraseInDisplay(params);\\r\\ncsiStateHandler['K'] = (handler, params, prefix) => handler.eraseInLine(params);\\r\\ncsiStateHandler['L'] = (handler, params, prefix) => handler.insertLines(params);\\r\\ncsiStateHandler['M'] = (handler, params, prefix) => handler.deleteLines(params);\\r\\ncsiStateHandler['P'] = (handler, params, prefix) => handler.deleteChars(params);\\r\\ncsiStateHandler['S'] = (handler, params, prefix) => handler.scrollUp(params);\\r\\ncsiStateHandler['T'] = (handler, params, prefix) => {\\r\\n if (params.length < 2 && !prefix) {\\r\\n handler.scrollDown(params);\\r\\n }\\r\\n};\\r\\ncsiStateHandler['X'] = (handler, params, prefix) => handler.eraseChars(params);\\r\\ncsiStateHandler['Z'] = (handler, params, prefix) => handler.cursorBackwardTab(params);\\r\\ncsiStateHandler['`'] = (handler, params, prefix) => handler.charPosAbsolute(params);\\r\\ncsiStateHandler['a'] = (handler, params, prefix) => handler.HPositionRelative(params);\\r\\ncsiStateHandler['b'] = (handler, params, prefix) => handler.repeatPrecedingCharacter(params);\\r\\ncsiStateHandler['c'] = (handler, params, prefix) => handler.sendDeviceAttributes(params);\\r\\ncsiStateHandler['d'] = (handler, params, prefix) => handler.linePosAbsolute(params);\\r\\ncsiStateHandler['e'] = (handler, params, prefix) => handler.VPositionRelative(params);\\r\\ncsiStateHandler['f'] = (handler, params, prefix) => handler.HVPosition(params);\\r\\ncsiStateHandler['g'] = (handler, params, prefix) => handler.tabClear(params);\\r\\ncsiStateHandler['h'] = (handler, params, prefix) => handler.setMode(params);\\r\\ncsiStateHandler['l'] = (handler, params, prefix) => handler.resetMode(params);\\r\\ncsiStateHandler['m'] = (handler, params, prefix) => handler.charAttributes(params);\\r\\ncsiStateHandler['n'] = (handler, params, prefix) => handler.deviceStatus(params);\\r\\ncsiStateHandler['p'] = (handler, params, prefix) => {\\r\\n switch (prefix) {\\r\\n case '!': handler.softReset(params); break;\\r\\n }\\r\\n};\\r\\ncsiStateHandler['q'] = (handler, params, prefix, postfix) => {\\r\\n if (postfix === ' ') {\\r\\n handler.setCursorStyle(params);\\r\\n }\\r\\n};\\r\\ncsiStateHandler['r'] = (handler, params) => handler.setScrollRegion(params);\\r\\ncsiStateHandler['s'] = (handler, params) => handler.saveCursor(params);\\r\\ncsiStateHandler['u'] = (handler, params) => handler.restoreCursor(params);\\r\\ncsiStateHandler[C0.CAN] = (handler, params, prefix, postfix, parser) => parser.setState(ParserState.NORMAL);\\r\\n\\r\\nexport enum ParserState {\\r\\n NORMAL = 0,\\r\\n ESCAPED = 1,\\r\\n CSI_PARAM = 2,\\r\\n CSI = 3,\\r\\n OSC = 4,\\r\\n CHARSET = 5,\\r\\n DCS = 6,\\r\\n IGNORE = 7\\r\\n}\\r\\n\\r\\n/**\\r\\n * The terminal's parser, all input into the terminal goes through the parser\\r\\n * which parses and defers the actual input handling the the IInputHandler\\r\\n * specified in the constructor.\\r\\n */\\r\\nexport class Parser {\\r\\n private _state: ParserState;\\r\\n private _position: number;\\r\\n\\r\\n // TODO: Remove terminal when handler can do everything\\r\\n constructor(\\r\\n private _inputHandler: IInputHandler,\\r\\n private _terminal: any\\r\\n ) {\\r\\n this._state = ParserState.NORMAL;\\r\\n }\\r\\n\\r\\n /**\\r\\n * Parse and handle data.\\r\\n *\\r\\n * @param data The data to parse.\\r\\n */\\r\\n public parse(data: string): ParserState {\\r\\n const l = data.length;\\r\\n let j;\\r\\n let cs;\\r\\n let ch;\\r\\n let code;\\r\\n let low;\\r\\n\\r\\n const cursorStartX = this._terminal.buffer.x;\\r\\n const cursorStartY = this._terminal.buffer.y;\\r\\n\\r\\n if (this._terminal.debug) {\\r\\n this._terminal.log('data: ' + data);\\r\\n }\\r\\n\\r\\n this._position = 0;\\r\\n // apply leftover surrogate high from last write\\r\\n if (this._terminal.surrogate_high) {\\r\\n data = this._terminal.surrogate_high + data;\\r\\n this._terminal.surrogate_high = '';\\r\\n }\\r\\n\\r\\n for (; this._position < l; this._position++) {\\r\\n ch = data[this._position];\\r\\n\\r\\n // FIXME: higher chars than 0xa0 are not allowed in escape sequences\\r\\n // --> maybe move to default\\r\\n code = data.charCodeAt(this._position);\\r\\n if (0xD800 <= code && code <= 0xDBFF) {\\r\\n // we got a surrogate high\\r\\n // get surrogate low (next 2 bytes)\\r\\n low = data.charCodeAt(this._position + 1);\\r\\n if (isNaN(low)) {\\r\\n // end of data stream, save surrogate high\\r\\n this._terminal.surrogate_high = ch;\\r\\n continue;\\r\\n }\\r\\n code = ((code - 0xD800) * 0x400) + (low - 0xDC00) + 0x10000;\\r\\n ch += data.charAt(this._position + 1);\\r\\n }\\r\\n // surrogate low - already handled above\\r\\n if (0xDC00 <= code && code <= 0xDFFF)\\r\\n continue;\\r\\n\\r\\n switch (this._state) {\\r\\n case ParserState.NORMAL:\\r\\n if (ch in normalStateHandler) {\\r\\n normalStateHandler[ch](this, this._inputHandler);\\r\\n } else {\\r\\n this._inputHandler.addChar(ch, code);\\r\\n }\\r\\n break;\\r\\n case ParserState.ESCAPED:\\r\\n if (ch in escapedStateHandler) {\\r\\n escapedStateHandler[ch](this, this._terminal);\\r\\n // Skip switch as it was just handled\\r\\n break;\\r\\n }\\r\\n switch (ch) {\\r\\n\\r\\n // ESC (,),*,+,-,. Designate G0-G2 Character Set.\\r\\n case '(': // <-- this seems to get all the attention\\r\\n case ')':\\r\\n case '*':\\r\\n case '+':\\r\\n case '-':\\r\\n case '.':\\r\\n switch (ch) {\\r\\n case '(':\\r\\n this._terminal.gcharset = 0;\\r\\n break;\\r\\n case ')':\\r\\n this._terminal.gcharset = 1;\\r\\n break;\\r\\n case '*':\\r\\n this._terminal.gcharset = 2;\\r\\n break;\\r\\n case '+':\\r\\n this._terminal.gcharset = 3;\\r\\n break;\\r\\n case '-':\\r\\n this._terminal.gcharset = 1;\\r\\n break;\\r\\n case '.':\\r\\n this._terminal.gcharset = 2;\\r\\n break;\\r\\n }\\r\\n this._state = ParserState.CHARSET;\\r\\n break;\\r\\n\\r\\n // Designate G3 Character Set (VT300).\\r\\n // A = ISO Latin-1 Supplemental.\\r\\n // Not implemented.\\r\\n case '/':\\r\\n this._terminal.gcharset = 3;\\r\\n this._state = ParserState.CHARSET;\\r\\n this._position--;\\r\\n break;\\r\\n\\r\\n // ESC N\\r\\n // Single Shift Select of G2 Character Set\\r\\n // ( SS2 is 0x8e). This affects next character only.\\r\\n case 'N':\\r\\n break;\\r\\n // ESC O\\r\\n // Single Shift Select of G3 Character Set\\r\\n // ( SS3 is 0x8f). This affects next character only.\\r\\n case 'O':\\r\\n break;\\r\\n // ESC n\\r\\n // Invoke the G2 Character Set as GL (LS2).\\r\\n case 'n':\\r\\n this._terminal.setgLevel(2);\\r\\n break;\\r\\n // ESC o\\r\\n // Invoke the G3 Character Set as GL (LS3).\\r\\n case 'o':\\r\\n this._terminal.setgLevel(3);\\r\\n break;\\r\\n // ESC |\\r\\n // Invoke the G3 Character Set as GR (LS3R).\\r\\n case '|':\\r\\n this._terminal.setgLevel(3);\\r\\n break;\\r\\n // ESC }\\r\\n // Invoke the G2 Character Set as GR (LS2R).\\r\\n case '}':\\r\\n this._terminal.setgLevel(2);\\r\\n break;\\r\\n // ESC ~\\r\\n // Invoke the G1 Character Set as GR (LS1R).\\r\\n case '~':\\r\\n this._terminal.setgLevel(1);\\r\\n break;\\r\\n\\r\\n // ESC 7 Save Cursor (DECSC).\\r\\n case '7':\\r\\n this._inputHandler.saveCursor();\\r\\n this._state = ParserState.NORMAL;\\r\\n break;\\r\\n\\r\\n // ESC 8 Restore Cursor (DECRC).\\r\\n case '8':\\r\\n this._inputHandler.restoreCursor();\\r\\n this._state = ParserState.NORMAL;\\r\\n break;\\r\\n\\r\\n // ESC # 3 DEC line height/width\\r\\n case '#':\\r\\n this._state = ParserState.NORMAL;\\r\\n this._position++;\\r\\n break;\\r\\n\\r\\n // ESC H Tab Set (HTS is 0x88).\\r\\n case 'H':\\r\\n this._terminal.tabSet();\\r\\n this._state = ParserState.NORMAL;\\r\\n break;\\r\\n\\r\\n // ESC = Application Keypad (DECKPAM).\\r\\n case '=':\\r\\n this._terminal.log('Serial port requested application keypad.');\\r\\n this._terminal.applicationKeypad = true;\\r\\n if (this._terminal.viewport) {\\r\\n this._terminal.viewport.syncScrollArea();\\r\\n }\\r\\n this._state = ParserState.NORMAL;\\r\\n break;\\r\\n\\r\\n // ESC > Normal Keypad (DECKPNM).\\r\\n case '>':\\r\\n this._terminal.log('Switching back to normal keypad.');\\r\\n this._terminal.applicationKeypad = false;\\r\\n if (this._terminal.viewport) {\\r\\n this._terminal.viewport.syncScrollArea();\\r\\n }\\r\\n this._state = ParserState.NORMAL;\\r\\n break;\\r\\n\\r\\n default:\\r\\n this._state = ParserState.NORMAL;\\r\\n this._terminal.error('Unknown ESC control: %s.', ch);\\r\\n break;\\r\\n }\\r\\n break;\\r\\n\\r\\n case ParserState.CHARSET:\\r\\n if (ch in CHARSETS) {\\r\\n cs = CHARSETS[ch];\\r\\n if (ch === '/') { // ISOLatin is actually /A\\r\\n this.skipNextChar();\\r\\n }\\r\\n } else {\\r\\n cs = DEFAULT_CHARSET;\\r\\n }\\r\\n this._terminal.setgCharset(this._terminal.gcharset, cs);\\r\\n this._terminal.gcharset = null;\\r\\n this._state = ParserState.NORMAL;\\r\\n break;\\r\\n\\r\\n case ParserState.OSC:\\r\\n // OSC Ps ; Pt ST\\r\\n // OSC Ps ; Pt BEL\\r\\n // Set Text Parameters.\\r\\n if (ch === C0.ESC || ch === C0.BEL) {\\r\\n if (ch === C0.ESC) this._position++;\\r\\n\\r\\n this._terminal.params.push(this._terminal.currentParam);\\r\\n\\r\\n switch (this._terminal.params[0]) {\\r\\n case 0:\\r\\n case 1:\\r\\n case 2:\\r\\n if (this._terminal.params[1]) {\\r\\n this._terminal.title = this._terminal.params[1];\\r\\n this._terminal.handleTitle(this._terminal.title);\\r\\n }\\r\\n break;\\r\\n case 3:\\r\\n // set X property\\r\\n break;\\r\\n case 4:\\r\\n case 5:\\r\\n // change dynamic colors\\r\\n break;\\r\\n case 10:\\r\\n case 11:\\r\\n case 12:\\r\\n case 13:\\r\\n case 14:\\r\\n case 15:\\r\\n case 16:\\r\\n case 17:\\r\\n case 18:\\r\\n case 19:\\r\\n // change dynamic ui colors\\r\\n break;\\r\\n case 46:\\r\\n // change log file\\r\\n break;\\r\\n case 50:\\r\\n // dynamic font\\r\\n break;\\r\\n case 51:\\r\\n // emacs shell\\r\\n break;\\r\\n case 52:\\r\\n // manipulate selection data\\r\\n break;\\r\\n case 104:\\r\\n case 105:\\r\\n case 110:\\r\\n case 111:\\r\\n case 112:\\r\\n case 113:\\r\\n case 114:\\r\\n case 115:\\r\\n case 116:\\r\\n case 117:\\r\\n case 118:\\r\\n // reset colors\\r\\n break;\\r\\n }\\r\\n\\r\\n this._terminal.params = [];\\r\\n this._terminal.currentParam = 0;\\r\\n this._state = ParserState.NORMAL;\\r\\n } else {\\r\\n if (!this._terminal.params.length) {\\r\\n if (ch >= '0' && ch <= '9') {\\r\\n this._terminal.currentParam =\\r\\n this._terminal.currentParam * 10 + ch.charCodeAt(0) - 48;\\r\\n } else if (ch === ';') {\\r\\n this._terminal.params.push(this._terminal.currentParam);\\r\\n this._terminal.currentParam = '';\\r\\n }\\r\\n } else {\\r\\n this._terminal.currentParam += ch;\\r\\n }\\r\\n }\\r\\n break;\\r\\n\\r\\n case ParserState.CSI_PARAM:\\r\\n if (ch in csiParamStateHandler) {\\r\\n csiParamStateHandler[ch](this);\\r\\n break;\\r\\n }\\r\\n this.finalizeParam();\\r\\n // Fall through the CSI as this character should be the CSI code.\\r\\n this._state = ParserState.CSI;\\r\\n\\r\\n case ParserState.CSI:\\r\\n if (ch in csiStateHandler) {\\r\\n if (this._terminal.debug) {\\r\\n this._terminal.log(`CSI ${this._terminal.prefix ? this._terminal.prefix : ''} ${this._terminal.params ? this._terminal.params.join(';') : ''} ${this._terminal.postfix ? this._terminal.postfix : ''} ${ch}`);\\r\\n }\\r\\n csiStateHandler[ch](this._inputHandler, this._terminal.params, this._terminal.prefix, this._terminal.postfix, this);\\r\\n } else {\\r\\n this._terminal.error('Unknown CSI code: %s.', ch);\\r\\n }\\r\\n\\r\\n this._state = ParserState.NORMAL;\\r\\n this._terminal.prefix = '';\\r\\n this._terminal.postfix = '';\\r\\n break;\\r\\n\\r\\n case ParserState.DCS:\\r\\n if (ch === C0.ESC || ch === C0.BEL) {\\r\\n if (ch === C0.ESC) this._position++;\\r\\n let pt;\\r\\n let valid: boolean;\\r\\n\\r\\n switch (this._terminal.prefix) {\\r\\n // User-Defined Keys (DECUDK).\\r\\n case '':\\r\\n break;\\r\\n\\r\\n // Request Status String (DECRQSS).\\r\\n // test: echo -e '\\\\eP$q\\\"p\\\\e\\\\\\\\'\\r\\n case '$q':\\r\\n pt = this._terminal.currentParam;\\r\\n valid = false;\\r\\n\\r\\n switch (pt) {\\r\\n // DECSCA\\r\\n case '\\\"q':\\r\\n pt = '0\\\"q';\\r\\n break;\\r\\n\\r\\n // DECSCL\\r\\n case '\\\"p':\\r\\n pt = '61\\\"p';\\r\\n break;\\r\\n\\r\\n // DECSTBM\\r\\n case 'r':\\r\\n pt = ''\\r\\n + (this._terminal.buffer.scrollTop + 1)\\r\\n + ';'\\r\\n + (this._terminal.buffer.scrollBottom + 1)\\r\\n + 'r';\\r\\n break;\\r\\n\\r\\n // SGR\\r\\n case 'm':\\r\\n pt = '0m';\\r\\n break;\\r\\n\\r\\n default:\\r\\n this._terminal.error('Unknown DCS Pt: %s.', pt);\\r\\n pt = '';\\r\\n break;\\r\\n }\\r\\n\\r\\n this._terminal.send(C0.ESC + 'P' + +valid + '$r' + pt + C0.ESC + '\\\\\\\\');\\r\\n break;\\r\\n\\r\\n // Set Termcap/Terminfo Data (xterm, experimental).\\r\\n case '+p':\\r\\n break;\\r\\n\\r\\n // Request Termcap/Terminfo String (xterm, experimental)\\r\\n // Regular xterm does not even respond to this sequence.\\r\\n // This can cause a small glitch in vim.\\r\\n // test: echo -ne '\\\\eP+q6b64\\\\e\\\\\\\\'\\r\\n case '+q':\\r\\n pt = this._terminal.currentParam;\\r\\n valid = false;\\r\\n\\r\\n this._terminal.send(C0.ESC + 'P' + +valid + '+r' + pt + C0.ESC + '\\\\\\\\');\\r\\n break;\\r\\n\\r\\n default:\\r\\n this._terminal.error('Unknown DCS prefix: %s.', this._terminal.prefix);\\r\\n break;\\r\\n }\\r\\n\\r\\n this._terminal.currentParam = 0;\\r\\n this._terminal.prefix = '';\\r\\n this._state = ParserState.NORMAL;\\r\\n } else if (!this._terminal.currentParam) {\\r\\n if (!this._terminal.prefix && ch !== '$' && ch !== '+') {\\r\\n this._terminal.currentParam = ch;\\r\\n } else if (this._terminal.prefix.length === 2) {\\r\\n this._terminal.currentParam = ch;\\r\\n } else {\\r\\n this._terminal.prefix += ch;\\r\\n }\\r\\n } else {\\r\\n this._terminal.currentParam += ch;\\r\\n }\\r\\n break;\\r\\n\\r\\n case ParserState.IGNORE:\\r\\n // For PM and APC.\\r\\n if (ch === C0.ESC || ch === C0.BEL) {\\r\\n if (ch === C0.ESC) this._position++;\\r\\n this._state = ParserState.NORMAL;\\r\\n }\\r\\n break;\\r\\n }\\r\\n }\\r\\n\\r\\n // Fire the cursormove event if it's moved. This is done inside the parser\\r\\n // as a render cannot happen in the middle of a parsing round.\\r\\n if (this._terminal.buffer.x !== cursorStartX || this._terminal.buffer.y !== cursorStartY) {\\r\\n this._terminal.emit('cursormove');\\r\\n }\\r\\n\\r\\n return this._state;\\r\\n }\\r\\n\\r\\n /**\\r\\n * Set the parser's current parsing state.\\r\\n *\\r\\n * @param state The new state.\\r\\n */\\r\\n public setState(state: ParserState): void {\\r\\n this._state = state;\\r\\n }\\r\\n\\r\\n /**\\r\\n * Sets the parsier's current prefix. CSI codes can have prefixes of '?', '>'\\r\\n * or '!'.\\r\\n *\\r\\n * @param prefix The prefix.\\r\\n */\\r\\n public setPrefix(prefix: string): void {\\r\\n this._terminal.prefix = prefix;\\r\\n }\\r\\n\\r\\n /**\\r\\n * Sets the parsier's current prefix. CSI codes can have postfixes of '$',\\r\\n * '\\\"', ' ', '\\\\''.\\r\\n *\\r\\n * @param postfix The postfix.\\r\\n */\\r\\n public setPostfix(postfix: string): void {\\r\\n this._terminal.postfix = postfix;\\r\\n }\\r\\n\\r\\n /**\\r\\n * Sets the parser's current parameter.\\r\\n *\\r\\n * @param param the parameter.\\r\\n */\\r\\n public setParam(param: number): void {\\r\\n this._terminal.currentParam = param;\\r\\n }\\r\\n\\r\\n /**\\r\\n * Gets the parser's current parameter.\\r\\n */\\r\\n public getParam(): number {\\r\\n return this._terminal.currentParam;\\r\\n }\\r\\n\\r\\n /**\\r\\n * Finalizes the parser's current parameter, adding it to the list of\\r\\n * parameters and setting the new current parameter to 0.\\r\\n */\\r\\n public finalizeParam(): void {\\r\\n this._terminal.params.push(this._terminal.currentParam);\\r\\n this._terminal.currentParam = 0;\\r\\n }\\r\\n\\r\\n /**\\r\\n * Tell the parser to skip the next character.\\r\\n */\\r\\n public skipNextChar(): void {\\r\\n this._position++;\\r\\n }\\r\\n\\r\\n /**\\r\\n * Tell the parser to repeat parsing the current character (for example if it\\r\\n * needs parsing using a different state.\\r\\n */\\r\\n // public repeatChar(): void {\\r\\n // this._position--;\\r\\n // }\\r\\n}\\r\\n\",\"/**\\r\\n * Copyright (c) 2017 The xterm.js authors. All rights reserved.\\r\\n * @license MIT\\r\\n */\\r\\n\\r\\nimport { ILinkMatcherOptions, ITerminal, IBufferAccessor, ILinkifier, IElementAccessor } from './Interfaces';\\r\\nimport { LinkMatcher, LinkMatcherHandler, LinkMatcherValidationCallback, LineData, LinkHoverEvent, LinkHoverEventTypes } from './Types';\\r\\nimport { IMouseZoneManager } from './input/Interfaces';\\r\\nimport { MouseZone } from './input/MouseZoneManager';\\r\\nimport { EventEmitter } from './EventEmitter';\\r\\n\\r\\nconst protocolClause = '(https?:\\\\\\\\/\\\\\\\\/)';\\r\\nconst domainCharacterSet = '[\\\\\\\\da-z\\\\\\\\.-]+';\\r\\nconst negatedDomainCharacterSet = '[^\\\\\\\\da-z\\\\\\\\.-]+';\\r\\nconst domainBodyClause = '(' + domainCharacterSet + ')';\\r\\nconst tldClause = '([a-z\\\\\\\\.]{2,6})';\\r\\nconst ipClause = '((\\\\\\\\d{1,3}\\\\\\\\.){3}\\\\\\\\d{1,3})';\\r\\nconst localHostClause = '(localhost)';\\r\\nconst portClause = '(:\\\\\\\\d{1,5})';\\r\\nconst hostClause = '((' + domainBodyClause + '\\\\\\\\.' + tldClause + ')|' + ipClause + '|' + localHostClause + ')' + portClause + '?';\\r\\nconst pathClause = '(\\\\\\\\/[\\\\\\\\/\\\\\\\\w\\\\\\\\.\\\\\\\\-%~]*)*';\\r\\nconst queryStringHashFragmentCharacterSet = '[0-9\\\\\\\\w\\\\\\\\[\\\\\\\\]\\\\\\\\(\\\\\\\\)\\\\\\\\/\\\\\\\\?\\\\\\\\!#@$%&\\\\'*+,:;~\\\\\\\\=\\\\\\\\.\\\\\\\\-]*';\\r\\nconst queryStringClause = '(\\\\\\\\?' + queryStringHashFragmentCharacterSet + ')?';\\r\\nconst hashFragmentClause = '(#' + queryStringHashFragmentCharacterSet + ')?';\\r\\nconst negatedPathCharacterSet = '[^\\\\\\\\/\\\\\\\\w\\\\\\\\.\\\\\\\\-%]+';\\r\\nconst bodyClause = hostClause + pathClause + queryStringClause + hashFragmentClause;\\r\\nconst start = '(?:^|' + negatedDomainCharacterSet + ')(';\\r\\nconst end = ')($|' + negatedPathCharacterSet + ')';\\r\\nconst strictUrlRegex = new RegExp(start + protocolClause + bodyClause + end);\\r\\n\\r\\n/**\\r\\n * The ID of the built in http(s) link matcher.\\r\\n */\\r\\nconst HYPERTEXT_LINK_MATCHER_ID = 0;\\r\\n\\r\\n/**\\r\\n * The Linkifier applies links to rows shortly after they have been refreshed.\\r\\n */\\r\\nexport class Linkifier extends EventEmitter implements ILinkifier {\\r\\n /**\\r\\n * The time to wait after a row is changed before it is linkified. This prevents\\r\\n * the costly operation of searching every row multiple times, potentially a\\r\\n * huge amount of times.\\r\\n */\\r\\n protected static TIME_BEFORE_LINKIFY = 200;\\r\\n\\r\\n protected _linkMatchers: LinkMatcher[] = [];\\r\\n\\r\\n private _mouseZoneManager: IMouseZoneManager;\\r\\n private _rowsTimeoutId: number;\\r\\n private _nextLinkMatcherId = HYPERTEXT_LINK_MATCHER_ID;\\r\\n private _rowsToLinkify: {start: number, end: number};\\r\\n\\r\\n constructor(\\r\\n protected _terminal: IBufferAccessor & IElementAccessor\\r\\n ) {\\r\\n super();\\r\\n this._rowsToLinkify = {\\r\\n start: null,\\r\\n end: null\\r\\n };\\r\\n this.registerLinkMatcher(strictUrlRegex, null, { matchIndex: 1 });\\r\\n }\\r\\n\\r\\n /**\\r\\n * Attaches the linkifier to the DOM, enabling linkification.\\r\\n * @param mouseZoneManager The mouse zone manager to register link zones with.\\r\\n */\\r\\n public attachToDom(mouseZoneManager: IMouseZoneManager): void {\\r\\n this._mouseZoneManager = mouseZoneManager;\\r\\n }\\r\\n\\r\\n /**\\r\\n * Queue linkification on a set of rows.\\r\\n * @param start The row to linkify from (inclusive).\\r\\n * @param end The row to linkify to (inclusive).\\r\\n */\\r\\n public linkifyRows(start: number, end: number): void {\\r\\n // Don't attempt linkify if not yet attached to DOM\\r\\n if (!this._mouseZoneManager) {\\r\\n return;\\r\\n }\\r\\n\\r\\n // Increase range to linkify\\r\\n if (!this._rowsToLinkify.start) {\\r\\n this._rowsToLinkify.start = start;\\r\\n this._rowsToLinkify.end = end;\\r\\n } else {\\r\\n this._rowsToLinkify.start = this._rowsToLinkify.start < start ? this._rowsToLinkify.start : start;\\r\\n this._rowsToLinkify.end = this._rowsToLinkify.end > end ? this._rowsToLinkify.end : end;\\r\\n }\\r\\n\\r\\n // Clear out any existing links on this row range\\r\\n this._mouseZoneManager.clearAll(start, end);\\r\\n\\r\\n // Restart timer\\r\\n if (this._rowsTimeoutId) {\\r\\n clearTimeout(this._rowsTimeoutId);\\r\\n }\\r\\n this._rowsTimeoutId = <number><any>setTimeout(() => this._linkifyRows(), Linkifier.TIME_BEFORE_LINKIFY);\\r\\n }\\r\\n\\r\\n /**\\r\\n * Linkifies the rows requested.\\r\\n */\\r\\n private _linkifyRows(): void {\\r\\n this._rowsTimeoutId = null;\\r\\n for (let i = this._rowsToLinkify.start; i <= this._rowsToLinkify.end; i++) {\\r\\n this._linkifyRow(i);\\r\\n }\\r\\n this._rowsToLinkify.start = null;\\r\\n this._rowsToLinkify.end = null;\\r\\n }\\r\\n\\r\\n /**\\r\\n * Attaches a handler for hypertext links, overriding default <a> behavior for\\r\\n * tandard http(s) links.\\r\\n * @param handler The handler to use, this can be cleared with null.\\r\\n */\\r\\n public setHypertextLinkHandler(handler: LinkMatcherHandler): void {\\r\\n this._linkMatchers[HYPERTEXT_LINK_MATCHER_ID].handler = handler;\\r\\n }\\r\\n\\r\\n /**\\r\\n * Attaches a validation callback for hypertext links.\\r\\n * @param callback The callback to use, this can be cleared with null.\\r\\n */\\r\\n public setHypertextValidationCallback(callback: LinkMatcherValidationCallback): void {\\r\\n this._linkMatchers[HYPERTEXT_LINK_MATCHER_ID].validationCallback = callback;\\r\\n }\\r\\n\\r\\n /**\\r\\n * Registers a link matcher, allowing custom link patterns to be matched and\\r\\n * handled.\\r\\n * @param regex The regular expression to search for. Specifically, this\\r\\n * searches the textContent of the rows. You will want to use \\\\s to match a\\r\\n * space ' ' character for example.\\r\\n * @param handler The callback when the link is called.\\r\\n * @param options Options for the link matcher.\\r\\n * @return The ID of the new matcher, this can be used to deregister.\\r\\n */\\r\\n public registerLinkMatcher(regex: RegExp, handler: LinkMatcherHandler, options: ILinkMatcherOptions = {}): number {\\r\\n if (this._nextLinkMatcherId !== HYPERTEXT_LINK_MATCHER_ID && !handler) {\\r\\n throw new Error('handler must be defined');\\r\\n }\\r\\n const matcher: LinkMatcher = {\\r\\n id: this._nextLinkMatcherId++,\\r\\n regex,\\r\\n handler,\\r\\n matchIndex: options.matchIndex,\\r\\n validationCallback: options.validationCallback,\\r\\n hoverTooltipCallback: options.tooltipCallback,\\r\\n hoverLeaveCallback: options.leaveCallback,\\r\\n priority: options.priority || 0\\r\\n };\\r\\n this._addLinkMatcherToList(matcher);\\r\\n return matcher.id;\\r\\n }\\r\\n\\r\\n /**\\r\\n * Inserts a link matcher to the list in the correct position based on the\\r\\n * priority of each link matcher. New link matchers of equal priority are\\r\\n * considered after older link matchers.\\r\\n * @param matcher The link matcher to be added.\\r\\n */\\r\\n private _addLinkMatcherToList(matcher: LinkMatcher): void {\\r\\n if (this._linkMatchers.length === 0) {\\r\\n this._linkMatchers.push(matcher);\\r\\n return;\\r\\n }\\r\\n\\r\\n for (let i = this._linkMatchers.length - 1; i >= 0; i--) {\\r\\n if (matcher.priority <= this._linkMatchers[i].priority) {\\r\\n this._linkMatchers.splice(i + 1, 0, matcher);\\r\\n return;\\r\\n }\\r\\n }\\r\\n\\r\\n this._linkMatchers.splice(0, 0, matcher);\\r\\n }\\r\\n\\r\\n /**\\r\\n * Deregisters a link matcher if it has been registered.\\r\\n * @param matcherId The link matcher's ID (returned after register)\\r\\n * @return Whether a link matcher was found and deregistered.\\r\\n */\\r\\n public deregisterLinkMatcher(matcherId: number): boolean {\\r\\n // ID 0 is the hypertext link matcher which cannot be deregistered\\r\\n for (let i = 1; i < this._linkMatchers.length; i++) {\\r\\n if (this._linkMatchers[i].id === matcherId) {\\r\\n this._linkMatchers.splice(i, 1);\\r\\n return true;\\r\\n }\\r\\n }\\r\\n return false;\\r\\n }\\r\\n\\r\\n /**\\r\\n * Linkifies a row.\\r\\n * @param rowIndex The index of the row to linkify.\\r\\n */\\r\\n private _linkifyRow(rowIndex: number): void {\\r\\n const absoluteRowIndex = this._terminal.buffer.ydisp + rowIndex;\\r\\n if (absoluteRowIndex >= this._terminal.buffer.lines.length) {\\r\\n return;\\r\\n }\\r\\n const text = this._terminal.buffer.translateBufferLineToString(absoluteRowIndex, false);\\r\\n for (let i = 0; i < this._linkMatchers.length; i++) {\\r\\n this._doLinkifyRow(rowIndex, text, this._linkMatchers[i]);\\r\\n }\\r\\n }\\r\\n\\r\\n /**\\r\\n * Linkifies a row given a specific handler.\\r\\n * @param rowIndex The row index to linkify.\\r\\n * @param text The text of the row (excludes text in the row that's already\\r\\n * linkified).\\r\\n * @param matcher The link matcher for this line.\\r\\n * @param offset The how much of the row has already been linkified.\\r\\n * @return The link element(s) that were added.\\r\\n */\\r\\n private _doLinkifyRow(rowIndex: number, text: string, matcher: LinkMatcher, offset: number = 0): void {\\r\\n // Iterate over nodes as we want to consider text nodes\\r\\n let result = [];\\r\\n const isHttpLinkMatcher = matcher.id === HYPERTEXT_LINK_MATCHER_ID;\\r\\n\\r\\n // Find the first match\\r\\n let match = text.match(matcher.regex);\\r\\n if (!match || match.length === 0) {\\r\\n return;\\r\\n }\\r\\n let uri = match[typeof matcher.matchIndex !== 'number' ? 0 : matcher.matchIndex];\\r\\n\\r\\n // Get index, match.index is for the outer match which includes negated chars\\r\\n const index = text.indexOf(uri);\\r\\n\\r\\n // Ensure the link is valid before registering\\r\\n if (matcher.validationCallback) {\\r\\n matcher.validationCallback(uri, isValid => {\\r\\n // Discard link if the line has already changed\\r\\n if (this._rowsTimeoutId) {\\r\\n return;\\r\\n }\\r\\n if (isValid) {\\r\\n this._addLink(offset + index, rowIndex, uri, matcher);\\r\\n }\\r\\n });\\r\\n } else {\\r\\n this._addLink(offset + index, rowIndex, uri, matcher);\\r\\n }\\r\\n\\r\\n // Recursively check for links in the rest of the text\\r\\n const remainingStartIndex = index + uri.length;\\r\\n const remainingText = text.substr(remainingStartIndex);\\r\\n if (remainingText.length > 0) {\\r\\n this._doLinkifyRow(rowIndex, remainingText, matcher, offset + remainingStartIndex);\\r\\n }\\r\\n }\\r\\n\\r\\n /**\\r\\n * Registers a link to the mouse zone manager.\\r\\n * @param x The column the link starts.\\r\\n * @param y The row the link is on.\\r\\n * @param uri The URI of the link.\\r\\n * @param matcher The link matcher for the link.\\r\\n */\\r\\n private _addLink(x: number, y: number, uri: string, matcher: LinkMatcher): void {\\r\\n this._mouseZoneManager.add(new MouseZone(\\r\\n x + 1,\\r\\n x + 1 + uri.length,\\r\\n y + 1,\\r\\n e => {\\r\\n if (matcher.handler) {\\r\\n return matcher.handler(e, uri);\\r\\n }\\r\\n window.open(uri, '_blank');\\r\\n },\\r\\n e => {\\r\\n this.emit(LinkHoverEventTypes.HOVER, <LinkHoverEvent>{ x, y, length: uri.length});\\r\\n this._terminal.element.style.cursor = 'pointer';\\r\\n },\\r\\n e => {\\r\\n this.emit(LinkHoverEventTypes.TOOLTIP, <LinkHoverEvent>{ x, y, length: uri.length});\\r\\n if (matcher.hoverTooltipCallback) {\\r\\n matcher.hoverTooltipCallback(e, uri);\\r\\n }\\r\\n },\\r\\n () => {\\r\\n this.emit(LinkHoverEventTypes.LEAVE, <LinkHoverEvent>{ x, y, length: uri.length});\\r\\n this._terminal.element.style.cursor = '';\\r\\n if (matcher.hoverLeaveCallback) {\\r\\n matcher.hoverLeaveCallback();\\r\\n }\\r\\n }\\r\\n ));\\r\\n }\\r\\n}\\r\\n\",\"/**\\r\\n * Copyright (c) 2014 The xterm.js authors. All rights reserved.\\r\\n * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)\\r\\n * @license MIT\\r\\n */\\r\\n\\r\\nimport { IInputHandler, ITerminal, IInputHandlingTerminal } from './Interfaces';\\r\\nimport { C0 } from './EscapeSequences';\\r\\nimport { DEFAULT_CHARSET } from './Charsets';\\r\\nimport { CharData } from './Types';\\r\\nimport { CHAR_DATA_CHAR_INDEX, CHAR_DATA_WIDTH_INDEX } from './Buffer';\\r\\nimport { FLAGS } from './renderer/Types';\\r\\n\\r\\n/**\\r\\n * The terminal's standard implementation of IInputHandler, this handles all\\r\\n * input from the Parser.\\r\\n *\\r\\n * Refer to http://invisible-island.net/xterm/ctlseqs/ctlseqs.html to understand\\r\\n * each function's header comment.\\r\\n */\\r\\nexport class InputHandler implements IInputHandler {\\r\\n constructor(private _terminal: IInputHandlingTerminal) { }\\r\\n\\r\\n public addChar(char: string, code: number): void {\\r\\n if (char >= ' ') {\\r\\n // calculate print space\\r\\n // expensive call, therefore we save width in line buffer\\r\\n const ch_width = wcwidth(code);\\r\\n\\r\\n if (this._terminal.charset && this._terminal.charset[char]) {\\r\\n char = this._terminal.charset[char];\\r\\n }\\r\\n\\r\\n let row = this._terminal.buffer.y + this._terminal.buffer.ybase;\\r\\n\\r\\n // insert combining char in last cell\\r\\n // FIXME: needs handling after cursor jumps\\r\\n if (!ch_width && this._terminal.buffer.x) {\\r\\n // dont overflow left\\r\\n if (this._terminal.buffer.lines.get(row)[this._terminal.buffer.x - 1]) {\\r\\n if (!this._terminal.buffer.lines.get(row)[this._terminal.buffer.x - 1][CHAR_DATA_WIDTH_INDEX]) {\\r\\n // found empty cell after fullwidth, need to go 2 cells back\\r\\n if (this._terminal.buffer.lines.get(row)[this._terminal.buffer.x - 2]) {\\r\\n this._terminal.buffer.lines.get(row)[this._terminal.buffer.x - 2][CHAR_DATA_CHAR_INDEX] += char;\\r\\n this._terminal.buffer.lines.get(row)[this._terminal.buffer.x - 2][3] = char.charCodeAt(0);\\r\\n }\\r\\n } else {\\r\\n this._terminal.buffer.lines.get(row)[this._terminal.buffer.x - 1][CHAR_DATA_CHAR_INDEX] += char;\\r\\n this._terminal.buffer.lines.get(row)[this._terminal.buffer.x - 1][3] = char.charCodeAt(0);\\r\\n }\\r\\n this._terminal.updateRange(this._terminal.buffer.y);\\r\\n }\\r\\n return;\\r\\n }\\r\\n\\r\\n // goto next line if ch would overflow\\r\\n // TODO: needs a global min terminal width of 2\\r\\n if (this._terminal.buffer.x + ch_width - 1 >= this._terminal.cols) {\\r\\n // autowrap - DECAWM\\r\\n if (this._terminal.wraparoundMode) {\\r\\n this._terminal.buffer.x = 0;\\r\\n this._terminal.buffer.y++;\\r\\n if (this._terminal.buffer.y > this._terminal.buffer.scrollBottom) {\\r\\n this._terminal.buffer.y--;\\r\\n this._terminal.scroll(true);\\r\\n } else {\\r\\n // The line already exists (eg. the initial viewport), mark it as a\\r\\n // wrapped line\\r\\n (<any>this._terminal.buffer.lines.get(this._terminal.buffer.y)).isWrapped = true;\\r\\n }\\r\\n } else {\\r\\n if (ch_width === 2) // FIXME: check for xterm behavior\\r\\n return;\\r\\n }\\r\\n }\\r\\n row = this._terminal.buffer.y + this._terminal.buffer.ybase;\\r\\n\\r\\n // insert mode: move characters to right\\r\\n if (this._terminal.insertMode) {\\r\\n // do this twice for a fullwidth char\\r\\n for (let moves = 0; moves < ch_width; ++moves) {\\r\\n // remove last cell, if it's width is 0\\r\\n // we have to adjust the second last cell as well\\r\\n const removed = this._terminal.buffer.lines.get(this._terminal.buffer.y + this._terminal.buffer.ybase).pop();\\r\\n if (removed[CHAR_DATA_WIDTH_INDEX] === 0\\r\\n && this._terminal.buffer.lines.get(row)[this._terminal.cols - 2]\\r\\n && this._terminal.buffer.lines.get(row)[this._terminal.cols - 2][CHAR_DATA_WIDTH_INDEX] === 2) {\\r\\n this._terminal.buffer.lines.get(row)[this._terminal.cols - 2] = [this._terminal.curAttr, ' ', 1, ' '.charCodeAt(0)];\\r\\n }\\r\\n\\r\\n // insert empty cell at cursor\\r\\n this._terminal.buffer.lines.get(row).splice(this._terminal.buffer.x, 0, [this._terminal.curAttr, ' ', 1, ' '.charCodeAt(0)]);\\r\\n }\\r\\n }\\r\\n\\r\\n this._terminal.buffer.lines.get(row)[this._terminal.buffer.x] = [this._terminal.curAttr, char, ch_width, char.charCodeAt(0)];\\r\\n this._terminal.buffer.x++;\\r\\n this._terminal.updateRange(this._terminal.buffer.y);\\r\\n\\r\\n // fullwidth char - set next cell width to zero and advance cursor\\r\\n if (ch_width === 2) {\\r\\n this._terminal.buffer.lines.get(row)[this._terminal.buffer.x] = [this._terminal.curAttr, '', 0, undefined];\\r\\n this._terminal.buffer.x++;\\r\\n }\\r\\n }\\r\\n }\\r\\n\\r\\n /**\\r\\n * BEL\\r\\n * Bell (Ctrl-G).\\r\\n */\\r\\n public bell(): void {\\r\\n this._terminal.bell();\\r\\n }\\r\\n\\r\\n /**\\r\\n * LF\\r\\n * Line Feed or New Line (NL). (LF is Ctrl-J).\\r\\n */\\r\\n public lineFeed(): void {\\r\\n if (this._terminal.convertEol) {\\r\\n this._terminal.buffer.x = 0;\\r\\n }\\r\\n this._terminal.buffer.y++;\\r\\n if (this._terminal.buffer.y > this._terminal.buffer.scrollBottom) {\\r\\n this._terminal.buffer.y--;\\r\\n this._terminal.scroll();\\r\\n }\\r\\n // If the end of the line is hit, prevent this action from wrapping around to the next line.\\r\\n if (this._terminal.buffer.x >= this._terminal.cols) {\\r\\n this._terminal.buffer.x--;\\r\\n }\\r\\n /**\\r\\n * This event is emitted whenever the terminal outputs a LF or NL.\\r\\n *\\r\\n * @event lineFeed\\r\\n */\\r\\n this._terminal.emit('lineFeed');\\r\\n }\\r\\n\\r\\n /**\\r\\n * CR\\r\\n * Carriage Return (Ctrl-M).\\r\\n */\\r\\n public carriageReturn(): void {\\r\\n this._terminal.buffer.x = 0;\\r\\n }\\r\\n\\r\\n /**\\r\\n * BS\\r\\n * Backspace (Ctrl-H).\\r\\n */\\r\\n public backspace(): void {\\r\\n if (this._terminal.buffer.x > 0) {\\r\\n this._terminal.buffer.x--;\\r\\n }\\r\\n }\\r\\n\\r\\n /**\\r\\n * TAB\\r\\n * Horizontal Tab (HT) (Ctrl-I).\\r\\n */\\r\\n public tab(): void {\\r\\n this._terminal.buffer.x = this._terminal.buffer.nextStop();\\r\\n }\\r\\n\\r\\n /**\\r\\n * SO\\r\\n * Shift Out (Ctrl-N) -> Switch to Alternate Character Set. This invokes the\\r\\n * G1 character set.\\r\\n */\\r\\n public shiftOut(): void {\\r\\n this._terminal.setgLevel(1);\\r\\n }\\r\\n\\r\\n /**\\r\\n * SI\\r\\n * Shift In (Ctrl-O) -> Switch to Standard Character Set. This invokes the G0\\r\\n * character set (the default).\\r\\n */\\r\\n public shiftIn(): void {\\r\\n this._terminal.setgLevel(0);\\r\\n }\\r\\n\\r\\n /**\\r\\n * CSI Ps @\\r\\n * Insert Ps (Blank) Character(s) (default = 1) (ICH).\\r\\n */\\r\\n public insertChars(params: number[]): void {\\r\\n let param = params[0];\\r\\n if (param < 1) param = 1;\\r\\n\\r\\n const row = this._terminal.buffer.y + this._terminal.buffer.ybase;\\r\\n let j = this._terminal.buffer.x;\\r\\n const ch: CharData = [this._terminal.eraseAttr(), ' ', 1, 32]; // xterm\\r\\n\\r\\n while (param-- && j < this._terminal.cols) {\\r\\n this._terminal.buffer.lines.get(row).splice(j++, 0, ch);\\r\\n this._terminal.buffer.lines.get(row).pop();\\r\\n }\\r\\n }\\r\\n\\r\\n /**\\r\\n * CSI Ps A\\r\\n * Cursor Up Ps Times (default = 1) (CUU).\\r\\n */\\r\\n public cursorUp(params: number[]): void {\\r\\n let param = params[0];\\r\\n if (param < 1) {\\r\\n param = 1;\\r\\n }\\r\\n this._terminal.buffer.y -= param;\\r\\n if (this._terminal.buffer.y < 0) {\\r\\n this._terminal.buffer.y = 0;\\r\\n }\\r\\n }\\r\\n\\r\\n /**\\r\\n * CSI Ps B\\r\\n * Cursor Down Ps Times (default = 1) (CUD).\\r\\n */\\r\\n public cursorDown(params: number[]): void {\\r\\n let param = params[0];\\r\\n if (param < 1) {\\r\\n param = 1;\\r\\n }\\r\\n this._terminal.buffer.y += param;\\r\\n if (this._terminal.buffer.y >= this._terminal.rows) {\\r\\n this._terminal.buffer.y = this._terminal.rows - 1;\\r\\n }\\r\\n // If the end of the line is hit, prevent this action from wrapping around to the next line.\\r\\n if (this._terminal.buffer.x >= this._terminal.cols) {\\r\\n this._terminal.buffer.x--;\\r\\n }\\r\\n }\\r\\n\\r\\n /**\\r\\n * CSI Ps C\\r\\n * Cursor Forward Ps Times (default = 1) (CUF).\\r\\n */\\r\\n public cursorForward(params: number[]): void {\\r\\n let param = params[0];\\r\\n if (param < 1) {\\r\\n param = 1;\\r\\n }\\r\\n this._terminal.buffer.x += param;\\r\\n if (this._terminal.buffer.x >= this._terminal.cols) {\\r\\n this._terminal.buffer.x = this._terminal.cols - 1;\\r\\n }\\r\\n }\\r\\n\\r\\n /**\\r\\n * CSI Ps D\\r\\n * Cursor Backward Ps Times (default = 1) (CUB).\\r\\n */\\r\\n public cursorBackward(params: number[]): void {\\r\\n let param = params[0];\\r\\n if (param < 1) {\\r\\n param = 1;\\r\\n }\\r\\n // If the end of the line is hit, prevent this action from wrapping around to the next line.\\r\\n if (this._terminal.buffer.x >= this._terminal.cols) {\\r\\n this._terminal.buffer.x--;\\r\\n }\\r\\n this._terminal.buffer.x -= param;\\r\\n if (this._terminal.buffer.x < 0) {\\r\\n this._terminal.buffer.x = 0;\\r\\n }\\r\\n }\\r\\n\\r\\n /**\\r\\n * CSI Ps E\\r\\n * Cursor Next Line Ps Times (default = 1) (CNL).\\r\\n * same as CSI Ps B ?\\r\\n */\\r\\n public cursorNextLine(params: number[]): void {\\r\\n let param = params[0];\\r\\n if (param < 1) {\\r\\n param = 1;\\r\\n }\\r\\n this._terminal.buffer.y += param;\\r\\n if (this._terminal.buffer.y >= this._terminal.rows) {\\r\\n this._terminal.buffer.y = this._terminal.rows - 1;\\r\\n }\\r\\n this._terminal.buffer.x = 0;\\r\\n }\\r\\n\\r\\n\\r\\n /**\\r\\n * CSI Ps F\\r\\n * Cursor Preceding Line Ps Times (default = 1) (CNL).\\r\\n * reuse CSI Ps A ?\\r\\n */\\r\\n public cursorPrecedingLine(params: number[]): void {\\r\\n let param = params[0];\\r\\n if (param < 1) {\\r\\n param = 1;\\r\\n }\\r\\n this._terminal.buffer.y -= param;\\r\\n if (this._terminal.buffer.y < 0) {\\r\\n this._terminal.buffer.y = 0;\\r\\n }\\r\\n this._terminal.buffer.x = 0;\\r\\n }\\r\\n\\r\\n\\r\\n /**\\r\\n * CSI Ps G\\r\\n * Cursor Character Absolute [column] (default = [row,1]) (CHA).\\r\\n */\\r\\n public cursorCharAbsolute(params: number[]): void {\\r\\n let param = params[0];\\r\\n if (param < 1) {\\r\\n param = 1;\\r\\n }\\r\\n this._terminal.buffer.x = param - 1;\\r\\n }\\r\\n\\r\\n /**\\r\\n * CSI Ps ; Ps H\\r\\n * Cursor Position [row;column] (default = [1,1]) (CUP).\\r\\n */\\r\\n public cursorPosition(params: number[]): void {\\r\\n let col: number;\\r\\n let row: number = params[0] - 1;\\r\\n\\r\\n if (params.length >= 2) {\\r\\n col = params[1] - 1;\\r\\n } else {\\r\\n col = 0;\\r\\n }\\r\\n\\r\\n if (row < 0) {\\r\\n row = 0;\\r\\n } else if (row >= this._terminal.rows) {\\r\\n row = this._terminal.rows - 1;\\r\\n }\\r\\n\\r\\n if (col < 0) {\\r\\n col = 0;\\r\\n } else if (col >= this._terminal.cols) {\\r\\n col = this._terminal.cols - 1;\\r\\n }\\r\\n\\r\\n this._terminal.buffer.x = col;\\r\\n this._terminal.buffer.y = row;\\r\\n }\\r\\n\\r\\n /**\\r\\n * CSI Ps I\\r\\n * Cursor Forward Tabulation Ps tab stops (default = 1) (CHT).\\r\\n */\\r\\n public cursorForwardTab(params: number[]): void {\\r\\n let param = params[0] || 1;\\r\\n while (param--) {\\r\\n this._terminal.buffer.x = this._terminal.buffer.nextStop();\\r\\n }\\r\\n }\\r\\n\\r\\n /**\\r\\n * CSI Ps J Erase in Display (ED).\\r\\n * Ps = 0 -> Erase Below (default).\\r\\n * Ps = 1 -> Erase Above.\\r\\n * Ps = 2 -> Erase All.\\r\\n * Ps = 3 -> Erase Saved Lines (xterm).\\r\\n * CSI ? Ps J\\r\\n * Erase in Display (DECSED).\\r\\n * Ps = 0 -> Selective Erase Below (default).\\r\\n * Ps = 1 -> Selective Erase Above.\\r\\n * Ps = 2 -> Selective Erase All.\\r\\n */\\r\\n public eraseInDisplay(params: number[]): void {\\r\\n let j;\\r\\n switch (params[0]) {\\r\\n case 0:\\r\\n this._terminal.eraseRight(this._terminal.buffer.x, this._terminal.buffer.y);\\r\\n j = this._terminal.buffer.y + 1;\\r\\n for (; j < this._terminal.rows; j++) {\\r\\n this._terminal.eraseLine(j);\\r\\n }\\r\\n break;\\r\\n case 1:\\r\\n this._terminal.eraseLeft(this._terminal.buffer.x, this._terminal.buffer.y);\\r\\n j = this._terminal.buffer.y;\\r\\n while (j--) {\\r\\n this._terminal.eraseLine(j);\\r\\n }\\r\\n break;\\r\\n case 2:\\r\\n j = this._terminal.rows;\\r\\n while (j--) this._terminal.eraseLine(j);\\r\\n break;\\r\\n case 3:\\r\\n // Clear scrollback (everything not in viewport)\\r\\n const scrollBackSize = this._terminal.buffer.lines.length - this._terminal.rows;\\r\\n if (scrollBackSize > 0) {\\r\\n this._terminal.buffer.lines.trimStart(scrollBackSize);\\r\\n this._terminal.buffer.ybase = Math.max(this._terminal.buffer.ybase - scrollBackSize, 0);\\r\\n this._terminal.buffer.ydisp = Math.max(this._terminal.buffer.ydisp - scrollBackSize, 0);\\r\\n // Force a scroll event to refresh viewport\\r\\n this._terminal.emit('scroll', 0);\\r\\n }\\r\\n break;\\r\\n }\\r\\n }\\r\\n\\r\\n /**\\r\\n * CSI Ps K Erase in Line (EL).\\r\\n * Ps = 0 -> Erase to Right (default).\\r\\n * Ps = 1 -> Erase to Left.\\r\\n * Ps = 2 -> Erase All.\\r\\n * CSI ? Ps K\\r\\n * Erase in Line (DECSEL).\\r\\n * Ps = 0 -> Selective Erase to Right (default).\\r\\n * Ps = 1 -> Selective Erase to Left.\\r\\n * Ps = 2 -> Selective Erase All.\\r\\n */\\r\\n public eraseInLine(params: number[]): void {\\r\\n switch (params[0]) {\\r\\n case 0:\\r\\n this._terminal.eraseRight(this._terminal.buffer.x, this._terminal.buffer.y);\\r\\n break;\\r\\n case 1:\\r\\n this._terminal.eraseLeft(this._terminal.buffer.x, this._terminal.buffer.y);\\r\\n break;\\r\\n case 2:\\r\\n this._terminal.eraseLine(this._terminal.buffer.y);\\r\\n break;\\r\\n }\\r\\n }\\r\\n\\r\\n /**\\r\\n * CSI Ps L\\r\\n * Insert Ps Line(s) (default = 1) (IL).\\r\\n */\\r\\n public insertLines(params: number[]): void {\\r\\n let param: number = params[0];\\r\\n if (param < 1) {\\r\\n param = 1;\\r\\n }\\r\\n let row: number = this._terminal.buffer.y + this._terminal.buffer.ybase;\\r\\n\\r\\n let scrollBottomRowsOffset = this._terminal.rows - 1 - this._terminal.buffer.scrollBottom;\\r\\n let scrollBottomAbsolute = this._terminal.rows - 1 + this._terminal.buffer.ybase - scrollBottomRowsOffset + 1;\\r\\n while (param--) {\\r\\n // test: echo -e '\\\\e[44m\\\\e[1L\\\\e[0m'\\r\\n // blankLine(true) - xterm/linux behavior\\r\\n this._terminal.buffer.lines.splice(scrollBottomAbsolute - 1, 1);\\r\\n this._terminal.buffer.lines.splice(row, 0, this._terminal.blankLine(true));\\r\\n }\\r\\n\\r\\n // this.maxRange();\\r\\n this._terminal.updateRange(this._terminal.buffer.y);\\r\\n this._terminal.updateRange(this._terminal.buffer.scrollBottom);\\r\\n }\\r\\n\\r\\n /**\\r\\n * CSI Ps M\\r\\n * Delete Ps Line(s) (default = 1) (DL).\\r\\n */\\r\\n public deleteLines(params: number[]): void {\\r\\n let param = params[0];\\r\\n if (param < 1) {\\r\\n param = 1;\\r\\n }\\r\\n const row: number = this._terminal.buffer.y + this._terminal.buffer.ybase;\\r\\n\\r\\n let j: number;\\r\\n j = this._terminal.rows - 1 - this._terminal.buffer.scrollBottom;\\r\\n j = this._terminal.rows - 1 + this._terminal.buffer.ybase - j;\\r\\n while (param--) {\\r\\n // test: echo -e '\\\\e[44m\\\\e[1M\\\\e[0m'\\r\\n // blankLine(true) - xterm/linux behavior\\r\\n this._terminal.buffer.lines.splice(row, 1);\\r\\n this._terminal.buffer.lines.splice(j, 0, this._terminal.blankLine(true));\\r\\n }\\r\\n\\r\\n // this.maxRange();\\r\\n this._terminal.updateRange(this._terminal.buffer.y);\\r\\n this._terminal.updateRange(this._terminal.buffer.scrollBottom);\\r\\n }\\r\\n\\r\\n /**\\r\\n * CSI Ps P\\r\\n * Delete Ps Character(s) (default = 1) (DCH).\\r\\n */\\r\\n public deleteChars(params: number[]): void {\\r\\n let param: number = params[0];\\r\\n if (param < 1) {\\r\\n param = 1;\\r\\n }\\r\\n\\r\\n const row = this._terminal.buffer.y + this._terminal.buffer.ybase;\\r\\n const ch: CharData = [this._terminal.eraseAttr(), ' ', 1, 32]; // xterm\\r\\n\\r\\n while (param--) {\\r\\n this._terminal.buffer.lines.get(row).splice(this._terminal.buffer.x, 1);\\r\\n this._terminal.buffer.lines.get(row).push(ch);\\r\\n }\\r\\n }\\r\\n\\r\\n /**\\r\\n * CSI Ps S Scroll up Ps lines (default = 1) (SU).\\r\\n */\\r\\n public scrollUp(params: number[]): void {\\r\\n let param = params[0] || 1;\\r\\n while (param--) {\\r\\n this._terminal.buffer.lines.splice(this._terminal.buffer.ybase + this._terminal.buffer.scrollTop, 1);\\r\\n this._terminal.buffer.lines.splice(this._terminal.buffer.ybase + this._terminal.buffer.scrollBottom, 0, this._terminal.blankLine());\\r\\n }\\r\\n // this.maxRange();\\r\\n this._terminal.updateRange(this._terminal.buffer.scrollTop);\\r\\n this._terminal.updateRange(this._terminal.buffer.scrollBottom);\\r\\n }\\r\\n\\r\\n /**\\r\\n * CSI Ps T Scroll down Ps lines (default = 1) (SD).\\r\\n */\\r\\n public scrollDown(params: number[]): void {\\r\\n let param = params[0] || 1;\\r\\n while (param--) {\\r\\n this._terminal.buffer.lines.splice(this._terminal.buffer.ybase + this._terminal.buffer.scrollBottom, 1);\\r\\n this._terminal.buffer.lines.splice(this._terminal.buffer.ybase + this._terminal.buffer.scrollTop, 0, this._terminal.blankLine());\\r\\n }\\r\\n // this.maxRange();\\r\\n this._terminal.updateRange(this._terminal.buffer.scrollTop);\\r\\n this._terminal.updateRange(this._terminal.buffer.scrollBottom);\\r\\n }\\r\\n\\r\\n /**\\r\\n * CSI Ps X\\r\\n * Erase Ps Character(s) (default = 1) (ECH).\\r\\n */\\r\\n public eraseChars(params: number[]): void {\\r\\n let param = params[0];\\r\\n if (param < 1) {\\r\\n param = 1;\\r\\n }\\r\\n\\r\\n const row = this._terminal.buffer.y + this._terminal.buffer.ybase;\\r\\n let j = this._terminal.buffer.x;\\r\\n const ch: CharData = [this._terminal.eraseAttr(), ' ', 1, 32]; // xterm\\r\\n\\r\\n while (param-- && j < this._terminal.cols) {\\r\\n this._terminal.buffer.lines.get(row)[j++] = ch;\\r\\n }\\r\\n }\\r\\n\\r\\n /**\\r\\n * CSI Ps Z Cursor Backward Tabulation Ps tab stops (default = 1) (CBT).\\r\\n */\\r\\n public cursorBackwardTab(params: number[]): void {\\r\\n let param = params[0] || 1;\\r\\n while (param--) {\\r\\n this._terminal.buffer.x = this._terminal.buffer.prevStop();\\r\\n }\\r\\n }\\r\\n\\r\\n /**\\r\\n * CSI Pm ` Character Position Absolute\\r\\n * [column] (default = [row,1]) (HPA).\\r\\n */\\r\\n public charPosAbsolute(params: number[]): void {\\r\\n let param = params[0];\\r\\n if (param < 1) {\\r\\n param = 1;\\r\\n }\\r\\n this._terminal.buffer.x = param - 1;\\r\\n if (this._terminal.buffer.x >= this._terminal.cols) {\\r\\n this._terminal.buffer.x = this._terminal.cols - 1;\\r\\n }\\r\\n }\\r\\n\\r\\n /**\\r\\n * CSI Pm a Character Position Relative\\r\\n * [columns] (default = [row,col+1]) (HPR)\\r\\n * reuse CSI Ps C ?\\r\\n */\\r\\n public HPositionRelative(params: number[]): void {\\r\\n let param = params[0];\\r\\n if (param < 1) {\\r\\n param = 1;\\r\\n }\\r\\n this._terminal.buffer.x += param;\\r\\n if (this._terminal.buffer.x >= this._terminal.cols) {\\r\\n this._terminal.buffer.x = this._terminal.cols - 1;\\r\\n }\\r\\n }\\r\\n\\r\\n /**\\r\\n * CSI Ps b Repeat the preceding graphic character Ps times (REP).\\r\\n */\\r\\n public repeatPrecedingCharacter(params: number[]): void {\\r\\n let param = params[0] || 1;\\r\\n const line = this._terminal.buffer.lines.get(this._terminal.buffer.ybase + this._terminal.buffer.y);\\r\\n const ch = line[this._terminal.buffer.x - 1] || [this._terminal.defAttr, ' ', 1, 32];\\r\\n\\r\\n while (param--) {\\r\\n line[this._terminal.buffer.x++] = ch;\\r\\n }\\r\\n }\\r\\n\\r\\n /**\\r\\n * CSI Ps c Send Device Attributes (Primary DA).\\r\\n * Ps = 0 or omitted -> request attributes from terminal. The\\r\\n * response depends on the decTerminalID resource setting.\\r\\n * -> CSI ? 1 ; 2 c (``VT100 with Advanced Video Option'')\\r\\n * -> CSI ? 1 ; 0 c (``VT101 with No Options'')\\r\\n * -> CSI ? 6 c (``VT102'')\\r\\n * -> CSI ? 6 0 ; 1 ; 2 ; 6 ; 8 ; 9 ; 1 5 ; c (``VT220'')\\r\\n * The VT100-style response parameters do not mean anything by\\r\\n * themselves. VT220 parameters do, telling the host what fea-\\r\\n * tures the terminal supports:\\r\\n * Ps = 1 -> 132-columns.\\r\\n * Ps = 2 -> Printer.\\r\\n * Ps = 6 -> Selective erase.\\r\\n * Ps = 8 -> User-defined keys.\\r\\n * Ps = 9 -> National replacement character sets.\\r\\n * Ps = 1 5 -> Technical characters.\\r\\n * Ps = 2 2 -> ANSI color, e.g., VT525.\\r\\n * Ps = 2 9 -> ANSI text locator (i.e., DEC Locator mode).\\r\\n * CSI > Ps c\\r\\n * Send Device Attributes (Secondary DA).\\r\\n * Ps = 0 or omitted -> request the terminal's identification\\r\\n * code. The response depends on the decTerminalID resource set-\\r\\n * ting. It should apply only to VT220 and up, but xterm extends\\r\\n * this to VT100.\\r\\n * -> CSI > Pp ; Pv ; Pc c\\r\\n * where Pp denotes the terminal type\\r\\n * Pp = 0 -> ``VT100''.\\r\\n * Pp = 1 -> ``VT220''.\\r\\n * and Pv is the firmware version (for xterm, this was originally\\r\\n * the XFree86 patch number, starting with 95). In a DEC termi-\\r\\n * nal, Pc indicates the ROM cartridge registration number and is\\r\\n * always zero.\\r\\n * More information:\\r\\n * xterm/charproc.c - line 2012, for more information.\\r\\n * vim responds with ^[[?0c or ^[[?1c after the terminal's response (?)\\r\\n */\\r\\n public sendDeviceAttributes(params: number[]): void {\\r\\n if (params[0] > 0) {\\r\\n return;\\r\\n }\\r\\n\\r\\n if (!this._terminal.prefix) {\\r\\n if (this._terminal.is('xterm') || this._terminal.is('rxvt-unicode') || this._terminal.is('screen')) {\\r\\n this._terminal.send(C0.ESC + '[?1;2c');\\r\\n } else if (this._terminal.is('linux')) {\\r\\n this._terminal.send(C0.ESC + '[?6c');\\r\\n }\\r\\n } else if (this._terminal.prefix === '>') {\\r\\n // xterm and urxvt\\r\\n // seem to spit this\\r\\n // out around ~370 times (?).\\r\\n if (this._terminal.is('xterm')) {\\r\\n this._terminal.send(C0.ESC + '[>0;276;0c');\\r\\n } else if (this._terminal.is('rxvt-unicode')) {\\r\\n this._terminal.send(C0.ESC + '[>85;95;0c');\\r\\n } else if (this._terminal.is('linux')) {\\r\\n // not supported by linux console.\\r\\n // linux console echoes parameters.\\r\\n this._terminal.send(params[0] + 'c');\\r\\n } else if (this._terminal.is('screen')) {\\r\\n this._terminal.send(C0.ESC + '[>83;40003;0c');\\r\\n }\\r\\n }\\r\\n }\\r\\n\\r\\n /**\\r\\n * CSI Pm d Vertical Position Absolute (VPA)\\r\\n * [row] (default = [1,column])\\r\\n */\\r\\n public linePosAbsolute(params: number[]): void {\\r\\n let param = params[0];\\r\\n if (param < 1) {\\r\\n param = 1;\\r\\n }\\r\\n this._terminal.buffer.y = param - 1;\\r\\n if (this._terminal.buffer.y >= this._terminal.rows) {\\r\\n this._terminal.buffer.y = this._terminal.rows - 1;\\r\\n }\\r\\n }\\r\\n\\r\\n /**\\r\\n * CSI Pm e Vertical Position Relative (VPR)\\r\\n * [rows] (default = [row+1,column])\\r\\n * reuse CSI Ps B ?\\r\\n */\\r\\n public VPositionRelative(params: number[]): void {\\r\\n let param = params[0];\\r\\n if (param < 1) {\\r\\n param = 1;\\r\\n }\\r\\n this._terminal.buffer.y += param;\\r\\n if (this._terminal.buffer.y >= this._terminal.rows) {\\r\\n this._terminal.buffer.y = this._terminal.rows - 1;\\r\\n }\\r\\n // If the end of the line is hit, prevent this action from wrapping around to the next line.\\r\\n if (this._terminal.buffer.x >= this._terminal.cols) {\\r\\n this._terminal.buffer.x--;\\r\\n }\\r\\n }\\r\\n\\r\\n /**\\r\\n * CSI Ps ; Ps f\\r\\n * Horizontal and Vertical Position [row;column] (default =\\r\\n * [1,1]) (HVP).\\r\\n */\\r\\n public HVPosition(params: number[]): void {\\r\\n if (params[0] < 1) params[0] = 1;\\r\\n if (params[1] < 1) params[1] = 1;\\r\\n\\r\\n this._terminal.buffer.y = params[0] - 1;\\r\\n if (this._terminal.buffer.y >= this._terminal.rows) {\\r\\n this._terminal.buffer.y = this._terminal.rows - 1;\\r\\n }\\r\\n\\r\\n this._terminal.buffer.x = params[1] - 1;\\r\\n if (this._terminal.buffer.x >= this._terminal.cols) {\\r\\n this._terminal.buffer.x = this._terminal.cols - 1;\\r\\n }\\r\\n }\\r\\n\\r\\n /**\\r\\n * CSI Ps g Tab Clear (TBC).\\r\\n * Ps = 0 -> Clear Current Column (default).\\r\\n * Ps = 3 -> Clear All.\\r\\n * Potentially:\\r\\n * Ps = 2 -> Clear Stops on Line.\\r\\n * http://vt100.net/annarbor/aaa-ug/section6.html\\r\\n */\\r\\n public tabClear(params: number[]): void {\\r\\n let param = params[0];\\r\\n if (param <= 0) {\\r\\n delete this._terminal.buffer.tabs[this._terminal.buffer.x];\\r\\n } else if (param === 3) {\\r\\n this._terminal.buffer.tabs = {};\\r\\n }\\r\\n }\\r\\n\\r\\n /**\\r\\n * CSI Pm h Set Mode (SM).\\r\\n * Ps = 2 -> Keyboard Action Mode (AM).\\r\\n * Ps = 4 -> Insert Mode (IRM).\\r\\n * Ps = 1 2 -> Send/receive (SRM).\\r\\n * Ps = 2 0 -> Automatic Newline (LNM).\\r\\n * CSI ? Pm h\\r\\n * DEC Private Mode Set (DECSET).\\r\\n * Ps = 1 -> Application Cursor Keys (DECCKM).\\r\\n * Ps = 2 -> Designate USASCII for character sets G0-G3\\r\\n * (DECANM), and set VT100 mode.\\r\\n * Ps = 3 -> 132 Column Mode (DECCOLM).\\r\\n * Ps = 4 -> Smooth (Slow) Scroll (DECSCLM).\\r\\n * Ps = 5 -> Reverse Video (DECSCNM).\\r\\n * Ps = 6 -> Origin Mode (DECOM).\\r\\n * Ps = 7 -> Wraparound Mode (DECAWM).\\r\\n * Ps = 8 -> Auto-repeat Keys (DECARM).\\r\\n * Ps = 9 -> Send Mouse X & Y on button press. See the sec-\\r\\n * tion Mouse Tracking.\\r\\n * Ps = 1 0 -> Show toolbar (rxvt).\\r\\n * Ps = 1 2 -> Start Blinking Cursor (att610).\\r\\n * Ps = 1 8 -> Print form feed (DECPFF).\\r\\n * Ps = 1 9 -> Set print extent to full screen (DECPEX).\\r\\n * Ps = 2 5 -> Show Cursor (DECTCEM).\\r\\n * Ps = 3 0 -> Show scrollbar (rxvt).\\r\\n * Ps = 3 5 -> Enable font-shifting functions (rxvt).\\r\\n * Ps = 3 8 -> Enter Tektronix Mode (DECTEK).\\r\\n * Ps = 4 0 -> Allow 80 -> 132 Mode.\\r\\n * Ps = 4 1 -> more(1) fix (see curses resource).\\r\\n * Ps = 4 2 -> Enable Nation Replacement Character sets (DECN-\\r\\n * RCM).\\r\\n * Ps = 4 4 -> Turn On Margin Bell.\\r\\n * Ps = 4 5 -> Reverse-wraparound Mode.\\r\\n * Ps = 4 6 -> Start Logging. This is normally disabled by a\\r\\n * compile-time option.\\r\\n * Ps = 4 7 -> Use Alternate Screen Buffer. (This may be dis-\\r\\n * abled by the titeInhibit resource).\\r\\n * Ps = 6 6 -> Application keypad (DECNKM).\\r\\n * Ps = 6 7 -> Backarrow key sends backspace (DECBKM).\\r\\n * Ps = 1 0 0 0 -> Send Mouse X & Y on button press and\\r\\n * release. See the section Mouse Tracking.\\r\\n * Ps = 1 0 0 1 -> Use Hilite Mouse Tracking.\\r\\n * Ps = 1 0 0 2 -> Use Cell Motion Mouse Tracking.\\r\\n * Ps = 1 0 0 3 -> Use All Motion Mouse Tracking.\\r\\n * Ps = 1 0 0 4 -> Send FocusIn/FocusOut events.\\r\\n * Ps = 1 0 0 5 -> Enable Extended Mouse Mode.\\r\\n * Ps = 1 0 1 0 -> Scroll to bottom on tty output (rxvt).\\r\\n * Ps = 1 0 1 1 -> Scroll to bottom on key press (rxvt).\\r\\n * Ps = 1 0 3 4 -> Interpret \\\"meta\\\" key, sets eighth bit.\\r\\n * (enables the eightBitInput resource).\\r\\n * Ps = 1 0 3 5 -> Enable special modifiers for Alt and Num-\\r\\n * Lock keys. (This enables the numLock resource).\\r\\n * Ps = 1 0 3 6 -> Send ESC when Meta modifies a key. (This\\r\\n * enables the metaSendsEscape resource).\\r\\n * Ps = 1 0 3 7 -> Send DEL from the editing-keypad Delete\\r\\n * key.\\r\\n * Ps = 1 0 3 9 -> Send ESC when Alt modifies a key. (This\\r\\n * enables the altSendsEscape resource).\\r\\n * Ps = 1 0 4 0 -> Keep selection even if not highlighted.\\r\\n * (This enables the keepSelection resource).\\r\\n * Ps = 1 0 4 1 -> Use the CLIPBOARD selection. (This enables\\r\\n * the selectToClipboard resource).\\r\\n * Ps = 1 0 4 2 -> Enable Urgency window manager hint when\\r\\n * Control-G is received. (This enables the bellIsUrgent\\r\\n * resource).\\r\\n * Ps = 1 0 4 3 -> Enable raising of the window when Control-G\\r\\n * is received. (enables the popOnBell resource).\\r\\n * Ps = 1 0 4 7 -> Use Alternate Screen Buffer. (This may be\\r\\n * disabled by the titeInhibit resource).\\r\\n * Ps = 1 0 4 8 -> Save cursor as in DECSC. (This may be dis-\\r\\n * abled by the titeInhibit resource).\\r\\n * Ps = 1 0 4 9 -> Save cursor as in DECSC and use Alternate\\r\\n * Screen Buffer, clearing it first. (This may be disabled by\\r\\n * the titeInhibit resource). This combines the effects of the 1\\r\\n * 0 4 7 and 1 0 4 8 modes. Use this with terminfo-based\\r\\n * applications rather than the 4 7 mode.\\r\\n * Ps = 1 0 5 0 -> Set terminfo/termcap function-key mode.\\r\\n * Ps = 1 0 5 1 -> Set Sun function-key mode.\\r\\n * Ps = 1 0 5 2 -> Set HP function-key mode.\\r\\n * Ps = 1 0 5 3 -> Set SCO function-key mode.\\r\\n * Ps = 1 0 6 0 -> Set legacy keyboard emulation (X11R6).\\r\\n * Ps = 1 0 6 1 -> Set VT220 keyboard emulation.\\r\\n * Ps = 2 0 0 4 -> Set bracketed paste mode.\\r\\n * Modes:\\r\\n * http: *vt100.net/docs/vt220-rm/chapter4.html\\r\\n */\\r\\n public setMode(params: number[]): void {\\r\\n if (params.length > 1) {\\r\\n for (let i = 0; i < params.length; i++) {\\r\\n this.setMode([params[i]]);\\r\\n }\\r\\n\\r\\n return;\\r\\n }\\r\\n\\r\\n if (!this._terminal.prefix) {\\r\\n switch (params[0]) {\\r\\n case 4:\\r\\n this._terminal.insertMode = true;\\r\\n break;\\r\\n case 20:\\r\\n // this._t.convertEol = true;\\r\\n break;\\r\\n }\\r\\n } else if (this._terminal.prefix === '?') {\\r\\n switch (params[0]) {\\r\\n case 1:\\r\\n this._terminal.applicationCursor = true;\\r\\n break;\\r\\n case 2:\\r\\n this._terminal.setgCharset(0, DEFAULT_CHARSET);\\r\\n this._terminal.setgCharset(1, DEFAULT_CHARSET);\\r\\n this._terminal.setgCharset(2, DEFAULT_CHARSET);\\r\\n this._terminal.setgCharset(3, DEFAULT_CHARSET);\\r\\n // set VT100 mode here\\r\\n break;\\r\\n case 3: // 132 col mode\\r\\n this._terminal.savedCols = this._terminal.cols;\\r\\n this._terminal.resize(132, this._terminal.rows);\\r\\n break;\\r\\n case 6:\\r\\n this._terminal.originMode = true;\\r\\n break;\\r\\n case 7:\\r\\n this._terminal.wraparoundMode = true;\\r\\n break;\\r\\n case 12:\\r\\n // this.cursorBlink = true;\\r\\n break;\\r\\n case 66:\\r\\n this._terminal.log('Serial port requested application keypad.');\\r\\n this._terminal.applicationKeypad = true;\\r\\n this._terminal.viewport.syncScrollArea();\\r\\n break;\\r\\n case 9: // X10 Mouse\\r\\n // no release, no motion, no wheel, no modifiers.\\r\\n case 1000: // vt200 mouse\\r\\n // no motion.\\r\\n // no modifiers, except control on the wheel.\\r\\n case 1002: // button event mouse\\r\\n case 1003: // any event mouse\\r\\n // any event - sends motion events,\\r\\n // even if there is no button held down.\\r\\n\\r\\n // TODO: Why are params[0] compares nested within a switch for params[0]?\\r\\n\\r\\n this._terminal.x10Mouse = params[0] === 9;\\r\\n this._terminal.vt200Mouse = params[0] === 1000;\\r\\n this._terminal.normalMouse = params[0] > 1000;\\r\\n this._terminal.mouseEvents = true;\\r\\n this._terminal.element.classList.add('enable-mouse-events');\\r\\n this._terminal.selectionManager.disable();\\r\\n this._terminal.log('Binding to mouse events.');\\r\\n break;\\r\\n case 1004: // send focusin/focusout events\\r\\n // focusin: ^[[I\\r\\n // focusout: ^[[O\\r\\n this._terminal.sendFocus = true;\\r\\n break;\\r\\n case 1005: // utf8 ext mode mouse\\r\\n this._terminal.utfMouse = true;\\r\\n // for wide terminals\\r\\n // simply encodes large values as utf8 characters\\r\\n break;\\r\\n case 1006: // sgr ext mode mouse\\r\\n this._terminal.sgrMouse = true;\\r\\n // for wide terminals\\r\\n // does not add 32 to fields\\r\\n // press: ^[[<b;x;yM\\r\\n // release: ^[[<b;x;ym\\r\\n break;\\r\\n case 1015: // urxvt ext mode mouse\\r\\n this._terminal.urxvtMouse = true;\\r\\n // for wide terminals\\r\\n // numbers for fields\\r\\n // press: ^[[b;x;yM\\r\\n // motion: ^[[b;x;yT\\r\\n break;\\r\\n case 25: // show cursor\\r\\n this._terminal.cursorHidden = false;\\r\\n break;\\r\\n case 1049: // alt screen buffer cursor\\r\\n // TODO: Not sure if we need to save/restore after switching the buffer\\r\\n // this.saveCursor(params);\\r\\n // FALL-THROUGH\\r\\n case 47: // alt screen buffer\\r\\n case 1047: // alt screen buffer\\r\\n this._terminal.buffers.activateAltBuffer();\\r\\n this._terminal.selectionManager.setBuffer(this._terminal.buffer);\\r\\n this._terminal.viewport.syncScrollArea();\\r\\n this._terminal.showCursor();\\r\\n break;\\r\\n }\\r\\n }\\r\\n }\\r\\n\\r\\n /**\\r\\n * CSI Pm l Reset Mode (RM).\\r\\n * Ps = 2 -> Keyboard Action Mode (AM).\\r\\n * Ps = 4 -> Replace Mode (IRM).\\r\\n * Ps = 1 2 -> Send/receive (SRM).\\r\\n * Ps = 2 0 -> Normal Linefeed (LNM).\\r\\n * CSI ? Pm l\\r\\n * DEC Private Mode Reset (DECRST).\\r\\n * Ps = 1 -> Normal Cursor Keys (DECCKM).\\r\\n * Ps = 2 -> Designate VT52 mode (DECANM).\\r\\n * Ps = 3 -> 80 Column Mode (DECCOLM).\\r\\n * Ps = 4 -> Jump (Fast) Scroll (DECSCLM).\\r\\n * Ps = 5 -> Normal Video (DECSCNM).\\r\\n * Ps = 6 -> Normal Cursor Mode (DECOM).\\r\\n * Ps = 7 -> No Wraparound Mode (DECAWM).\\r\\n * Ps = 8 -> No Auto-repeat Keys (DECARM).\\r\\n * Ps = 9 -> Don't send Mouse X & Y on button press.\\r\\n * Ps = 1 0 -> Hide toolbar (rxvt).\\r\\n * Ps = 1 2 -> Stop Blinking Cursor (att610).\\r\\n * Ps = 1 8 -> Don't print form feed (DECPFF).\\r\\n * Ps = 1 9 -> Limit print to scrolling region (DECPEX).\\r\\n * Ps = 2 5 -> Hide Cursor (DECTCEM).\\r\\n * Ps = 3 0 -> Don't show scrollbar (rxvt).\\r\\n * Ps = 3 5 -> Disable font-shifting functions (rxvt).\\r\\n * Ps = 4 0 -> Disallow 80 -> 132 Mode.\\r\\n * Ps = 4 1 -> No more(1) fix (see curses resource).\\r\\n * Ps = 4 2 -> Disable Nation Replacement Character sets (DEC-\\r\\n * NRCM).\\r\\n * Ps = 4 4 -> Turn Off Margin Bell.\\r\\n * Ps = 4 5 -> No Reverse-wraparound Mode.\\r\\n * Ps = 4 6 -> Stop Logging. (This is normally disabled by a\\r\\n * compile-time option).\\r\\n * Ps = 4 7 -> Use Normal Screen Buffer.\\r\\n * Ps = 6 6 -> Numeric keypad (DECNKM).\\r\\n * Ps = 6 7 -> Backarrow key sends delete (DECBKM).\\r\\n * Ps = 1 0 0 0 -> Don't send Mouse X & Y on button press and\\r\\n * release. See the section Mouse Tracking.\\r\\n * Ps = 1 0 0 1 -> Don't use Hilite Mouse Tracking.\\r\\n * Ps = 1 0 0 2 -> Don't use Cell Motion Mouse Tracking.\\r\\n * Ps = 1 0 0 3 -> Don't use All Motion Mouse Tracking.\\r\\n * Ps = 1 0 0 4 -> Don't send FocusIn/FocusOut events.\\r\\n * Ps = 1 0 0 5 -> Disable Extended Mouse Mode.\\r\\n * Ps = 1 0 1 0 -> Don't scroll to bottom on tty output\\r\\n * (rxvt).\\r\\n * Ps = 1 0 1 1 -> Don't scroll to bottom on key press (rxvt).\\r\\n * Ps = 1 0 3 4 -> Don't interpret \\\"meta\\\" key. (This disables\\r\\n * the eightBitInput resource).\\r\\n * Ps = 1 0 3 5 -> Disable special modifiers for Alt and Num-\\r\\n * Lock keys. (This disables the numLock resource).\\r\\n * Ps = 1 0 3 6 -> Don't send ESC when Meta modifies a key.\\r\\n * (This disables the metaSendsEscape resource).\\r\\n * Ps = 1 0 3 7 -> Send VT220 Remove from the editing-keypad\\r\\n * Delete key.\\r\\n * Ps = 1 0 3 9 -> Don't send ESC when Alt modifies a key.\\r\\n * (This disables the altSendsEscape resource).\\r\\n * Ps = 1 0 4 0 -> Do not keep selection when not highlighted.\\r\\n * (This disables the keepSelection resource).\\r\\n * Ps = 1 0 4 1 -> Use the PRIMARY selection. (This disables\\r\\n * the selectToClipboard resource).\\r\\n * Ps = 1 0 4 2 -> Disable Urgency window manager hint when\\r\\n * Control-G is received. (This disables the bellIsUrgent\\r\\n * resource).\\r\\n * Ps = 1 0 4 3 -> Disable raising of the window when Control-\\r\\n * G is received. (This disables the popOnBell resource).\\r\\n * Ps = 1 0 4 7 -> Use Normal Screen Buffer, clearing screen\\r\\n * first if in the Alternate Screen. (This may be disabled by\\r\\n * the titeInhibit resource).\\r\\n * Ps = 1 0 4 8 -> Restore cursor as in DECRC. (This may be\\r\\n * disabled by the titeInhibit resource).\\r\\n * Ps = 1 0 4 9 -> Use Normal Screen Buffer and restore cursor\\r\\n * as in DECRC. (This may be disabled by the titeInhibit\\r\\n * resource). This combines the effects of the 1 0 4 7 and 1 0\\r\\n * 4 8 modes. Use this with terminfo-based applications rather\\r\\n * than the 4 7 mode.\\r\\n * Ps = 1 0 5 0 -> Reset terminfo/termcap function-key mode.\\r\\n * Ps = 1 0 5 1 -> Reset Sun function-key mode.\\r\\n * Ps = 1 0 5 2 -> Reset HP function-key mode.\\r\\n * Ps = 1 0 5 3 -> Reset SCO function-key mode.\\r\\n * Ps = 1 0 6 0 -> Reset legacy keyboard emulation (X11R6).\\r\\n * Ps = 1 0 6 1 -> Reset keyboard emulation to Sun/PC style.\\r\\n * Ps = 2 0 0 4 -> Reset bracketed paste mode.\\r\\n */\\r\\n public resetMode(params: number[]): void {\\r\\n if (params.length > 1) {\\r\\n for (let i = 0; i < params.length; i++) {\\r\\n this.resetMode([params[i]]);\\r\\n }\\r\\n\\r\\n return;\\r\\n }\\r\\n\\r\\n if (!this._terminal.prefix) {\\r\\n switch (params[0]) {\\r\\n case 4:\\r\\n this._terminal.insertMode = false;\\r\\n break;\\r\\n case 20:\\r\\n // this._t.convertEol = false;\\r\\n break;\\r\\n }\\r\\n } else if (this._terminal.prefix === '?') {\\r\\n switch (params[0]) {\\r\\n case 1:\\r\\n this._terminal.applicationCursor = false;\\r\\n break;\\r\\n case 3:\\r\\n if (this._terminal.cols === 132 && this._terminal.savedCols) {\\r\\n this._terminal.resize(this._terminal.savedCols, this._terminal.rows);\\r\\n }\\r\\n delete this._terminal.savedCols;\\r\\n break;\\r\\n case 6:\\r\\n this._terminal.originMode = false;\\r\\n break;\\r\\n case 7:\\r\\n this._terminal.wraparoundMode = false;\\r\\n break;\\r\\n case 12:\\r\\n // this.cursorBlink = false;\\r\\n break;\\r\\n case 66:\\r\\n this._terminal.log('Switching back to normal keypad.');\\r\\n this._terminal.applicationKeypad = false;\\r\\n this._terminal.viewport.syncScrollArea();\\r\\n break;\\r\\n case 9: // X10 Mouse\\r\\n case 1000: // vt200 mouse\\r\\n case 1002: // button event mouse\\r\\n case 1003: // any event mouse\\r\\n this._terminal.x10Mouse = false;\\r\\n this._terminal.vt200Mouse = false;\\r\\n this._terminal.normalMouse = false;\\r\\n this._terminal.mouseEvents = false;\\r\\n this._terminal.element.classList.remove('enable-mouse-events');\\r\\n this._terminal.selectionManager.enable();\\r\\n break;\\r\\n case 1004: // send focusin/focusout events\\r\\n this._terminal.sendFocus = false;\\r\\n break;\\r\\n case 1005: // utf8 ext mode mouse\\r\\n this._terminal.utfMouse = false;\\r\\n break;\\r\\n case 1006: // sgr ext mode mouse\\r\\n this._terminal.sgrMouse = false;\\r\\n break;\\r\\n case 1015: // urxvt ext mode mouse\\r\\n this._terminal.urxvtMouse = false;\\r\\n break;\\r\\n case 25: // hide cursor\\r\\n this._terminal.cursorHidden = true;\\r\\n break;\\r\\n case 1049: // alt screen buffer cursor\\r\\n // FALL-THROUGH\\r\\n case 47: // normal screen buffer\\r\\n case 1047: // normal screen buffer - clearing it first\\r\\n // Ensure the selection manager has the correct buffer\\r\\n this._terminal.buffers.activateNormalBuffer();\\r\\n // TODO: Not sure if we need to save/restore after switching the buffer\\r\\n // if (params[0] === 1049) {\\r\\n // this.restoreCursor(params);\\r\\n // }\\r\\n this._terminal.selectionManager.setBuffer(this._terminal.buffer);\\r\\n this._terminal.refresh(0, this._terminal.rows - 1);\\r\\n this._terminal.viewport.syncScrollArea();\\r\\n this._terminal.showCursor();\\r\\n break;\\r\\n }\\r\\n }\\r\\n }\\r\\n\\r\\n /**\\r\\n * CSI Pm m Character Attributes (SGR).\\r\\n * Ps = 0 -> Normal (default).\\r\\n * Ps = 1 -> Bold.\\r\\n * Ps = 2 -> Faint, decreased intensity (ISO 6429).\\r\\n * Ps = 4 -> Underlined.\\r\\n * Ps = 5 -> Blink (appears as Bold).\\r\\n * Ps = 7 -> Inverse.\\r\\n * Ps = 8 -> Invisible, i.e., hidden (VT300).\\r\\n * Ps = 2 2 -> Normal (neither bold nor faint).\\r\\n * Ps = 2 4 -> Not underlined.\\r\\n * Ps = 2 5 -> Steady (not blinking).\\r\\n * Ps = 2 7 -> Positive (not inverse).\\r\\n * Ps = 2 8 -> Visible, i.e., not hidden (VT300).\\r\\n * Ps = 3 0 -> Set foreground color to Black.\\r\\n * Ps = 3 1 -> Set foreground color to Red.\\r\\n * Ps = 3 2 -> Set foreground color to Green.\\r\\n * Ps = 3 3 -> Set foreground color to Yellow.\\r\\n * Ps = 3 4 -> Set foreground color to Blue.\\r\\n * Ps = 3 5 -> Set foreground color to Magenta.\\r\\n * Ps = 3 6 -> Set foreground color to Cyan.\\r\\n * Ps = 3 7 -> Set foreground color to White.\\r\\n * Ps = 3 9 -> Set foreground color to default (original).\\r\\n * Ps = 4 0 -> Set background color to Black.\\r\\n * Ps = 4 1 -> Set background color to Red.\\r\\n * Ps = 4 2 -> Set background color to Green.\\r\\n * Ps = 4 3 -> Set background color to Yellow.\\r\\n * Ps = 4 4 -> Set background color to Blue.\\r\\n * Ps = 4 5 -> Set background color to Magenta.\\r\\n * Ps = 4 6 -> Set background color to Cyan.\\r\\n * Ps = 4 7 -> Set background color to White.\\r\\n * Ps = 4 9 -> Set background color to default (original).\\r\\n *\\r\\n * If 16-color support is compiled, the following apply. Assume\\r\\n * that xterm's resources are set so that the ISO color codes are\\r\\n * the first 8 of a set of 16. Then the aixterm colors are the\\r\\n * bright versions of the ISO colors:\\r\\n * Ps = 9 0 -> Set foreground color to Black.\\r\\n * Ps = 9 1 -> Set foreground color to Red.\\r\\n * Ps = 9 2 -> Set foreground color to Green.\\r\\n * Ps = 9 3 -> Set foreground color to Yellow.\\r\\n * Ps = 9 4 -> Set foreground color to Blue.\\r\\n * Ps = 9 5 -> Set foreground color to Magenta.\\r\\n * Ps = 9 6 -> Set foreground color to Cyan.\\r\\n * Ps = 9 7 -> Set foreground color to White.\\r\\n * Ps = 1 0 0 -> Set background color to Black.\\r\\n * Ps = 1 0 1 -> Set background color to Red.\\r\\n * Ps = 1 0 2 -> Set background color to Green.\\r\\n * Ps = 1 0 3 -> Set background color to Yellow.\\r\\n * Ps = 1 0 4 -> Set background color to Blue.\\r\\n * Ps = 1 0 5 -> Set background color to Magenta.\\r\\n * Ps = 1 0 6 -> Set background color to Cyan.\\r\\n * Ps = 1 0 7 -> Set background color to White.\\r\\n *\\r\\n * If xterm is compiled with the 16-color support disabled, it\\r\\n * supports the following, from rxvt:\\r\\n * Ps = 1 0 0 -> Set foreground and background color to\\r\\n * default.\\r\\n *\\r\\n * If 88- or 256-color support is compiled, the following apply.\\r\\n * Ps = 3 8 ; 5 ; Ps -> Set foreground color to the second\\r\\n * Ps.\\r\\n * Ps = 4 8 ; 5 ; Ps -> Set background color to the second\\r\\n * Ps.\\r\\n */\\r\\n public charAttributes(params: number[]): void {\\r\\n // Optimize a single SGR0.\\r\\n if (params.length === 1 && params[0] === 0) {\\r\\n this._terminal.curAttr = this._terminal.defAttr;\\r\\n return;\\r\\n }\\r\\n\\r\\n const l = params.length;\\r\\n let flags = this._terminal.curAttr >> 18;\\r\\n let fg = (this._terminal.curAttr >> 9) & 0x1ff;\\r\\n let bg = this._terminal.curAttr & 0x1ff;\\r\\n let p;\\r\\n\\r\\n for (let i = 0; i < l; i++) {\\r\\n p = params[i];\\r\\n if (p >= 30 && p <= 37) {\\r\\n // fg color 8\\r\\n fg = p - 30;\\r\\n } else if (p >= 40 && p <= 47) {\\r\\n // bg color 8\\r\\n bg = p - 40;\\r\\n } else if (p >= 90 && p <= 97) {\\r\\n // fg color 16\\r\\n p += 8;\\r\\n fg = p - 90;\\r\\n } else if (p >= 100 && p <= 107) {\\r\\n // bg color 16\\r\\n p += 8;\\r\\n bg = p - 100;\\r\\n } else if (p === 0) {\\r\\n // default\\r\\n flags = this._terminal.defAttr >> 18;\\r\\n fg = (this._terminal.defAttr >> 9) & 0x1ff;\\r\\n bg = this._terminal.defAttr & 0x1ff;\\r\\n // flags = 0;\\r\\n // fg = 0x1ff;\\r\\n // bg = 0x1ff;\\r\\n } else if (p === 1) {\\r\\n // bold text\\r\\n flags |= FLAGS.BOLD;\\r\\n } else if (p === 4) {\\r\\n // underlined text\\r\\n flags |= FLAGS.UNDERLINE;\\r\\n } else if (p === 5) {\\r\\n // blink\\r\\n flags |= FLAGS.BLINK;\\r\\n } else if (p === 7) {\\r\\n // inverse and positive\\r\\n // test with: echo -e '\\\\e[31m\\\\e[42mhello\\\\e[7mworld\\\\e[27mhi\\\\e[m'\\r\\n flags |= FLAGS.INVERSE;\\r\\n } else if (p === 8) {\\r\\n // invisible\\r\\n flags |= FLAGS.INVISIBLE;\\r\\n } else if (p === 2) {\\r\\n // dimmed text\\r\\n flags |= FLAGS.DIM;\\r\\n } else if (p === 22) {\\r\\n // not bold nor faint\\r\\n flags &= ~FLAGS.BOLD;\\r\\n flags &= ~FLAGS.DIM;\\r\\n } else if (p === 24) {\\r\\n // not underlined\\r\\n flags &= ~FLAGS.UNDERLINE;\\r\\n } else if (p === 25) {\\r\\n // not blink\\r\\n flags &= ~FLAGS.BLINK;\\r\\n } else if (p === 27) {\\r\\n // not inverse\\r\\n flags &= ~FLAGS.INVERSE;\\r\\n } else if (p === 28) {\\r\\n // not invisible\\r\\n flags &= ~FLAGS.INVISIBLE;\\r\\n } else if (p === 39) {\\r\\n // reset fg\\r\\n fg = (this._terminal.defAttr >> 9) & 0x1ff;\\r\\n } else if (p === 49) {\\r\\n // reset bg\\r\\n bg = this._terminal.defAttr & 0x1ff;\\r\\n } else if (p === 38) {\\r\\n // fg color 256\\r\\n if (params[i + 1] === 2) {\\r\\n i += 2;\\r\\n fg = this._terminal.matchColor(\\r\\n params[i] & 0xff,\\r\\n params[i + 1] & 0xff,\\r\\n params[i + 2] & 0xff);\\r\\n if (fg === -1) fg = 0x1ff;\\r\\n i += 2;\\r\\n } else if (params[i + 1] === 5) {\\r\\n i += 2;\\r\\n p = params[i] & 0xff;\\r\\n fg = p;\\r\\n }\\r\\n } else if (p === 48) {\\r\\n // bg color 256\\r\\n if (params[i + 1] === 2) {\\r\\n i += 2;\\r\\n bg = this._terminal.matchColor(\\r\\n params[i] & 0xff,\\r\\n params[i + 1] & 0xff,\\r\\n params[i + 2] & 0xff);\\r\\n if (bg === -1) bg = 0x1ff;\\r\\n i += 2;\\r\\n } else if (params[i + 1] === 5) {\\r\\n i += 2;\\r\\n p = params[i] & 0xff;\\r\\n bg = p;\\r\\n }\\r\\n } else if (p === 100) {\\r\\n // reset fg/bg\\r\\n fg = (this._terminal.defAttr >> 9) & 0x1ff;\\r\\n bg = this._terminal.defAttr & 0x1ff;\\r\\n } else {\\r\\n this._terminal.error('Unknown SGR attribute: %d.', p);\\r\\n }\\r\\n }\\r\\n\\r\\n this._terminal.curAttr = (flags << 18) | (fg << 9) | bg;\\r\\n }\\r\\n\\r\\n /**\\r\\n * CSI Ps n Device Status Report (DSR).\\r\\n * Ps = 5 -> Status Report. Result (``OK'') is\\r\\n * CSI 0 n\\r\\n * Ps = 6 -> Report Cursor Position (CPR) [row;column].\\r\\n * Result is\\r\\n * CSI r ; c R\\r\\n * CSI ? Ps n\\r\\n * Device Status Report (DSR, DEC-specific).\\r\\n * Ps = 6 -> Report Cursor Position (CPR) [row;column] as CSI\\r\\n * ? r ; c R (assumes page is zero).\\r\\n * Ps = 1 5 -> Report Printer status as CSI ? 1 0 n (ready).\\r\\n * or CSI ? 1 1 n (not ready).\\r\\n * Ps = 2 5 -> Report UDK status as CSI ? 2 0 n (unlocked)\\r\\n * or CSI ? 2 1 n (locked).\\r\\n * Ps = 2 6 -> Report Keyboard status as\\r\\n * CSI ? 2 7 ; 1 ; 0 ; 0 n (North American).\\r\\n * The last two parameters apply to VT400 & up, and denote key-\\r\\n * board ready and LK01 respectively.\\r\\n * Ps = 5 3 -> Report Locator status as\\r\\n * CSI ? 5 3 n Locator available, if compiled-in, or\\r\\n * CSI ? 5 0 n No Locator, if not.\\r\\n */\\r\\n public deviceStatus(params: number[]): void {\\r\\n if (!this._terminal.prefix) {\\r\\n switch (params[0]) {\\r\\n case 5:\\r\\n // status report\\r\\n this._terminal.send(C0.ESC + '[0n');\\r\\n break;\\r\\n case 6:\\r\\n // cursor position\\r\\n this._terminal.send(C0.ESC + '['\\r\\n + (this._terminal.buffer.y + 1)\\r\\n + ';'\\r\\n + (this._terminal.buffer.x + 1)\\r\\n + 'R');\\r\\n break;\\r\\n }\\r\\n } else if (this._terminal.prefix === '?') {\\r\\n // modern xterm doesnt seem to\\r\\n // respond to any of these except ?6, 6, and 5\\r\\n switch (params[0]) {\\r\\n case 6:\\r\\n // cursor position\\r\\n this._terminal.send(C0.ESC + '[?'\\r\\n + (this._terminal.buffer.y + 1)\\r\\n + ';'\\r\\n + (this._terminal.buffer.x + 1)\\r\\n + 'R');\\r\\n break;\\r\\n case 15:\\r\\n // no printer\\r\\n // this.send(C0.ESC + '[?11n');\\r\\n break;\\r\\n case 25:\\r\\n // dont support user defined keys\\r\\n // this.send(C0.ESC + '[?21n');\\r\\n break;\\r\\n case 26:\\r\\n // north american keyboard\\r\\n // this.send(C0.ESC + '[?27;1;0;0n');\\r\\n break;\\r\\n case 53:\\r\\n // no dec locator/mouse\\r\\n // this.send(C0.ESC + '[?50n');\\r\\n break;\\r\\n }\\r\\n }\\r\\n }\\r\\n\\r\\n /**\\r\\n * CSI ! p Soft terminal reset (DECSTR).\\r\\n * http://vt100.net/docs/vt220-rm/table4-10.html\\r\\n */\\r\\n public softReset(params: number[]): void {\\r\\n this._terminal.cursorHidden = false;\\r\\n this._terminal.insertMode = false;\\r\\n this._terminal.originMode = false;\\r\\n this._terminal.wraparoundMode = true; // defaults: xterm - true, vt100 - false\\r\\n this._terminal.applicationKeypad = false; // ?\\r\\n this._terminal.viewport.syncScrollArea();\\r\\n this._terminal.applicationCursor = false;\\r\\n this._terminal.buffer.scrollTop = 0;\\r\\n this._terminal.buffer.scrollBottom = this._terminal.rows - 1;\\r\\n this._terminal.curAttr = this._terminal.defAttr;\\r\\n this._terminal.buffer.x = this._terminal.buffer.y = 0; // ?\\r\\n this._terminal.charset = null;\\r\\n this._terminal.glevel = 0; // ??\\r\\n this._terminal.charsets = [null]; // ??\\r\\n }\\r\\n\\r\\n /**\\r\\n * CSI Ps SP q Set cursor style (DECSCUSR, VT520).\\r\\n * Ps = 0 -> blinking block.\\r\\n * Ps = 1 -> blinking block (default).\\r\\n * Ps = 2 -> steady block.\\r\\n * Ps = 3 -> blinking underline.\\r\\n * Ps = 4 -> steady underline.\\r\\n * Ps = 5 -> blinking bar (xterm).\\r\\n * Ps = 6 -> steady bar (xterm).\\r\\n */\\r\\n public setCursorStyle(params?: number[]): void {\\r\\n const param = params[0] < 1 ? 1 : params[0];\\r\\n switch (param) {\\r\\n case 1:\\r\\n case 2:\\r\\n this._terminal.setOption('cursorStyle', 'block');\\r\\n break;\\r\\n case 3:\\r\\n case 4:\\r\\n this._terminal.setOption('cursorStyle', 'underline');\\r\\n break;\\r\\n case 5:\\r\\n case 6:\\r\\n this._terminal.setOption('cursorStyle', 'bar');\\r\\n break;\\r\\n }\\r\\n const isBlinking = param % 2 === 1;\\r\\n this._terminal.setOption('cursorBlink', isBlinking);\\r\\n }\\r\\n\\r\\n /**\\r\\n * CSI Ps ; Ps r\\r\\n * Set Scrolling Region [top;bottom] (default = full size of win-\\r\\n * dow) (DECSTBM).\\r\\n * CSI ? Pm r\\r\\n */\\r\\n public setScrollRegion(params: number[]): void {\\r\\n if (this._terminal.prefix) return;\\r\\n this._terminal.buffer.scrollTop = (params[0] || 1) - 1;\\r\\n this._terminal.buffer.scrollBottom = (params[1] && params[1] <= this._terminal.rows ? params[1] : this._terminal.rows) - 1;\\r\\n this._terminal.buffer.x = 0;\\r\\n this._terminal.buffer.y = 0;\\r\\n }\\r\\n\\r\\n\\r\\n /**\\r\\n * CSI s\\r\\n * Save cursor (ANSI.SYS).\\r\\n */\\r\\n public saveCursor(params: number[]): void {\\r\\n this._terminal.buffer.savedX = this._terminal.buffer.x;\\r\\n this._terminal.buffer.savedY = this._terminal.buffer.y;\\r\\n }\\r\\n\\r\\n\\r\\n /**\\r\\n * CSI u\\r\\n * Restore cursor (ANSI.SYS).\\r\\n */\\r\\n public restoreCursor(params: number[]): void {\\r\\n this._terminal.buffer.x = this._terminal.buffer.savedX || 0;\\r\\n this._terminal.buffer.y = this._terminal.buffer.savedY || 0;\\r\\n }\\r\\n}\\r\\n\\r\\nexport const wcwidth = (function(opts: {nul: number, control: number}): (ucs: number) => number {\\r\\n // extracted from https://www.cl.cam.ac.uk/%7Emgk25/ucs/wcwidth.c\\r\\n // combining characters\\r\\n const COMBINING_BMP = [\\r\\n [0x0300, 0x036F], [0x0483, 0x0486], [0x0488, 0x0489],\\r\\n [0x0591, 0x05BD], [0x05BF, 0x05BF], [0x05C1, 0x05C2],\\r\\n [0x05C4, 0x05C5], [0x05C7, 0x05C7], [0x0600, 0x0603],\\r\\n [0x0610, 0x0615], [0x064B, 0x065E], [0x0670, 0x0670],\\r\\n [0x06D6, 0x06E4], [0x06E7, 0x06E8], [0x06EA, 0x06ED],\\r\\n [0x070F, 0x070F], [0x0711, 0x0711], [0x0730, 0x074A],\\r\\n [0x07A6, 0x07B0], [0x07EB, 0x07F3], [0x0901, 0x0902],\\r\\n [0x093C, 0x093C], [0x0941, 0x0948], [0x094D, 0x094D],\\r\\n [0x0951, 0x0954], [0x0962, 0x0963], [0x0981, 0x0981],\\r\\n [0x09BC, 0x09BC], [0x09C1, 0x09C4], [0x09CD, 0x09CD],\\r\\n [0x09E2, 0x09E3], [0x0A01, 0x0A02], [0x0A3C, 0x0A3C],\\r\\n [0x0A41, 0x0A42], [0x0A47, 0x0A48], [0x0A4B, 0x0A4D],\\r\\n [0x0A70, 0x0A71], [0x0A81, 0x0A82], [0x0ABC, 0x0ABC],\\r\\n [0x0AC1, 0x0AC5], [0x0AC7, 0x0AC8], [0x0ACD, 0x0ACD],\\r\\n [0x0AE2, 0x0AE3], [0x0B01, 0x0B01], [0x0B3C, 0x0B3C],\\r\\n [0x0B3F, 0x0B3F], [0x0B41, 0x0B43], [0x0B4D, 0x0B4D],\\r\\n [0x0B56, 0x0B56], [0x0B82, 0x0B82], [0x0BC0, 0x0BC0],\\r\\n [0x0BCD, 0x0BCD], [0x0C3E, 0x0C40], [0x0C46, 0x0C48],\\r\\n [0x0C4A, 0x0C4D], [0x0C55, 0x0C56], [0x0CBC, 0x0CBC],\\r\\n [0x0CBF, 0x0CBF], [0x0CC6, 0x0CC6], [0x0CCC, 0x0CCD],\\r\\n [0x0CE2, 0x0CE3], [0x0D41, 0x0D43], [0x0D4D, 0x0D4D],\\r\\n [0x0DCA, 0x0DCA], [0x0DD2, 0x0DD4], [0x0DD6, 0x0DD6],\\r\\n [0x0E31, 0x0E31], [0x0E34, 0x0E3A], [0x0E47, 0x0E4E],\\r\\n [0x0EB1, 0x0EB1], [0x0EB4, 0x0EB9], [0x0EBB, 0x0EBC],\\r\\n [0x0EC8, 0x0ECD], [0x0F18, 0x0F19], [0x0F35, 0x0F35],\\r\\n [0x0F37, 0x0F37], [0x0F39, 0x0F39], [0x0F71, 0x0F7E],\\r\\n [0x0F80, 0x0F84], [0x0F86, 0x0F87], [0x0F90, 0x0F97],\\r\\n [0x0F99, 0x0FBC], [0x0FC6, 0x0FC6], [0x102D, 0x1030],\\r\\n [0x1032, 0x1032], [0x1036, 0x1037], [0x1039, 0x1039],\\r\\n [0x1058, 0x1059], [0x1160, 0x11FF], [0x135F, 0x135F],\\r\\n [0x1712, 0x1714], [0x1732, 0x1734], [0x1752, 0x1753],\\r\\n [0x1772, 0x1773], [0x17B4, 0x17B5], [0x17B7, 0x17BD],\\r\\n [0x17C6, 0x17C6], [0x17C9, 0x17D3], [0x17DD, 0x17DD],\\r\\n [0x180B, 0x180D], [0x18A9, 0x18A9], [0x1920, 0x1922],\\r\\n [0x1927, 0x1928], [0x1932, 0x1932], [0x1939, 0x193B],\\r\\n [0x1A17, 0x1A18], [0x1B00, 0x1B03], [0x1B34, 0x1B34],\\r\\n [0x1B36, 0x1B3A], [0x1B3C, 0x1B3C], [0x1B42, 0x1B42],\\r\\n [0x1B6B, 0x1B73], [0x1DC0, 0x1DCA], [0x1DFE, 0x1DFF],\\r\\n [0x200B, 0x200F], [0x202A, 0x202E], [0x2060, 0x2063],\\r\\n [0x206A, 0x206F], [0x20D0, 0x20EF], [0x302A, 0x302F],\\r\\n [0x3099, 0x309A], [0xA806, 0xA806], [0xA80B, 0xA80B],\\r\\n [0xA825, 0xA826], [0xFB1E, 0xFB1E], [0xFE00, 0xFE0F],\\r\\n [0xFE20, 0xFE23], [0xFEFF, 0xFEFF], [0xFFF9, 0xFFFB],\\r\\n ];\\r\\n const COMBINING_HIGH = [\\r\\n [0x10A01, 0x10A03], [0x10A05, 0x10A06], [0x10A0C, 0x10A0F],\\r\\n [0x10A38, 0x10A3A], [0x10A3F, 0x10A3F], [0x1D167, 0x1D169],\\r\\n [0x1D173, 0x1D182], [0x1D185, 0x1D18B], [0x1D1AA, 0x1D1AD],\\r\\n [0x1D242, 0x1D244], [0xE0001, 0xE0001], [0xE0020, 0xE007F],\\r\\n [0xE0100, 0xE01EF]\\r\\n ];\\r\\n // binary search\\r\\n function bisearch(ucs: number, data: number[][]): boolean {\\r\\n let min = 0;\\r\\n let max = data.length - 1;\\r\\n let mid;\\r\\n if (ucs < data[0][0] || ucs > data[max][1])\\r\\n return false;\\r\\n while (max >= min) {\\r\\n mid = (min + max) >> 1;\\r\\n if (ucs > data[mid][1])\\r\\n min = mid + 1;\\r\\n else if (ucs < data[mid][0])\\r\\n max = mid - 1;\\r\\n else\\r\\n return true;\\r\\n }\\r\\n return false;\\r\\n }\\r\\n function wcwidthBMP(ucs: number): number {\\r\\n // test for 8-bit control characters\\r\\n if (ucs === 0)\\r\\n return opts.nul;\\r\\n if (ucs < 32 || (ucs >= 0x7f && ucs < 0xa0))\\r\\n return opts.control;\\r\\n // binary search in table of non-spacing characters\\r\\n if (bisearch(ucs, COMBINING_BMP))\\r\\n return 0;\\r\\n // if we arrive here, ucs is not a combining or C0/C1 control character\\r\\n if (isWideBMP(ucs)) {\\r\\n return 2;\\r\\n }\\r\\n return 1;\\r\\n }\\r\\n function isWideBMP(ucs: number): boolean {\\r\\n return (\\r\\n ucs >= 0x1100 && (\\r\\n ucs <= 0x115f || // Hangul Jamo init. consonants\\r\\n ucs === 0x2329 ||\\r\\n ucs === 0x232a ||\\r\\n (ucs >= 0x2e80 && ucs <= 0xa4cf && ucs !== 0x303f) || // CJK..Yi\\r\\n (ucs >= 0xac00 && ucs <= 0xd7a3) || // Hangul Syllables\\r\\n (ucs >= 0xf900 && ucs <= 0xfaff) || // CJK Compat Ideographs\\r\\n (ucs >= 0xfe10 && ucs <= 0xfe19) || // Vertical forms\\r\\n (ucs >= 0xfe30 && ucs <= 0xfe6f) || // CJK Compat Forms\\r\\n (ucs >= 0xff00 && ucs <= 0xff60) || // Fullwidth Forms\\r\\n (ucs >= 0xffe0 && ucs <= 0xffe6)));\\r\\n }\\r\\n function wcwidthHigh(ucs: number): 0 | 1 | 2 {\\r\\n if (bisearch(ucs, COMBINING_HIGH))\\r\\n return 0;\\r\\n if ((ucs >= 0x20000 && ucs <= 0x2fffd) || (ucs >= 0x30000 && ucs <= 0x3fffd)) {\\r\\n return 2;\\r\\n }\\r\\n return 1;\\r\\n }\\r\\n const control = opts.control | 0;\\r\\n let table: number[] | Uint32Array = null;\\r\\n function init_table(): number[] | Uint32Array {\\r\\n // lookup table for BMP\\r\\n const CODEPOINTS = 65536; // BMP holds 65536 codepoints\\r\\n const BITWIDTH = 2; // a codepoint can have a width of 0, 1 or 2\\r\\n const ITEMSIZE = 32; // using uint32_t\\r\\n const CONTAINERSIZE = CODEPOINTS * BITWIDTH / ITEMSIZE;\\r\\n const CODEPOINTS_PER_ITEM = ITEMSIZE / BITWIDTH;\\r\\n table = (typeof Uint32Array === 'undefined')\\r\\n ? new Array(CONTAINERSIZE)\\r\\n : new Uint32Array(CONTAINERSIZE);\\r\\n for (let i = 0; i < CONTAINERSIZE; ++i) {\\r\\n let num = 0;\\r\\n let pos = CODEPOINTS_PER_ITEM;\\r\\n while (pos--)\\r\\n num = (num << 2) | wcwidthBMP(CODEPOINTS_PER_ITEM * i + pos);\\r\\n table[i] = num;\\r\\n }\\r\\n return table;\\r\\n }\\r\\n // get width from lookup table\\r\\n // position in container : num / CODEPOINTS_PER_ITEM\\r\\n // ==> n = table[Math.floor(num / 16)]\\r\\n // ==> n = table[num >> 4]\\r\\n // 16 codepoints per number: FFEEDDCCBBAA99887766554433221100\\r\\n // position in number : (num % CODEPOINTS_PER_ITEM) * BITWIDTH\\r\\n // ==> m = (n % 16) * 2\\r\\n // ==> m = (num & 15) << 1\\r\\n // right shift to position m\\r\\n // ==> n = n >> m e.g. m=12 000000000000FFEEDDCCBBAA99887766\\r\\n // we are only interested in 2 LSBs, cut off higher bits\\r\\n // ==> n = n & 3 e.g. 000000000000000000000000000000XX\\r\\n return function (num: number): number {\\r\\n num = num | 0; // get asm.js like optimization under V8\\r\\n if (num < 32)\\r\\n return control | 0;\\r\\n if (num < 127)\\r\\n return 1;\\r\\n let t = table || init_table();\\r\\n if (num < 65536)\\r\\n return t[num >> 4] >> ((num & 15) << 1) & 3;\\r\\n // do a full search for high codepoints\\r\\n return wcwidthHigh(num);\\r\\n };\\r\\n})({nul: 0, control: 0}); // configurable options\\r\\n\",\"/**\\r\\n * Copyright (c) 2017 The xterm.js authors. All rights reserved.\\r\\n * @license MIT\\r\\n */\\r\\n\\r\\nimport { IEventEmitter, IListenerType } from './Interfaces';\\r\\n\\r\\nexport class EventEmitter implements IEventEmitter {\\r\\n private _events: {[type: string]: IListenerType[]};\\r\\n\\r\\n constructor() {\\r\\n // Restore the previous events if available, this will happen if the\\r\\n // constructor is called multiple times on the same object (terminal reset).\\r\\n this._events = this._events || {};\\r\\n }\\r\\n\\r\\n public on(type: string, listener: IListenerType): void {\\r\\n this._events[type] = this._events[type] || [];\\r\\n this._events[type].push(listener);\\r\\n }\\r\\n\\r\\n public off(type: string, listener: IListenerType): void {\\r\\n if (!this._events[type]) {\\r\\n return;\\r\\n }\\r\\n\\r\\n let obj = this._events[type];\\r\\n let i = obj.length;\\r\\n\\r\\n while (i--) {\\r\\n if (obj[i] === listener || obj[i].listener === listener) {\\r\\n obj.splice(i, 1);\\r\\n return;\\r\\n }\\r\\n }\\r\\n }\\r\\n\\r\\n public removeAllListeners(type: string): void {\\r\\n if (this._events[type]) {\\r\\n delete this._events[type];\\r\\n }\\r\\n }\\r\\n\\r\\n public once(type: string, listener: IListenerType): void {\\r\\n function on(): void {\\r\\n let args = Array.prototype.slice.call(arguments);\\r\\n this.off(type, on);\\r\\n listener.apply(this, args);\\r\\n }\\r\\n (<any>on).listener = listener;\\r\\n this.on(type, on);\\r\\n }\\r\\n\\r\\n public emit(type: string, ...args: any[]): void {\\r\\n if (!this._events[type]) {\\r\\n return;\\r\\n }\\r\\n let obj = this._events[type];\\r\\n for (let i = 0; i < obj.length; i++) {\\r\\n obj[i].apply(this, args);\\r\\n }\\r\\n }\\r\\n\\r\\n public listeners(type: string): IListenerType[] {\\r\\n return this._events[type] || [];\\r\\n }\\r\\n\\r\\n protected destroy(): void {\\r\\n this._events = {};\\r\\n }\\r\\n}\\r\\n\",\"/**\\r\\n * Copyright (c) 2017 The xterm.js authors. All rights reserved.\\r\\n * @license MIT\\r\\n */\\r\\n\\r\\n/**\\r\\n * C0 control codes\\r\\n * See = https://en.wikipedia.org/wiki/C0_and_C1_control_codes\\r\\n */\\r\\nexport namespace C0 {\\r\\n /** Null (Caret = ^@, C = \\\\0) */\\r\\n export const NUL = '\\\\x00';\\r\\n /** Start of Heading (Caret = ^A) */\\r\\n export const SOH = '\\\\x01';\\r\\n /** Start of Text (Caret = ^B) */\\r\\n export const STX = '\\\\x02';\\r\\n /** End of Text (Caret = ^C) */\\r\\n export const ETX = '\\\\x03';\\r\\n /** End of Transmission (Caret = ^D) */\\r\\n export const EOT = '\\\\x04';\\r\\n /** Enquiry (Caret = ^E) */\\r\\n export const ENQ = '\\\\x05';\\r\\n /** Acknowledge (Caret = ^F) */\\r\\n export const ACK = '\\\\x06';\\r\\n /** Bell (Caret = ^G, C = \\\\a) */\\r\\n export const BEL = '\\\\x07';\\r\\n /** Backspace (Caret = ^H, C = \\\\b) */\\r\\n export const BS = '\\\\x08';\\r\\n /** Character Tabulation, Horizontal Tabulation (Caret = ^I, C = \\\\t) */\\r\\n export const HT = '\\\\x09';\\r\\n /** Line Feed (Caret = ^J, C = \\\\n) */\\r\\n export const LF = '\\\\x0a';\\r\\n /** Line Tabulation, Vertical Tabulation (Caret = ^K, C = \\\\v) */\\r\\n export const VT = '\\\\x0b';\\r\\n /** Form Feed (Caret = ^L, C = \\\\f) */\\r\\n export const FF = '\\\\x0c';\\r\\n /** Carriage Return (Caret = ^M, C = \\\\r) */\\r\\n export const CR = '\\\\x0d';\\r\\n /** Shift Out (Caret = ^N) */\\r\\n export const SO = '\\\\x0e';\\r\\n /** Shift In (Caret = ^O) */\\r\\n export const SI = '\\\\x0f';\\r\\n /** Data Link Escape (Caret = ^P) */\\r\\n export const DLE = '\\\\x10';\\r\\n /** Device Control One (XON) (Caret = ^Q) */\\r\\n export const DC1 = '\\\\x11';\\r\\n /** Device Control Two (Caret = ^R) */\\r\\n export const DC2 = '\\\\x12';\\r\\n /** Device Control Three (XOFF) (Caret = ^S) */\\r\\n export const DC3 = '\\\\x13';\\r\\n /** Device Control Four (Caret = ^T) */\\r\\n export const DC4 = '\\\\x14';\\r\\n /** Negative Acknowledge (Caret = ^U) */\\r\\n export const NAK = '\\\\x15';\\r\\n /** Synchronous Idle (Caret = ^V) */\\r\\n export const SYN = '\\\\x16';\\r\\n /** End of Transmission Block (Caret = ^W) */\\r\\n export const ETB = '\\\\x17';\\r\\n /** Cancel (Caret = ^X) */\\r\\n export const CAN = '\\\\x18';\\r\\n /** End of Medium (Caret = ^Y) */\\r\\n export const EM = '\\\\x19';\\r\\n /** Substitute (Caret = ^Z) */\\r\\n export const SUB = '\\\\x1a';\\r\\n /** Escape (Caret = ^[, C = \\\\e) */\\r\\n export const ESC = '\\\\x1b';\\r\\n /** File Separator (Caret = ^\\\\) */\\r\\n export const FS = '\\\\x1c';\\r\\n /** Group Separator (Caret = ^]) */\\r\\n export const GS = '\\\\x1d';\\r\\n /** Record Separator (Caret = ^^) */\\r\\n export const RS = '\\\\x1e';\\r\\n /** Unit Separator (Caret = ^_) */\\r\\n export const US = '\\\\x1f';\\r\\n /** Space */\\r\\n export const SP = '\\\\x20';\\r\\n /** Delete (Caret = ^?) */\\r\\n export const DEL = '\\\\x7f';\\r\\n};\\r\\n\",\"/**\\r\\n * Copyright (c) 2016 The xterm.js authors. All rights reserved.\\r\\n * @license MIT\\r\\n */\\r\\n\\r\\nimport { ITerminal } from './Interfaces';\\r\\n\\r\\ninterface IPosition {\\r\\n start: number;\\r\\n end: number;\\r\\n}\\r\\n\\r\\n/**\\r\\n * Encapsulates the logic for handling compositionstart, compositionupdate and compositionend\\r\\n * events, displaying the in-progress composition to the UI and forwarding the final composition\\r\\n * to the handler.\\r\\n */\\r\\nexport class CompositionHelper {\\r\\n /**\\r\\n * Whether input composition is currently happening, eg. via a mobile keyboard, speech input or\\r\\n * IME. This variable determines whether the compositionText should be displayed on the UI.\\r\\n */\\r\\n private isComposing: boolean;\\r\\n\\r\\n /**\\r\\n * The position within the input textarea's value of the current composition.\\r\\n */\\r\\n private compositionPosition: IPosition;\\r\\n\\r\\n /**\\r\\n * Whether a composition is in the process of being sent, setting this to false will cancel any\\r\\n * in-progress composition.\\r\\n */\\r\\n private isSendingComposition: boolean;\\r\\n\\r\\n /**\\r\\n * Creates a new CompositionHelper.\\r\\n * @param textarea The textarea that xterm uses for input.\\r\\n * @param compositionView The element to display the in-progress composition in.\\r\\n * @param terminal The Terminal to forward the finished composition to.\\r\\n */\\r\\n constructor(\\r\\n private textarea: HTMLTextAreaElement,\\r\\n private compositionView: HTMLElement,\\r\\n private terminal: ITerminal\\r\\n ) {\\r\\n this.isComposing = false;\\r\\n this.isSendingComposition = false;\\r\\n this.compositionPosition = { start: null, end: null };\\r\\n }\\r\\n\\r\\n /**\\r\\n * Handles the compositionstart event, activating the composition view.\\r\\n */\\r\\n public compositionstart(): void {\\r\\n this.isComposing = true;\\r\\n this.compositionPosition.start = this.textarea.value.length;\\r\\n this.compositionView.textContent = '';\\r\\n this.compositionView.classList.add('active');\\r\\n }\\r\\n\\r\\n /**\\r\\n * Handles the compositionupdate event, updating the composition view.\\r\\n * @param {CompositionEvent} ev The event.\\r\\n */\\r\\n public compositionupdate(ev: CompositionEvent): void {\\r\\n this.compositionView.textContent = ev.data;\\r\\n this.updateCompositionElements();\\r\\n setTimeout(() => {\\r\\n this.compositionPosition.end = this.textarea.value.length;\\r\\n }, 0);\\r\\n }\\r\\n\\r\\n /**\\r\\n * Handles the compositionend event, hiding the composition view and sending the composition to\\r\\n * the handler.\\r\\n */\\r\\n public compositionend(): void {\\r\\n this.finalizeComposition(true);\\r\\n }\\r\\n\\r\\n /**\\r\\n * Handles the keydown event, routing any necessary events to the CompositionHelper functions.\\r\\n * @param ev The keydown event.\\r\\n * @return Whether the Terminal should continue processing the keydown event.\\r\\n */\\r\\n public keydown(ev: KeyboardEvent): boolean {\\r\\n if (this.isComposing || this.isSendingComposition) {\\r\\n if (ev.keyCode === 229) {\\r\\n // Continue composing if the keyCode is the \\\"composition character\\\"\\r\\n return false;\\r\\n } else if (ev.keyCode === 16 || ev.keyCode === 17 || ev.keyCode === 18) {\\r\\n // Continue composing if the keyCode is a modifier key\\r\\n return false;\\r\\n } else {\\r\\n // Finish composition immediately. This is mainly here for the case where enter is\\r\\n // pressed and the handler needs to be triggered before the command is executed.\\r\\n this.finalizeComposition(false);\\r\\n }\\r\\n }\\r\\n\\r\\n if (ev.keyCode === 229) {\\r\\n // If the \\\"composition character\\\" is used but gets to this point it means a non-composition\\r\\n // character (eg. numbers and punctuation) was pressed when the IME was active.\\r\\n this.handleAnyTextareaChanges();\\r\\n return false;\\r\\n }\\r\\n\\r\\n return true;\\r\\n }\\r\\n\\r\\n /**\\r\\n * Finalizes the composition, resuming regular input actions. This is called when a composition\\r\\n * is ending.\\r\\n * @param waitForPropogation Whether to wait for events to propogate before sending\\r\\n * the input. This should be false if a non-composition keystroke is entered before the\\r\\n * compositionend event is triggered, such as enter, so that the composition is send before\\r\\n * the command is executed.\\r\\n */\\r\\n private finalizeComposition(waitForPropogation: boolean): void {\\r\\n this.compositionView.classList.remove('active');\\r\\n this.isComposing = false;\\r\\n this.clearTextareaPosition();\\r\\n\\r\\n if (!waitForPropogation) {\\r\\n // Cancel any delayed composition send requests and send the input immediately.\\r\\n this.isSendingComposition = false;\\r\\n const input = this.textarea.value.substring(this.compositionPosition.start, this.compositionPosition.end);\\r\\n this.terminal.handler(input);\\r\\n } else {\\r\\n // Make a deep copy of the composition position here as a new compositionstart event may\\r\\n // fire before the setTimeout executes.\\r\\n const currentCompositionPosition = {\\r\\n start: this.compositionPosition.start,\\r\\n end: this.compositionPosition.end,\\r\\n };\\r\\n\\r\\n // Since composition* events happen before the changes take place in the textarea on most\\r\\n // browsers, use a setTimeout with 0ms time to allow the native compositionend event to\\r\\n // complete. This ensures the correct character is retrieved, this solution was used\\r\\n // because:\\r\\n // - The compositionend event's data property is unreliable, at least on Chromium\\r\\n // - The last compositionupdate event's data property does not always accurately describe\\r\\n // the character, a counter example being Korean where an ending consonsant can move to\\r\\n // the following character if the following input is a vowel.\\r\\n this.isSendingComposition = true;\\r\\n setTimeout(() => {\\r\\n // Ensure that the input has not already been sent\\r\\n if (this.isSendingComposition) {\\r\\n this.isSendingComposition = false;\\r\\n let input;\\r\\n if (this.isComposing) {\\r\\n // Use the end position to get the string if a new composition has started.\\r\\n input = this.textarea.value.substring(currentCompositionPosition.start, currentCompositionPosition.end);\\r\\n } else {\\r\\n // Don't use the end position here in order to pick up any characters after the\\r\\n // composition has finished, for example when typing a non-composition character\\r\\n // (eg. 2) after a composition character.\\r\\n input = this.textarea.value.substring(currentCompositionPosition.start);\\r\\n }\\r\\n this.terminal.handler(input);\\r\\n }\\r\\n }, 0);\\r\\n }\\r\\n }\\r\\n\\r\\n /**\\r\\n * Apply any changes made to the textarea after the current event chain is allowed to complete.\\r\\n * This should be called when not currently composing but a keydown event with the \\\"composition\\r\\n * character\\\" (229) is triggered, in order to allow non-composition text to be entered when an\\r\\n * IME is active.\\r\\n */\\r\\n private handleAnyTextareaChanges(): void {\\r\\n const oldValue = this.textarea.value;\\r\\n setTimeout(() => {\\r\\n // Ignore if a composition has started since the timeout\\r\\n if (!this.isComposing) {\\r\\n const newValue = this.textarea.value;\\r\\n const diff = newValue.replace(oldValue, '');\\r\\n if (diff.length > 0) {\\r\\n this.terminal.handler(diff);\\r\\n }\\r\\n }\\r\\n }, 0);\\r\\n }\\r\\n\\r\\n /**\\r\\n * Positions the composition view on top of the cursor and the textarea just below it (so the\\r\\n * IME helper dialog is positioned correctly).\\r\\n * @param dontRecurse Whether to use setTimeout to recursively trigger another update, this is\\r\\n * necessary as the IME events across browsers are not consistently triggered.\\r\\n */\\r\\n public updateCompositionElements(dontRecurse?: boolean): void {\\r\\n if (!this.isComposing) {\\r\\n return;\\r\\n }\\r\\n\\r\\n if (this.terminal.buffer.isCursorInViewport) {\\r\\n const cellHeight = Math.ceil(this.terminal.charMeasure.height * this.terminal.options.lineHeight);\\r\\n const cursorTop = this.terminal.buffer.y * cellHeight;\\r\\n const cursorLeft = this.terminal.buffer.x * this.terminal.charMeasure.width;\\r\\n\\r\\n this.compositionView.style.left = cursorLeft + 'px';\\r\\n this.compositionView.style.top = cursorTop + 'px';\\r\\n this.compositionView.style.height = cellHeight + 'px';\\r\\n this.compositionView.style.lineHeight = cellHeight + 'px';\\r\\n // Sync the textarea to the exact position of the composition view so the IME knows where the\\r\\n // text is.\\r\\n const compositionViewBounds = this.compositionView.getBoundingClientRect();\\r\\n this.textarea.style.left = cursorLeft + 'px';\\r\\n this.textarea.style.top = cursorTop + 'px';\\r\\n this.textarea.style.width = compositionViewBounds.width + 'px';\\r\\n this.textarea.style.height = compositionViewBounds.height + 'px';\\r\\n this.textarea.style.lineHeight = compositionViewBounds.height + 'px';\\r\\n }\\r\\n\\r\\n if (!dontRecurse) {\\r\\n setTimeout(() => this.updateCompositionElements(true), 0);\\r\\n }\\r\\n };\\r\\n\\r\\n /**\\r\\n * Clears the textarea's position so that the cursor does not blink on IE.\\r\\n * @private\\r\\n */\\r\\n private clearTextareaPosition(): void {\\r\\n this.textarea.style.left = '';\\r\\n this.textarea.style.top = '';\\r\\n };\\r\\n}\\r\\n\",\"/**\\r\\n * Copyright (c) 2016 The xterm.js authors. All rights reserved.\\r\\n * @license MIT\\r\\n */\\r\\n\\r\\nimport { Charset } from './Types';\\r\\n\\r\\n/**\\r\\n * The character sets supported by the terminal. These enable several languages\\r\\n * to be represented within the terminal with only 8-bit encoding. See ISO 2022\\r\\n * for a discussion on character sets. Only VT100 character sets are supported.\\r\\n */\\r\\nexport const CHARSETS: { [key: string]: Charset } = {};\\r\\n\\r\\n/**\\r\\n * The default character set, US.\\r\\n */\\r\\nexport const DEFAULT_CHARSET: Charset = CHARSETS['B'];\\r\\n\\r\\n/**\\r\\n * DEC Special Character and Line Drawing Set.\\r\\n * Reference: http://vt100.net/docs/vt102-ug/table5-13.html\\r\\n * A lot of curses apps use this if they see TERM=xterm.\\r\\n * testing: echo -e '\\\\e(0a\\\\e(B'\\r\\n * The xterm output sometimes seems to conflict with the\\r\\n * reference above. xterm seems in line with the reference\\r\\n * when running vttest however.\\r\\n * The table below now uses xterm's output from vttest.\\r\\n */\\r\\nCHARSETS['0'] = {\\r\\n '`': '\\\\u25c6', // '◆'\\r\\n 'a': '\\\\u2592', // '▒'\\r\\n 'b': '\\\\u0009', // '\\\\t'\\r\\n 'c': '\\\\u000c', // '\\\\f'\\r\\n 'd': '\\\\u000d', // '\\\\r'\\r\\n 'e': '\\\\u000a', // '\\\\n'\\r\\n 'f': '\\\\u00b0', // '°'\\r\\n 'g': '\\\\u00b1', // '±'\\r\\n 'h': '\\\\u2424', // '\\\\u2424' (NL)\\r\\n 'i': '\\\\u000b', // '\\\\v'\\r\\n 'j': '\\\\u2518', // '┘'\\r\\n 'k': '\\\\u2510', // '┐'\\r\\n 'l': '\\\\u250c', // '┌'\\r\\n 'm': '\\\\u2514', // '└'\\r\\n 'n': '\\\\u253c', // '┼'\\r\\n 'o': '\\\\u23ba', // '⎺'\\r\\n 'p': '\\\\u23bb', // '⎻'\\r\\n 'q': '\\\\u2500', // '─'\\r\\n 'r': '\\\\u23bc', // '⎼'\\r\\n 's': '\\\\u23bd', // '⎽'\\r\\n 't': '\\\\u251c', // '├'\\r\\n 'u': '\\\\u2524', // '┤'\\r\\n 'v': '\\\\u2534', // '┴'\\r\\n 'w': '\\\\u252c', // '┬'\\r\\n 'x': '\\\\u2502', // '│'\\r\\n 'y': '\\\\u2264', // '≤'\\r\\n 'z': '\\\\u2265', // '≥'\\r\\n '{': '\\\\u03c0', // 'π'\\r\\n '|': '\\\\u2260', // '≠'\\r\\n '}': '\\\\u00a3', // '£'\\r\\n '~': '\\\\u00b7' // '·'\\r\\n};\\r\\n\\r\\n/**\\r\\n * British character set\\r\\n * ESC (A\\r\\n * Reference: http://vt100.net/docs/vt220-rm/table2-5.html\\r\\n */\\r\\nCHARSETS['A'] = {\\r\\n '#': '£'\\r\\n};\\r\\n\\r\\n/**\\r\\n * United States character set\\r\\n * ESC (B\\r\\n */\\r\\nCHARSETS['B'] = null;\\r\\n\\r\\n/**\\r\\n * Dutch character set\\r\\n * ESC (4\\r\\n * Reference: http://vt100.net/docs/vt220-rm/table2-6.html\\r\\n */\\r\\nCHARSETS['4'] = {\\r\\n '#': '£',\\r\\n '@': '¾',\\r\\n '[': 'ij',\\r\\n '\\\\\\\\': '½',\\r\\n ']': '|',\\r\\n '{': '¨',\\r\\n '|': 'f',\\r\\n '}': '¼',\\r\\n '~': '´'\\r\\n};\\r\\n\\r\\n/**\\r\\n * Finnish character set\\r\\n * ESC (C or ESC (5\\r\\n * Reference: http://vt100.net/docs/vt220-rm/table2-7.html\\r\\n */\\r\\nCHARSETS['C'] =\\r\\nCHARSETS['5'] = {\\r\\n '[': 'Ä',\\r\\n '\\\\\\\\': 'Ö',\\r\\n ']': 'Å',\\r\\n '^': 'Ü',\\r\\n '`': 'é',\\r\\n '{': 'ä',\\r\\n '|': 'ö',\\r\\n '}': 'å',\\r\\n '~': 'ü'\\r\\n};\\r\\n\\r\\n/**\\r\\n * French character set\\r\\n * ESC (R\\r\\n * Reference: http://vt100.net/docs/vt220-rm/table2-8.html\\r\\n */\\r\\nCHARSETS['R'] = {\\r\\n '#': '£',\\r\\n '@': 'à',\\r\\n '[': '°',\\r\\n '\\\\\\\\': 'ç',\\r\\n ']': '§',\\r\\n '{': 'é',\\r\\n '|': 'ù',\\r\\n '}': 'è',\\r\\n '~': '¨'\\r\\n};\\r\\n\\r\\n/**\\r\\n * French Canadian character set\\r\\n * ESC (Q\\r\\n * Reference: http://vt100.net/docs/vt220-rm/table2-9.html\\r\\n */\\r\\nCHARSETS['Q'] = {\\r\\n '@': 'à',\\r\\n '[': 'â',\\r\\n '\\\\\\\\': 'ç',\\r\\n ']': 'ê',\\r\\n '^': 'î',\\r\\n '`': 'ô',\\r\\n '{': 'é',\\r\\n '|': 'ù',\\r\\n '}': 'è',\\r\\n '~': 'û'\\r\\n};\\r\\n\\r\\n/**\\r\\n * German character set\\r\\n * ESC (K\\r\\n * Reference: http://vt100.net/docs/vt220-rm/table2-10.html\\r\\n */\\r\\nCHARSETS['K'] = {\\r\\n '@': '§',\\r\\n '[': 'Ä',\\r\\n '\\\\\\\\': 'Ö',\\r\\n ']': 'Ü',\\r\\n '{': 'ä',\\r\\n '|': 'ö',\\r\\n '}': 'ü',\\r\\n '~': 'ß'\\r\\n};\\r\\n\\r\\n/**\\r\\n * Italian character set\\r\\n * ESC (Y\\r\\n * Reference: http://vt100.net/docs/vt220-rm/table2-11.html\\r\\n */\\r\\nCHARSETS['Y'] = {\\r\\n '#': '£',\\r\\n '@': '§',\\r\\n '[': '°',\\r\\n '\\\\\\\\': 'ç',\\r\\n ']': 'é',\\r\\n '`': 'ù',\\r\\n '{': 'à',\\r\\n '|': 'ò',\\r\\n '}': 'è',\\r\\n '~': 'ì'\\r\\n};\\r\\n\\r\\n/**\\r\\n * Norwegian/Danish character set\\r\\n * ESC (E or ESC (6\\r\\n * Reference: http://vt100.net/docs/vt220-rm/table2-12.html\\r\\n */\\r\\nCHARSETS['E'] =\\r\\nCHARSETS['6'] = {\\r\\n '@': 'Ä',\\r\\n '[': 'Æ',\\r\\n '\\\\\\\\': 'Ø',\\r\\n ']': 'Å',\\r\\n '^': 'Ü',\\r\\n '`': 'ä',\\r\\n '{': 'æ',\\r\\n '|': 'ø',\\r\\n '}': 'å',\\r\\n '~': 'ü'\\r\\n};\\r\\n\\r\\n/**\\r\\n * Spanish character set\\r\\n * ESC (Z\\r\\n * Reference: http://vt100.net/docs/vt220-rm/table2-13.html\\r\\n */\\r\\nCHARSETS['Z'] = {\\r\\n '#': '£',\\r\\n '@': '§',\\r\\n '[': '¡',\\r\\n '\\\\\\\\': 'Ñ',\\r\\n ']': '¿',\\r\\n '{': '°',\\r\\n '|': 'ñ',\\r\\n '}': 'ç'\\r\\n};\\r\\n\\r\\n/**\\r\\n * Swedish character set\\r\\n * ESC (H or ESC (7\\r\\n * Reference: http://vt100.net/docs/vt220-rm/table2-14.html\\r\\n */\\r\\nCHARSETS['H'] =\\r\\nCHARSETS['7'] = {\\r\\n '@': 'É',\\r\\n '[': 'Ä',\\r\\n '\\\\\\\\': 'Ö',\\r\\n ']': 'Å',\\r\\n '^': 'Ü',\\r\\n '`': 'é',\\r\\n '{': 'ä',\\r\\n '|': 'ö',\\r\\n '}': 'å',\\r\\n '~': 'ü'\\r\\n};\\r\\n\\r\\n/**\\r\\n * Swiss character set\\r\\n * ESC (=\\r\\n * Reference: http://vt100.net/docs/vt220-rm/table2-15.html\\r\\n */\\r\\nCHARSETS['='] = {\\r\\n '#': 'ù',\\r\\n '@': 'à',\\r\\n '[': 'é',\\r\\n '\\\\\\\\': 'ç',\\r\\n ']': 'ê',\\r\\n '^': 'î',\\r\\n '_': 'è',\\r\\n '`': 'ô',\\r\\n '{': 'ä',\\r\\n '|': 'ö',\\r\\n '}': 'ü',\\r\\n '~': 'û'\\r\\n};\\r\\n\",\"/**\\r\\n * Copyright (c) 2017 The xterm.js authors. All rights reserved.\\r\\n * @license MIT\\r\\n */\\r\\n\\r\\nimport { ITerminal, IBufferSet } from './Interfaces';\\r\\nimport { Buffer } from './Buffer';\\r\\nimport { EventEmitter } from './EventEmitter';\\r\\n\\r\\n/**\\r\\n * The BufferSet represents the set of two buffers used by xterm terminals (normal and alt) and\\r\\n * provides also utilities for working with them.\\r\\n */\\r\\nexport class BufferSet extends EventEmitter implements IBufferSet {\\r\\n private _normal: Buffer;\\r\\n private _alt: Buffer;\\r\\n private _activeBuffer: Buffer;\\r\\n\\r\\n /**\\r\\n * Create a new BufferSet for the given terminal.\\r\\n * @param {Terminal} terminal - The terminal the BufferSet will belong to\\r\\n */\\r\\n constructor(private _terminal: ITerminal) {\\r\\n super();\\r\\n this._normal = new Buffer(this._terminal, true);\\r\\n this._normal.fillViewportRows();\\r\\n\\r\\n // The alt buffer should never have scrollback.\\r\\n // See http://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-The-Alternate-Screen-Buffer\\r\\n this._alt = new Buffer(this._terminal, false);\\r\\n this._activeBuffer = this._normal;\\r\\n\\r\\n this.setupTabStops();\\r\\n }\\r\\n\\r\\n /**\\r\\n * Returns the alt Buffer of the BufferSet\\r\\n * @returns {Buffer}\\r\\n */\\r\\n public get alt(): Buffer {\\r\\n return this._alt;\\r\\n }\\r\\n\\r\\n /**\\r\\n * Returns the normal Buffer of the BufferSet\\r\\n * @returns {Buffer}\\r\\n */\\r\\n public get active(): Buffer {\\r\\n return this._activeBuffer;\\r\\n }\\r\\n\\r\\n /**\\r\\n * Returns the currently active Buffer of the BufferSet\\r\\n * @returns {Buffer}\\r\\n */\\r\\n public get normal(): Buffer {\\r\\n return this._normal;\\r\\n }\\r\\n\\r\\n /**\\r\\n * Sets the normal Buffer of the BufferSet as its currently active Buffer\\r\\n */\\r\\n public activateNormalBuffer(): void {\\r\\n // The alt buffer should always be cleared when we switch to the normal\\r\\n // buffer. This frees up memory since the alt buffer should always be new\\r\\n // when activated.\\r\\n this._alt.clear();\\r\\n\\r\\n this._activeBuffer = this._normal;\\r\\n this.emit('activate', this._normal);\\r\\n }\\r\\n\\r\\n /**\\r\\n * Sets the alt Buffer of the BufferSet as its currently active Buffer\\r\\n */\\r\\n public activateAltBuffer(): void {\\r\\n // Since the alt buffer is always cleared when the normal buffer is\\r\\n // activated, we want to fill it when switching to it.\\r\\n this._alt.fillViewportRows();\\r\\n this._activeBuffer = this._alt;\\r\\n this.emit('activate', this._alt);\\r\\n }\\r\\n\\r\\n /**\\r\\n * Resizes both normal and alt buffers, adjusting their data accordingly.\\r\\n * @param newCols The new number of columns.\\r\\n * @param newRows The new number of rows.\\r\\n */\\r\\n public resize(newCols: number, newRows: number): void {\\r\\n this._normal.resize(newCols, newRows);\\r\\n this._alt.resize(newCols, newRows);\\r\\n }\\r\\n\\r\\n /**\\r\\n * Setup the tab stops.\\r\\n * @param i The index to start setting up tab stops from.\\r\\n */\\r\\n public setupTabStops(i?: number): void {\\r\\n this._normal.setupTabStops(i);\\r\\n this._alt.setupTabStops(i);\\r\\n }\\r\\n}\\r\\n\",\"/**\\r\\n * Copyright (c) 2017 The xterm.js authors. All rights reserved.\\r\\n * @license MIT\\r\\n */\\r\\n\\r\\nimport { ITerminal, IBuffer } from './Interfaces';\\r\\nimport { CircularList } from './utils/CircularList';\\r\\nimport { LineData, CharData } from './Types';\\r\\n\\r\\nexport const CHAR_DATA_ATTR_INDEX = 0;\\r\\nexport const CHAR_DATA_CHAR_INDEX = 1;\\r\\nexport const CHAR_DATA_WIDTH_INDEX = 2;\\r\\nexport const CHAR_DATA_CODE_INDEX = 3;\\r\\n\\r\\n/**\\r\\n * This class represents a terminal buffer (an internal state of the terminal), where the\\r\\n * following information is stored (in high-level):\\r\\n * - text content of this particular buffer\\r\\n * - cursor position\\r\\n * - scroll position\\r\\n */\\r\\nexport class Buffer implements IBuffer {\\r\\n private _lines: CircularList<LineData>;\\r\\n\\r\\n public ydisp: number;\\r\\n public ybase: number;\\r\\n public y: number;\\r\\n public x: number;\\r\\n public scrollBottom: number;\\r\\n public scrollTop: number;\\r\\n public tabs: any;\\r\\n public savedY: number;\\r\\n public savedX: number;\\r\\n\\r\\n /**\\r\\n * Create a new Buffer.\\r\\n * @param _terminal The terminal the Buffer will belong to.\\r\\n * @param _hasScrollback Whether the buffer should respect the scrollback of\\r\\n * the terminal.\\r\\n */\\r\\n constructor(\\r\\n private _terminal: ITerminal,\\r\\n private _hasScrollback: boolean\\r\\n ) {\\r\\n this.clear();\\r\\n }\\r\\n\\r\\n public get lines(): CircularList<LineData> {\\r\\n return this._lines;\\r\\n }\\r\\n\\r\\n public get hasScrollback(): boolean {\\r\\n return this._hasScrollback && this.lines.maxLength > this._terminal.rows;\\r\\n }\\r\\n\\r\\n public get isCursorInViewport(): boolean {\\r\\n const absoluteY = this.ybase + this.y;\\r\\n const relativeY = absoluteY - this.ydisp;\\r\\n return (relativeY >= 0 && relativeY < this._terminal.rows);\\r\\n }\\r\\n\\r\\n /**\\r\\n * Gets the correct buffer length based on the rows provided, the terminal's\\r\\n * scrollback and whether this buffer is flagged to have scrollback or not.\\r\\n * @param rows The terminal rows to use in the calculation.\\r\\n */\\r\\n private _getCorrectBufferLength(rows: number): number {\\r\\n if (!this._hasScrollback) {\\r\\n return rows;\\r\\n }\\r\\n return rows + this._terminal.options.scrollback;\\r\\n }\\r\\n\\r\\n /**\\r\\n * Fills the buffer's viewport with blank lines.\\r\\n */\\r\\n public fillViewportRows(): void {\\r\\n if (this._lines.length === 0) {\\r\\n let i = this._terminal.rows;\\r\\n while (i--) {\\r\\n this.lines.push(this._terminal.blankLine());\\r\\n }\\r\\n }\\r\\n }\\r\\n\\r\\n /**\\r\\n * Clears the buffer to it's initial state, discarding all previous data.\\r\\n */\\r\\n public clear(): void {\\r\\n this.ydisp = 0;\\r\\n this.ybase = 0;\\r\\n this.y = 0;\\r\\n this.x = 0;\\r\\n this._lines = new CircularList<LineData>(this._getCorrectBufferLength(this._terminal.rows));\\r\\n this.scrollTop = 0;\\r\\n this.scrollBottom = this._terminal.rows - 1;\\r\\n this.setupTabStops();\\r\\n }\\r\\n\\r\\n /**\\r\\n * Resizes the buffer, adjusting its data accordingly.\\r\\n * @param newCols The new number of columns.\\r\\n * @param newRows The new number of rows.\\r\\n */\\r\\n public resize(newCols: number, newRows: number): void {\\r\\n // Increase max length if needed before adjustments to allow space to fill\\r\\n // as required.\\r\\n const newMaxLength = this._getCorrectBufferLength(newRows);\\r\\n if (newMaxLength > this._lines.maxLength) {\\r\\n this._lines.maxLength = newMaxLength;\\r\\n }\\r\\n\\r\\n // The following adjustments should only happen if the buffer has been\\r\\n // initialized/filled.\\r\\n if (this._lines.length > 0) {\\r\\n // Deal with columns increasing (we don't do anything when columns reduce)\\r\\n if (this._terminal.cols < newCols) {\\r\\n const ch: CharData = [this._terminal.defAttr, ' ', 1, 32]; // does xterm use the default attr?\\r\\n for (let i = 0; i < this._lines.length; i++) {\\r\\n // TODO: This should be removed, with tests setup for the case that was\\r\\n // causing the underlying bug, see https://github.com/sourcelair/xterm.js/issues/824\\r\\n if (this._lines.get(i) === undefined) {\\r\\n this._lines.set(i, this._terminal.blankLine(undefined, undefined, newCols));\\r\\n }\\r\\n while (this._lines.get(i).length < newCols) {\\r\\n this._lines.get(i).push(ch);\\r\\n }\\r\\n }\\r\\n }\\r\\n\\r\\n // Resize rows in both directions as needed\\r\\n let addToY = 0;\\r\\n if (this._terminal.rows < newRows) {\\r\\n for (let y = this._terminal.rows; y < newRows; y++) {\\r\\n if (this._lines.length < newRows + this.ybase) {\\r\\n if (this.ybase > 0 && this._lines.length <= this.ybase + this.y + addToY + 1) {\\r\\n // There is room above the buffer and there are no empty elements below the line,\\r\\n // scroll up\\r\\n this.ybase--;\\r\\n addToY++;\\r\\n if (this.ydisp > 0) {\\r\\n // Viewport is at the top of the buffer, must increase downwards\\r\\n this.ydisp--;\\r\\n }\\r\\n } else {\\r\\n // Add a blank line if there is no buffer left at the top to scroll to, or if there\\r\\n // are blank lines after the cursor\\r\\n this._lines.push(this._terminal.blankLine(undefined, undefined, newCols));\\r\\n }\\r\\n }\\r\\n }\\r\\n } else { // (this._terminal.rows >= newRows)\\r\\n for (let y = this._terminal.rows; y > newRows; y--) {\\r\\n if (this._lines.length > newRows + this.ybase) {\\r\\n if (this._lines.length > this.ybase + this.y + 1) {\\r\\n // The line is a blank line below the cursor, remove it\\r\\n this._lines.pop();\\r\\n } else {\\r\\n // The line is the cursor, scroll down\\r\\n this.ybase++;\\r\\n this.ydisp++;\\r\\n }\\r\\n }\\r\\n }\\r\\n }\\r\\n\\r\\n // Reduce max length if needed after adjustments, this is done after as it\\r\\n // would otherwise cut data from the bottom of the buffer.\\r\\n if (newMaxLength < this._lines.maxLength) {\\r\\n // Trim from the top of the buffer and adjust ybase and ydisp.\\r\\n const amountToTrim = this._lines.length - newMaxLength;\\r\\n if (amountToTrim > 0) {\\r\\n this._lines.trimStart(amountToTrim);\\r\\n this.ybase = Math.max(this.ybase - amountToTrim, 0);\\r\\n this.ydisp = Math.max(this.ydisp - amountToTrim, 0);\\r\\n }\\r\\n this._lines.maxLength = newMaxLength;\\r\\n }\\r\\n\\r\\n // Make sure that the cursor stays on screen\\r\\n if (this.y >= newRows) {\\r\\n this.y = newRows - 1;\\r\\n }\\r\\n if (addToY) {\\r\\n this.y += addToY;\\r\\n }\\r\\n\\r\\n if (this.x >= newCols) {\\r\\n this.x = newCols - 1;\\r\\n }\\r\\n\\r\\n this.scrollTop = 0;\\r\\n }\\r\\n\\r\\n this.scrollBottom = newRows - 1;\\r\\n }\\r\\n\\r\\n /**\\r\\n * Translates a buffer line to a string, with optional start and end columns.\\r\\n * Wide characters will count as two columns in the resulting string. This\\r\\n * function is useful for getting the actual text underneath the raw selection\\r\\n * position.\\r\\n * @param line The line being translated.\\r\\n * @param trimRight Whether to trim whitespace to the right.\\r\\n * @param startCol The column to start at.\\r\\n * @param endCol The column to end at.\\r\\n */\\r\\n public translateBufferLineToString(lineIndex: number, trimRight: boolean, startCol: number = 0, endCol: number = null): string {\\r\\n // Get full line\\r\\n let lineString = '';\\r\\n const line = this.lines.get(lineIndex);\\r\\n if (!line) {\\r\\n return '';\\r\\n }\\r\\n\\r\\n // Initialize column and index values. Column values represent the actual\\r\\n // cell column, indexes represent the index in the string. Indexes are\\r\\n // needed here because some chars are 0 characters long (eg. after wide\\r\\n // chars) and some chars are longer than 1 characters long (eg. emojis).\\r\\n let startIndex = startCol;\\r\\n endCol = endCol || line.length;\\r\\n let endIndex = endCol;\\r\\n\\r\\n for (let i = 0; i < line.length; i++) {\\r\\n const char = line[i];\\r\\n lineString += char[CHAR_DATA_CHAR_INDEX];\\r\\n // Adjust start and end cols for wide characters if they affect their\\r\\n // column indexes\\r\\n if (char[CHAR_DATA_WIDTH_INDEX] === 0) {\\r\\n if (startCol >= i) {\\r\\n startIndex--;\\r\\n }\\r\\n if (endCol >= i) {\\r\\n endIndex--;\\r\\n }\\r\\n } else {\\r\\n // Adjust the columns to take glyphs that are represented by multiple\\r\\n // code points into account.\\r\\n if (char[CHAR_DATA_CHAR_INDEX].length > 1) {\\r\\n if (startCol > i) {\\r\\n startIndex += char[CHAR_DATA_CHAR_INDEX].length - 1;\\r\\n }\\r\\n if (endCol > i) {\\r\\n endIndex += char[CHAR_DATA_CHAR_INDEX].length - 1;\\r\\n }\\r\\n }\\r\\n }\\r\\n }\\r\\n\\r\\n // Calculate the final end col by trimming whitespace on the right of the\\r\\n // line if needed.\\r\\n if (trimRight) {\\r\\n const rightWhitespaceIndex = lineString.search(/\\\\s+$/);\\r\\n if (rightWhitespaceIndex !== -1) {\\r\\n endIndex = Math.min(endIndex, rightWhitespaceIndex);\\r\\n }\\r\\n // Return the empty string if only trimmed whitespace is selected\\r\\n if (endIndex <= startIndex) {\\r\\n return '';\\r\\n }\\r\\n }\\r\\n\\r\\n return lineString.substring(startIndex, endIndex);\\r\\n }\\r\\n\\r\\n /**\\r\\n * Setup the tab stops.\\r\\n * @param i The index to start setting up tab stops from.\\r\\n */\\r\\n public setupTabStops(i?: number): void {\\r\\n if (i != null) {\\r\\n if (!this.tabs[i]) {\\r\\n i = this.prevStop(i);\\r\\n }\\r\\n } else {\\r\\n this.tabs = {};\\r\\n i = 0;\\r\\n }\\r\\n\\r\\n for (; i < this._terminal.cols; i += this._terminal.options.tabStopWidth) {\\r\\n this.tabs[i] = true;\\r\\n }\\r\\n }\\r\\n\\r\\n /**\\r\\n * Move the cursor to the previous tab stop from the given position (default is current).\\r\\n * @param x The position to move the cursor to the previous tab stop.\\r\\n */\\r\\n public prevStop(x?: number): number {\\r\\n if (x == null) {\\r\\n x = this.x;\\r\\n }\\r\\n while (!this.tabs[--x] && x > 0);\\r\\n return x >= this._terminal.cols ? this._terminal.cols - 1 : x < 0 ? 0 : x;\\r\\n }\\r\\n\\r\\n /**\\r\\n * Move the cursor one tab stop forward from the given position (default is current).\\r\\n * @param x The position to move the cursor one tab stop forward.\\r\\n */\\r\\n public nextStop(x?: number): number {\\r\\n if (x == null) {\\r\\n x = this.x;\\r\\n }\\r\\n while (!this.tabs[++x] && x < this._terminal.cols);\\r\\n return x >= this._terminal.cols ? this._terminal.cols - 1 : x < 0 ? 0 : x;\\r\\n }\\r\\n}\\r\\n\",null],\"names\":[],\"mappings\":\"AiCAA;;;ADMA;AAGa;AACA;AACA;AACA;AASb;AAmBA;AACA;AACA;AAEA;AACA;AAEA;AAAA;AACA;AACA;;;AAAA;AAEA;AAAA;AACA;AACA;;;AAAA;AAEA;AAAA;AACA;AACA;AACA;AACA;;;AAAA;AAOA;AACA;AACA;AACA;AACA;AACA;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAOA;AAGA;AACA;AACA;AACA;AAIA;AAEA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AAEA;AACA;AACA;AAAA;AAGA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AAEA;AACA;AAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AAIA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AAEA;AACA;AAYA;AAAA;AAAA;AAEA;AACA;AACA;AACA;AACA;AAMA;AACA;AACA;AAEA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAIA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AAMA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAMA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AAMA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AAAA;AA9Ra;;;;;;;;;;;;;;;;;ADfb;AACA;AAMA;AAAA;AASA;AAAA;AAAA;AAEA;AACA;AAIA;AACA;AAEA;;AACA;AAMA;AAAA;AACA;AACA;;;AAAA;AAMA;AAAA;AACA;AACA;;;AAAA;AAMA;AAAA;AACA;AACA;;;AAAA;AAKA;AAIA;AAEA;AACA;AACA;AAKA;AAGA;AACA;AACA;AACA;AAOA;AACA;AACA;AACA;AAMA;AACA;AACA;AACA;AACA;AAAA;AAxFa;;;;;;;ADDA;AAKA;AAYb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAOA;AACA;AACA;AAMA;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;AD7OA;AAwBA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAKA;AACA;AACA;AACA;AACA;AACA;AAMA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AAMA;AACA;AACA;AAOA;AACA;AACA;AAEA;AACA;AAAA;AAEA;AACA;AAAA;AAGA;AACA;AACA;AAEA;AAGA;AACA;AACA;AAEA;AACA;AAUA;AAAA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACA;AAAA;AAGA;AACA;AACA;AACA;AAUA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AAAA;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AAQA;AAAA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAQA;AAAA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAAA;AAMA;AACA;AACA;AACA;AAAA;AACA;AAAA;AApNa;;;;;;;ADRb;AAAA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AACA;AAAC;;;;;;;ADvED;AAGA;AAGA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAAA;AAAA;AAAA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AAAA;AA/Da;;;;;;;ADAb;AACA;AAEA;AACA;AASA;AACA;AAAA;AAAA;AAEA;AACA;AAGA;AAEA;AACA;AACA;AAEA;AAIA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAIA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAGA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AAGA;AAEA;AAGA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AAEA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AAMA;AACA;AACA;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAMA;AACA;AAMA;AACA;AACA;AAMA;AACA;AACA;AACA;AACA;AAMA;AACA;AACA;AAOA;AACA;AACA;AAOA;AACA;AACA;AAMA;AACA;AACA;AAAA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAMA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AAMA;AACA;AACA;AAEA;AACA;AACA;AAAA;AACA;AACA;AAEA;AACA;AACA;AAAA;AACA;AACA;AAEA;AACA;AACA;AAAA;AACA;AACA;AAEA;AACA;AACA;AAMA;AACA;AACA;AACA;AACA;AACA;AAcA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAaA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAMA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAGA;AACA;AACA;AAGA;AACA;AACA;AAMA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAGA;AACA;AACA;AAGA;AACA;AACA;AAMA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AAKA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAKA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAMA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AAKA;AACA;AACA;AACA;AACA;AACA;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAKA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAuCA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AAAA;AAIA;AACA;AACA;AAAA;AACA;AACA;AAAA;AAGA;AACA;AAAA;AACA;AACA;AACA;AACA;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAOA;AACA;AAAA;AACA;AAAA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAUA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AAwFA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAGA;AACA;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AAGA;AACA;AACA;AAKA;AACA;AACA;AAKA;AACA;AACA;AACA;AACA;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAoFA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAmEA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AAAA;AAEA;AACA;AAAA;AAEA;AACA;AACA;AAAA;AAEA;AACA;AACA;AAAA;AAEA;AACA;AACA;AAIA;AAAA;AAEA;AACA;AAAA;AAEA;AACA;AAAA;AAEA;AACA;AAAA;AAGA;AACA;AAAA;AAEA;AACA;AAAA;AAEA;AACA;AAAA;AAEA;AACA;AACA;AAAA;AAEA;AACA;AAAA;AAEA;AACA;AAAA;AAEA;AACA;AAAA;AAEA;AACA;AAAA;AAEA;AACA;AAAA;AAEA;AACA;AAAA;AAEA;AACA;AACA;AAIA;AAAA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AAAA;AAEA;AACA;AACA;AAIA;AAAA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AAAA;AAEA;AACA;AACA;AAAA;AACA;AACA;AACA;AAEA;AACA;AAyBA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAGA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AAGA;AACA;AAGA;AACA;AAGA;AACA;AACA;AACA;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAYA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAQA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AAOA;AACA;AACA;AACA;AAOA;AACA;AACA;AACA;AACA;AAAA;AAl5Ca;AAo5CA;AAGb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAaA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;;;;;;;;;;;;;;;;;AD7jDA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAKA;AAKA;AAAA;AAeA;AAAA;AACA;AARA;AAIA;AAOA;AACA;AACA;AACA;AACA;;AACA;AAMA;AACA;AACA;AAOA;AAAA;AAEA;AACA;AACA;AAGA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AAGA;AAGA;AACA;AACA;AACA;AACA;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAOA;AACA;AACA;AAMA;AACA;AACA;AAYA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAQA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAOA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAWA;AAAA;AAAA;AAEA;AACA;AAGA;AACA;AACA;AACA;AACA;AAGA;AAGA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AASA;AAAA;AACA;AAKA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AA3PA;AA4PA;AAlQA;AAAa;;;;;;;ADhCb;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAOA;AAKA;AACA;AACA;AAEA;AACA;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACA;AAEA;AACA;AAIA;AACA;AAGA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAKA;AACA;AACA;AACA;AACA;AAKA;AACA;AAIA;AACA;AAGA;AACA;AACA;AAGA;AACA;AACA;AAGA;AACA;AACA;AAGA;AACA;AACA;AAGA;AACA;AACA;AAGA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAIA;AACA;AAAA;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AAEA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AAAA;AACA;AACA;AAEA;AAEA;AACA;AAIA;AACA;AACA;AAEA;AAEA;AACA;AACA;AAGA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AAGA;AACA;AAMA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AAAA;AACA;AACA;AAAA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AAEA;AAEA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AAIA;AACA;AACA;AAEA;AACA;AAOA;AACA;AACA;AAQA;AACA;AACA;AAQA;AACA;AACA;AAOA;AACA;AACA;AAKA;AACA;AACA;AAMA;AACA;AACA;AACA;AAKA;AACA;AACA;AASA;AAAA;AAjfa;;;;;;;;;;;;;;;;;ADnKb;AACA;AAGA;AAEA;AAEA;AAMA;AAKA;AAKA;AAMA;AAEA;AACA;AAaA;AAAA;AACA;AACA;AACA;AACA;AAUA;AAAA;AAiCA;AAAA;AACA;AACA;AACA;AARA;AAWA;AACA;AAEA;AACA;;AACA;AAKA;AAAA;AACA;AACA;AAMA;AACA;AAMA;AACA;AACA;AACA;AAKA;AACA;AACA;AAOA;AACA;AACA;AACA;AAEA;AAAA;;;AAAA;AACA;AAAA;;;AAAA;AAKA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAAA;AAKA;AAAA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AAIA;AACA;AACA;AAEA;AACA;;;AAAA;AAKA;AACA;AACA;AACA;AACA;AAOA;AAAA;AAEA;AACA;AACA;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AAMA;AACA;AACA;AACA;AAKA;AACA;AACA;AACA;AAMA;AACA;AACA;AACA;AACA;AACA;AAMA;AACA;AACA;AACA;AACA;AAGA;AACA;AAGA;AACA;AACA;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAMA;AAGA;AACA;AACA;AAGA;AACA;AACA;AAGA;AACA;AAEA;AACA;AACA;AAGA;AACA;AAGA;AAGA;AAEA;AACA;AACA;AAAA;AACA;AACA;AACA;AAAA;AACA;AACA;AAAA;AACA;AACA;AACA;AAEA;AACA;AACA;AAKA;AAAA;AAEA;AACA;AACA;AACA;AAKA;AACA;AACA;AACA;AACA;AACA;AAOA;AACA;AACA;AACA;AACA;AAOA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AAGA;AACA;AACA;AAIA;AACA;AACA;AACA;AACA;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AAOA;AAIA;AAIA;AAGA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AAAA;AACA;AACA;AAGA;AAIA;AACA;AACA;AAAA;AACA;AACA;AAKA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AAMA;AACA;AACA;AAEA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AAMA;AACA;AACA;AAOA;AACA;AACA;AACA;AACA;AAGA;AACA;AAAA;AAIA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAMA;AACA;AACA;AACA;AACA;AAEA;AAGA;AACA;AAGA;AACA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAKA;AACA;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AAGA;AACA;AACA;AAEA;AACA;AACA;AAAA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAAA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AAIA;AAEA;AACA;AACA;AAIA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AAMA;AACA;AACA;AACA;AACA;AACA;AAOA;AAGA;AACA;AACA;AACA;AACA;AAMA;AACA;AACA;AACA;AACA;AAAA;AAtpBa;;;;;;;ADtDb;AAuBA;AACA;AAEA;AACA;AAKA;AACA;AACA;AACA;AACA;AACA;AAKA;AAAA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;;;AAAA;AAMA;AAAA;AACA;AACA;AACA;AAEA;AACA;AACA;AAGA;AACA;AACA;AAGA;AAEA;AACA;AACA;AACA;AACA;AACA;;;AAAA;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAOA;AAEA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AAAA;AAxHa;;;;;;;;;;;;;;;;;ADYb;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAIA;AACA;AAEA;AACA;AAUA;AAOA;AAMA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AAEA;AAAA;AA6HA;AACA;AADA;AA1GA;AA8GA;AACA;;AACA;AAEA;AAAA;AACA;AACA;AACA;AACA;AAEA;AACA;AAKA;AAEA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AAEA;AAEA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AAGA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AAKA;AAEA;AACA;AAKA;AACA;AACA;AAEA;AAAA;AACA;AACA;;;AAAA;AAMA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAAA;AAAA;AACA;AACA;AAAA;AAAA;AACA;AAEA;AACA;AACA;AACA;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAMA;AACA;AACA;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAKA;AAAA;AACA;AAGA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AAEA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AAKA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AAKA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAOA;AAAA;AACA;AACA;AAEA;AAEA;AACA;AACA;AAGA;AACA;AACA;AAEA;AAGA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AAGA;AAEA;AACA;AACA;AAIA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AAEA;AAEA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAGA;AAGA;AAGA;AAIA;AACA;AAMA;AACA;AACA;AACA;AACA;AACA;AAOA;AAEA;AAEA;AACA;AAAA;AAEA;AACA;AAAA;AACA;AACA;AACA;AACA;AAYA;AAAA;AACA;AACA;AACA;AAKA;AACA;AACA;AAGA;AAGA;AACA;AAAA;AAEA;AAEA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AAIA;AACA;AACA;AAIA;AACA;AACA;AACA;AAAA;AAIA;AAEA;AACA;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AAQA;AAOA;AAGA;AACA;AACA;AACA;AACA;AAAA;AACA;AAAA;AACA;AAAA;AACA;AAAA;AACA;AAAA;AACA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACA;AAAA;AACA;AAAA;AACA;AAAA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AASA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAIA;AACA;AACA;AACA;AAGA;AAEA;AACA;AAAA;AACA;AACA;AAGA;AAEA;AACA;AAEA;AAIA;AACA;AAEA;AAAA;AAGA;AAIA;AACA;AACA;AACA;AACA;AAGA;AAAA;AAGA;AACA;AACA;AAEA;AAAA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AAMA;AACA;AAAA;AACA;AAAA;AACA;AACA;AACA;AAIA;AACA;AAAA;AACA;AACA;AACA;AAEA;AACA;AAAA;AACA;AACA;AACA;AAEA;AACA;AAAA;AACA;AACA;AACA;AACA;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAQA;AACA;AACA;AACA;AACA;AAOA;AACA;AACA;AACA;AACA;AAKA;AACA;AACA;AACA;AACA;AACA;AAMA;AACA;AACA;AACA;AAEA;AAEA;AAGA;AACA;AACA;AAAA;AACA;AACA;AAGA;AACA;AAEA;AACA;AACA;AACA;AAAA;AAGA;AACA;AACA;AACA;AACA;AAAA;AAGA;AACA;AACA;AACA;AAIA;AACA;AACA;AAGA;AACA;AAQA;AACA;AASA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AAEA;AACA;AAGA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AAMA;AACA;AACA;AAKA;AACA;AACA;AAKA;AACA;AACA;AAMA;AAAA;AACA;AAKA;AAGA;AACA;AACA;AAEA;AAEA;AAEA;AACA;AACA;AACA;AACA;AAEA;AAAA;AACA;AACA;AACA;AAIA;AACA;AACA;AACA;AAEA;AACA;AAOA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AAAA;AACA;AACA;AACA;AAMA;AACA;AACA;AAWA;AACA;AACA;AAQA;AACA;AACA;AACA;AACA;AAEA;AACA;AAQA;AACA;AACA;AACA;AACA;AAEA;AACA;AAYA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AAKA;AACA;AACA;AAMA;AACA;AACA;AAKA;AACA;AACA;AACA;AACA;AAKA;AACA;AACA;AACA;AACA;AAQA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AAAA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AAEA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AASA;AACA;AAGA;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AAIA;AACA;AACA;AACA;AAAA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AAEA;AACA;AAIA;AACA;AACA;AACA;AAAA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AAEA;AACA;AAGA;AACA;AACA;AACA;AAAA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AAEA;AACA;AAGA;AACA;AACA;AACA;AAAA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AAEA;AAGA;AACA;AACA;AACA;AAEA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAAA;AAEA;AACA;AAAA;AAEA;AACA;AAAA;AAEA;AACA;AAAA;AAEA;AACA;AAAA;AAEA;AACA;AAAA;AAEA;AACA;AACA;AAAA;AAEA;AACA;AACA;AAAA;AACA;AACA;AAAA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAMA;AACA;AACA;AACA;AAOA;AACA;AACA;AACA;AACA;AACA;AAQA;AACA;AAEA;AACA;AACA;AAEA;AAEA;AACA;AACA;AAAA;AACA;AACA;AAAA;AACA;AACA;AAAA;AACA;AACA;AAEA;AAGA;AACA;AAEA;AAEA;AACA;AACA;AACA;AAEA;AACA;AAMA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAMA;AAAA;AACA;AACA;AAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAKA;AACA;AAAA;AACA;AAAA;AACA;AACA;AAKA;AACA;AAAA;AACA;AAAA;AACA;AACA;AAQA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACA;AACA;AAEA;AAAA;AACA;AAAA;AAEA;AAEA;AACA;AACA;AAEA;AAEA;AAEA;AACA;AACA;AAMA;AACA;AAAA;AACA;AAAA;AAOA;AAKA;AACA;AACA;AACA;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAKA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAMA;AACA;AACA;AASA;AACA;AAEA;AACA;AAIA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AAMA;AACA;AACA;AACA;AACA;AACA;AAMA;AACA;AACA;AAMA;AAEA;AACA;AACA;AAGA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AAMA;AAOA;AACA;AASA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAOA;AACA;AAIA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAMA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AAAA;AAt/Da;AA4/Db;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAEA;AAAA;AACA;AACA;AAEA;AACA;AAEA;AAEA;AACA;AACA;AAGA;AACA;AAEA;AACA;AACA;AACA;AACA;AAWA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AAGA;AACA;AACA;AACA;AACA;AAAC;AAGD;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;;;;;;;ADrrEA;AAAA;AACA;AACA;AACA;AACA;AAAC;;;;;;;ADrBD;AAcA;AAAA;AACA;AACA;AACA;AACA;AAjBA;AACA;AACA;AACA;AAgBA;AAGA;AACA;AAEA;AACA;AACA;AAMA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAKA;AACA;AAEA;AACA;AACA;AAAA;AAEA;AACA;AAAA;AAEA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AAOA;AACA;AACA;AACA;AACA;AAQA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AAEA;AACA;AAAA;AAMA;AACA;AACA;AAAA;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AAAA;AAnIa;;;;;;;ADOb;AACA;AACA;AACA;AACA;AACA;AALA;AAWA;AACA;AACA;AACA;AAAA;AACA;AACA;AAGA;AACA;AATA;AAgBA;AACA;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AAxBA;AA+BA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AApBA;AA4BA;AACA;AAGA;AACA;AACA;AANA;;;;;;;ADlGA;AAUA;AAWA;AAAA;AACA;AAXA;AAEA;AAIA;AACA;AACA;AAKA;AAGA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AAGA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAGA;AACA;AAEA;AACA;AACA;AAEA;AAAA;AACA;AAGA;AACA;AACA;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AAGA;AACA;AACA;AAGA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AAIA;AACA;AAGA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AAAA;AArKa;AAuKb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAAA;AAXa;;;;;;;ADlLb;AAEA;AAEa;AACb;AAEA;AAYA;AAIA;AACA;AAdA;AACA;AACA;AACA;AACA;AACA;AAWA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAOA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AAEA;AACA;AACA;AACA;AAWA;AACA;AAKA;AAQA;AAAA;AACA;AAKA;AAQA;AACA;AAKA;AAQA;AACA;AACA;AAKA;AAKA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AASA;AACA;AACA;AAKA;AAAA;AACA;AACA;AAKA;AACA;AAYA;AACA;AACA;AACA;AACA;AAIA;AAgBA;AACA;AACA;AACA;AACA;AAAA;AAEA;AACA;AACA;AACA;AACA;AAIA;AACA;AACA;AACA;AAEA;AACA;AAGA;AACA;AACA;AAGA;AAEA;AACA;AACA;AACA;AAEA;AASA;AAAA;AACA;AACA;AAIA;AAaA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAAA;AAEA;AACA;AAAA;AACA;AACA;AAEA;AAGA;AACA;AACA;AAEA;AAIA;AACA;AAOA;AACA;AACA;AAKA;AACA;AACA;AAAA;AAhUsB;;;;;;;ADPtB;AAEa;AAgBb;AAQA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAEA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAvCA;AAyCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAMA;AACA;AACA;AACA;AACA;AAJA;AAMA;AAIA;AAAA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAMA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AAGA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;;;;;;;ADrNA;AACA;AACA;AACA;AACA;AACa;AAEb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAMA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AAKA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AA1Da;;;;;;;;;;;;;;;;;AD5Db;AAGA;AAcA;AAEA;AAAA;AAMA;AAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AAEA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACA;AAEA;AACA;AAGA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AApMa;AAsMb;AAcA;AAEA;AAEA;AACA;AACA;AACA;AACA;AAEA;AAAA;;;AAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAAA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAAA;AAAA;AAEA;AACA;AACA;AAMA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AAGA;AAEA;AAGA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAAA;;;;;;;AD5VA;AAGA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AA3Ba;;;;;;;;;;;;;;;;;ADKb;AACA;AAEA;AAAA;AAGA;AAAA;AAFA;AAIA;AACA;;AACA;AAEA;AACA;AAEA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAAA;AAnCa;;;;;;;;;;;;;;;;;ADNb;AACA;AACA;AACA;AAGA;AACA;AAEA;AAAA;AAWA;AAAA;AAAA;AATA;AACA;AAUA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA;AAEA;AAGA;AACA;AACA;AACA;AACA;AAEA;AAAA;AACA;AAGA;AACA;AACA;AACA;AAEA;AAEA;AACA;AAEA;AAAA;AACA;AACA;AACA;AAMA;AAKA;AAMA;AAIA;AAGA;AAIA;AAIA;AACA;AAOA;AACA;AAQA;AACA;AAGA;AAGA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AAAA;AACA;AACA;AAEA;AAAA;AACA;AACA;AAEA;AAAA;AACA;AACA;AAEA;AAAA;AACA;AACA;AAEA;AAAA;AACA;AACA;AAEA;AAAA;AACA;AACA;AAQA;AACA;AACA;AACA;AACA;AACA;AAMA;AAAA;AACA;AACA;AACA;AAEA;AACA;AACA;AAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AAAA;AA5Ma;;;;;;;;;;;;;;;;;ADNb;AAEA;AAAA;AAGA;AAAA;AAEA;AACA;AACA;AACA;;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AAGA;AAGA;AACA;AACA;AAGA;AACA;AACA;AACA;AAGA;AACA;AACA;AAGA;AACA;AACA;AACA;AAGA;AACA;AAGA;AAEA;AACA;AACA;AAGA;AACA;AACA;AACA;AAAA;AA5Ea;;;;;;;;;;;;;;;;;ADLb;AACA;AACA;AAEA;AAOA;AAEA;AAAA;AAMA;AAAA;AAFA;AAIA;;AACA;AAEA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AAEA;AACA;AACA;AAEA;AAKA;AACA;AACA;AACA;AACA;AACA;AAIA;AAEA;AACA;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAiBA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AAIA;AAQA;AACA;AAMA;AACA;AAEA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AAEA;AAGA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAAA;AAEA;AACA;AAAA;AACA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACA;AAKA;AAGA;AACA;AACA;AAGA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AAGA;AACA;AAKA;AAGA;AAGA;AACA;AACA;AAOA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAnOa;;;;;;;ADZb;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAC;;;;;;;ADVD;AAEA;AACA;AACA;AAEa;AACA;AAKA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;;ADhBb;AAQA;AAAA;AAOA;AAAA;AAEA;AACA;;AACA;AAEA;AAAA;AACA;AACA;;;AAAA;AAEA;AAAA;AACA;AACA;;;AAAA;AAEA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AAAA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAtDa;;;;;;;;;;;;;;;;;ADRb;AAOA;AAAA;AAKA;AAAA;AACA;AAGA;AACA;AACA;;AACA;AAEA;AAAA;AACA;AACA;AAEA;AAEA;AACA;AACA;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAjBA;AAmBA;AAAA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AATA;AAWA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAAA;AAUA;AACA;AACA;AAUA;AACA;AACA;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AAMA;AACA;AACA;AAWA;AAAA;AAAA;AAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AAQA;AACA;AACA;AACA;AAAA;AAxMa;;;;;;;ADFb;AACA;AACA;AAFA;AAEC;;;;;;;ADJD;AACA;AAAA;AAAA;AAEA;AAEA;AACA;AACA;AAEA;AACA;AACA;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAeA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AAGA;AACA;AAEA;AACA;AAYA;AACA;AACA;AACA;AAGA;AACA;AAEA;AACA;AACA;AAAA;AApFa;;;;;;;ADCA;;;;;;;ADFb;AAEA;;;\"}"),
}
// define dirs
dir1 := &embedded.EmbeddedDir{
Filename: ``,
DirModTime: time.Unix(1512991935, 0),
ChildFiles: []*embedded.EmbeddedFile{
filek, // base64.js
filel, // favicon.ico
filem, // main.js
filen, // terminal.html
fileo, // xterm.css
filep, // xterm.js
fileq, // xterm.js.map
},
}
dir2 := &embedded.EmbeddedDir{
Filename: `addons`,
DirModTime: time.Unix(1512991935, 0),
ChildFiles: []*embedded.EmbeddedFile{},
}
dir3 := &embedded.EmbeddedDir{
Filename: `addons/attach`,
DirModTime: time.Unix(1512991935, 0),
ChildFiles: []*embedded.EmbeddedFile{
file4, // addons/attach/attach.js
file5, // addons/attach/index.html
file6, // addons/attach/package.json
},
}
dir7 := &embedded.EmbeddedDir{
Filename: `addons/fit`,
DirModTime: time.Unix(1512991935, 0),
ChildFiles: []*embedded.EmbeddedFile{
file8, // addons/fit/fit.js
file9, // addons/fit/package.json
},
}
dira := &embedded.EmbeddedDir{
Filename: `addons/fullscreen`,
DirModTime: time.Unix(1512991935, 0),
ChildFiles: []*embedded.EmbeddedFile{
fileb, // addons/fullscreen/fullscreen.css
filec, // addons/fullscreen/fullscreen.js
filed, // addons/fullscreen/package.json
},
}
dire := &embedded.EmbeddedDir{
Filename: `addons/search`,
DirModTime: time.Unix(1512991935, 0),
ChildFiles: []*embedded.EmbeddedFile{
filef, // addons/search/search.js
fileg, // addons/search/search.js.map
},
}
dirh := &embedded.EmbeddedDir{
Filename: `addons/terminado`,
DirModTime: time.Unix(1512991935, 0),
ChildFiles: []*embedded.EmbeddedFile{
filei, // addons/terminado/package.json
filej, // addons/terminado/terminado.js
},
}
// link ChildDirs
dir1.ChildDirs = []*embedded.EmbeddedDir{
dir2, // addons
}
dir2.ChildDirs = []*embedded.EmbeddedDir{
dir3, // addons/attach
dir7, // addons/fit
dira, // addons/fullscreen
dire, // addons/search
dirh, // addons/terminado
}
dir3.ChildDirs = []*embedded.EmbeddedDir{}
dir7.ChildDirs = []*embedded.EmbeddedDir{}
dira.ChildDirs = []*embedded.EmbeddedDir{}
dire.ChildDirs = []*embedded.EmbeddedDir{}
dirh.ChildDirs = []*embedded.EmbeddedDir{}
// register embeddedBox
embedded.RegisterEmbeddedBox(`static`, &embedded.EmbeddedBox{
Name: `static`,
Time: time.Unix(1512991935, 0),
Dirs: map[string]*embedded.EmbeddedDir{
"": dir1,
"addons": dir2,
"addons/attach": dir3,
"addons/fit": dir7,
"addons/fullscreen": dira,
"addons/search": dire,
"addons/terminado": dirh,
},
Files: map[string]*embedded.EmbeddedFile{
"addons/attach/attach.js": file4,
"addons/attach/index.html": file5,
"addons/attach/package.json": file6,
"addons/fit/fit.js": file8,
"addons/fit/package.json": file9,
"addons/fullscreen/fullscreen.css": fileb,
"addons/fullscreen/fullscreen.js": filec,
"addons/fullscreen/package.json": filed,
"addons/search/search.js": filef,
"addons/search/search.js.map": fileg,
"addons/terminado/package.json": filei,
"addons/terminado/terminado.js": filej,
"base64.js": filek,
"favicon.ico": filel,
"main.js": filem,
"terminal.html": filen,
"xterm.css": fileo,
"xterm.js": filep,
"xterm.js.map": fileq,
},
})
}