blob: e950d5ed09ca2cf749ca6ed197c07a8ba6b4831a [file] [log] [blame]
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001'use strict';
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002if ('undefined' != typeof lib)
3 throw new Error('Global "lib" object already exists.');
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004var lib = {};
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005lib.runtimeDependencies_ = {},
6 lib.initCallbacks_ = [], lib.rtdep = function(e) {
7 var t;
8 try {
9 throw new Error;
10 } catch (r) {
11 var o = r.stack.split('\n');
12 t = o.length >= 3 ? o[2].replace(/^\s*at\s+/, '') :
13 o[1].replace(/^\s*global code@/, '');
14 }
15 for (var i = 0; i < arguments.length; i++) {
16 var s = arguments[i];
17 if (s instanceof Array)
18 lib.rtdep.apply(lib, s);
19 else {
20 var n = this.runtimeDependencies_[s];
21 n || (n = this.runtimeDependencies_[s] = []), n.push(t);
22 }
23 }
24 };
25, lib.ensureRuntimeDependencies_ = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070026 var e = !0;
27 for (var t in lib.runtimeDependencies_)
Andrew Geisslerd27bb132018-05-24 11:07:27 -070028 for (var r = lib.runtimeDependencies_[t], o = t.split('.'),
29 i = window || self, s = 0;
30 s < o.length; s++) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070031 if (!(o[s] in i)) {
32 console.warn('Missing "' + t + '" is needed by', r), e = !1;
33 break;
34 }
35 i = i[o[s]];
36 }
37 if (!e) throw new Error('Failed runtime dependency check');
Andrew Geisslerd27bb132018-05-24 11:07:27 -070038};
39, lib.registerInit = function(e, t) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070040 return lib.initCallbacks_.push([e, t]), t;
Andrew Geisslerd27bb132018-05-24 11:07:27 -070041};
42, lib.init = function(e, t) {
43 var r = lib.initCallbacks_, o = function() {
44 if (r.length) {
45 var i = r.shift();
46 t && t('init: ' + i[0]), i[1](lib.f.alarm(o));
47 } else
48 e();
49 };
50 if ('function' != typeof e)
51 throw new Error('Missing or invalid argument: onInit');
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070052 lib.ensureRuntimeDependencies_(), setTimeout(o, 0);
Andrew Geisslerd27bb132018-05-24 11:07:27 -070053};
54, lib.colors = {}, lib.colors.re_ = {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070055 hex16: /#([a-f0-9])([a-f0-9])([a-f0-9])/i,
56 hex24: /#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})/i,
Andrew Geisslerd27bb132018-05-24 11:07:27 -070057 rgb: new RegExp(
58 '^/s*rgb/s*/(/s*(/d{1,3})/s*,/s*(/d{1,3})/s*,/s*(/d{1,3})/s*/)/s*$'
59 .replace(/\//g, '\\'),
60 'i'),
61 rgba: new RegExp(
62 '^/s*rgba/s*/(/s*(/d{1,3})/s*,/s*(/d{1,3})/s*,/s*(/d{1,3})/s*(?:,/s*(/d+(?:/./d+)?)/s*)/)/s*$'
63 .replace(/\//g, '\\'),
64 'i'),
65 rgbx: new RegExp(
66 '^/s*rgba?/s*/(/s*(/d{1,3})/s*,/s*(/d{1,3})/s*,/s*(/d{1,3})/s*(?:,/s*(/d+(?:/./d+)?)/s*)?/)/s*$'
67 .replace(/\//g, '\\'),
68 'i'),
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070069 x11rgb: /^\s*rgb:([a-f0-9]{1,4})\/([a-f0-9]{1,4})\/([a-f0-9]{1,4})\s*$/i,
70 name: /[a-z][a-z0-9\s]+/
Andrew Geisslerd27bb132018-05-24 11:07:27 -070071},
72 lib.colors.rgbToX11 = function(e) {
73 function t(e) {
74 return e = (257 * Math.min(e, 255)).toString(16), lib.f.zpad(e, 4);
75 }
76 var r = e.match(lib.colors.re_.rgbx);
77 return r ? 'rgb:' + t(r[1]) + '/' + t(r[2]) + '/' + t(r[3]) : null;
78 };
79, lib.colors.x11HexToCSS = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070080 function t(e) {
81 return e = parseInt(e, 16), 2 == r ? e : 1 == r ? e << 4 : e >> 4 * (r - 2)
82 }
83 if (!e.startsWith('#')) return null;
84 if (e = e.substr(1), -1 == [3, 6, 9, 12].indexOf(e.length)) return null;
85 if (e.match(/[^a-f0-9]/i)) return null;
Andrew Geisslerd27bb132018-05-24 11:07:27 -070086 var r = e.length / 3, o = e.substr(0, r), i = e.substr(r, r),
87 s = e.substr(r + r, r);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070088 return lib.colors.arrayToRGBA([o, i, s].map(t));
Andrew Geisslerd27bb132018-05-24 11:07:27 -070089};
90, lib.colors.x11ToCSS = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070091 function t(e) {
Andrew Geisslerd27bb132018-05-24 11:07:27 -070092 return 1 == e.length ?
93 parseInt(e + e, 16) :
94 2 == e.length ?
95 parseInt(e, 16) :
96 (3 == e.length && (e += e.substr(2)), Math.round(parseInt(e, 16) / 257))
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070097 }
98 var r = e.match(lib.colors.re_.x11rgb);
Andrew Geisslerd27bb132018-05-24 11:07:27 -070099 return r ?
100 (r.splice(0, 1), lib.colors.arrayToRGBA(r.map(t))) :
101 e.startsWith('#') ? lib.colors.x11HexToCSS(e) : lib.colors.nameToRGB(e)
102};
103, lib.colors.hexToRGB = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -0700104 function t(e) {
105 4 == e.length && (e = e.replace(r, function(e, t, r, o) {
106 return '#' + t + t + r + r + o + o;
107 }));
108 var t = e.match(o);
Andrew Geisslerd27bb132018-05-24 11:07:27 -0700109 return t ? 'rgb(' + parseInt(t[1], 16) + ', ' + parseInt(t[2], 16) + ', ' +
110 parseInt(t[3], 16) + ')' :
111 null;
Andrew Geisslerba5e3f32018-05-24 10:58:00 -0700112 }
Andrew Geisslerd27bb132018-05-24 11:07:27 -0700113 var r = lib.colors.re_.hex16, o = lib.colors.re_.hex24;
Andrew Geisslerba5e3f32018-05-24 10:58:00 -0700114 if (e instanceof Array)
115 for (var i = 0; i < e.length; i++) e[i] = t(e[i]);
Andrew Geisslerd27bb132018-05-24 11:07:27 -0700116 else
117 e = t(e);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -0700118 return e;
Andrew Geisslerd27bb132018-05-24 11:07:27 -0700119};
120, lib.colors.rgbToHex = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -0700121 function t(e) {
122 var t = lib.colors.crackRGB(e);
Andrew Geisslerd27bb132018-05-24 11:07:27 -0700123 return t ? '#' +
124 lib.f.zpad(
125 (parseInt(t[0]) << 16 | parseInt(t[1]) << 8 |
126 parseInt(t[2]) << 0)
127 .toString(16),
128 6) :
129 null;
Andrew Geisslerba5e3f32018-05-24 10:58:00 -0700130 }
131 if (e instanceof Array)
132 for (var r = 0; r < e.length; r++) e[r] = t(e[r]);
Andrew Geisslerd27bb132018-05-24 11:07:27 -0700133 else
134 e = t(e);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -0700135 return e;
Andrew Geisslerd27bb132018-05-24 11:07:27 -0700136};
137, lib.colors.normalizeCSS = function(e) {
138 return '#' == e.substr(0, 1) ?
139 lib.colors.hexToRGB(e) :
140 lib.colors.re_.rgbx.test(e) ? e : lib.colors.nameToRGB(e)
141};
142, lib.colors.arrayToRGBA = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -0700143 var t = e.length > 3 ? e[3] : 1;
144 return 'rgba(' + e[0] + ', ' + e[1] + ', ' + e[2] + ', ' + t + ')';
Andrew Geisslerd27bb132018-05-24 11:07:27 -0700145};
146, lib.colors.setAlpha = function(e, t) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -0700147 var r = lib.colors.crackRGB(e);
148 return r[3] = t, lib.colors.arrayToRGBA(r);
Andrew Geisslerd27bb132018-05-24 11:07:27 -0700149};
150, lib.colors.mix = function(e, t, r) {
151 for (var o = lib.colors.crackRGB(e), i = lib.colors.crackRGB(t), s = 0; 4 > s;
152 ++s) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -0700153 var n = i[s] - o[s];
154 o[s] = Math.round(parseInt(o[s]) + n * r);
155 }
156 return lib.colors.arrayToRGBA(o);
Andrew Geisslerd27bb132018-05-24 11:07:27 -0700157};
158, lib.colors.crackRGB = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -0700159 if ('rgba' == e.substr(0, 4)) {
160 var t = e.match(lib.colors.re_.rgba);
161 if (t) return t.shift(), t;
Andrew Geisslerd27bb132018-05-24 11:07:27 -0700162 } else {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -0700163 var t = e.match(lib.colors.re_.rgb);
164 if (t) return t.shift(), t.push(1), t;
165 }
Andrew Geisslerd27bb132018-05-24 11:07:27 -0700166 return console.error('Couldn\'t crack: ' + e), null;
167};
168, lib.colors.nameToRGB = function(e) {
169 return e in lib.colors.colorNames ?
170 lib.colors.colorNames[e] :
171 (e = e.toLowerCase(),
172 e in lib.colors.colorNames ?
173 lib.colors.colorNames[e] :
174 (e = e.replace(/\s+/g, ''),
175 e in lib.colors.colorNames ? lib.colors.colorNames[e] : null));
176};
177, lib.colors.stockColorPalette = lib.colors.hexToRGB([
178 '#000000', '#CC0000', '#4E9A06', '#C4A000', '#3465A4', '#75507B', '#06989A',
179 '#D3D7CF', '#555753', '#EF2929', '#00BA13', '#FCE94F', '#729FCF', '#F200CB',
180 '#00B5BD', '#EEEEEC', '#000000', '#00005F', '#000087', '#0000AF', '#0000D7',
181 '#0000FF', '#005F00', '#005F5F', '#005F87', '#005FAF', '#005FD7', '#005FFF',
182 '#008700', '#00875F', '#008787', '#0087AF', '#0087D7', '#0087FF', '#00AF00',
183 '#00AF5F', '#00AF87', '#00AFAF', '#00AFD7', '#00AFFF', '#00D700', '#00D75F',
184 '#00D787', '#00D7AF', '#00D7D7', '#00D7FF', '#00FF00', '#00FF5F', '#00FF87',
185 '#00FFAF', '#00FFD7', '#00FFFF', '#5F0000', '#5F005F', '#5F0087', '#5F00AF',
186 '#5F00D7', '#5F00FF', '#5F5F00', '#5F5F5F', '#5F5F87', '#5F5FAF', '#5F5FD7',
187 '#5F5FFF', '#5F8700', '#5F875F', '#5F8787', '#5F87AF', '#5F87D7', '#5F87FF',
188 '#5FAF00', '#5FAF5F', '#5FAF87', '#5FAFAF', '#5FAFD7', '#5FAFFF', '#5FD700',
189 '#5FD75F', '#5FD787', '#5FD7AF', '#5FD7D7', '#5FD7FF', '#5FFF00', '#5FFF5F',
190 '#5FFF87', '#5FFFAF', '#5FFFD7', '#5FFFFF', '#870000', '#87005F', '#870087',
191 '#8700AF', '#8700D7', '#8700FF', '#875F00', '#875F5F', '#875F87', '#875FAF',
192 '#875FD7', '#875FFF', '#878700', '#87875F', '#878787', '#8787AF', '#8787D7',
193 '#8787FF', '#87AF00', '#87AF5F', '#87AF87', '#87AFAF', '#87AFD7', '#87AFFF',
194 '#87D700', '#87D75F', '#87D787', '#87D7AF', '#87D7D7', '#87D7FF', '#87FF00',
195 '#87FF5F', '#87FF87', '#87FFAF', '#87FFD7', '#87FFFF', '#AF0000', '#AF005F',
196 '#AF0087', '#AF00AF', '#AF00D7', '#AF00FF', '#AF5F00', '#AF5F5F', '#AF5F87',
197 '#AF5FAF', '#AF5FD7', '#AF5FFF', '#AF8700', '#AF875F', '#AF8787', '#AF87AF',
198 '#AF87D7', '#AF87FF', '#AFAF00', '#AFAF5F', '#AFAF87', '#AFAFAF', '#AFAFD7',
199 '#AFAFFF', '#AFD700', '#AFD75F', '#AFD787', '#AFD7AF', '#AFD7D7', '#AFD7FF',
200 '#AFFF00', '#AFFF5F', '#AFFF87', '#AFFFAF', '#AFFFD7', '#AFFFFF', '#D70000',
201 '#D7005F', '#D70087', '#D700AF', '#D700D7', '#D700FF', '#D75F00', '#D75F5F',
202 '#D75F87', '#D75FAF', '#D75FD7', '#D75FFF', '#D78700', '#D7875F', '#D78787',
203 '#D787AF', '#D787D7', '#D787FF', '#D7AF00', '#D7AF5F', '#D7AF87', '#D7AFAF',
204 '#D7AFD7', '#D7AFFF', '#D7D700', '#D7D75F', '#D7D787', '#D7D7AF', '#D7D7D7',
205 '#D7D7FF', '#D7FF00', '#D7FF5F', '#D7FF87', '#D7FFAF', '#D7FFD7', '#D7FFFF',
206 '#FF0000', '#FF005F', '#FF0087', '#FF00AF', '#FF00D7', '#FF00FF', '#FF5F00',
207 '#FF5F5F', '#FF5F87', '#FF5FAF', '#FF5FD7', '#FF5FFF', '#FF8700', '#FF875F',
208 '#FF8787', '#FF87AF', '#FF87D7', '#FF87FF', '#FFAF00', '#FFAF5F', '#FFAF87',
209 '#FFAFAF', '#FFAFD7', '#FFAFFF', '#FFD700', '#FFD75F', '#FFD787', '#FFD7AF',
210 '#FFD7D7', '#FFD7FF', '#FFFF00', '#FFFF5F', '#FFFF87', '#FFFFAF', '#FFFFD7',
211 '#FFFFFF', '#080808', '#121212', '#1C1C1C', '#262626', '#303030', '#3A3A3A',
212 '#444444', '#4E4E4E', '#585858', '#626262', '#6C6C6C', '#767676', '#808080',
213 '#8A8A8A', '#949494', '#9E9E9E', '#A8A8A8', '#B2B2B2', '#BCBCBC', '#C6C6C6',
214 '#D0D0D0', '#DADADA', '#E4E4E4', '#EEEEEE'
215]),
216 lib.colors.colorPalette = lib.colors.stockColorPalette,
217 lib.colors.colorNames = {
218 aliceblue: 'rgb(240, 248, 255)',
219 antiquewhite: 'rgb(250, 235, 215)',
220 antiquewhite1: 'rgb(255, 239, 219)',
221 antiquewhite2: 'rgb(238, 223, 204)',
222 antiquewhite3: 'rgb(205, 192, 176)',
223 antiquewhite4: 'rgb(139, 131, 120)',
224 aquamarine: 'rgb(127, 255, 212)',
225 aquamarine1: 'rgb(127, 255, 212)',
226 aquamarine2: 'rgb(118, 238, 198)',
227 aquamarine3: 'rgb(102, 205, 170)',
228 aquamarine4: 'rgb(69, 139, 116)',
229 azure: 'rgb(240, 255, 255)',
230 azure1: 'rgb(240, 255, 255)',
231 azure2: 'rgb(224, 238, 238)',
232 azure3: 'rgb(193, 205, 205)',
233 azure4: 'rgb(131, 139, 139)',
234 beige: 'rgb(245, 245, 220)',
235 bisque: 'rgb(255, 228, 196)',
236 bisque1: 'rgb(255, 228, 196)',
237 bisque2: 'rgb(238, 213, 183)',
238 bisque3: 'rgb(205, 183, 158)',
239 bisque4: 'rgb(139, 125, 107)',
240 black: 'rgb(0, 0, 0)',
241 blanchedalmond: 'rgb(255, 235, 205)',
242 blue: 'rgb(0, 0, 255)',
243 blue1: 'rgb(0, 0, 255)',
244 blue2: 'rgb(0, 0, 238)',
245 blue3: 'rgb(0, 0, 205)',
246 blue4: 'rgb(0, 0, 139)',
247 blueviolet: 'rgb(138, 43, 226)',
248 brown: 'rgb(165, 42, 42)',
249 brown1: 'rgb(255, 64, 64)',
250 brown2: 'rgb(238, 59, 59)',
251 brown3: 'rgb(205, 51, 51)',
252 brown4: 'rgb(139, 35, 35)',
253 burlywood: 'rgb(222, 184, 135)',
254 burlywood1: 'rgb(255, 211, 155)',
255 burlywood2: 'rgb(238, 197, 145)',
256 burlywood3: 'rgb(205, 170, 125)',
257 burlywood4: 'rgb(139, 115, 85)',
258 cadetblue: 'rgb(95, 158, 160)',
259 cadetblue1: 'rgb(152, 245, 255)',
260 cadetblue2: 'rgb(142, 229, 238)',
261 cadetblue3: 'rgb(122, 197, 205)',
262 cadetblue4: 'rgb(83, 134, 139)',
263 chartreuse: 'rgb(127, 255, 0)',
264 chartreuse1: 'rgb(127, 255, 0)',
265 chartreuse2: 'rgb(118, 238, 0)',
266 chartreuse3: 'rgb(102, 205, 0)',
267 chartreuse4: 'rgb(69, 139, 0)',
268 chocolate: 'rgb(210, 105, 30)',
269 chocolate1: 'rgb(255, 127, 36)',
270 chocolate2: 'rgb(238, 118, 33)',
271 chocolate3: 'rgb(205, 102, 29)',
272 chocolate4: 'rgb(139, 69, 19)',
273 coral: 'rgb(255, 127, 80)',
274 coral1: 'rgb(255, 114, 86)',
275 coral2: 'rgb(238, 106, 80)',
276 coral3: 'rgb(205, 91, 69)',
277 coral4: 'rgb(139, 62, 47)',
278 cornflowerblue: 'rgb(100, 149, 237)',
279 cornsilk: 'rgb(255, 248, 220)',
280 cornsilk1: 'rgb(255, 248, 220)',
281 cornsilk2: 'rgb(238, 232, 205)',
282 cornsilk3: 'rgb(205, 200, 177)',
283 cornsilk4: 'rgb(139, 136, 120)',
284 cyan: 'rgb(0, 255, 255)',
285 cyan1: 'rgb(0, 255, 255)',
286 cyan2: 'rgb(0, 238, 238)',
287 cyan3: 'rgb(0, 205, 205)',
288 cyan4: 'rgb(0, 139, 139)',
289 darkblue: 'rgb(0, 0, 139)',
290 darkcyan: 'rgb(0, 139, 139)',
291 darkgoldenrod: 'rgb(184, 134, 11)',
292 darkgoldenrod1: 'rgb(255, 185, 15)',
293 darkgoldenrod2: 'rgb(238, 173, 14)',
294 darkgoldenrod3: 'rgb(205, 149, 12)',
295 darkgoldenrod4: 'rgb(139, 101, 8)',
296 darkgray: 'rgb(169, 169, 169)',
297 darkgreen: 'rgb(0, 100, 0)',
298 darkgrey: 'rgb(169, 169, 169)',
299 darkkhaki: 'rgb(189, 183, 107)',
300 darkmagenta: 'rgb(139, 0, 139)',
301 darkolivegreen: 'rgb(85, 107, 47)',
302 darkolivegreen1: 'rgb(202, 255, 112)',
303 darkolivegreen2: 'rgb(188, 238, 104)',
304 darkolivegreen3: 'rgb(162, 205, 90)',
305 darkolivegreen4: 'rgb(110, 139, 61)',
306 darkorange: 'rgb(255, 140, 0)',
307 darkorange1: 'rgb(255, 127, 0)',
308 darkorange2: 'rgb(238, 118, 0)',
309 darkorange3: 'rgb(205, 102, 0)',
310 darkorange4: 'rgb(139, 69, 0)',
311 darkorchid: 'rgb(153, 50, 204)',
312 darkorchid1: 'rgb(191, 62, 255)',
313 darkorchid2: 'rgb(178, 58, 238)',
314 darkorchid3: 'rgb(154, 50, 205)',
315 darkorchid4: 'rgb(104, 34, 139)',
316 darkred: 'rgb(139, 0, 0)',
317 darksalmon: 'rgb(233, 150, 122)',
318 darkseagreen: 'rgb(143, 188, 143)',
319 darkseagreen1: 'rgb(193, 255, 193)',
320 darkseagreen2: 'rgb(180, 238, 180)',
321 darkseagreen3: 'rgb(155, 205, 155)',
322 darkseagreen4: 'rgb(105, 139, 105)',
323 darkslateblue: 'rgb(72, 61, 139)',
324 darkslategray: 'rgb(47, 79, 79)',
325 darkslategray1: 'rgb(151, 255, 255)',
326 darkslategray2: 'rgb(141, 238, 238)',
327 darkslategray3: 'rgb(121, 205, 205)',
328 darkslategray4: 'rgb(82, 139, 139)',
329 darkslategrey: 'rgb(47, 79, 79)',
330 darkturquoise: 'rgb(0, 206, 209)',
331 darkviolet: 'rgb(148, 0, 211)',
332 debianred: 'rgb(215, 7, 81)',
333 deeppink: 'rgb(255, 20, 147)',
334 deeppink1: 'rgb(255, 20, 147)',
335 deeppink2: 'rgb(238, 18, 137)',
336 deeppink3: 'rgb(205, 16, 118)',
337 deeppink4: 'rgb(139, 10, 80)',
338 deepskyblue: 'rgb(0, 191, 255)',
339 deepskyblue1: 'rgb(0, 191, 255)',
340 deepskyblue2: 'rgb(0, 178, 238)',
341 deepskyblue3: 'rgb(0, 154, 205)',
342 deepskyblue4: 'rgb(0, 104, 139)',
343 dimgray: 'rgb(105, 105, 105)',
344 dimgrey: 'rgb(105, 105, 105)',
345 dodgerblue: 'rgb(30, 144, 255)',
346 dodgerblue1: 'rgb(30, 144, 255)',
347 dodgerblue2: 'rgb(28, 134, 238)',
348 dodgerblue3: 'rgb(24, 116, 205)',
349 dodgerblue4: 'rgb(16, 78, 139)',
350 firebrick: 'rgb(178, 34, 34)',
351 firebrick1: 'rgb(255, 48, 48)',
352 firebrick2: 'rgb(238, 44, 44)',
353 firebrick3: 'rgb(205, 38, 38)',
354 firebrick4: 'rgb(139, 26, 26)',
355 floralwhite: 'rgb(255, 250, 240)',
356 forestgreen: 'rgb(34, 139, 34)',
357 gainsboro: 'rgb(220, 220, 220)',
358 ghostwhite: 'rgb(248, 248, 255)',
359 gold: 'rgb(255, 215, 0)',
360 gold1: 'rgb(255, 215, 0)',
361 gold2: 'rgb(238, 201, 0)',
362 gold3: 'rgb(205, 173, 0)',
363 gold4: 'rgb(139, 117, 0)',
364 goldenrod: 'rgb(218, 165, 32)',
365 goldenrod1: 'rgb(255, 193, 37)',
366 goldenrod2: 'rgb(238, 180, 34)',
367 goldenrod3: 'rgb(205, 155, 29)',
368 goldenrod4: 'rgb(139, 105, 20)',
369 gray: 'rgb(190, 190, 190)',
370 gray0: 'rgb(0, 0, 0)',
371 gray1: 'rgb(3, 3, 3)',
372 gray10: 'rgb(26, 26, 26)',
373 gray100: 'rgb(255, 255, 255)',
374 gray11: 'rgb(28, 28, 28)',
375 gray12: 'rgb(31, 31, 31)',
376 gray13: 'rgb(33, 33, 33)',
377 gray14: 'rgb(36, 36, 36)',
378 gray15: 'rgb(38, 38, 38)',
379 gray16: 'rgb(41, 41, 41)',
380 gray17: 'rgb(43, 43, 43)',
381 gray18: 'rgb(46, 46, 46)',
382 gray19: 'rgb(48, 48, 48)',
383 gray2: 'rgb(5, 5, 5)',
384 gray20: 'rgb(51, 51, 51)',
385 gray21: 'rgb(54, 54, 54)',
386 gray22: 'rgb(56, 56, 56)',
387 gray23: 'rgb(59, 59, 59)',
388 gray24: 'rgb(61, 61, 61)',
389 gray25: 'rgb(64, 64, 64)',
390 gray26: 'rgb(66, 66, 66)',
391 gray27: 'rgb(69, 69, 69)',
392 gray28: 'rgb(71, 71, 71)',
393 gray29: 'rgb(74, 74, 74)',
394 gray3: 'rgb(8, 8, 8)',
395 gray30: 'rgb(77, 77, 77)',
396 gray31: 'rgb(79, 79, 79)',
397 gray32: 'rgb(82, 82, 82)',
398 gray33: 'rgb(84, 84, 84)',
399 gray34: 'rgb(87, 87, 87)',
400 gray35: 'rgb(89, 89, 89)',
401 gray36: 'rgb(92, 92, 92)',
402 gray37: 'rgb(94, 94, 94)',
403 gray38: 'rgb(97, 97, 97)',
404 gray39: 'rgb(99, 99, 99)',
405 gray4: 'rgb(10, 10, 10)',
406 gray40: 'rgb(102, 102, 102)',
407 gray41: 'rgb(105, 105, 105)',
408 gray42: 'rgb(107, 107, 107)',
409 gray43: 'rgb(110, 110, 110)',
410 gray44: 'rgb(112, 112, 112)',
411 gray45: 'rgb(115, 115, 115)',
412 gray46: 'rgb(117, 117, 117)',
413 gray47: 'rgb(120, 120, 120)',
414 gray48: 'rgb(122, 122, 122)',
415 gray49: 'rgb(125, 125, 125)',
416 gray5: 'rgb(13, 13, 13)',
417 gray50: 'rgb(127, 127, 127)',
418 gray51: 'rgb(130, 130, 130)',
419 gray52: 'rgb(133, 133, 133)',
420 gray53: 'rgb(135, 135, 135)',
421 gray54: 'rgb(138, 138, 138)',
422 gray55: 'rgb(140, 140, 140)',
423 gray56: 'rgb(143, 143, 143)',
424 gray57: 'rgb(145, 145, 145)',
425 gray58: 'rgb(148, 148, 148)',
426 gray59: 'rgb(150, 150, 150)',
427 gray6: 'rgb(15, 15, 15)',
428 gray60: 'rgb(153, 153, 153)',
429 gray61: 'rgb(156, 156, 156)',
430 gray62: 'rgb(158, 158, 158)',
431 gray63: 'rgb(161, 161, 161)',
432 gray64: 'rgb(163, 163, 163)',
433 gray65: 'rgb(166, 166, 166)',
434 gray66: 'rgb(168, 168, 168)',
435 gray67: 'rgb(171, 171, 171)',
436 gray68: 'rgb(173, 173, 173)',
437 gray69: 'rgb(176, 176, 176)',
438 gray7: 'rgb(18, 18, 18)',
439 gray70: 'rgb(179, 179, 179)',
440 gray71: 'rgb(181, 181, 181)',
441 gray72: 'rgb(184, 184, 184)',
442 gray73: 'rgb(186, 186, 186)',
443 gray74: 'rgb(189, 189, 189)',
444 gray75: 'rgb(191, 191, 191)',
445 gray76: 'rgb(194, 194, 194)',
446 gray77: 'rgb(196, 196, 196)',
447 gray78: 'rgb(199, 199, 199)',
448 gray79: 'rgb(201, 201, 201)',
449 gray8: 'rgb(20, 20, 20)',
450 gray80: 'rgb(204, 204, 204)',
451 gray81: 'rgb(207, 207, 207)',
452 gray82: 'rgb(209, 209, 209)',
453 gray83: 'rgb(212, 212, 212)',
454 gray84: 'rgb(214, 214, 214)',
455 gray85: 'rgb(217, 217, 217)',
456 gray86: 'rgb(219, 219, 219)',
457 gray87: 'rgb(222, 222, 222)',
458 gray88: 'rgb(224, 224, 224)',
459 gray89: 'rgb(227, 227, 227)',
460 gray9: 'rgb(23, 23, 23)',
461 gray90: 'rgb(229, 229, 229)',
462 gray91: 'rgb(232, 232, 232)',
463 gray92: 'rgb(235, 235, 235)',
464 gray93: 'rgb(237, 237, 237)',
465 gray94: 'rgb(240, 240, 240)',
466 gray95: 'rgb(242, 242, 242)',
467 gray96: 'rgb(245, 245, 245)',
468 gray97: 'rgb(247, 247, 247)',
469 gray98: 'rgb(250, 250, 250)',
470 gray99: 'rgb(252, 252, 252)',
471 green: 'rgb(0, 255, 0)',
472 green1: 'rgb(0, 255, 0)',
473 green2: 'rgb(0, 238, 0)',
474 green3: 'rgb(0, 205, 0)',
475 green4: 'rgb(0, 139, 0)',
476 greenyellow: 'rgb(173, 255, 47)',
477 grey: 'rgb(190, 190, 190)',
478 grey0: 'rgb(0, 0, 0)',
479 grey1: 'rgb(3, 3, 3)',
480 grey10: 'rgb(26, 26, 26)',
481 grey100: 'rgb(255, 255, 255)',
482 grey11: 'rgb(28, 28, 28)',
483 grey12: 'rgb(31, 31, 31)',
484 grey13: 'rgb(33, 33, 33)',
485 grey14: 'rgb(36, 36, 36)',
486 grey15: 'rgb(38, 38, 38)',
487 grey16: 'rgb(41, 41, 41)',
488 grey17: 'rgb(43, 43, 43)',
489 grey18: 'rgb(46, 46, 46)',
490 grey19: 'rgb(48, 48, 48)',
491 grey2: 'rgb(5, 5, 5)',
492 grey20: 'rgb(51, 51, 51)',
493 grey21: 'rgb(54, 54, 54)',
494 grey22: 'rgb(56, 56, 56)',
495 grey23: 'rgb(59, 59, 59)',
496 grey24: 'rgb(61, 61, 61)',
497 grey25: 'rgb(64, 64, 64)',
498 grey26: 'rgb(66, 66, 66)',
499 grey27: 'rgb(69, 69, 69)',
500 grey28: 'rgb(71, 71, 71)',
501 grey29: 'rgb(74, 74, 74)',
502 grey3: 'rgb(8, 8, 8)',
503 grey30: 'rgb(77, 77, 77)',
504 grey31: 'rgb(79, 79, 79)',
505 grey32: 'rgb(82, 82, 82)',
506 grey33: 'rgb(84, 84, 84)',
507 grey34: 'rgb(87, 87, 87)',
508 grey35: 'rgb(89, 89, 89)',
509 grey36: 'rgb(92, 92, 92)',
510 grey37: 'rgb(94, 94, 94)',
511 grey38: 'rgb(97, 97, 97)',
512 grey39: 'rgb(99, 99, 99)',
513 grey4: 'rgb(10, 10, 10)',
514 grey40: 'rgb(102, 102, 102)',
515 grey41: 'rgb(105, 105, 105)',
516 grey42: 'rgb(107, 107, 107)',
517 grey43: 'rgb(110, 110, 110)',
518 grey44: 'rgb(112, 112, 112)',
519 grey45: 'rgb(115, 115, 115)',
520 grey46: 'rgb(117, 117, 117)',
521 grey47: 'rgb(120, 120, 120)',
522 grey48: 'rgb(122, 122, 122)',
523 grey49: 'rgb(125, 125, 125)',
524 grey5: 'rgb(13, 13, 13)',
525 grey50: 'rgb(127, 127, 127)',
526 grey51: 'rgb(130, 130, 130)',
527 grey52: 'rgb(133, 133, 133)',
528 grey53: 'rgb(135, 135, 135)',
529 grey54: 'rgb(138, 138, 138)',
530 grey55: 'rgb(140, 140, 140)',
531 grey56: 'rgb(143, 143, 143)',
532 grey57: 'rgb(145, 145, 145)',
533 grey58: 'rgb(148, 148, 148)',
534 grey59: 'rgb(150, 150, 150)',
535 grey6: 'rgb(15, 15, 15)',
536 grey60: 'rgb(153, 153, 153)',
537 grey61: 'rgb(156, 156, 156)',
538 grey62: 'rgb(158, 158, 158)',
539 grey63: 'rgb(161, 161, 161)',
540 grey64: 'rgb(163, 163, 163)',
541 grey65: 'rgb(166, 166, 166)',
542 grey66: 'rgb(168, 168, 168)',
543 grey67: 'rgb(171, 171, 171)',
544 grey68: 'rgb(173, 173, 173)',
545 grey69: 'rgb(176, 176, 176)',
546 grey7: 'rgb(18, 18, 18)',
547 grey70: 'rgb(179, 179, 179)',
548 grey71: 'rgb(181, 181, 181)',
549 grey72: 'rgb(184, 184, 184)',
550 grey73: 'rgb(186, 186, 186)',
551 grey74: 'rgb(189, 189, 189)',
552 grey75: 'rgb(191, 191, 191)',
553 grey76: 'rgb(194, 194, 194)',
554 grey77: 'rgb(196, 196, 196)',
555 grey78: 'rgb(199, 199, 199)',
556 grey79: 'rgb(201, 201, 201)',
557 grey8: 'rgb(20, 20, 20)',
558 grey80: 'rgb(204, 204, 204)',
559 grey81: 'rgb(207, 207, 207)',
560 grey82: 'rgb(209, 209, 209)',
561 grey83: 'rgb(212, 212, 212)',
562 grey84: 'rgb(214, 214, 214)',
563 grey85: 'rgb(217, 217, 217)',
564 grey86: 'rgb(219, 219, 219)',
565 grey87: 'rgb(222, 222, 222)',
566 grey88: 'rgb(224, 224, 224)',
567 grey89: 'rgb(227, 227, 227)',
568 grey9: 'rgb(23, 23, 23)',
569 grey90: 'rgb(229, 229, 229)',
570 grey91: 'rgb(232, 232, 232)',
571 grey92: 'rgb(235, 235, 235)',
572 grey93: 'rgb(237, 237, 237)',
573 grey94: 'rgb(240, 240, 240)',
574 grey95: 'rgb(242, 242, 242)',
575 grey96: 'rgb(245, 245, 245)',
576 grey97: 'rgb(247, 247, 247)',
577 grey98: 'rgb(250, 250, 250)',
578 grey99: 'rgb(252, 252, 252)',
579 honeydew: 'rgb(240, 255, 240)',
580 honeydew1: 'rgb(240, 255, 240)',
581 honeydew2: 'rgb(224, 238, 224)',
582 honeydew3: 'rgb(193, 205, 193)',
583 honeydew4: 'rgb(131, 139, 131)',
584 hotpink: 'rgb(255, 105, 180)',
585 hotpink1: 'rgb(255, 110, 180)',
586 hotpink2: 'rgb(238, 106, 167)',
587 hotpink3: 'rgb(205, 96, 144)',
588 hotpink4: 'rgb(139, 58, 98)',
589 indianred: 'rgb(205, 92, 92)',
590 indianred1: 'rgb(255, 106, 106)',
591 indianred2: 'rgb(238, 99, 99)',
592 indianred3: 'rgb(205, 85, 85)',
593 indianred4: 'rgb(139, 58, 58)',
594 ivory: 'rgb(255, 255, 240)',
595 ivory1: 'rgb(255, 255, 240)',
596 ivory2: 'rgb(238, 238, 224)',
597 ivory3: 'rgb(205, 205, 193)',
598 ivory4: 'rgb(139, 139, 131)',
599 khaki: 'rgb(240, 230, 140)',
600 khaki1: 'rgb(255, 246, 143)',
601 khaki2: 'rgb(238, 230, 133)',
602 khaki3: 'rgb(205, 198, 115)',
603 khaki4: 'rgb(139, 134, 78)',
604 lavender: 'rgb(230, 230, 250)',
605 lavenderblush: 'rgb(255, 240, 245)',
606 lavenderblush1: 'rgb(255, 240, 245)',
607 lavenderblush2: 'rgb(238, 224, 229)',
608 lavenderblush3: 'rgb(205, 193, 197)',
609 lavenderblush4: 'rgb(139, 131, 134)',
610 lawngreen: 'rgb(124, 252, 0)',
611 lemonchiffon: 'rgb(255, 250, 205)',
612 lemonchiffon1: 'rgb(255, 250, 205)',
613 lemonchiffon2: 'rgb(238, 233, 191)',
614 lemonchiffon3: 'rgb(205, 201, 165)',
615 lemonchiffon4: 'rgb(139, 137, 112)',
616 lightblue: 'rgb(173, 216, 230)',
617 lightblue1: 'rgb(191, 239, 255)',
618 lightblue2: 'rgb(178, 223, 238)',
619 lightblue3: 'rgb(154, 192, 205)',
620 lightblue4: 'rgb(104, 131, 139)',
621 lightcoral: 'rgb(240, 128, 128)',
622 lightcyan: 'rgb(224, 255, 255)',
623 lightcyan1: 'rgb(224, 255, 255)',
624 lightcyan2: 'rgb(209, 238, 238)',
625 lightcyan3: 'rgb(180, 205, 205)',
626 lightcyan4: 'rgb(122, 139, 139)',
627 lightgoldenrod: 'rgb(238, 221, 130)',
628 lightgoldenrod1: 'rgb(255, 236, 139)',
629 lightgoldenrod2: 'rgb(238, 220, 130)',
630 lightgoldenrod3: 'rgb(205, 190, 112)',
631 lightgoldenrod4: 'rgb(139, 129, 76)',
632 lightgoldenrodyellow: 'rgb(250, 250, 210)',
633 lightgray: 'rgb(211, 211, 211)',
634 lightgreen: 'rgb(144, 238, 144)',
635 lightgrey: 'rgb(211, 211, 211)',
636 lightpink: 'rgb(255, 182, 193)',
637 lightpink1: 'rgb(255, 174, 185)',
638 lightpink2: 'rgb(238, 162, 173)',
639 lightpink3: 'rgb(205, 140, 149)',
640 lightpink4: 'rgb(139, 95, 101)',
641 lightsalmon: 'rgb(255, 160, 122)',
642 lightsalmon1: 'rgb(255, 160, 122)',
643 lightsalmon2: 'rgb(238, 149, 114)',
644 lightsalmon3: 'rgb(205, 129, 98)',
645 lightsalmon4: 'rgb(139, 87, 66)',
646 lightseagreen: 'rgb(32, 178, 170)',
647 lightskyblue: 'rgb(135, 206, 250)',
648 lightskyblue1: 'rgb(176, 226, 255)',
649 lightskyblue2: 'rgb(164, 211, 238)',
650 lightskyblue3: 'rgb(141, 182, 205)',
651 lightskyblue4: 'rgb(96, 123, 139)',
652 lightslateblue: 'rgb(132, 112, 255)',
653 lightslategray: 'rgb(119, 136, 153)',
654 lightslategrey: 'rgb(119, 136, 153)',
655 lightsteelblue: 'rgb(176, 196, 222)',
656 lightsteelblue1: 'rgb(202, 225, 255)',
657 lightsteelblue2: 'rgb(188, 210, 238)',
658 lightsteelblue3: 'rgb(162, 181, 205)',
659 lightsteelblue4: 'rgb(110, 123, 139)',
660 lightyellow: 'rgb(255, 255, 224)',
661 lightyellow1: 'rgb(255, 255, 224)',
662 lightyellow2: 'rgb(238, 238, 209)',
663 lightyellow3: 'rgb(205, 205, 180)',
664 lightyellow4: 'rgb(139, 139, 122)',
665 limegreen: 'rgb(50, 205, 50)',
666 linen: 'rgb(250, 240, 230)',
667 magenta: 'rgb(255, 0, 255)',
668 magenta1: 'rgb(255, 0, 255)',
669 magenta2: 'rgb(238, 0, 238)',
670 magenta3: 'rgb(205, 0, 205)',
671 magenta4: 'rgb(139, 0, 139)',
672 maroon: 'rgb(176, 48, 96)',
673 maroon1: 'rgb(255, 52, 179)',
674 maroon2: 'rgb(238, 48, 167)',
675 maroon3: 'rgb(205, 41, 144)',
676 maroon4: 'rgb(139, 28, 98)',
677 mediumaquamarine: 'rgb(102, 205, 170)',
678 mediumblue: 'rgb(0, 0, 205)',
679 mediumorchid: 'rgb(186, 85, 211)',
680 mediumorchid1: 'rgb(224, 102, 255)',
681 mediumorchid2: 'rgb(209, 95, 238)',
682 mediumorchid3: 'rgb(180, 82, 205)',
683 mediumorchid4: 'rgb(122, 55, 139)',
684 mediumpurple: 'rgb(147, 112, 219)',
685 mediumpurple1: 'rgb(171, 130, 255)',
686 mediumpurple2: 'rgb(159, 121, 238)',
687 mediumpurple3: 'rgb(137, 104, 205)',
688 mediumpurple4: 'rgb(93, 71, 139)',
689 mediumseagreen: 'rgb(60, 179, 113)',
690 mediumslateblue: 'rgb(123, 104, 238)',
691 mediumspringgreen: 'rgb(0, 250, 154)',
692 mediumturquoise: 'rgb(72, 209, 204)',
693 mediumvioletred: 'rgb(199, 21, 133)',
694 midnightblue: 'rgb(25, 25, 112)',
695 mintcream: 'rgb(245, 255, 250)',
696 mistyrose: 'rgb(255, 228, 225)',
697 mistyrose1: 'rgb(255, 228, 225)',
698 mistyrose2: 'rgb(238, 213, 210)',
699 mistyrose3: 'rgb(205, 183, 181)',
700 mistyrose4: 'rgb(139, 125, 123)',
701 moccasin: 'rgb(255, 228, 181)',
702 navajowhite: 'rgb(255, 222, 173)',
703 navajowhite1: 'rgb(255, 222, 173)',
704 navajowhite2: 'rgb(238, 207, 161)',
705 navajowhite3: 'rgb(205, 179, 139)',
706 navajowhite4: 'rgb(139, 121, 94)',
707 navy: 'rgb(0, 0, 128)',
708 navyblue: 'rgb(0, 0, 128)',
709 oldlace: 'rgb(253, 245, 230)',
710 olivedrab: 'rgb(107, 142, 35)',
711 olivedrab1: 'rgb(192, 255, 62)',
712 olivedrab2: 'rgb(179, 238, 58)',
713 olivedrab3: 'rgb(154, 205, 50)',
714 olivedrab4: 'rgb(105, 139, 34)',
715 orange: 'rgb(255, 165, 0)',
716 orange1: 'rgb(255, 165, 0)',
717 orange2: 'rgb(238, 154, 0)',
718 orange3: 'rgb(205, 133, 0)',
719 orange4: 'rgb(139, 90, 0)',
720 orangered: 'rgb(255, 69, 0)',
721 orangered1: 'rgb(255, 69, 0)',
722 orangered2: 'rgb(238, 64, 0)',
723 orangered3: 'rgb(205, 55, 0)',
724 orangered4: 'rgb(139, 37, 0)',
725 orchid: 'rgb(218, 112, 214)',
726 orchid1: 'rgb(255, 131, 250)',
727 orchid2: 'rgb(238, 122, 233)',
728 orchid3: 'rgb(205, 105, 201)',
729 orchid4: 'rgb(139, 71, 137)',
730 palegoldenrod: 'rgb(238, 232, 170)',
731 palegreen: 'rgb(152, 251, 152)',
732 palegreen1: 'rgb(154, 255, 154)',
733 palegreen2: 'rgb(144, 238, 144)',
734 palegreen3: 'rgb(124, 205, 124)',
735 palegreen4: 'rgb(84, 139, 84)',
736 paleturquoise: 'rgb(175, 238, 238)',
737 paleturquoise1: 'rgb(187, 255, 255)',
738 paleturquoise2: 'rgb(174, 238, 238)',
739 paleturquoise3: 'rgb(150, 205, 205)',
740 paleturquoise4: 'rgb(102, 139, 139)',
741 palevioletred: 'rgb(219, 112, 147)',
742 palevioletred1: 'rgb(255, 130, 171)',
743 palevioletred2: 'rgb(238, 121, 159)',
744 palevioletred3: 'rgb(205, 104, 137)',
745 palevioletred4: 'rgb(139, 71, 93)',
746 papayawhip: 'rgb(255, 239, 213)',
747 peachpuff: 'rgb(255, 218, 185)',
748 peachpuff1: 'rgb(255, 218, 185)',
749 peachpuff2: 'rgb(238, 203, 173)',
750 peachpuff3: 'rgb(205, 175, 149)',
751 peachpuff4: 'rgb(139, 119, 101)',
752 peru: 'rgb(205, 133, 63)',
753 pink: 'rgb(255, 192, 203)',
754 pink1: 'rgb(255, 181, 197)',
755 pink2: 'rgb(238, 169, 184)',
756 pink3: 'rgb(205, 145, 158)',
757 pink4: 'rgb(139, 99, 108)',
758 plum: 'rgb(221, 160, 221)',
759 plum1: 'rgb(255, 187, 255)',
760 plum2: 'rgb(238, 174, 238)',
761 plum3: 'rgb(205, 150, 205)',
762 plum4: 'rgb(139, 102, 139)',
763 powderblue: 'rgb(176, 224, 230)',
764 purple: 'rgb(160, 32, 240)',
765 purple1: 'rgb(155, 48, 255)',
766 purple2: 'rgb(145, 44, 238)',
767 purple3: 'rgb(125, 38, 205)',
768 purple4: 'rgb(85, 26, 139)',
769 red: 'rgb(255, 0, 0)',
770 red1: 'rgb(255, 0, 0)',
771 red2: 'rgb(238, 0, 0)',
772 red3: 'rgb(205, 0, 0)',
773 red4: 'rgb(139, 0, 0)',
774 rosybrown: 'rgb(188, 143, 143)',
775 rosybrown1: 'rgb(255, 193, 193)',
776 rosybrown2: 'rgb(238, 180, 180)',
777 rosybrown3: 'rgb(205, 155, 155)',
778 rosybrown4: 'rgb(139, 105, 105)',
779 royalblue: 'rgb(65, 105, 225)',
780 royalblue1: 'rgb(72, 118, 255)',
781 royalblue2: 'rgb(67, 110, 238)',
782 royalblue3: 'rgb(58, 95, 205)',
783 royalblue4: 'rgb(39, 64, 139)',
784 saddlebrown: 'rgb(139, 69, 19)',
785 salmon: 'rgb(250, 128, 114)',
786 salmon1: 'rgb(255, 140, 105)',
787 salmon2: 'rgb(238, 130, 98)',
788 salmon3: 'rgb(205, 112, 84)',
789 salmon4: 'rgb(139, 76, 57)',
790 sandybrown: 'rgb(244, 164, 96)',
791 seagreen: 'rgb(46, 139, 87)',
792 seagreen1: 'rgb(84, 255, 159)',
793 seagreen2: 'rgb(78, 238, 148)',
794 seagreen3: 'rgb(67, 205, 128)',
795 seagreen4: 'rgb(46, 139, 87)',
796 seashell: 'rgb(255, 245, 238)',
797 seashell1: 'rgb(255, 245, 238)',
798 seashell2: 'rgb(238, 229, 222)',
799 seashell3: 'rgb(205, 197, 191)',
800 seashell4: 'rgb(139, 134, 130)',
801 sienna: 'rgb(160, 82, 45)',
802 sienna1: 'rgb(255, 130, 71)',
803 sienna2: 'rgb(238, 121, 66)',
804 sienna3: 'rgb(205, 104, 57)',
805 sienna4: 'rgb(139, 71, 38)',
806 skyblue: 'rgb(135, 206, 235)',
807 skyblue1: 'rgb(135, 206, 255)',
808 skyblue2: 'rgb(126, 192, 238)',
809 skyblue3: 'rgb(108, 166, 205)',
810 skyblue4: 'rgb(74, 112, 139)',
811 slateblue: 'rgb(106, 90, 205)',
812 slateblue1: 'rgb(131, 111, 255)',
813 slateblue2: 'rgb(122, 103, 238)',
814 slateblue3: 'rgb(105, 89, 205)',
815 slateblue4: 'rgb(71, 60, 139)',
816 slategray: 'rgb(112, 128, 144)',
817 slategray1: 'rgb(198, 226, 255)',
818 slategray2: 'rgb(185, 211, 238)',
819 slategray3: 'rgb(159, 182, 205)',
820 slategray4: 'rgb(108, 123, 139)',
821 slategrey: 'rgb(112, 128, 144)',
822 snow: 'rgb(255, 250, 250)',
823 snow1: 'rgb(255, 250, 250)',
824 snow2: 'rgb(238, 233, 233)',
825 snow3: 'rgb(205, 201, 201)',
826 snow4: 'rgb(139, 137, 137)',
827 springgreen: 'rgb(0, 255, 127)',
828 springgreen1: 'rgb(0, 255, 127)',
829 springgreen2: 'rgb(0, 238, 118)',
830 springgreen3: 'rgb(0, 205, 102)',
831 springgreen4: 'rgb(0, 139, 69)',
832 steelblue: 'rgb(70, 130, 180)',
833 steelblue1: 'rgb(99, 184, 255)',
834 steelblue2: 'rgb(92, 172, 238)',
835 steelblue3: 'rgb(79, 148, 205)',
836 steelblue4: 'rgb(54, 100, 139)',
837 tan: 'rgb(210, 180, 140)',
838 tan1: 'rgb(255, 165, 79)',
839 tan2: 'rgb(238, 154, 73)',
840 tan3: 'rgb(205, 133, 63)',
841 tan4: 'rgb(139, 90, 43)',
842 thistle: 'rgb(216, 191, 216)',
843 thistle1: 'rgb(255, 225, 255)',
844 thistle2: 'rgb(238, 210, 238)',
845 thistle3: 'rgb(205, 181, 205)',
846 thistle4: 'rgb(139, 123, 139)',
847 tomato: 'rgb(255, 99, 71)',
848 tomato1: 'rgb(255, 99, 71)',
849 tomato2: 'rgb(238, 92, 66)',
850 tomato3: 'rgb(205, 79, 57)',
851 tomato4: 'rgb(139, 54, 38)',
852 turquoise: 'rgb(64, 224, 208)',
853 turquoise1: 'rgb(0, 245, 255)',
854 turquoise2: 'rgb(0, 229, 238)',
855 turquoise3: 'rgb(0, 197, 205)',
856 turquoise4: 'rgb(0, 134, 139)',
857 violet: 'rgb(238, 130, 238)',
858 violetred: 'rgb(208, 32, 144)',
859 violetred1: 'rgb(255, 62, 150)',
860 violetred2: 'rgb(238, 58, 140)',
861 violetred3: 'rgb(205, 50, 120)',
862 violetred4: 'rgb(139, 34, 82)',
863 wheat: 'rgb(245, 222, 179)',
864 wheat1: 'rgb(255, 231, 186)',
865 wheat2: 'rgb(238, 216, 174)',
866 wheat3: 'rgb(205, 186, 150)',
867 wheat4: 'rgb(139, 126, 102)',
868 white: 'rgb(255, 255, 255)',
869 whitesmoke: 'rgb(245, 245, 245)',
870 yellow: 'rgb(255, 255, 0)',
871 yellow1: 'rgb(255, 255, 0)',
872 yellow2: 'rgb(238, 238, 0)',
873 yellow3: 'rgb(205, 205, 0)',
874 yellow4: 'rgb(139, 139, 0)',
875 yellowgreen: 'rgb(154, 205, 50)'
876 },
877 lib.f = {}, lib.f.replaceVars = function(e, t) {
878 return e.replace(/%([a-z]*)\(([^\)]+)\)/gi, function(e, r, o) {
879 if ('undefined' == typeof t[o]) throw 'Unknown variable: ' + o;
880 var i = t[o];
881 if (r in lib.f.replaceVars.functions)
882 i = lib.f.replaceVars.functions[r](i);
883 else if (r)
884 throw 'Unknown escape function: ' + r;
885 return i;
886 });
887 };
888, lib.f.replaceVars.functions = {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -0700889 encodeURI: encodeURI,
890 encodeURIComponent: encodeURIComponent,
891 escapeHTML: function(e) {
Andrew Geisslerd27bb132018-05-24 11:07:27 -0700892 var t =
893 {'<': '&lt;', '>': '&gt;', '&': '&amp;', '"': '&quot;', '\'': '&#39;'};
Andrew Geisslerba5e3f32018-05-24 10:58:00 -0700894 return e.replace(/[<>&\"\']/g, function(e) {
895 return t[e];
896 });
897 }
Andrew Geisslerd27bb132018-05-24 11:07:27 -0700898},
899 lib.f.getAcceptLanguages = function(e) {
900 lib.f.getAcceptLanguages.chromeSupported() ?
901 chrome.i18n.getAcceptLanguages(e) :
902 setTimeout(function() {
903 e([navigator.language.replace(/-/g, '_')]);
904 }, 0);
905 };
906, lib.f.getAcceptLanguages.chromeSupported = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -0700907 return window.chrome && chrome.i18n;
Andrew Geisslerd27bb132018-05-24 11:07:27 -0700908};
909, lib.f.parseQuery = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -0700910 '?' == e.substr(0, 1) && (e = e.substr(1));
911 for (var t = {}, r = e.split('&'), o = 0; o < r.length; o++) {
912 var i = r[o].split('=');
913 t[decodeURIComponent(i[0])] = decodeURIComponent(i[1]);
914 }
915 return t;
Andrew Geisslerd27bb132018-05-24 11:07:27 -0700916};
917, lib.f.getURL = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -0700918 return lib.f.getURL.chromeSupported() ? chrome.runtime.getURL(e) : e;
Andrew Geisslerd27bb132018-05-24 11:07:27 -0700919};
920, lib.f.getURL.chromeSupported = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -0700921 return window.chrome && chrome.runtime && chrome.runtime.getURL;
Andrew Geisslerd27bb132018-05-24 11:07:27 -0700922};
923, lib.f.clamp = function(e, t, r) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -0700924 return t > e ? t : e > r ? r : e
Andrew Geisslerd27bb132018-05-24 11:07:27 -0700925};
926, lib.f.lpad = function(e, t, r) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -0700927 for (e = String(e), r = r || ' '; e.length < t;) e = r + e;
928 return e;
Andrew Geisslerd27bb132018-05-24 11:07:27 -0700929};
930, lib.f.zpad = function(e, t) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -0700931 return lib.f.lpad(e, t, '0');
Andrew Geisslerd27bb132018-05-24 11:07:27 -0700932};
933, lib.f.getWhitespace = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -0700934 if (0 >= e) return '';
935 var t = this.getWhitespace;
Andrew Geisslerd27bb132018-05-24 11:07:27 -0700936 for (t.whitespace || (t.whitespace = ' '); e > t.whitespace.length;)
937 t.whitespace += t.whitespace;
Andrew Geisslerba5e3f32018-05-24 10:58:00 -0700938 return t.whitespace.substr(0, e);
Andrew Geisslerd27bb132018-05-24 11:07:27 -0700939};
940, lib.f.alarm = function(e, t) {
941 var r = t || 5e3, o = lib.f.getStack(1);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -0700942 return function() {
943 var t = setTimeout(function() {
Andrew Geisslerd27bb132018-05-24 11:07:27 -0700944 var i = 'string' == typeof e ? i : e.name;
945 i = i ? ': ' + i : '',
946 console.warn('lib.f.alarm: timeout expired: ' + r / 1e3 + 's' + i),
947 console.log(o), t = null;
948 }, r), i = function(e) {
949 return function() {
950 return t && (clearTimeout(t), t = null), e.apply(null, arguments);
951 }
952 };
Andrew Geisslerba5e3f32018-05-24 10:58:00 -0700953 return 'string' == typeof e ? i : i(e);
954 }();
Andrew Geisslerd27bb132018-05-24 11:07:27 -0700955};
956, lib.f.getStack = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -0700957 var t, r = e ? e + 2 : 2;
958 try {
959 throw new Error;
Andrew Geisslerd27bb132018-05-24 11:07:27 -0700960 } catch (o) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -0700961 t = o.stack.split('\n');
962 }
Andrew Geisslerd27bb132018-05-24 11:07:27 -0700963 for (var i = {}, s = r; s < t.length; s++)
964 i[s - r] = t[s].replace(/^\s*at\s+/, '');
Andrew Geisslerba5e3f32018-05-24 10:58:00 -0700965 return i;
Andrew Geisslerd27bb132018-05-24 11:07:27 -0700966};
967, lib.f.smartFloorDivide = function(e, t) {
968 var r = e / t, o = Math.ceil(r);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -0700969 return 1e-4 > o - r ? o : Math.floor(r);
Andrew Geisslerd27bb132018-05-24 11:07:27 -0700970};
971, lib.MessageManager = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -0700972 this.languages_ = e.map(function(e) {
973 return e.replace(/-/g, '_');
Andrew Geisslerd27bb132018-05-24 11:07:27 -0700974 }),
975 -1 == this.languages_.indexOf('en') && this.languages_.unshift('en'),
976 this.messages = {};
977};
978, lib.MessageManager.prototype.addMessages = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -0700979 for (var t in e) {
980 var r = e[t];
Andrew Geisslerd27bb132018-05-24 11:07:27 -0700981 r.placeholders ? this.messages[t] = r.message.replace(
982 /\$([a-z][^\s\$]+)\$/gi,
983 function(r, o) {
984 return e[t].placeholders[o.toLowerCase()].content;
985 }) :
986 this.messages[t] = r.message;
Andrew Geisslerba5e3f32018-05-24 10:58:00 -0700987 }
Andrew Geisslerd27bb132018-05-24 11:07:27 -0700988};
989, lib.MessageManager.prototype.findAndLoadMessages = function(e, t) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -0700990 function r(e) {
991 e ? i = o.shift() : s = o.shift(), o.length ? n() : t(i, s);
992 }
Andrew Geisslerd27bb132018-05-24 11:07:27 -0700993 var o = this.languages_.concat(), i = [], s = [], n = function() {
994 this.loadMessages(
995 this.replaceReferences(e, o), r.bind(this, !0), r.bind(this, !1));
996 }.bind(this);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -0700997 n();
Andrew Geisslerd27bb132018-05-24 11:07:27 -0700998};
999, lib.MessageManager.prototype.loadMessages = function(e, t, r) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001000 var o = new XMLHttpRequest;
1001 o.onloadend = function() {
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001002 return 200 != o.status ?
Gunnar Mills4ddda582018-09-04 09:18:30 -05001003 void (r && r(o.status)) :
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001004 (this.addMessages(JSON.parse(o.responseText)), void t());
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001005 }.bind(this), o.open('GET', e), o.send();
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001006};
1007, lib.MessageManager.replaceReferences = function(e, t) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001008 return e.replace(/\$(\d+)/g, function(e, r) {
1009 return t[r - 1];
1010 });
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001011};
1012,
1013 lib.MessageManager.prototype.replaceReferences =
1014 lib.MessageManager.replaceReferences,
1015 lib.MessageManager.prototype.get = function(e, t, r) {
1016 var o;
1017 if (e in this.messages)
1018 o = this.messages[e];
1019 else if (window.chrome.i18n && (o = chrome.i18n.getMessage(e)), !o)
1020 return console.warn('Unknown message: ' + e),
1021 'undefined' == typeof r ? e : r;
1022 return t ?
1023 (t instanceof Array || (t = [t]), this.replaceReferences(o, t)) :
1024 o;
1025 };
1026, lib.MessageManager.prototype.processI18nAttributes = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001027 function t(e) {
1028 return e.replace(/-/g, '_').toUpperCase();
1029 }
1030 for (var r = e.querySelectorAll('[i18n]'), o = 0; o < r.length; o++) {
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001031 var i = r[o], s = i.getAttribute('i18n');
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001032 if (s) {
1033 try {
1034 s = JSON.parse(s);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001035 } catch (n) {
1036 throw console.error(
1037 'Can\'t parse ' + i.tagName + '#' + i.id + ': ' + s),
1038 n;
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001039 }
1040 for (var a in s) {
1041 var l = s[a];
1042 '$' == l.substr(0, 1) && (l = t(i.getAttribute(l.substr(1)) + '_' + a));
1043 var h = this.get(l);
1044 '_' == a ? i.textContent = h : i.setAttribute(a, h);
1045 }
1046 }
1047 }
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001048};
1049, lib.PreferenceManager = function(e, t) {
1050 this.storage = e, this.storageObserver_ = this.onStorageChange_.bind(this),
1051 this.isActive_ = !1, this.activate(), this.trace = !1;
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001052 var r = t || '/';
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001053 '/' != r.substr(r.length - 1) && (r += '/'),
1054 this.prefix = r, this.prefRecords_ = {}, this.globalObservers_ = [],
1055 this.childFactories_ = {}, this.childLists_ = {};
1056};
1057, lib.PreferenceManager.prototype.DEFAULT_VALUE = new String('DEFAULT'),
1058 lib.PreferenceManager.Record = function(e, t) {
1059 this.name = e, this.defaultValue = t,
1060 this.currentValue = this.DEFAULT_VALUE, this.observers = [];
1061 };
1062,
1063 lib.PreferenceManager.Record.prototype.DEFAULT_VALUE =
1064 lib.PreferenceManager.prototype.DEFAULT_VALUE,
1065 lib.PreferenceManager.Record.prototype.addObserver = function(e) {
1066 this.observers.push(e);
1067 };
1068, lib.PreferenceManager.Record.prototype.removeObserver = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001069 var t = this.observers.indexOf(e);
1070 t >= 0 && this.observers.splice(t, 1);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001071};
1072, lib.PreferenceManager.Record.prototype.get = function() {
1073 return this.currentValue === this.DEFAULT_VALUE ?
1074 /^(string|number)$/.test(typeof this.defaultValue) ?
1075 this.defaultValue :
1076 'object' == typeof this.defaultValue ?
1077 JSON.parse(JSON.stringify(this.defaultValue)) :
1078 this.defaultValue :
1079 this.currentValue
1080};
1081, lib.PreferenceManager.prototype.deactivate = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001082 if (!this.isActive_) throw new Error('Not activated');
1083 this.isActive_ = !1, this.storage.removeObserver(this.storageObserver_);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001084};
1085, lib.PreferenceManager.prototype.activate = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001086 if (this.isActive_) throw new Error('Already activated');
1087 this.isActive_ = !0, this.storage.addObserver(this.storageObserver_);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001088};
1089, lib.PreferenceManager.prototype.readStorage = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001090 function t() {
1091 0 == --r && e && e();
1092 }
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001093 var r = 0, o = Object.keys(this.prefRecords_).map(function(e) {
1094 return this.prefix + e;
1095 }.bind(this));
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001096 this.trace && console.log('Preferences read: ' + this.prefix),
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001097 this.storage.getItems(o, function(o) {
1098 var i = this.prefix.length;
1099 for (var s in o) {
1100 var n = o[s], a = s.substr(i),
1101 l = a in this.childLists_ &&
1102 JSON.stringify(n) !=
1103 JSON.stringify(this.prefRecords_[a].currentValue);
1104 this.prefRecords_[a].currentValue = n,
1105 l && (r++, this.syncChildList(a, t));
1106 }
1107 0 == r && e && setTimeout(e);
1108 }.bind(this));
1109};
1110, lib.PreferenceManager.prototype.definePreference = function(e, t, r) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001111 var o = this.prefRecords_[e];
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001112 o ? this.changeDefault(e, t) :
1113 o = this.prefRecords_[e] = new lib.PreferenceManager.Record(e, t),
1114 r && o.addObserver(r);
1115};
1116, lib.PreferenceManager.prototype.definePreferences = function(e) {
1117 for (var t = 0; t < e.length; t++)
1118 this.definePreference(e[t][0], e[t][1], e[t][2]);
1119};
1120, lib.PreferenceManager.prototype.defineChildren = function(e, t) {
1121 this.definePreference(e, [], this.onChildListChange_.bind(this, e)),
1122 this.childFactories_[e] = t, this.childLists_[e] = {};
1123};
1124, lib.PreferenceManager.prototype.addObservers = function(e, t) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001125 if (e && 'function' != typeof e) throw new Error('Invalid param: globals');
1126 if (e && this.globalObservers_.push(e), t)
1127 for (var r in t) {
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001128 if (!(r in this.prefRecords_))
1129 throw new Error('Unknown preference: ' + r);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001130 this.prefRecords_[r].addObserver(t[r]);
1131 }
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001132};
1133, lib.PreferenceManager.prototype.notifyAll = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001134 for (var e in this.prefRecords_) this.notifyChange_(e);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001135};
1136, lib.PreferenceManager.prototype.notifyChange_ = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001137 var t = this.prefRecords_[e];
1138 if (!t) throw new Error('Unknown preference: ' + e);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001139 for (var r = t.get(), o = 0; o < this.globalObservers_.length; o++)
1140 this.globalObservers_[o](e, r);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001141 for (var o = 0; o < t.observers.length; o++) t.observers[o](r, e, this);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001142};
1143, lib.PreferenceManager.prototype.createChild = function(e, t, r) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001144 var o, i = this.get(e);
1145 if (r) {
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001146 if (o = r, -1 != i.indexOf(o))
1147 throw new Error('Duplicate child: ' + e + ': ' + o);
1148 } else
1149 for (; !o || -1 != i.indexOf(o);)
1150 o = Math.floor(65535 * Math.random() + 1).toString(16),
1151 o = lib.f.zpad(o, 4), t && (o = t + ':' + o);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001152 var s = this.childFactories_[e](this, o);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001153 return s.trace = this.trace, s.resetAll(), this.childLists_[e][o] = s,
1154 i.push(o), this.set(e, i), s;
1155};
1156, lib.PreferenceManager.prototype.removeChild = function(e, t) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001157 var r = this.getChild(e, t);
1158 r.resetAll();
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001159 var o = this.get(e), i = o.indexOf(t);
1160 -1 != i && (o.splice(i, 1), this.set(e, o)), delete this.childLists_[e][t];
1161};
1162, lib.PreferenceManager.prototype.getChild = function(e, t, r) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001163 if (!(e in this.childLists_)) throw new Error('Unknown child list: ' + e);
1164 var o = this.childLists_[e];
1165 if (!(t in o)) {
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001166 if ('undefined' == typeof r)
1167 throw new Error('Unknown "' + e + '" child: ' + t);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001168 return r;
1169 }
1170 return o[t];
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001171};
1172, lib.PreferenceManager.diffChildLists = function(e, t) {
1173 for (var r = {added: {}, removed: {}, common: {}}, o = 0; o < e.length; o++)
1174 -1 != t.indexOf(e[o]) ? r.common[e[o]] = !0 : r.added[e[o]] = !0;
1175 for (var o = 0; o < t.length; o++)
1176 t[o] in r.added || t[o] in r.common || (r.removed[t[o]] = !0);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001177 return r;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001178};
1179, lib.PreferenceManager.prototype.syncChildList = function(e, t) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001180 function r() {
1181 0 == --o && t && t();
1182 }
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001183 for (var o = 0, i = this.get(e), s = Object.keys(this.childLists_[e]),
1184 n = (lib.PreferenceManager.diffChildLists(i, s), 0);
1185 n < i.length; n++) {
1186 var a = i[n], l = s.indexOf(a);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001187 if (l >= 0 && s.splice(l, 1), !this.childLists_[e][a]) {
1188 var h = this.childFactories_[e](this, a);
1189 if (!h) {
1190 console.warn('Unable to restore child: ' + e + ': ' + a);
1191 continue;
1192 }
1193 h.trace = this.trace, this.childLists_[e][a] = h, o++, h.readStorage(r);
1194 }
1195 }
1196 for (var n = 0; n < s.length; n++) delete this.childLists_[e][s[n]];
1197 !o && t && setTimeout(t);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001198};
1199, lib.PreferenceManager.prototype.reset = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001200 var t = this.prefRecords_[e];
1201 if (!t) throw new Error('Unknown preference: ' + e);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001202 this.storage.removeItem(this.prefix + e),
1203 t.currentValue !== this.DEFAULT_VALUE &&
1204 (t.currentValue = this.DEFAULT_VALUE, this.notifyChange_(e));
1205};
1206, lib.PreferenceManager.prototype.resetAll = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001207 var e = [];
1208 for (var t in this.childLists_) {
1209 var r = this.childLists_[t];
1210 for (var o in r) r[o].resetAll();
1211 }
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001212 for (var i in this.prefRecords_)
1213 this.prefRecords_[i].currentValue !== this.DEFAULT_VALUE &&
1214 (this.prefRecords_[i].currentValue = this.DEFAULT_VALUE, e.push(i));
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001215 var s = Object.keys(this.prefRecords_).map(function(e) {
1216 return this.prefix + e;
1217 }.bind(this));
1218 this.storage.removeItems(s), e.forEach(this.notifyChange_.bind(this));
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001219};
1220, lib.PreferenceManager.prototype.diff = function(e, t) {
1221 return typeof e == typeof t &&
1222 /^(undefined|boolean|number|string)$/.test(typeof e) ?
1223 e !== t :
1224 !0;
1225};
1226, lib.PreferenceManager.prototype.changeDefault = function(e, t) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001227 var r = this.prefRecords_[e];
1228 if (!r) throw new Error('Unknown preference: ' + e);
1229 if (this.diff(r.defaultValue, t)) {
Gunnar Mills4ddda582018-09-04 09:18:30 -05001230 if (r.currentValue !== this.DEFAULT_VALUE) return void (r.defaultValue = t);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001231 r.defaultValue = t, this.notifyChange_(e);
1232 }
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001233};
1234, lib.PreferenceManager.prototype.changeDefaults = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001235 for (var t in e) this.changeDefault(t, e[t]);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001236};
1237, lib.PreferenceManager.prototype.set = function(e, t) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001238 var r = this.prefRecords_[e];
1239 if (!r) throw new Error('Unknown preference: ' + e);
1240 var o = r.get();
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001241 this.diff(o, t) &&
1242 (this.diff(r.defaultValue, t) ?
1243 (r.currentValue = t, this.storage.setItem(this.prefix + e, t)) :
1244 (r.currentValue = this.DEFAULT_VALUE,
1245 this.storage.removeItem(this.prefix + e)),
1246 setTimeout(this.notifyChange_.bind(this, e), 0));
1247};
1248, lib.PreferenceManager.prototype.get = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001249 var t = this.prefRecords_[e];
1250 if (!t) throw new Error('Unknown preference: ' + e);
1251 return t.get();
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001252};
1253, lib.PreferenceManager.prototype.exportAsJson = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001254 var e = {};
1255 for (var t in this.prefRecords_)
1256 if (t in this.childLists_) {
1257 e[t] = [];
1258 for (var r = this.get(t), o = 0; o < r.length; o++) {
1259 var i = r[o];
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001260 e[t].push({id: i, json: this.getChild(t, i).exportAsJson()});
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001261 }
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001262 } else {
1263 var s = this.prefRecords_[t];
1264 s.currentValue != this.DEFAULT_VALUE && (e[t] = s.currentValue);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001265 }
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001266 return e;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001267};
1268, lib.PreferenceManager.prototype.importFromJson = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001269 for (var t in e)
1270 if (t in this.childLists_)
1271 for (var r = e[t], o = 0; o < r.length; o++) {
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001272 var i = r[o].id, s = this.childLists_[t][i];
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001273 s || (s = this.createChild(t, null, i)), s.importFromJson(r[o].json);
1274 }
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001275 else
1276 this.set(t, e[t]);
1277};
1278, lib.PreferenceManager.prototype.onChildListChange_ = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001279 this.syncChildList(e);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001280};
1281, lib.PreferenceManager.prototype.onStorageChange_ = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001282 for (var t in e)
1283 if (!this.prefix || 0 == t.lastIndexOf(this.prefix, 0)) {
1284 var r = t.substr(this.prefix.length);
1285 if (r in this.prefRecords_) {
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001286 var o = this.prefRecords_[r], i = e[t].newValue, s = o.currentValue;
1287 s === o.DEFAULT_VALUE && (s = void 0),
1288 this.diff(s, i) &&
1289 ('undefined' == typeof i ? o.currentValue = o.DEFAULT_VALUE :
1290 o.currentValue = i,
1291 this.notifyChange_(r));
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001292 }
1293 }
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001294};
1295, lib.resource = {resources_: {}}, lib.resource.add = function(e, t, r) {
1296 lib.resource.resources_[e] = {type: t, name: e, data: r};
1297};
1298, lib.resource.get = function(e, t) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001299 if (!(e in lib.resource.resources_)) {
1300 if ('undefined' == typeof t) throw 'Unknown resource: ' + e;
1301 return t;
1302 }
1303 return lib.resource.resources_[e];
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001304};
1305, lib.resource.getData = function(e, t) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001306 if (!(e in lib.resource.resources_)) {
1307 if ('undefined' == typeof t) throw 'Unknown resource: ' + e;
1308 return t;
1309 }
1310 return lib.resource.resources_[e].data;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001311};
1312, lib.resource.getDataUrl = function(e, t) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001313 var r = lib.resource.get(e, t);
1314 return 'data:' + r.type + ',' + r.data;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001315};
1316, lib.Storage = new Object, lib.Storage.Chrome = function(e) {
1317 this.storage_ = e, this.observers_ = [],
1318 chrome.storage.onChanged.addListener(this.onChanged_.bind(this));
1319};
1320, lib.Storage.Chrome.prototype.onChanged_ = function(e, t) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001321 if (chrome.storage[t] == this.storage_)
1322 for (var r = 0; r < this.observers_.length; r++) this.observers_[r](e);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001323};
1324, lib.Storage.Chrome.prototype.addObserver = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001325 this.observers_.push(e);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001326};
1327, lib.Storage.Chrome.prototype.removeObserver = function(e) {
1328 var t = this.observers_.indexOf(e);
1329 -1 != t && this.observers_.splice(t, 1);
1330};
1331, lib.Storage.Chrome.prototype.clear = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001332 this.storage_.clear(), e && setTimeout(e, 0);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001333};
1334, lib.Storage.Chrome.prototype.getItem = function(e, t) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001335 this.storage_.get(e, t);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001336};
1337, lib.Storage.Chrome.prototype.getItems = function(e, t) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001338 this.storage_.get(e, t);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001339};
1340, lib.Storage.Chrome.prototype.setItem = function(e, t, r) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001341 var o = {};
1342 o[e] = t, this.storage_.set(o, r);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001343};
1344, lib.Storage.Chrome.prototype.setItems = function(e, t) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001345 this.storage_.set(e, t);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001346};
1347, lib.Storage.Chrome.prototype.removeItem = function(e, t) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001348 this.storage_.remove(e, t);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001349};
1350, lib.Storage.Chrome.prototype.removeItems = function(e, t) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001351 this.storage_.remove(e, t);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001352};
1353, lib.Storage.Local = function() {
1354 this.observers_ = [], this.storage_ = window.localStorage,
1355 window.addEventListener('storage', this.onStorage_.bind(this));
1356};
1357, lib.Storage.Local.prototype.onStorage_ = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001358 if (e.storageArea == this.storage_) {
1359 var t = e.oldValue ? JSON.parse(e.oldValue) : '',
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001360 r = e.newValue ? JSON.parse(e.newValue) : '', o = {};
1361 o[e.key] = {oldValue: t, newValue: r};
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001362 for (var i = 0; i < this.observers_.length; i++) this.observers_[i](o);
1363 }
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001364};
1365, lib.Storage.Local.prototype.addObserver = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001366 this.observers_.push(e);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001367};
1368, lib.Storage.Local.prototype.removeObserver = function(e) {
1369 var t = this.observers_.indexOf(e);
1370 -1 != t && this.observers_.splice(t, 1);
1371};
1372, lib.Storage.Local.prototype.clear = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001373 this.storage_.clear(), e && setTimeout(e, 0);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001374};
1375, lib.Storage.Local.prototype.getItem = function(e, t) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001376 var r = this.storage_.getItem(e);
1377 if ('string' == typeof r) try {
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001378 r = JSON.parse(r);
1379 } catch (o) {
1380 }
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001381 setTimeout(t.bind(null, r), 0);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001382};
1383, lib.Storage.Local.prototype.getItems = function(e, t) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001384 for (var r = {}, o = e.length - 1; o >= 0; o--) {
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001385 var i = e[o], s = this.storage_.getItem(i);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001386 if ('string' == typeof s) try {
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001387 r[i] = JSON.parse(s);
1388 } catch (n) {
1389 r[i] = s;
1390 }
1391 else
1392 e.splice(o, 1);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001393 }
1394 setTimeout(t.bind(null, r), 0);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001395};
1396, lib.Storage.Local.prototype.setItem = function(e, t, r) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001397 this.storage_.setItem(e, JSON.stringify(t)), r && setTimeout(r, 0);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001398};
1399, lib.Storage.Local.prototype.setItems = function(e, t) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001400 for (var r in e) this.storage_.setItem(r, JSON.stringify(e[r]));
1401 t && setTimeout(t, 0);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001402};
1403, lib.Storage.Local.prototype.removeItem = function(e, t) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001404 this.storage_.removeItem(e), t && setTimeout(t, 0);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001405};
1406, lib.Storage.Local.prototype.removeItems = function(e, t) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001407 for (var r = 0; r < e.length; r++) this.storage_.removeItem(e[r]);
1408 t && setTimeout(t, 0);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001409};
1410, lib.Storage.Memory = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001411 this.observers_ = [], this.storage_ = {};
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001412};
1413, lib.Storage.Memory.prototype.addObserver = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001414 this.observers_.push(e);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001415};
1416, lib.Storage.Memory.prototype.removeObserver = function(e) {
1417 var t = this.observers_.indexOf(e);
1418 -1 != t && this.observers_.splice(t, 1);
1419};
1420, lib.Storage.Memory.prototype.clear = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001421 var t = {};
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001422 for (var r in this.storage_)
1423 t[r] = {oldValue: this.storage_[r], newValue: void 0};
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001424 this.storage_ = {}, setTimeout(function() {
1425 for (var e = 0; e < this.observers_.length; e++) this.observers_[e](t);
1426 }.bind(this), 0), e && setTimeout(e, 0);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001427};
1428, lib.Storage.Memory.prototype.getItem = function(e, t) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001429 var r = this.storage_[e];
1430 if ('string' == typeof r) try {
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001431 r = JSON.parse(r);
1432 } catch (o) {
1433 }
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001434 setTimeout(t.bind(null, r), 0);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001435};
1436, lib.Storage.Memory.prototype.getItems = function(e, t) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001437 for (var r = {}, o = e.length - 1; o >= 0; o--) {
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001438 var i = e[o], s = this.storage_[i];
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001439 if ('string' == typeof s) try {
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001440 r[i] = JSON.parse(s);
1441 } catch (n) {
1442 r[i] = s;
1443 }
1444 else
1445 e.splice(o, 1);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001446 }
1447 setTimeout(t.bind(null, r), 0);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001448};
1449, lib.Storage.Memory.prototype.setItem = function(e, t, r) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001450 var o = this.storage_[e];
1451 this.storage_[e] = JSON.stringify(t);
1452 var i = {};
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001453 i[e] = {oldValue: o, newValue: t}, setTimeout(function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001454 for (var e = 0; e < this.observers_.length; e++) this.observers_[e](i);
1455 }.bind(this), 0), r && setTimeout(r, 0);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001456};
1457, lib.Storage.Memory.prototype.setItems = function(e, t) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001458 var r = {};
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001459 for (var o in e)
1460 r[o] = {oldValue: this.storage_[o], newValue: e[o]},
1461 this.storage_[o] = JSON.stringify(e[o]);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001462 setTimeout(function() {
1463 for (var e = 0; e < this.observers_.length; e++) this.observers_[e](r);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001464 }.bind(this)),
1465 t && setTimeout(t, 0);
1466};
1467, lib.Storage.Memory.prototype.removeItem = function(e, t) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001468 delete this.storage_[e], t && setTimeout(t, 0);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001469};
1470, lib.Storage.Memory.prototype.removeItems = function(e, t) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001471 for (var r = 0; r < e.length; r++) delete this.storage_[e[r]];
1472 t && setTimeout(t, 0);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001473};
1474, lib.TestManager = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001475 this.log = e || new lib.TestManager.Log;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001476};
1477, lib.TestManager.prototype.createTestRun = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001478 return new lib.TestManager.TestRun(this, e);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001479};
1480, lib.TestManager.prototype.onTestRunComplete = function(e) {};
1481, lib.TestManager.prototype.testPreamble = function(e, t) {};
1482, lib.TestManager.prototype.testPostamble = function(e, t) {};
1483, lib.TestManager.Log = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001484 this.save = !1, this.data = '', this.logFunction_ = e || function(e) {
1485 this.save && (this.data += e + '\n'), console.log(e);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001486 };
1487 , this.pending_ = '', this.prefix_ = '', this.prefixStack_ = [];
1488};
1489, lib.TestManager.Log.prototype.pushPrefix = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001490 this.prefixStack_.push(e), this.prefix_ = this.prefixStack_.join('');
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001491};
1492, lib.TestManager.Log.prototype.popPrefix = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001493 this.prefixStack_.pop(), this.prefix_ = this.prefixStack_.join('');
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001494};
1495, lib.TestManager.Log.prototype.print = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001496 this.pending_ ? this.pending_ += e : this.pending_ = this.prefix_ + e;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001497};
1498, lib.TestManager.Log.prototype.println = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001499 this.pending_ && this.flush(), this.logFunction_(this.prefix_ + e);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001500};
1501, lib.TestManager.Log.prototype.flush = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001502 this.pending_ && (this.logFunction_(this.pending_), this.pending_ = '');
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001503};
1504, lib.TestManager.Suite = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001505 function t(t, r) {
1506 this.testManager_ = t, this.suiteName = e, this.setup(r);
1507 }
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001508 return t.suiteName = e, t.addTest = lib.TestManager.Suite.addTest,
1509 t.disableTest = lib.TestManager.Suite.disableTest,
1510 t.getTest = lib.TestManager.Suite.getTest,
1511 t.getTestList = lib.TestManager.Suite.getTestList, t.testList_ = [],
1512 t.testMap_ = {},
1513 t.prototype = {__proto__: lib.TestManager.Suite.prototype},
1514 lib.TestManager.Suite.subclasses.push(t), t;
1515};
1516, lib.TestManager.Suite.subclasses = [],
1517 lib.TestManager.Suite.addTest = function(e, t) {
1518 if (e in this.testMap_) throw 'Duplicate test name: ' + e;
1519 var r = new lib.TestManager.Test(this, e, t);
1520 this.testMap_[e] = r, this.testList_.push(r);
1521 };
1522, lib.TestManager.Suite.disableTest = function(e, t) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001523 if (e in this.testMap_) throw 'Duplicate test name: ' + e;
1524 var r = new lib.TestManager.Test(this, e, t);
1525 console.log('Disabled test: ' + r.fullName);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001526};
1527, lib.TestManager.Suite.getTest = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001528 return this.testMap_[e];
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001529};
1530, lib.TestManager.Suite.getTestList = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001531 return this.testList_;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001532};
1533, lib.TestManager.Suite.prototype.setDefaults = function(e, t) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001534 for (var r in t) this[r] = r in e ? e[r] : t[r];
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001535};
1536, lib.TestManager.Suite.prototype.setup = function(e) {};
1537, lib.TestManager.Suite.prototype.preamble = function(e, t) {};
1538, lib.TestManager.Suite.prototype.postamble = function(e, t) {};
1539, lib.TestManager.Test = function(e, t, r) {
1540 this.suiteClass = e, this.testName = t,
1541 this.fullName = e.suiteName + '[' + t + ']', this.testFunction_ = r;
1542};
1543, lib.TestManager.Test.prototype.run = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001544 try {
1545 this.testFunction_.apply(e.suite, [e, e.testRun.cx]);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001546 } catch (t) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001547 if (t instanceof lib.TestManager.Result.TestComplete) return;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001548 e.println('Test raised an exception: ' + t),
1549 t.stack &&
1550 (t.stack instanceof Array ? e.println(t.stack.join('\n')) :
1551 e.println(t.stack)),
1552 e.completeTest_(e.FAILED, !1);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001553 }
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001554};
1555, lib.TestManager.TestRun = function(e, t) {
1556 this.testManager = e, this.log = e.log, this.cx = t || {}, this.failures = [],
1557 this.passes = [], this.startDate = null, this.duration = null,
1558 this.currentResult = null, this.maxFailures = 0, this.panic = !1,
1559 this.testQueue_ = [];
1560};
1561, lib.TestManager.TestRun.prototype.ALL_TESTS = new String('<all-tests>'),
1562 lib.TestManager.TestRun.prototype.selectTest = function(e) {
1563 this.testQueue_.push(e);
1564 };
1565, lib.TestManager.TestRun.prototype.selectSuite = function(e, t) {
1566 for (var r = t || this.ALL_TESTS, o = 0, i = e.getTestList(), s = 0;
1567 s < i.length; s++) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001568 var n = i[s];
1569 if (r !== this.ALL_TESTS)
1570 if (r instanceof RegExp) {
1571 if (!r.test(n.testName)) continue;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001572 } else if (n.testName != r)
1573 continue;
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001574 this.selectTest(n), o++;
1575 }
1576 return o;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001577};
1578, lib.TestManager.TestRun.prototype.selectPattern = function(e) {
1579 for (var t = 0, r = 0; r < lib.TestManager.Suite.subclasses.length; r++)
1580 t += this.selectSuite(lib.TestManager.Suite.subclasses[r], e);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001581 return t || this.log.println('No tests matched selection criteria: ' + e), t;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001582};
1583, lib.TestManager.TestRun.prototype.onUncaughtException_ = function(e, t, r) {
1584 if (0 == e.indexOf('Uncaught lib.TestManager.Result.TestComplete') ||
1585 -1 != e.indexOf('status: passed'))
1586 return !0;
1587 if (this.currentResult &&
1588 e != 'Uncaught ' + this.currentResult.expectedErrorMessage_) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001589 var o = 'during';
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001590 return this.currentResult.status != this.currentResult.PENDING &&
1591 (o = 'after'),
1592 this.log.println(
1593 'Uncaught exception ' + o +
1594 ' test case: ' + this.currentResult.test.fullName),
1595 this.log.println(e + ', ' + t + ':' + r),
1596 this.currentResult.completeTest_(this.currentResult.FAILED, !1), !1;
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001597 }
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001598};
1599, lib.TestManager.TestRun.prototype.onTestRunComplete_ = function(e) {
1600 return e ?
1601 (this.duration = new Date - this.startDate, this.log.popPrefix(),
1602 this.log.println(
1603 '} ' + this.passes.length + ' passed, ' + this.failures.length +
1604 ' failed, ' + this.msToSeconds_(this.duration)),
1605 this.log.println(''), this.summarize(), window.onerror = null,
1606 void this.testManager.onTestRunComplete(this)) :
1607 void setTimeout(this.onTestRunComplete_.bind(this), 0, !0);
1608};
1609, lib.TestManager.TestRun.prototype.onResultComplete = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001610 try {
1611 this.testManager.testPostamble(e, this.cx), e.suite.postamble(e, this.ctx);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001612 } catch (t) {
1613 this.log.println(
1614 'Unexpected exception in postamble: ' + (t.stack ? t.stack : t)),
1615 this.panic = !0;
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001616 }
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001617 if (this.log.popPrefix(),
1618 this.log.print('} ' + e.status + ', ' + this.msToSeconds_(e.duration)),
1619 this.log.flush(), e.status == e.FAILED)
1620 this.failures.push(e), this.currentSuite = null;
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001621 else {
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001622 if (e.status != e.PASSED)
1623 return this.log.println(
1624 'Unknown result status: ' + e.test.fullName + ': ' + e.status),
1625 this.panic = !0;
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001626 this.passes.push(e);
1627 }
1628 this.runNextTest_();
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001629};
1630, lib.TestManager.TestRun.prototype.onResultReComplete = function(e, t) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001631 this.log.println('Late complete for test: ' + e.test.fullName + ': ' + t);
1632 var r = this.passes.indexOf(e);
1633 r >= 0 && (this.passes.splice(r, 1), this.failures.push(e));
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001634};
1635, lib.TestManager.TestRun.prototype.runNextTest_ = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001636 if (this.panic || !this.testQueue_.length) return this.onTestRunComplete_();
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001637 if (this.maxFailures && this.failures.length >= this.maxFailures)
1638 return this.log.println(
1639 'Maximum failure count reached, aborting test run.'),
1640 this.onTestRunComplete_();
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001641 var e = this.testQueue_[0],
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001642 t = this.currentResult ? this.currentResult.suite : null;
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001643 try {
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001644 t && t instanceof e.suiteClass ||
1645 (this.log.println('Initializing suite: ' + e.suiteClass.suiteName),
1646 t = new e.suiteClass(this.testManager, this.cx));
1647 } catch (r) {
1648 return this.log.println(
1649 'Exception during setup: ' + (r.stack ? r.stack : r)),
1650 this.panic = !0, void this.onTestRunComplete_();
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001651 }
1652 try {
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001653 this.log.print('Test: ' + e.fullName + ' {'), this.log.pushPrefix(' '),
1654 this.currentResult = new lib.TestManager.Result(this, t, e),
1655 this.testManager.testPreamble(this.currentResult, this.cx),
1656 t.preamble(this.currentResult, this.cx), this.testQueue_.shift();
1657 } catch (r) {
1658 return this.log.println(
1659 'Unexpected exception during test preamble: ' +
1660 (r.stack ? r.stack : r)),
1661 this.log.popPrefix(), this.log.println('}'),
1662 this.panic = !0, void this.onTestRunComplete_();
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001663 }
1664 try {
1665 this.currentResult.run();
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001666 } catch (r) {
1667 this.log.println(
1668 'Unexpected exception during test run: ' + (r.stack ? r.stack : r)),
1669 this.panic = !0;
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001670 }
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001671};
1672, lib.TestManager.TestRun.prototype.run = function() {
1673 this.log.println('Running ' + this.testQueue_.length + ' test(s) {'),
1674 this.log.pushPrefix(' '),
1675 window.onerror = this.onUncaughtException_.bind(this),
1676 this.startDate = new Date, this.runNextTest_();
1677};
1678, lib.TestManager.TestRun.prototype.msToSeconds_ = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001679 var t = (e / 1e3).toFixed(2);
1680 return t + 's';
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001681};
1682, lib.TestManager.TestRun.prototype.summarize = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001683 if (this.failures.length)
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001684 for (var e = 0; e < this.failures.length; e++)
1685 this.log.println('FAILED: ' + this.failures[e].test.fullName);
1686 this.testQueue_.length &&
1687 this.log.println(
1688 'Test run incomplete: ' + this.testQueue_.length +
1689 ' test(s) were not run.');
1690};
1691, lib.TestManager.Result = function(e, t, r) {
1692 this.testRun = e, this.suite = t, this.test = r, this.startDate = null,
1693 this.duration = null, this.status = this.PENDING,
1694 this.expectedErrorMessage_ = null;
1695};
1696, lib.TestManager.Result.prototype.PENDING = 'pending',
1697 lib.TestManager.Result.prototype.FAILED = 'FAILED',
1698 lib.TestManager.Result.prototype.PASSED = 'passed',
1699 lib.TestManager.Result.TestComplete = function(e) {
1700 this.result = e;
1701 };
1702, lib.TestManager.Result.TestComplete.prototype.toString = function() {
1703 return 'lib.TestManager.Result.TestComplete: ' + this.result.test.fullName +
1704 ', status: ' + this.result.status;
1705};
1706, lib.TestManager.Result.prototype.run = function() {
1707 this.startDate = new Date, this.test.run(this),
1708 this.status != this.PENDING || this.timeout_ ||
1709 (this.println(
1710 'Test did not return a value and did not request more time.'),
1711 this.completeTest_(this.FAILED, !1));
1712};
1713, lib.TestManager.Result.prototype.expectErrorMessage = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001714 this.expectedErrorMessage_ = e;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001715};
1716, lib.TestManager.Result.prototype.onTimeout_ = function() {
1717 this.timeout_ = null,
1718 this.status == this.PENDING &&
1719 (this.println('Test timed out.'), this.completeTest_(this.FAILED, !1));
1720};
1721, lib.TestManager.Result.prototype.requestTime = function(e) {
1722 this.timeout_ && clearTimeout(this.timeout_),
1723 this.timeout_ = setTimeout(this.onTimeout_.bind(this), e);
1724};
1725, lib.TestManager.Result.prototype.completeTest_ = function(e, t) {
1726 if (this.status == this.PENDING ?
1727 (this.duration = new Date - this.startDate, this.status = e,
1728 this.testRun.onResultComplete(this)) :
1729 this.testRun.onResultReComplete(this, e),
1730 arguments.length < 2 || t)
1731 throw new lib.TestManager.Result.TestComplete(this);
1732};
1733, lib.TestManager.Result.prototype.arrayEQ_ = function(e, t) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001734 if (!e || !t) return !e && !t;
1735 if (e.length != t.length) return !1;
1736 for (var r = 0; r < e.length; ++r)
1737 if (e[r] != t[r]) return !1;
1738 return !0;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001739};
1740, lib.TestManager.Result.prototype.assertEQ = function(e, t, r) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001741 function o(e) {
1742 if ('number' == typeof e) return e;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001743 var t = String(e), r = t.split('\n').map(function(e) {
1744 return JSON.stringify(e);
1745 });
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001746 return r.length > 1 ? '\n' + r.join('\n') : r.join('\n');
1747 }
1748 if (e !== t && !(t instanceof Array && this.arrayEQ_(e, t))) {
1749 var i = r ? '[' + r + ']' : '';
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001750 this.fail(
1751 'assertEQ' + i + ': ' + this.getCallerLocation_(1) + ': ' + o(e) +
1752 ' !== ' + o(t));
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001753 }
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001754};
1755, lib.TestManager.Result.prototype.assert = function(e, t) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001756 if (e !== !0) {
1757 var r = t ? '[' + t + ']' : '';
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001758 this.fail(
1759 'assert' + r + ': ' + this.getCallerLocation_(1) + ': ' + String(e));
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001760 }
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001761};
1762, lib.TestManager.Result.prototype.getCallerLocation_ = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001763 try {
1764 throw new Error;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001765 } catch (t) {
1766 var r = t.stack.split('\n')[e + 2], o = r.match(/([^\/]+:\d+):\d+\)?$/);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001767 return o ? o[1] : '???';
1768 }
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001769};
1770, lib.TestManager.Result.prototype.println = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001771 this.testRun.log.println(e);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001772};
1773, lib.TestManager.Result.prototype.fail = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001774 arguments.length && this.println(e), this.completeTest_(this.FAILED, !0);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001775};
1776, lib.TestManager.Result.prototype.pass = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001777 this.completeTest_(this.PASSED, !0);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001778};
1779, lib.UTF8Decoder = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001780 this.bytesLeft = 0, this.codePoint = 0, this.lowerBound = 0;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001781};
1782, lib.UTF8Decoder.prototype.decode = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001783 for (var t = '', r = 0; r < e.length; r++) {
1784 var o = e.charCodeAt(r);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001785 if (0 == this.bytesLeft)
1786 127 >= o ?
1787 t += e.charAt(r) :
1788 o >= 192 && 223 >= o ?
1789 (this.codePoint = o - 192, this.bytesLeft = 1,
1790 this.lowerBound = 128) :
1791 o >= 224 && 239 >= o ?
1792 (this.codePoint = o - 224, this.bytesLeft = 2,
1793 this.lowerBound = 2048) :
1794 o >= 240 && 247 >= o ?
1795 (this.codePoint = o - 240, this.bytesLeft = 3,
1796 this.lowerBound = 65536) :
1797 o >= 248 && 251 >= o ?
1798 (this.codePoint = o - 248, this.bytesLeft = 4,
1799 this.lowerBound = 2097152) :
1800 o >= 252 && 253 >= o ? (this.codePoint = o - 252, this.bytesLeft = 5,
1801 this.lowerBound = 67108864) :
1802 t += '�';
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001803 else if (o >= 128 && 191 >= o) {
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001804 if (this.bytesLeft--, this.codePoint = (this.codePoint << 6) + (o - 128),
1805 0 == this.bytesLeft) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001806 var i = this.codePoint;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001807 i<this.lowerBound || i >= 55296 && 57343 >= i || i>1114111 ?
1808 t += '�' :
1809 65536 > i ? t += String.fromCharCode(i) :
1810 (i -= 65536,
1811 t += String.fromCharCode(
1812 55296 + (i >>> 10 & 1023), 56320 + (1023 & i)))
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001813 }
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001814 } else
1815 t += '�', this.bytesLeft = 0, r--;
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001816 }
1817 return t;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001818};
1819, lib.decodeUTF8 = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001820 return (new lib.UTF8Decoder).decode(e);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001821};
1822, lib.encodeUTF8 = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001823 for (var t = '', r = 0; r < e.length; r++) {
1824 var o = e.charCodeAt(r);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001825 if (o >= 56320 && 57343 >= o)
1826 o = 65533;
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001827 else if (o >= 55296 && 56319 >= o)
1828 if (r + 1 < e.length) {
1829 var i = e.charCodeAt(r + 1);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001830 i >= 56320 && 57343 >= i ?
1831 (o = 65536 + ((1023 & o) << 10) + (1023 & i), r++) :
1832 o = 65533;
1833 } else
1834 o = 65533;
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001835 var s;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001836 if (127 >= o)
1837 t += e.charAt(r);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001838 else
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001839 for (2047 >= o ?
1840 (t += String.fromCharCode(192 | o >>> 6), s = 1) :
1841 65535 >= o ? (t += String.fromCharCode(224 | o >>> 12), s = 2) :
1842 (t += String.fromCharCode(240 | o >>> 18), s = 3);
1843 s > 0;)
1844 s--, t += String.fromCharCode(128 | o >>> 6 * s & 63);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001845 }
1846 return t;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001847};
1848,
1849 String.prototype.codePointAt ||
1850 !function() {
1851 var e = function(e) {
1852 if (null == this) throw TypeError();
1853 var t = String(this), r = t.length, o = e ? Number(e) : 0;
1854 if (o != o && (o = 0), 0 > o || o >= r) return void 0;
1855 var i, s = t.charCodeAt(o);
1856 return s >= 55296 && 56319 >= s && r > o + 1 &&
1857 (i = t.charCodeAt(o + 1), i >= 56320 && 57343 >= i) ?
1858 1024 * (s - 55296) + i - 56320 + 65536 :
1859 s;
1860 };
1861 Object.defineProperty ? Object.defineProperty(
1862 String.prototype, 'codePointAt',
1863 {value: e, configurable: !0, writable: !0}) :
1864 String.prototype.codePointAt = e;
1865 }(),
1866 lib.wc = {}, lib.wc.nulWidth = 0, lib.wc.controlWidth = 0,
1867 lib.wc.regardCjkAmbiguous = !1, lib.wc.cjkAmbiguousWidth = 2,
1868 lib.wc.combining =
1869 [
1870 [768, 879], [1155, 1158], [1160, 1161],
1871 [1425, 1469], [1471, 1471], [1473, 1474],
1872 [1476, 1477], [1479, 1479], [1536, 1539],
1873 [1552, 1557], [1611, 1630], [1648, 1648],
1874 [1750, 1764], [1767, 1768], [1770, 1773],
1875 [1807, 1807], [1809, 1809], [1840, 1866],
1876 [1958, 1968], [2027, 2035], [2305, 2306],
1877 [2364, 2364], [2369, 2376], [2381, 2381],
1878 [2385, 2388], [2402, 2403], [2433, 2433],
1879 [2492, 2492], [2497, 2500], [2509, 2509],
1880 [2530, 2531], [2561, 2562], [2620, 2620],
1881 [2625, 2626], [2631, 2632], [2635, 2637],
1882 [2672, 2673], [2689, 2690], [2748, 2748],
1883 [2753, 2757], [2759, 2760], [2765, 2765],
1884 [2786, 2787], [2817, 2817], [2876, 2876],
1885 [2879, 2879], [2881, 2883], [2893, 2893],
1886 [2902, 2902], [2946, 2946], [3008, 3008],
1887 [3021, 3021], [3134, 3136], [3142, 3144],
1888 [3146, 3149], [3157, 3158], [3260, 3260],
1889 [3263, 3263], [3270, 3270], [3276, 3277],
1890 [3298, 3299], [3393, 3395], [3405, 3405],
1891 [3530, 3530], [3538, 3540], [3542, 3542],
1892 [3633, 3633], [3636, 3642], [3655, 3662],
1893 [3761, 3761], [3764, 3769], [3771, 3772],
1894 [3784, 3789], [3864, 3865], [3893, 3893],
1895 [3895, 3895], [3897, 3897], [3953, 3966],
1896 [3968, 3972], [3974, 3975], [3984, 3991],
1897 [3993, 4028], [4038, 4038], [4141, 4144],
1898 [4146, 4146], [4150, 4151], [4153, 4153],
1899 [4184, 4185], [4448, 4607], [4959, 4959],
1900 [5906, 5908], [5938, 5940], [5970, 5971],
1901 [6002, 6003], [6068, 6069], [6071, 6077],
1902 [6086, 6086], [6089, 6099], [6109, 6109],
1903 [6155, 6157], [6313, 6313], [6432, 6434],
1904 [6439, 6440], [6450, 6450], [6457, 6459],
1905 [6679, 6680], [6912, 6915], [6964, 6964],
1906 [6966, 6970], [6972, 6972], [6978, 6978],
1907 [7019, 7027], [7616, 7626], [7678, 7679],
1908 [8203, 8207], [8234, 8238], [8288, 8291],
1909 [8298, 8303], [8400, 8431], [12330, 12335],
1910 [12441, 12442], [43014, 43014], [43019, 43019],
1911 [43045, 43046], [64286, 64286], [65024, 65039],
1912 [65056, 65059], [65279, 65279], [65529, 65531],
1913 [68097, 68099], [68101, 68102], [68108, 68111],
1914 [68152, 68154], [68159, 68159], [119143, 119145],
1915 [119155, 119170], [119173, 119179], [119210, 119213],
1916 [119362, 119364], [917505, 917505], [917536, 917631],
1917 [917760, 917999]
1918 ],
1919 lib.wc.ambiguous =
1920 [
1921 [161, 161], [164, 164], [167, 168],
1922 [170, 170], [174, 174], [176, 180],
1923 [182, 186], [188, 191], [198, 198],
1924 [208, 208], [215, 216], [222, 225],
1925 [230, 230], [232, 234], [236, 237],
1926 [240, 240], [242, 243], [247, 250],
1927 [252, 252], [254, 254], [257, 257],
1928 [273, 273], [275, 275], [283, 283],
1929 [294, 295], [299, 299], [305, 307],
1930 [312, 312], [319, 322], [324, 324],
1931 [328, 331], [333, 333], [338, 339],
1932 [358, 359], [363, 363], [462, 462],
1933 [464, 464], [466, 466], [468, 468],
1934 [470, 470], [472, 472], [474, 474],
1935 [476, 476], [593, 593], [609, 609],
1936 [708, 708], [711, 711], [713, 715],
1937 [717, 717], [720, 720], [728, 731],
1938 [733, 733], [735, 735], [913, 929],
1939 [931, 937], [945, 961], [963, 969],
1940 [1025, 1025], [1040, 1103], [1105, 1105],
1941 [8208, 8208], [8211, 8214], [8216, 8217],
1942 [8220, 8221], [8224, 8226], [8228, 8231],
1943 [8240, 8240], [8242, 8243], [8245, 8245],
1944 [8251, 8251], [8254, 8254], [8308, 8308],
1945 [8319, 8319], [8321, 8324], [8364, 8364],
1946 [8451, 8451], [8453, 8453], [8457, 8457],
1947 [8467, 8467], [8470, 8470], [8481, 8482],
1948 [8486, 8486], [8491, 8491], [8531, 8532],
1949 [8539, 8542], [8544, 8555], [8560, 8569],
1950 [8592, 8601], [8632, 8633], [8658, 8658],
1951 [8660, 8660], [8679, 8679], [8704, 8704],
1952 [8706, 8707], [8711, 8712], [8715, 8715],
1953 [8719, 8719], [8721, 8721], [8725, 8725],
1954 [8730, 8730], [8733, 8736], [8739, 8739],
1955 [8741, 8741], [8743, 8748], [8750, 8750],
1956 [8756, 8759], [8764, 8765], [8776, 8776],
1957 [8780, 8780], [8786, 8786], [8800, 8801],
1958 [8804, 8807], [8810, 8811], [8814, 8815],
1959 [8834, 8835], [8838, 8839], [8853, 8853],
1960 [8857, 8857], [8869, 8869], [8895, 8895],
1961 [8978, 8978], [9312, 9449], [9451, 9547],
1962 [9552, 9587], [9600, 9615], [9618, 9621],
1963 [9632, 9633], [9635, 9641], [9650, 9651],
1964 [9654, 9655], [9660, 9661], [9664, 9665],
1965 [9670, 9672], [9675, 9675], [9678, 9681],
1966 [9698, 9701], [9711, 9711], [9733, 9734],
1967 [9737, 9737], [9742, 9743], [9748, 9749],
1968 [9756, 9756], [9758, 9758], [9792, 9792],
1969 [9794, 9794], [9824, 9825], [9827, 9829],
1970 [9831, 9834], [9836, 9837], [9839, 9839],
1971 [10045, 10045], [10102, 10111], [57344, 63743],
1972 [65533, 65533], [983040, 1048573], [1048576, 1114109]
1973 ],
1974 lib.wc.isSpace = function(e) {
1975 var t, r = 0, o = lib.wc.combining.length - 1;
1976 if (e < lib.wc.combining[0][0] || e > lib.wc.combining[o][1]) return !1;
1977 for (; o >= r;)
1978 if (t = Math.floor((r + o) / 2), e > lib.wc.combining[t][1])
1979 r = t + 1;
1980 else {
1981 if (!(e < lib.wc.combining[t][0])) return !0;
1982 o = t - 1;
1983 }
1984 return !1;
1985 };
1986, lib.wc.isCjkAmbiguous = function(e) {
1987 var t, r = 0, o = lib.wc.ambiguous.length - 1;
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001988 if (e < lib.wc.ambiguous[0][0] || e > lib.wc.ambiguous[o][1]) return !1;
1989 for (; o >= r;)
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001990 if (t = Math.floor((r + o) / 2), e > lib.wc.ambiguous[t][1])
1991 r = t + 1;
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001992 else {
1993 if (!(e < lib.wc.ambiguous[t][0])) return !0;
1994 o = t - 1;
1995 }
1996 return !1;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07001997};
1998, lib.wc.charWidth = function(e) {
1999 return lib.wc.regardCjkAmbiguous ? lib.wc.charWidthRegardAmbiguous(e) :
2000 lib.wc.charWidthDisregardAmbiguous(e);
2001};
2002, lib.wc.charWidthDisregardAmbiguous = function(e) {
2003 return 0 === e ?
2004 lib.wc.nulWidth :
2005 32 > e || e >= 127 && 160 > e ? lib.wc.controlWidth :
2006 127 > e ? 1 :
2007 lib.wc.isSpace(e) ? 0 :
2008 1 +
2009 (e >= 4352 &&
2010 (4447 >= e || 9001 == e || 9002 == e ||
2011 e >= 11904 && 42191 >= e && 12351 != e ||
2012 e >= 44032 && 55203 >= e || e >= 63744 && 64255 >= e ||
2013 e >= 65040 && 65049 >= e || e >= 65072 && 65135 >= e ||
2014 e >= 65280 && 65376 >= e || e >= 65504 && 65510 >= e ||
2015 e >= 131072 && 196605 >= e ||
2016 e >= 196608 && 262141 >= e))
2017};
2018, lib.wc.charWidthRegardAmbiguous = function(e) {
2019 return lib.wc.isCjkAmbiguous(e) ? lib.wc.cjkAmbiguousWidth :
2020 lib.wc.charWidthDisregardAmbiguous(e);
2021};
2022, lib.wc.strWidth = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002023 for (var t, r = 0, o = 0; o < e.length;) {
2024 var i = e.codePointAt(o);
2025 if (t = lib.wc.charWidth(i), 0 > t) return -1;
2026 r += t, o += 65535 >= i ? 1 : 2;
2027 }
2028 return r;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002029};
2030, lib.wc.substr = function(e, t, r) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002031 var o, i, s;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002032 for (o = 0, s = 0;
2033 o < e.length && (s += lib.wc.charWidth(e.charCodeAt(o)), !(s > t)); o++)
2034 ;
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002035 if (void 0 != r) {
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002036 for (i = o, s = 0; i < e.length && r > s;
2037 s += lib.wc.charWidth(e.charCodeAt(i)), i++)
2038 ;
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002039 return s > r && i--, e.substring(o, i);
2040 }
2041 return e.substr(o);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002042};
2043, lib.wc.substring = function(e, t, r) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002044 return lib.wc.substr(e, t, r - t);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002045};
2046, lib.resource.add('libdot/changelog/version', 'text/plain', '1.11'),
2047 lib.resource.add('libdot/changelog/date', 'text/plain', '2017-04-17'),
2048 lib.rtdep('lib.Storage');
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002049var hterm = {};
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002050hterm.windowType = null,
2051 hterm.zoomWarningMessage = 'ZOOM != 100%', hterm.notifyCopyMessage = '✂',
2052 hterm.desktopNotificationTitle = '♪ %(title) ♪',
2053 hterm.testDeps =
2054 [
2055 'hterm.ScrollPort.Tests', 'hterm.Screen.Tests',
2056 'hterm.Terminal.Tests', 'hterm.VT.Tests', 'hterm.VT.CannedTests'
2057 ],
2058 lib.registerInit('hterm', function(e) {
2059 function t(t) {
2060 hterm.windowType = t.type, setTimeout(e, 0);
2061 }
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002062
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002063 function r(r) {
2064 r && window.chrome ? chrome.windows.get(r.windowId, null, t) :
2065 (hterm.windowType = 'normal', setTimeout(e, 0));
2066 }
2067 if (!hterm.defaultStorage) {
2068 var o = navigator.userAgent.match(/\sChrome\/(\d\d)/),
2069 i = o ? parseInt(o[1]) : -1;
2070 window.chrome &&chrome.storage &&chrome.storage.sync &&i > 21 ?
2071 hterm.defaultStorage = new lib.Storage.Chrome(chrome.storage.sync) :
2072 hterm.defaultStorage = new lib.Storage.Local;
2073 }
2074 var s = !1;
2075 if (window.chrome && chrome.runtime && chrome.runtime.getManifest) {
2076 var n = chrome.runtime.getManifest();
2077 s = n.app && n.app.background;
2078 }
2079 s ? setTimeout(t.bind(null, {type: 'popup'}), 0) :
2080 window.chrome && chrome.tabs ?
2081 chrome.tabs.getCurrent(r) :
2082 setTimeout(t.bind(null, {type: 'normal'}), 0)
2083 }), hterm.getClientSize = function(e) {
2084 return e.getBoundingClientRect();
2085 };
2086, hterm.getClientWidth = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002087 return e.getBoundingClientRect().width;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002088};
2089, hterm.getClientHeight = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002090 return e.getBoundingClientRect().height;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002091};
2092, hterm.copySelectionToClipboard = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002093 try {
2094 e.execCommand('copy');
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002095 } catch (t) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002096 }
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002097};
2098, hterm.pasteFromClipboard = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002099 try {
2100 e.execCommand('paste');
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002101 } catch (t) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002102 }
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002103};
2104, hterm.Size = function(e, t) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002105 this.width = e, this.height = t;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002106};
2107, hterm.Size.prototype.resize = function(e, t) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002108 this.width = e, this.height = t;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002109};
2110, hterm.Size.prototype.clone = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002111 return new hterm.Size(this.width, this.height);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002112};
2113, hterm.Size.prototype.setTo = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002114 this.width = e.width, this.height = e.height;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002115};
2116, hterm.Size.prototype.equals = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002117 return this.width == e.width && this.height == e.height;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002118};
2119, hterm.Size.prototype.toString = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002120 return '[hterm.Size: ' + this.width + ', ' + this.height + ']';
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002121};
2122, hterm.RowCol = function(e, t, r) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002123 this.row = e, this.column = t, this.overflow = !!r;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002124};
2125, hterm.RowCol.prototype.move = function(e, t, r) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002126 this.row = e, this.column = t, this.overflow = !!r;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002127};
2128, hterm.RowCol.prototype.clone = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002129 return new hterm.RowCol(this.row, this.column, this.overflow);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002130};
2131, hterm.RowCol.prototype.setTo = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002132 this.row = e.row, this.column = e.column, this.overflow = e.overflow;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002133};
2134, hterm.RowCol.prototype.equals = function(e) {
2135 return this.row == e.row && this.column == e.column &&
2136 this.overflow == e.overflow;
2137};
2138, hterm.RowCol.prototype.toString = function() {
2139 return '[hterm.RowCol: ' + this.row + ', ' + this.column + ', ' +
2140 this.overflow + ']';
2141};
2142, lib.rtdep('lib.f'), hterm.Frame = function(e, t, r) {
2143 this.terminal_ = e, this.div_ = e.div_, this.url = t, this.options = r || {},
2144 this.iframe_ = null, this.container_ = null, this.messageChannel_ = null;
2145};
2146, hterm.Frame.prototype.onMessage_ = function(e) {
2147 return 'ipc-init-ok' != e.data.name ?
2148 void console.log('Unknown message from frame:', e.data) :
2149 (this.sendTerminalInfo_(),
2150 this.messageChannel_.port1.onmessage = this.onMessage.bind(this),
2151 void this.onLoad());
2152};
2153, hterm.Frame.prototype.onMessage = function() {};
2154, hterm.Frame.prototype.onLoad_ = function() {
2155 this.messageChannel_ = new MessageChannel,
2156 this.messageChannel_.port1.onmessage = this.onMessage_.bind(this),
2157 this.messageChannel_.port1.start(),
2158 this.iframe_.contentWindow.postMessage(
2159 {name: 'ipc-init', argv: [{messagePort: this.messageChannel_.port2}]},
2160 this.url, [this.messageChannel_.port2]);
2161};
2162, hterm.Frame.prototype.onLoad = function() {};
2163, hterm.Frame.prototype.sendTerminalInfo_ = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002164 lib.f.getAcceptLanguages(function(e) {
2165 this.postMessage('terminal-info', [{
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002166 acceptLanguages: e,
2167 foregroundColor: this.terminal_.getForegroundColor(),
2168 backgroundColor: this.terminal_.getBackgroundColor(),
2169 cursorColor: this.terminal_.getCursorColor(),
2170 fontSize: this.terminal_.getFontSize(),
2171 fontFamily: this.terminal_.getFontFamily(),
2172 baseURL: lib.f.getURL('/')
2173 }]);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002174 }.bind(this));
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002175};
2176, hterm.Frame.prototype.onCloseClicked_ = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002177 this.close();
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002178};
2179, hterm.Frame.prototype.close = function() {
2180 this.container_ && this.container_.parentNode &&
2181 (this.container_.parentNode.removeChild(this.container_), this.onClose());
2182};
2183, hterm.Frame.prototype.onClose = function() {};
2184, hterm.Frame.prototype.postMessage = function(e, t) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002185 if (!this.messageChannel_) throw new Error('Message channel is not set up.');
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002186 this.messageChannel_.port1.postMessage({name: e, argv: t});
2187};
2188, hterm.Frame.prototype.show = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002189 function e(e, r) {
2190 return e in t.options ? t.options[e] : r;
2191 }
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002192 var t = this, t = this;
2193 if (this.container_ && this.container_.parentNode)
2194 return void console.error('Frame already visible');
2195 var r = '16px', o = hterm.getClientSize(this.div_), i = e('width', 640),
2196 s = e('height', 480),
2197 n = ((o.width - i) / 2, (o.height - s) / 2, this.terminal_.document_),
2198 a = this.container_ = n.createElement('div');
2199 a.style.cssText =
2200 'position: absolute;display: -webkit-flex;-webkit-flex-direction: column;top: 10%;left: 4%;width: 90%;height: 80%;box-shadow: 0 0 2px ' +
2201 this.terminal_.getForegroundColor() + ';border: 2px ' +
2202 this.terminal_.getForegroundColor() + ' solid;';
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002203 var l = n.createElement('div');
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002204 l.style.cssText =
2205 'display: -webkit-flex;-webkit-justify-content: flex-end;height: ' + r +
2206 ';background-color: ' + this.terminal_.getForegroundColor() +
2207 ';color: ' + this.terminal_.getBackgroundColor() +
2208 ';font-size: 16px;font-family: ' + this.terminal_.getFontFamily(),
2209 a.appendChild(l);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002210 var h = this.iframe_ = n.createElement('iframe');
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002211 h.onload = this.onLoad_.bind(this),
2212 h.style.cssText = 'display: -webkit-flex;-webkit-flex: 1;width: 100%',
2213 h.setAttribute('src', this.url), h.setAttribute('seamless', !0),
2214 a.appendChild(h), this.div_.appendChild(a);
2215};
2216, lib.rtdep('hterm.Keyboard.KeyMap'), hterm.Keyboard = function(e) {
2217 this.terminal = e, this.keyboardElement_ = null,
2218 this.handlers_ =
2219 [
2220 ['focusout', this.onFocusOut_.bind(this)],
2221 ['keydown', this.onKeyDown_.bind(this)],
2222 ['keypress', this.onKeyPress_.bind(this)],
2223 ['keyup', this.onKeyUp_.bind(this)],
2224 ['textInput', this.onTextInput_.bind(this)]
2225 ],
2226 this.keyMap = new hterm.Keyboard.KeyMap(this),
2227 this.bindings = new hterm.Keyboard.Bindings(this), this.altGrMode = 'none',
2228 this.shiftInsertPaste = !0, this.homeKeysScroll = !1,
2229 this.pageKeysScroll = !1, this.ctrlPlusMinusZeroZoom = !0,
2230 this.ctrlCCopy = !1, this.ctrlVPaste = !1, this.applicationKeypad = !1,
2231 this.applicationCursor = !1, this.backspaceSendsBackspace = !1,
2232 this.characterEncoding = 'utf-8', this.metaSendsEscape = !0,
2233 this.passMetaV = !0, this.altSendsWhat = 'escape', this.altIsMeta = !1,
2234 this.altBackspaceIsMetaBackspace = !1, this.altKeyPressed = 0,
2235 this.mediaKeysAreFKeys = !1, this.previousAltSendsWhat_ = null;
2236};
2237, hterm.Keyboard.KeyActions = {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002238 CANCEL: new String('CANCEL'),
2239 DEFAULT: new String('DEFAULT'),
2240 PASS: new String('PASS'),
2241 STRIP: new String('STRIP')
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002242},
2243 hterm.Keyboard.prototype.encode = function(e) {
2244 return 'utf-8' == this.characterEncoding ? this.terminal.vt.encodeUTF8(e) :
2245 e;
2246 };
2247, hterm.Keyboard.prototype.installKeyboard = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002248 if (e != this.keyboardElement_) {
2249 e && this.keyboardElement_ && this.installKeyboard(null);
2250 for (var t = 0; t < this.handlers_.length; t++) {
2251 var r = this.handlers_[t];
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002252 e ? e.addEventListener(r[0], r[1]) :
2253 this.keyboardElement_.removeEventListener(r[0], r[1]);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002254 }
2255 this.keyboardElement_ = e;
2256 }
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002257};
2258, hterm.Keyboard.prototype.uninstallKeyboard = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002259 this.installKeyboard(null);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002260};
2261, hterm.Keyboard.prototype.onTextInput_ = function(e) {
2262 e.data &&
2263 e.data.split('').forEach(this.terminal.onVTKeystroke.bind(this.terminal));
2264};
2265, hterm.Keyboard.prototype.onKeyPress_ = function(e) {
2266 var t, r = String.fromCharCode(e.which), o = r.toLowerCase();
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002267 if (!e.ctrlKey && !e.metaKey || 'c' != o && 'v' != o) {
2268 if (e.altKey && 'browser-key' == this.altSendsWhat && 0 == e.charCode) {
2269 var i = String.fromCharCode(e.keyCode);
2270 e.shiftKey || (i = i.toLowerCase()), t = i.charCodeAt(0) + 128;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002271 } else
2272 e.charCode >= 32 && (i = e.charCode);
2273 i && this.terminal.onVTKeystroke(String.fromCharCode(i)),
2274 e.preventDefault(), e.stopPropagation();
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002275 }
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002276};
2277, hterm.Keyboard.prototype.preventChromeAppNonCtrlShiftDefault_ = function(e) {
2278 window.chrome && window.chrome.app && window.chrome.app.window &&
2279 (e.ctrlKey && e.shiftKey || e.preventDefault());
2280};
2281, hterm.Keyboard.prototype.onFocusOut_ = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002282 this.altKeyPressed = 0;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002283};
2284, hterm.Keyboard.prototype.onKeyUp_ = function(e) {
2285 18 == e.keyCode &&
2286 (this.altKeyPressed = this.altKeyPressed & ~(1 << e.location - 1)),
2287 27 == e.keyCode && this.preventChromeAppNonCtrlShiftDefault_(e);
2288};
2289, hterm.Keyboard.prototype.onKeyDown_ = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002290 function t(s) {
2291 o = s;
2292 var a = r[s];
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002293 return 'function' == typeof a && (a = a.apply(i.keyMap, [e, r])),
2294 a === n && 'normal' != s && (a = t('normal')), a;
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002295 }
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002296 18 == e.keyCode &&
2297 (this.altKeyPressed = this.altKeyPressed | 1 << e.location - 1),
2298 27 == e.keyCode && this.preventChromeAppNonCtrlShiftDefault_(e);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002299 var r = this.keyMap.keyDefs[e.keyCode];
2300 if (!r) return void console.warn('No definition for keyCode: ' + e.keyCode);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002301 var o = null, i = this, s = hterm.Keyboard.KeyActions.CANCEL,
2302 n = hterm.Keyboard.KeyActions.DEFAULT, a = hterm.Keyboard.KeyActions.PASS,
2303 l = hterm.Keyboard.KeyActions.STRIP, h = e.ctrlKey,
2304 c = this.altIsMeta ? !1 : e.altKey,
2305 u = this.altIsMeta ? e.altKey || e.metaKey : e.metaKey,
2306 g = !/^\[\w+\]$/.test(r.keyCap);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002307 switch (this.altGrMode) {
2308 case 'ctrl-alt':
2309 g && h && c && (h = !1, c = !1);
2310 break;
2311 case 'right-alt':
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002312 g && 2&this.terminal.keyboard.altKeyPressed && (h = !1, c = !1);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002313 break;
2314 case 'left-alt':
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002315 g && 1&this.terminal.keyboard.altKeyPressed && (h = !1, c = !1);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002316 }
2317 var d;
2318 d = t(h ? 'control' : c ? 'alt' : u ? 'meta' : 'normal');
2319 var p = !e.maskShiftKey && e.shiftKey,
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002320 m = {keyCode: e.keyCode, shift: e.shiftKey, ctrl: h, alt: c, meta: u},
2321 b = this.bindings.getBinding(m);
2322 if (b &&
2323 (p = h = c = u = !1, o = 'normal', d = b.action,
2324 'function' == typeof d && (d = d.call(this, this.terminal, m))),
2325 c && 'browser-key' == this.altSendsWhat && d == n && (d = a),
2326 d !== a && (d !== n || h || c || u) &&
2327 (d === l &&
2328 (c = h = !1, d = r.normal,
2329 'function' == typeof d && (d = d.apply(this.keyMap, [e, r])),
2330 d == n && 2 == r.keyCap.length &&
2331 (d = r.keyCap.substr(p ? 1 : 0, 1))),
2332 e.preventDefault(), e.stopPropagation(), d !== s)) {
2333 if (d !== n && 'string' != typeof d)
2334 return void console.warn('Invalid action: ' + JSON.stringify(d));
2335 if ('control' == o ? h = !1 : 'alt' == o ? c = !1 : 'meta' == o && (u = !1),
2336 '[' == d.substr(0, 2) && (c || h || p)) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002337 var f;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002338 !p || c || h ? !c || p || h ?
2339 p && c && !h ?
2340 f = ';4' :
2341 !h || p || c ?
2342 p && h && !c ?
2343 f = ';6' :
2344 c && h && !p ? f = ';7' : p && c && h && (f = ';8') :
2345 f = ';5' :
2346 f = ';3' :
2347 f = ';2',
2348 d = 3 == d.length ?
2349 '[1' + f + d.substr(2, 1) :
2350 d.substr(0, d.length - 1) + f + d.substr(d.length - 1);
2351 } else {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002352 if (d === n && (d = r.keyCap.substr(p ? 1 : 0, 1), h)) {
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002353 var y = r.keyCap.substr(0, 1), _ = y.charCodeAt(0);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002354 _ >= 64 && 95 >= _ && (d = String.fromCharCode(_ - 64));
2355 }
2356 if (c && '8-bit' == this.altSendsWhat && 1 == d.length) {
2357 var _ = d.charCodeAt(0) + 128;
2358 d = String.fromCharCode(_);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002359 }
2360 (c && 'escape' == this.altSendsWhat || u && this.metaSendsEscape) &&
2361 (d = '' + d);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002362 }
2363 this.terminal.onVTKeystroke(d);
2364 }
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002365};
2366, hterm.Keyboard.Bindings = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002367 this.bindings_ = {};
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002368};
2369, hterm.Keyboard.Bindings.prototype.clear = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002370 this.bindings_ = {};
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002371};
2372, hterm.Keyboard.Bindings.prototype.addBinding_ = function(e, t) {
2373 var r = null, o = this.bindings_[e.keyCode];
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002374 if (o)
2375 for (var i = 0; i < o.length; i++)
2376 if (o[i].keyPattern.matchKeyPattern(e)) {
2377 r = o[i];
2378 break;
2379 }
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002380 r ? r.action = t :
2381 (r = {keyPattern: e, action: t},
2382 o ? (this.bindings_[e.keyCode].push(r), o.sort(function(e, t) {
2383 return hterm.Keyboard.KeyPattern.sortCompare(
2384 e.keyPattern, t.keyPattern);
2385 })) :
2386 this.bindings_[e.keyCode] = [r]);
2387};
2388, hterm.Keyboard.Bindings.prototype.addBinding = function(e, t) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002389 if ('string' != typeof e) return void this.addBinding_(e, t);
2390 var r = new hterm.Parser;
2391 r.reset(e);
2392 var o;
2393 try {
2394 o = r.parseKeySequence();
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002395 } catch (i) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002396 return void console.error(i);
2397 }
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002398 if (!r.isComplete())
2399 return void console.error(r.error('Expected end of sequence: ' + o));
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002400 if ('string' == typeof t) {
2401 r.reset(t);
2402 try {
2403 t = r.parseKeyAction();
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002404 } catch (i) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002405 return void console.error(i);
2406 }
2407 }
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002408 return r.isComplete() ?
2409 void this.addBinding_(new hterm.Keyboard.KeyPattern(o), t) :
2410 void console.error(r.error('Expected end of sequence: ' + o));
2411};
2412, hterm.Keyboard.Bindings.prototype.addBindings = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002413 for (var t in e) this.addBinding(t, e[t]);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002414};
2415, hterm.Keyboard.Bindings.prototype.getBinding = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002416 var t = this.bindings_[e.keyCode];
2417 if (!t) return null;
2418 for (var r = 0; r < t.length; r++) {
2419 var o = t[r];
2420 if (o.keyPattern.matchKeyDown(e)) return o;
2421 }
2422 return null;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002423};
2424, lib.rtdep('hterm.Keyboard.KeyActions'), hterm.Keyboard.KeyMap = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002425 this.keyboard = e, this.keyDefs = {}, this.reset();
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002426};
2427, hterm.Keyboard.KeyMap.prototype.addKeyDef = function(e, t) {
2428 e in this.keyDefs && console.warn('Duplicate keyCode: ' + e),
2429 this.keyDefs[e] = t;
2430};
2431, hterm.Keyboard.KeyMap.prototype.addKeyDefs = function(e) {
2432 for (var t = 0; t < arguments.length; t++)
2433 this.addKeyDef(arguments[t][0], {
2434 keyCap: arguments[t][1],
2435 normal: arguments[t][2],
2436 control: arguments[t][3],
2437 alt: arguments[t][4],
2438 meta: arguments[t][5]
2439 });
2440};
2441, hterm.Keyboard.KeyMap.prototype.reset = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002442 function e(e, t, r) {
2443 return 'function' == typeof e ? e.apply(h, [t, r]) : e;
2444 }
2445
2446 function t(t, r) {
2447 return function(o, i) {
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002448 var s = o.shiftKey || o.ctrlKey || o.altKey || o.metaKey ||
2449 !h.keyboard.applicationCursor ?
2450 t :
2451 r;
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002452 return e(s, o, i);
2453 }
2454 }
2455
2456 function r(t, r) {
2457 return function(o, i) {
2458 var s = h.keyboard.backspaceSendsBackspace ? r : t;
2459 return e(s, o, i);
2460 }
2461 }
2462
2463 function o(t, r) {
2464 return function(o, i) {
2465 var s = o.shiftKey ? r : t;
2466 return o.maskShiftKey = !0, e(s, o, i);
2467 }
2468 }
2469
2470 function i(t, r) {
2471 return function(o, i) {
2472 var s = o.altKey ? r : t;
2473 return e(s, o, i);
2474 }
2475 }
2476
2477 function s(t, r) {
2478 return function(o, i) {
2479 var s = o.shiftKey || o.ctrlKey || o.altKey || o.metaKey ? r : t;
2480 return e(s, o, i);
2481 }
2482 }
2483
2484 function n(e) {
2485 return String.fromCharCode(e.charCodeAt(0) - 64);
2486 }
2487
2488 function a(e) {
2489 return function(t, r) {
2490 return this[e](t, r);
2491 }
2492 }
2493
2494 function l(t) {
2495 return function(r, o) {
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002496 return h.keyboard.mediaKeysAreFKeys ?
2497 e(t, r, o) :
2498 166 == r.keyCode || 167 == r.keyCode || 168 == r.keyCode ?
2499 hterm.Keyboard.KeyActions.CANCEL :
2500 hterm.Keyboard.KeyActions.PASS
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002501 }
2502 }
2503 this.keyDefs = {};
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002504 var h = this, c = '', u = '[', g = 'O',
2505 d = hterm.Keyboard.KeyActions.CANCEL,
2506 p = hterm.Keyboard.KeyActions.DEFAULT, m = hterm.Keyboard.KeyActions.PASS,
2507 b = hterm.Keyboard.KeyActions.STRIP;
2508 this.addKeyDefs(
2509 [0, '[UNKNOWN]', m, m, m, m], [27, '[ESC]', c, p, p, p],
2510 [112, '[F1]', s(g + 'P', u + 'P'), p, u + '23~', p],
2511 [113, '[F2]', s(g + 'Q', u + 'Q'), p, u + '24~', p],
2512 [114, '[F3]', s(g + 'R', u + 'R'), p, u + '25~', p],
2513 [115, '[F4]', s(g + 'S', u + 'S'), p, u + '26~', p],
2514 [116, '[F5]', u + '15~', p, u + '28~', p],
2515 [117, '[F6]', u + '17~', p, u + '29~', p],
2516 [118, '[F7]', u + '18~', p, u + '31~', p],
2517 [119, '[F8]', u + '19~', p, u + '32~', p],
2518 [120, '[F9]', u + '20~', p, u + '33~', p],
2519 [121, '[F10]', u + '21~', p, u + '34~', p],
2520 [122, '[F11]', u + '23~', p, u + '42~', p],
2521 [123, '[F12]', u + '24~', p, u + '43~', p],
2522 [192, '`~', p, o(n('@'), n('^')), p, m],
2523 [49, '1!', p, a('onCtrlNum_'), a('onAltNum_'), a('onMetaNum_')],
2524 [50, '2@', p, a('onCtrlNum_'), a('onAltNum_'), a('onMetaNum_')],
2525 [51, '3#', p, a('onCtrlNum_'), a('onAltNum_'), a('onMetaNum_')],
2526 [52, '4$', p, a('onCtrlNum_'), a('onAltNum_'), a('onMetaNum_')],
2527 [53, '5%', p, a('onCtrlNum_'), a('onAltNum_'), a('onMetaNum_')],
2528 [54, '6^', p, a('onCtrlNum_'), a('onAltNum_'), a('onMetaNum_')],
2529 [55, '7&', p, a('onCtrlNum_'), a('onAltNum_'), a('onMetaNum_')],
2530 [56, '8*', p, a('onCtrlNum_'), a('onAltNum_'), a('onMetaNum_')],
2531 [57, '9(', p, a('onCtrlNum_'), a('onAltNum_'), a('onMetaNum_')],
2532 [
2533 48, '0)', p, a('onPlusMinusZero_'), a('onAltNum_'),
2534 a('onPlusMinusZero_')
2535 ],
2536 [189, '-_', p, a('onPlusMinusZero_'), p, a('onPlusMinusZero_')],
2537 [187, '=+', p, a('onPlusMinusZero_'), p, a('onPlusMinusZero_')],
2538 [173, '-_', p, a('onPlusMinusZero_'), p, a('onPlusMinusZero_')],
2539 [61, '=+', p, a('onPlusMinusZero_'), p, a('onPlusMinusZero_')],
2540 [171, '+*', p, a('onPlusMinusZero_'), p, a('onPlusMinusZero_')],
2541 [8, '[BKSP]', r('', '\b'), r('\b', ''), p, p],
2542 [9, '[TAB]', o(' ', u + 'Z'), b, m, p], [81, 'qQ', p, n('Q'), p, p],
2543 [87, 'wW', p, n('W'), p, p], [69, 'eE', p, n('E'), p, p],
2544 [82, 'rR', p, n('R'), p, p], [84, 'tT', p, n('T'), p, p],
2545 [89, 'yY', p, n('Y'), p, p], [85, 'uU', p, n('U'), p, p],
2546 [73, 'iI', p, n('I'), p, p], [79, 'oO', p, n('O'), p, p],
2547 [80, 'pP', p, n('P'), p, p], [219, '[{', p, n('['), p, p],
2548 [221, ']}', p, n(']'), p, p], [220, '\\|', p, n('\\'), p, p],
2549 [20, '[CAPS]', m, m, m, p], [65, 'aA', p, n('A'), p, p],
2550 [83, 'sS', p, n('S'), p, p], [68, 'dD', p, n('D'), p, p],
2551 [70, 'fF', p, n('F'), p, p], [71, 'gG', p, n('G'), p, p],
2552 [72, 'hH', p, n('H'), p, p], [74, 'jJ', p, o(n('J'), m), p, p],
2553 [75, 'kK', p, o(n('K'), a('onClear_')), p, p],
2554 [76, 'lL', p, o(n('L'), m), p, p], [186, ';:', p, b, p, p],
2555 [222, '\'"', p, b, p, p], [13, '[ENTER]', '\r', d, d, p],
2556 [16, '[SHIFT]', m, m, m, p], [90, 'zZ', p, n('Z'), p, p],
2557 [88, 'xX', p, n('X'), p, p],
2558 [67, 'cC', p, a('onCtrlC_'), p, a('onMetaC_')],
2559 [86, 'vV', p, a('onCtrlV_'), p, a('onMetaV_')],
2560 [66, 'bB', p, o(n('B'), m), p, o(p, m)],
2561 [78, 'nN', p, a('onCtrlN_'), p, a('onMetaN_')],
2562 [77, 'mM', p, n('M'), p, p], [188, ',<', p, i(b, m), p, p],
2563 [190, '.>', p, i(b, m), p, p], [191, '/?', p, o(n('_'), n('?')), p, p],
2564 [17, '[CTRL]', m, m, m, m], [18, '[ALT]', m, m, m, m],
2565 [91, '[LAPL]', m, m, m, m], [32, ' ', p, n('@'), p, p],
2566 [92, '[RAPL]', m, m, m, m], [93, '[RMENU]', m, m, m, m],
2567 [42, '[PRTSCR]', m, m, m, m], [145, '[SCRLK]', m, m, m, m],
2568 [19, '[BREAK]', m, m, m, m], [45, '[INSERT]', a('onKeyInsert_'), p, p, p],
2569 [36, '[HOME]', a('onKeyHome_'), p, p, p],
2570 [33, '[PGUP]', a('onKeyPageUp_'), p, p, p],
2571 [46, '[DEL]', a('onKeyDel_'), p, p, p],
2572 [35, '[END]', a('onKeyEnd_'), p, p, p],
2573 [34, '[PGDOWN]', a('onKeyPageDown_'), p, p, p],
2574 [38, '[UP]', t(u + 'A', g + 'A'), p, p, p],
2575 [40, '[DOWN]', t(u + 'B', g + 'B'), p, p, p],
2576 [39, '[RIGHT]', t(u + 'C', g + 'C'), p, p, p],
2577 [37, '[LEFT]', t(u + 'D', g + 'D'), p, p, p],
2578 [144, '[NUMLOCK]', m, m, m, m], [96, '[KP0]', p, p, p, p],
2579 [97, '[KP1]', p, p, p, p], [98, '[KP2]', p, p, p, p],
2580 [99, '[KP3]', p, p, p, p], [100, '[KP4]', p, p, p, p],
2581 [101, '[KP5]', p, p, p, p], [102, '[KP6]', p, p, p, p],
2582 [103, '[KP7]', p, p, p, p], [104, '[KP8]', p, p, p, p],
2583 [105, '[KP9]', p, p, p, p],
2584 [107, '[KP+]', p, a('onPlusMinusZero_'), p, a('onPlusMinusZero_')],
2585 [109, '[KP-]', p, a('onPlusMinusZero_'), p, a('onPlusMinusZero_')],
2586 [106, '[KP*]', p, p, p, p], [111, '[KP/]', p, p, p, p],
2587 [110, '[KP.]', p, p, p, p],
2588 [166, '[BACK]', l(s(g + 'P', u + 'P')), p, u + '23~', p],
2589 [167, '[FWD]', l(s(g + 'Q', u + 'Q')), p, u + '24~', p],
2590 [168, '[RELOAD]', l(s(g + 'R', u + 'R')), p, u + '25~', p],
2591 [183, '[FSCR]', l(s(g + 'S', u + 'S')), p, u + '26~', p],
2592 [182, '[WINS]', l(u + '15~'), p, u + '28~', p],
2593 [216, '[BRIT-]', l(u + '17~'), p, u + '29~', p],
2594 [217, '[BRIT+]', l(u + '18~'), p, u + '31~', p]);
2595};
2596, hterm.Keyboard.KeyMap.prototype.onKeyInsert_ = function(e) {
2597 return this.keyboard.shiftInsertPaste && e.shiftKey ?
2598 hterm.Keyboard.KeyActions.PASS :
2599 '[2~';
2600};
2601, hterm.Keyboard.KeyMap.prototype.onKeyHome_ = function(e) {
2602 return !this.keyboard.homeKeysScroll ^ e.shiftKey ?
2603 e.altey || e.ctrlKey || e.shiftKey || !this.keyboard.applicationCursor ?
2604 '' :
2605 'OH' :
2606 (this.keyboard.terminal.scrollHome(), hterm.Keyboard.KeyActions.CANCEL);
2607};
2608, hterm.Keyboard.KeyMap.prototype.onKeyEnd_ = function(e) {
2609 return !this.keyboard.homeKeysScroll ^ e.shiftKey ?
2610 e.altKey || e.ctrlKey || e.shiftKey || !this.keyboard.applicationCursor ?
2611 '' :
2612 'OF' :
2613 (this.keyboard.terminal.scrollEnd(), hterm.Keyboard.KeyActions.CANCEL);
2614};
2615, hterm.Keyboard.KeyMap.prototype.onKeyPageUp_ = function(e) {
2616 return !this.keyboard.pageKeysScroll ^ e.shiftKey ?
2617 '[5~' :
2618 (this.keyboard.terminal.scrollPageUp(), hterm.Keyboard.KeyActions.CANCEL);
2619};
2620, hterm.Keyboard.KeyMap.prototype.onKeyDel_ = function(e) {
2621 return this.keyboard.altBackspaceIsMetaBackspace &&
2622 this.keyboard.altKeyPressed && !e.altKey ?
2623 '' :
2624 '[3~';
2625};
2626, hterm.Keyboard.KeyMap.prototype.onKeyPageDown_ = function(e) {
2627 return !this.keyboard.pageKeysScroll ^ e.shiftKey ?
2628 '[6~' :
2629 (this.keyboard.terminal.scrollPageDown(),
2630 hterm.Keyboard.KeyActions.CANCEL);
2631};
2632, hterm.Keyboard.KeyMap.prototype.onClear_ = function(e, t) {
2633 return this.keyboard.terminal.wipeContents(),
2634 hterm.Keyboard.KeyActions.CANCEL;
2635};
2636, hterm.Keyboard.KeyMap.prototype.onCtrlNum_ = function(e, t) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002637 function r(e) {
2638 return String.fromCharCode(e.charCodeAt(0) - 64);
2639 }
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002640 if (this.keyboard.terminal.passCtrlNumber && !e.shiftKey)
2641 return hterm.Keyboard.KeyActions.PASS;
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002642 switch (t.keyCap.substr(0, 1)) {
2643 case '1':
2644 return '1';
2645 case '2':
2646 return r('@');
2647 case '3':
2648 return r('[');
2649 case '4':
2650 return r('\\');
2651 case '5':
2652 return r(']');
2653 case '6':
2654 return r('^');
2655 case '7':
2656 return r('_');
2657 case '8':
2658 return '';
2659 case '9':
2660 return '9';
2661 }
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002662};
2663, hterm.Keyboard.KeyMap.prototype.onAltNum_ = function(e, t) {
2664 return this.keyboard.terminal.passAltNumber && !e.shiftKey ?
2665 hterm.Keyboard.KeyActions.PASS :
2666 hterm.Keyboard.KeyActions.DEFAULT;
2667};
2668, hterm.Keyboard.KeyMap.prototype.onMetaNum_ = function(e, t) {
2669 return this.keyboard.terminal.passMetaNumber && !e.shiftKey ?
2670 hterm.Keyboard.KeyActions.PASS :
2671 hterm.Keyboard.KeyActions.DEFAULT;
2672};
2673, hterm.Keyboard.KeyMap.prototype.onCtrlC_ = function(e, t) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002674 var r = this.keyboard.terminal.getDocument().getSelection();
2675 if (!r.isCollapsed) {
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002676 if (this.keyboard.ctrlCCopy && !e.shiftKey)
2677 return this.keyboard.terminal.clearSelectionAfterCopy &&
2678 setTimeout(r.collapseToEnd.bind(r), 50),
2679 hterm.Keyboard.KeyActions.PASS;
2680 if (!this.keyboard.ctrlCCopy && e.shiftKey)
2681 return this.keyboard.terminal.clearSelectionAfterCopy &&
2682 setTimeout(r.collapseToEnd.bind(r), 50),
2683 this.keyboard.terminal.copySelectionToClipboard(),
2684 hterm.Keyboard.KeyActions.CANCEL;
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002685 }
2686 return '';
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002687};
2688, hterm.Keyboard.KeyMap.prototype.onCtrlN_ = function(e, t) {
2689 return e.shiftKey ?
2690 (window.open(
2691 document.location.href, '',
2692 'chrome=no,close=yes,resize=yes,scrollbars=yes,minimizable=yes,width=' +
2693 window.innerWidth + ',height=' + window.innerHeight),
2694 hterm.Keyboard.KeyActions.CANCEL) :
2695 '';
2696};
2697, hterm.Keyboard.KeyMap.prototype.onCtrlV_ = function(e, t) {
2698 return !e.shiftKey && this.keyboard.ctrlVPaste ||
2699 e.shiftKey && !this.keyboard.ctrlVPaste ?
2700 hterm.Keyboard.KeyActions.PASS :
2701 '';
2702};
2703, hterm.Keyboard.KeyMap.prototype.onMetaN_ = function(e, t) {
2704 return e.shiftKey ?
2705 (window.open(
2706 document.location.href, '',
2707 'chrome=no,close=yes,resize=yes,scrollbars=yes,minimizable=yes,width=' +
2708 window.outerWidth + ',height=' + window.outerHeight),
2709 hterm.Keyboard.KeyActions.CANCEL) :
2710 hterm.Keyboard.KeyActions.DEFAULT;
2711};
2712, hterm.Keyboard.KeyMap.prototype.onMetaC_ = function(e, t) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002713 var r = this.keyboard.terminal.getDocument();
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002714 return e.shiftKey || r.getSelection().isCollapsed ?
2715 t.keyCap.substr(e.shiftKey ? 1 : 0, 1) :
2716 (this.keyboard.terminal.clearSelectionAfterCopy && setTimeout(function() {
2717 r.getSelection().collapseToEnd();
2718 }, 50), hterm.Keyboard.KeyActions.PASS);
2719};
2720, hterm.Keyboard.KeyMap.prototype.onMetaV_ = function(e, t) {
2721 return e.shiftKey ?
2722 hterm.Keyboard.KeyActions.PASS :
2723 this.keyboard.passMetaV ? hterm.Keyboard.KeyActions.PASS :
2724 hterm.Keyboard.KeyActions.DEFAULT
2725};
2726, hterm.Keyboard.KeyMap.prototype.onPlusMinusZero_ = function(e, t) {
2727 if (!(this.keyboard.ctrlPlusMinusZeroZoom ^ e.shiftKey))
2728 return '-_' == t.keyCap ? '' : hterm.Keyboard.KeyActions.CANCEL;
2729 if (1 != this.keyboard.terminal.getZoomFactor())
2730 return hterm.Keyboard.KeyActions.PASS;
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002731 var r = t.keyCap.substr(0, 1);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002732 if ('0' == r)
2733 this.keyboard.terminal.setFontSize(0);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002734 else {
2735 var o = this.keyboard.terminal.getFontSize();
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002736 '-' == r || '[KP-]' == t.keyCap ? o -= 1 : o += 1,
2737 this.keyboard.terminal.setFontSize(o);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002738 }
2739 return hterm.Keyboard.KeyActions.CANCEL;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002740};
2741, hterm.Keyboard.KeyPattern = function(e) {
2742 this.wildcardCount = 0, this.keyCode = e.keyCode,
2743 hterm.Keyboard.KeyPattern.modifiers.forEach(function(t) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002744 this[t] = e[t] || !1, '*' == this[t] && this.wildcardCount++;
2745 }.bind(this));
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002746};
2747, hterm.Keyboard.KeyPattern.modifiers = ['shift', 'ctrl', 'alt', 'meta'],
2748 hterm.Keyboard.KeyPattern.sortCompare = function(e, t) {
2749 return e.wildcardCount < t.wildcardCount ?
2750 -1 :
2751 e.wildcardCount > t.wildcardCount ? 1 : 0
2752 };
2753, hterm.Keyboard.KeyPattern.prototype.match_ = function(e, t) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002754 if (this.keyCode != e.keyCode) return !1;
2755 var r = !0;
2756 return hterm.Keyboard.KeyPattern.modifiers.forEach(function(o) {
2757 var i = o in e ? e[o] : !1;
2758 r && (t || '*' != this[o]) && this[o] != i && (r = !1);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002759 }.bind(this)),
2760 r;
2761};
2762, hterm.Keyboard.KeyPattern.prototype.matchKeyDown = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002763 return this.match_(e, !1);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002764};
2765, hterm.Keyboard.KeyPattern.prototype.matchKeyPattern = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002766 return this.match_(e, !0);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002767};
2768, hterm.Options = function(e) {
2769 this.wraparound = e ? e.wraparound : !0,
2770 this.reverseWraparound = e ? e.reverseWraparound : !1,
2771 this.originMode = e ? e.originMode : !1,
2772 this.autoCarriageReturn = e ? e.autoCarriageReturn : !1,
2773 this.cursorVisible = e ? e.cursorVisible : !1,
2774 this.cursorBlink = e ? e.cursorBlink : !1,
2775 this.insertMode = e ? e.insertMode : !1,
2776 this.reverseVideo = e ? e.reverseVideo : !1,
2777 this.bracketedPaste = e ? e.bracketedPaste : !1;
2778};
2779, lib.rtdep('hterm.Keyboard.KeyActions'), hterm.Parser = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002780 this.source = '', this.pos = 0, this.ch = null;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002781};
2782, hterm.Parser.prototype.error = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002783 return new Error('Parse error at ' + this.pos + ': ' + e);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002784};
2785, hterm.Parser.prototype.isComplete = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002786 return this.pos == this.source.length;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002787};
2788, hterm.Parser.prototype.reset = function(e, t) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002789 this.source = e, this.pos = t || 0, this.ch = e.substr(0, 1);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002790};
2791, hterm.Parser.prototype.parseKeySequence = function() {
2792 var e = {keyCode: null};
2793 for (var t in hterm.Parser.identifiers.modifierKeys)
2794 e[hterm.Parser.identifiers.modifierKeys[t]] = !1;
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002795 for (; this.pos < this.source.length;) {
2796 this.skipSpace();
2797 var r = this.parseToken();
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002798 if ('integer' == r.type)
2799 e.keyCode = r.value;
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002800 else if ('identifier' == r.type)
2801 if (r.value in hterm.Parser.identifiers.modifierKeys) {
2802 var o = hterm.Parser.identifiers.modifierKeys[r.value];
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002803 if (e[o] && '*' != e[o])
2804 throw this.error('Duplicate modifier: ' + r.value);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002805 e[o] = !0;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002806 } else {
2807 if (!(r.value in hterm.Parser.identifiers.keyCodes))
2808 throw this.error('Unknown key: ' + r.value);
2809 e.keyCode = hterm.Parser.identifiers.keyCodes[r.value];
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002810 }
2811 else {
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002812 if ('symbol' != r.type)
2813 throw this.error('Expected integer or identifier');
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002814 if ('*' != r.value) throw this.error('Unexpected symbol: ' + r.value);
2815 for (var i in hterm.Parser.identifiers.modifierKeys) {
2816 var s = hterm.Parser.identifiers.modifierKeys[i];
2817 e[s] || (e[s] = '*');
2818 }
2819 }
2820 if (this.skipSpace(), '-' != this.ch) break;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002821 if (null != e.keyCode)
2822 throw this.error('Extra definition after target key');
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002823 this.advance(1);
2824 }
2825 if (null == e.keyCode) throw this.error('Missing target key');
2826 return e;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002827};
2828, hterm.Parser.prototype.parseKeyAction = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002829 this.skipSpace();
2830 var e = this.parseToken();
2831 if ('string' == e.type) return e.value;
2832 if ('identifier' == e.type) {
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002833 if (e.value in hterm.Parser.identifiers.actions)
2834 return hterm.Parser.identifiers.actions[e.value];
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002835 throw this.error('Unknown key action: ' + e.value);
2836 }
2837 throw this.error('Expected string or identifier');
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002838};
2839, hterm.Parser.prototype.peekString = function() {
2840 return '\'' == this.ch || '"' == this.ch;
2841};
2842, hterm.Parser.prototype.peekIdentifier = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002843 return this.ch.match(/[a-z_]/i);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002844};
2845, hterm.Parser.prototype.peekInteger = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002846 return this.ch.match(/[0-9]/);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002847};
2848, hterm.Parser.prototype.parseToken = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002849 if ('*' == this.ch) {
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002850 var e = {type: 'symbol', value: this.ch};
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002851 return this.advance(1), e;
2852 }
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002853 if (this.peekIdentifier())
2854 return {type: 'identifier', value: this.parseIdentifier()};
2855 if (this.peekString()) return {type: 'string', value: this.parseString()};
2856 if (this.peekInteger()) return {type: 'integer', value: this.parseInteger()};
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002857 throw this.error('Unexpected token');
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002858};
2859, hterm.Parser.prototype.parseIdentifier = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002860 if (!this.peekIdentifier()) throw this.error('Expected identifier');
2861 return this.parsePattern(/[a-z0-9_]+/gi);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002862};
2863, hterm.Parser.prototype.parseInteger = function() {
2864 return '0' == this.ch && this.pos < this.source.length - 1 &&
2865 'x' == this.source.substr(this.pos + 1, 1) ?
2866 parseInt(this.parsePattern(/0x[0-9a-f]+/gi)) :
2867 parseInt(this.parsePattern(/\d+/g));
2868};
2869, hterm.Parser.prototype.parseString = function() {
2870 var e = '', t = this.ch;
2871 if ('"' != t && '\'' != t) throw this.error('String expected');
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002872 this.advance(1);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002873 for (var r = new RegExp('[\\\\' + t + ']', 'g');
2874 this.pos < this.source.length;) {
2875 if (r.lastIndex = this.pos, !r.exec(this.source))
2876 throw this.error('Unterminated string literal');
2877 if (e += this.source.substring(this.pos, r.lastIndex - 1),
2878 this.advance(r.lastIndex - this.pos - 1), '"' != t || '\\' != this.ch)
2879 if ('\'' != t || '\\' != this.ch) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002880 if (this.ch == t) return this.advance(1), e;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002881 } else
2882 e += this.ch, this.advance(1);
2883 else
2884 this.advance(1), e += this.parseEscape();
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002885 }
2886 throw this.error('Unterminated string literal');
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002887};
2888, hterm.Parser.prototype.parseEscape = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002889 var e = {
2890 '"': '"',
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002891 '\'': '\'',
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002892 '\\': '\\',
2893 a: '',
2894 b: '\b',
2895 e: '',
2896 f: '\f',
2897 n: '\n',
2898 r: '\r',
2899 t: ' ',
2900 v: ' ',
2901 x: function() {
2902 var e = this.parsePattern(/[a-z0-9]{2}/gi);
2903 return String.fromCharCode(parseInt(e, 16));
2904 },
2905 u: function() {
2906 var e = this.parsePattern(/[a-z0-9]{4}/gi);
2907 return String.fromCharCode(parseInt(e, 16));
2908 }
2909 };
2910 if (!(this.ch in e)) throw this.error('Unknown escape: ' + this.ch);
2911 var t = e[this.ch];
2912 return this.advance(1), 'function' == typeof t && (t = t.call(this)), t;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002913};
2914, hterm.Parser.prototype.parsePattern = function(e) {
2915 if (!e.global)
2916 throw this.error('Internal error: Span patterns must be global');
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002917 e.lastIndex = this.pos;
2918 var t = e.exec(this.source);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002919 if (!t || e.lastIndex - t[0].length != this.pos)
2920 throw this.error('Expected match for: ' + e);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002921 return this.pos = e.lastIndex - 1, this.advance(1), t[0];
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002922};
2923, hterm.Parser.prototype.advance = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002924 this.pos += e, this.ch = this.source.substr(this.pos, 1);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002925};
2926, hterm.Parser.prototype.skipSpace = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002927 if (/\s/.test(this.ch)) {
2928 var t = /\s+/gm;
2929 t.lastIndex = this.pos;
2930 var r = this.source;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002931 if (t.exec(r) && (this.pos = t.lastIndex),
2932 this.ch = this.source.substr(this.pos, 1),
2933 e && -1 == this.ch.indexOf(e))
2934 throw this.error('Expected one of ' + e + ', found: ' + this.ch);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07002935 }
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002936};
2937, hterm.Parser.identifiers = {},
2938 hterm.Parser.identifiers
2939 .modifierKeys = {Shift: 'shift', Ctrl: 'ctrl', Alt: 'alt', Meta: 'meta'},
2940 hterm.Parser.identifiers.keyCodes = {
2941 ESC: 27,
2942 F1: 112,
2943 F2: 113,
2944 F3: 114,
2945 F4: 115,
2946 F5: 116,
2947 F6: 117,
2948 F7: 118,
2949 F8: 119,
2950 F9: 120,
2951 F10: 121,
2952 F11: 122,
2953 F12: 123,
2954 ONE: 49,
2955 TWO: 50,
2956 THREE: 51,
2957 FOUR: 52,
2958 FIVE: 53,
2959 SIX: 54,
2960 SEVEN: 55,
2961 EIGHT: 56,
2962 NINE: 57,
2963 ZERO: 48,
2964 BACKSPACE: 8,
2965 TAB: 9,
2966 Q: 81,
2967 W: 87,
2968 E: 69,
2969 R: 82,
2970 T: 84,
2971 Y: 89,
2972 U: 85,
2973 I: 73,
2974 O: 79,
2975 P: 80,
2976 CAPSLOCK: 20,
2977 A: 65,
2978 S: 83,
2979 D: 68,
2980 F: 70,
2981 G: 71,
2982 H: 72,
2983 J: 74,
2984 K: 75,
2985 L: 76,
2986 ENTER: 13,
2987 Z: 90,
2988 X: 88,
2989 C: 67,
2990 V: 86,
2991 B: 66,
2992 N: 78,
2993 M: 77,
2994 SPACE: 32,
2995 PRINT_SCREEN: 42,
2996 SCROLL_LOCK: 145,
2997 BREAK: 19,
2998 INSERT: 45,
2999 HOME: 36,
3000 PGUP: 33,
3001 DEL: 46,
3002 END: 35,
3003 PGDOWN: 34,
3004 UP: 38,
3005 DOWN: 40,
3006 RIGHT: 39,
3007 LEFT: 37,
3008 NUMLOCK: 144,
3009 KP0: 96,
3010 KP1: 97,
3011 KP2: 98,
3012 KP3: 99,
3013 KP4: 100,
3014 KP5: 101,
3015 KP6: 102,
3016 KP7: 103,
3017 KP8: 104,
3018 KP9: 105,
3019 KP_PLUS: 107,
3020 KP_MINUS: 109,
3021 KP_STAR: 106,
3022 KP_DIVIDE: 111,
3023 KP_DECIMAL: 110,
3024 NAVIGATE_BACK: 166,
3025 NAVIGATE_FORWARD: 167,
3026 RELOAD: 168,
3027 FULL_SCREEN: 183,
3028 WINDOW_OVERVIEW: 182,
3029 BRIGHTNESS_UP: 216,
3030 BRIGHTNESS_DOWN: 217
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003031 },
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003032 hterm.Parser.identifiers.actions = {
3033 CANCEL: hterm.Keyboard.KeyActions.CANCEL,
3034 DEFAULT: hterm.Keyboard.KeyActions.DEFAULT,
3035 PASS: hterm.Keyboard.KeyActions.PASS,
3036 scrollPageUp: function(e) {
3037 return e.scrollPageUp(), hterm.Keyboard.KeyActions.CANCEL;
3038 },
3039 scrollPageDown: function(e) {
3040 return e.scrollPageDown(), hterm.Keyboard.KeyActions.CANCEL;
3041 },
3042 scrollToTop: function(e) {
3043 return e.scrollEnd(), hterm.Keyboard.KeyActions.CANCEL;
3044 },
3045 scrollToBottom: function(e) {
3046 return e.scrollEnd(), hterm.Keyboard.KeyActions.CANCEL;
3047 },
3048 clearScrollback: function(e) {
3049 return e.wipeContents(), hterm.Keyboard.KeyActions.CANCEL;
3050 }
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003051 },
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003052 lib.rtdep('lib.f', 'lib.Storage'), hterm.PreferenceManager = function(e) {
3053 lib.PreferenceManager.call(
3054 this, hterm.defaultStorage, '/hterm/profiles/' + e);
3055 var t = hterm.PreferenceManager.defaultPreferences;
3056 Object.keys(t).forEach(function(e) {
3057 this.definePreference(e, t[e][1]);
3058 }.bind(this));
3059 };
3060,
3061 hterm.PreferenceManager.categories = {},
3062 hterm.PreferenceManager.categories.Keyboard = 'Keyboard',
3063 hterm.PreferenceManager.categories.Appearance = 'Appearance',
3064 hterm.PreferenceManager.categories.CopyPaste = 'CopyPaste',
3065 hterm.PreferenceManager.categories.Sounds = 'Sounds',
3066 hterm.PreferenceManager.categories.Scrolling = 'Scrolling',
3067 hterm.PreferenceManager.categories.Encoding = 'Encoding',
3068 hterm.PreferenceManager.categories.Miscellaneous = 'Miscellaneous',
3069 hterm.PreferenceManager.categoryDefinitions =
3070 [
3071 {
3072 id: hterm.PreferenceManager.categories.Appearance,
3073 text: 'Appearance (fonts, colors, images)'
3074 },
3075 {
3076 id: hterm.PreferenceManager.categories.CopyPaste,
3077 text: 'Copy & Paste'
3078 },
3079 {id: hterm.PreferenceManager.categories.Encoding, text: 'Encoding'},
3080 {id: hterm.PreferenceManager.categories.Keyboard, text: 'Keyboard'},
3081 {id: hterm.PreferenceManager.categories.Scrolling, text: 'Scrolling'},
3082 {id: hterm.PreferenceManager.categories.Sounds, text: 'Sounds'}, {
3083 id: hterm.PreferenceManager.categories.Miscellaneous,
3084 text: 'Misc.'
3085 }
3086 ],
3087 hterm.PreferenceManager.defaultPreferences = {
3088 'alt-gr-mode': [
3089 hterm.PreferenceManager.categories.Keyboard, null,
3090 [null, 'none', 'ctrl-alt', 'left-alt', 'right-alt'],
3091 'Select an AltGr detection hack^Wheuristic.\n\n\'null\': Autodetect based on navigator.language:\n \'en-us\' => \'none\', else => \'right-alt\'\n\'none\': Disable any AltGr related munging.\n\'ctrl-alt\': Assume Ctrl+Alt means AltGr.\n\'left-alt\': Assume left Alt means AltGr.\n\'right-alt\': Assume right Alt means AltGr.\n'
3092 ],
3093 'alt-backspace-is-meta-backspace': [
3094 hterm.PreferenceManager.categories.Keyboard, !1, 'bool',
3095 'If set, undoes the Chrome OS Alt-Backspace->DEL remap, so that alt-backspace indeed is alt-backspace.'
3096 ],
3097 'alt-is-meta': [
3098 hterm.PreferenceManager.categories.Keyboard, !1, 'bool',
3099 'Set whether the alt key acts as a meta key or as a distinct alt key.'
3100 ],
3101 'alt-sends-what': [
3102 hterm.PreferenceManager.categories.Keyboard, 'escape',
3103 ['escape', '8-bit', 'browser-key'],
3104 'Controls how the alt key is handled.\n\n escape....... Send an ESC prefix.\n 8-bit........ Add 128 to the unshifted character as in xterm.\n browser-key.. Wait for the keypress event and see what the browser \n says. (This won\'t work well on platforms where the \n browser performs a default action for some alt sequences.)'
3105 ],
3106 'audible-bell-sound': [
3107 hterm.PreferenceManager.categories.Sounds,
3108 'lib-resource:hterm/audio/bell', 'url',
3109 'URL of the terminal bell sound. Empty string for no audible bell.'
3110 ],
3111 'desktop-notification-bell': [
3112 hterm.PreferenceManager.categories.Sounds, !1, 'bool',
3113 'If true, terminal bells in the background will create a Web Notification. https://www.w3.org/TR/notifications/\n\nDisplaying notifications requires permission from the user. When this option is set to true, hterm will attempt to ask the user for permission if necessary. Note browsers may not show this permission request if it did not originate from a user action.\n\nChrome extensions with the "notifications" permission have permission to display notifications.'
3114 ],
3115 'background-color': [
3116 hterm.PreferenceManager.categories.Appearance, 'rgb(16, 16, 16)',
3117 'color', 'The background color for text with no other color attributes.'
3118 ],
3119 'background-image': [
3120 hterm.PreferenceManager.categories.Appearance, '', 'string',
3121 'CSS value of the background image. Empty string for no image.\n\nFor example:\n url(https://goo.gl/anedTK)\n linear-gradient(top bottom, blue, red)'
3122 ],
3123 'background-size': [
3124 hterm.PreferenceManager.categories.Appearance, '', 'string',
3125 'CSS value of the background image size. Defaults to none.'
3126 ],
3127 'background-position': [
3128 hterm.PreferenceManager.categories.Appearance, '', 'string',
3129 'CSS value of the background image position.\n\nFor example:\n 10% 10%\n center'
3130 ],
3131 'backspace-sends-backspace': [
3132 hterm.PreferenceManager.categories.Keyboard, !1, 'bool',
3133 'If true, the backspace should send BS (\'\\x08\', aka ^H). Otherwise the backspace key should send \'\\x7f\'.'
3134 ],
3135 'character-map-overrides': [
3136 hterm.PreferenceManager.categories.Appearance, null, 'value',
3137 'This is specified as an object. It is a sparse array, where each property is the character set code and the value is an object that is a sparse array itself. In that sparse array, each property is the received character and the value is the displayed character.\n\nFor example:\n {"0":{"+":"\\u2192",",":"\\u2190","-":"\\u2191",".":"\\u2193", "0":"\\u2588"}}'
3138 ],
3139 'close-on-exit': [
3140 hterm.PreferenceManager.categories.Miscellaneous, !0, 'bool',
3141 'Whether or not to close the window when the command exits.'
3142 ],
3143 'cursor-blink': [
3144 hterm.PreferenceManager.categories.Appearance, !1, 'bool',
3145 'Whether or not to blink the cursor by default.'
3146 ],
3147 'cursor-blink-cycle': [
3148 hterm.PreferenceManager.categories.Appearance, [1e3, 500], 'value',
3149 'The cursor blink rate in milliseconds.\n\nA two element array, the first of which is how long the cursor should be on, second is how long it should be off.'
3150 ],
3151 'cursor-color': [
3152 hterm.PreferenceManager.categories.Appearance, 'rgba(255, 0, 0, 0.5)',
3153 'color', 'The color of the visible cursor.'
3154 ],
3155 'color-palette-overrides': [
3156 hterm.PreferenceManager.categories.Appearance, null, 'value',
3157 'Override colors in the default palette.\n\nThis can be specified as an array or an object. If specified as an object it is assumed to be a sparse array, where each property is a numeric index into the color palette.\n\nValues can be specified as almost any css color value. This includes #RGB, #RRGGBB, rgb(...), rgba(...), and any color names that are also part of the stock X11 rgb.txt file.\n\nYou can use \'null\' to specify that the default value should be not be changed. This is useful for skipping a small number of indices when the value is specified as an array.'
3158 ],
3159 'copy-on-select': [
3160 hterm.PreferenceManager.categories.CopyPaste, !0, 'bool',
3161 'Automatically copy mouse selection to the clipboard.'
3162 ],
3163 'use-default-window-copy': [
3164 hterm.PreferenceManager.categories.CopyPaste, !1, 'bool',
3165 'Whether to use the default window copy behavior'
3166 ],
3167 'clear-selection-after-copy': [
3168 hterm.PreferenceManager.categories.CopyPaste, !0, 'bool',
3169 'Whether to clear the selection after copying.'
3170 ],
3171 'ctrl-plus-minus-zero-zoom': [
3172 hterm.PreferenceManager.categories.Keyboard, !0, 'bool',
3173 'If true, Ctrl-Plus/Minus/Zero controls zoom.\nIf false, Ctrl-Shift-Plus/Minus/Zero controls zoom, Ctrl-Minus sends ^_, Ctrl-Plus/Zero do nothing.'
3174 ],
3175 'ctrl-c-copy': [
3176 hterm.PreferenceManager.categories.Keyboard, !1, 'bool',
3177 'Ctrl+C copies if true, send ^C to host if false.\nCtrl+Shift+C sends ^C to host if true, copies if false.'
3178 ],
3179 'ctrl-v-paste': [
3180 hterm.PreferenceManager.categories.Keyboard, !1, 'bool',
3181 'Ctrl+V pastes if true, send ^V to host if false.\nCtrl+Shift+V sends ^V to host if true, pastes if false.'
3182 ],
3183 'east-asian-ambiguous-as-two-column': [
3184 hterm.PreferenceManager.categories.Keyboard, !1, 'bool',
3185 'Set whether East Asian Ambiguous characters have two column width.'
3186 ],
3187 'enable-8-bit-control': [
3188 hterm.PreferenceManager.categories.Keyboard, !1, 'bool',
3189 'True to enable 8-bit control characters, false to ignore them.\n\nWe\'ll respect the two-byte versions of these control characters regardless of this setting.'
3190 ],
3191 'enable-bold': [
3192 hterm.PreferenceManager.categories.Appearance, null, 'tristate',
3193 'True if we should use bold weight font for text with the bold/bright attribute. False to use the normal weight font. Null to autodetect.'
3194 ],
3195 'enable-bold-as-bright': [
3196 hterm.PreferenceManager.categories.Appearance, !0, 'bool',
3197 'True if we should use bright colors (8-15 on a 16 color palette) for any text with the bold attribute. False otherwise.'
3198 ],
3199 'enable-blink': [
3200 hterm.PreferenceManager.categories.Appearance, !0, 'bool',
3201 'True if we should respect the blink attribute. False to ignore it. '
3202 ],
3203 'enable-clipboard-notice': [
3204 hterm.PreferenceManager.categories.CopyPaste, !0, 'bool',
3205 'Show a message in the terminal when the host writes to the clipboard.'
3206 ],
3207 'enable-clipboard-write': [
3208 hterm.PreferenceManager.categories.CopyPaste, !0, 'bool',
3209 'Allow the host to write directly to the system clipboard.'
3210 ],
3211 'enable-dec12': [
3212 hterm.PreferenceManager.categories.Miscellaneous, !1, 'bool',
3213 'Respect the host\'s attempt to change the cursor blink status using DEC Private Mode 12.'
3214 ],
3215 environment: [
3216 hterm.PreferenceManager.categories.Miscellaneous,
3217 {TERM: 'xterm-256color'}, 'value',
3218 'The default environment variables, as an object.'
3219 ],
3220 'font-family': [
3221 hterm.PreferenceManager.categories.Appearance,
3222 '"DejaVu Sans Mono", "Everson Mono", FreeMono, "Menlo", "Terminal", monospace',
3223 'string', 'Default font family for the terminal text.'
3224 ],
3225 'font-size': [
3226 hterm.PreferenceManager.categories.Appearance, 15, 'int',
3227 'The default font size in pixels.'
3228 ],
3229 'font-smoothing': [
3230 hterm.PreferenceManager.categories.Appearance, 'antialiased', 'string',
3231 'CSS font-smoothing property.'
3232 ],
3233 'foreground-color': [
3234 hterm.PreferenceManager.categories.Appearance, 'rgb(240, 240, 240)',
3235 'color', 'The foreground color for text with no other color attributes.'
3236 ],
3237 'home-keys-scroll': [
3238 hterm.PreferenceManager.categories.Keyboard, !1, 'bool',
3239 'If true, home/end will control the terminal scrollbar and shift home/end will send the VT keycodes. If false then home/end sends VT codes and shift home/end scrolls.'
3240 ],
3241 keybindings: [
3242 hterm.PreferenceManager.categories.Keyboard, null, 'value',
3243 'A map of key sequence to key actions. Key sequences include zero or more modifier keys followed by a key code. Key codes can be decimal or hexadecimal numbers, or a key identifier. Key actions can be specified a string to send to the host, or an action identifier. For a full list of key code and action identifiers, see https://goo.gl/8AoD09.\n\nSample keybindings:\n{ "Ctrl-Alt-K": "clearScrollback",\n "Ctrl-Shift-L": "PASS",\n "Ctrl-H": "\'HELLO\\n\'"\n}'
3244 ],
3245 'max-string-sequence': [
3246 hterm.PreferenceManager.categories.Encoding, 1e5, 'int',
3247 'Max length of a DCS, OSC, PM, or APS sequence before we give up and ignore the code.'
3248 ],
3249 'media-keys-are-fkeys': [
3250 hterm.PreferenceManager.categories.Keyboard, !1, 'bool',
3251 'If true, convert media keys to their Fkey equivalent. If false, let the browser handle the keys.'
3252 ],
3253 'meta-sends-escape': [
3254 hterm.PreferenceManager.categories.Keyboard, !0, 'bool',
3255 'Set whether the meta key sends a leading escape or not.'
3256 ],
3257 'mouse-paste-button': [
3258 hterm.PreferenceManager.categories.CopyPaste, null,
3259 [null, 0, 1, 2, 3, 4, 5, 6],
3260 'Mouse paste button, or null to autodetect.\n\nFor autodetect, we\'ll try to enable middle button paste for non-X11 platforms. On X11 we move it to button 3.'
3261 ],
3262 'page-keys-scroll': [
3263 hterm.PreferenceManager.categories.Keyboard, !1, 'bool',
3264 'If true, page up/down will control the terminal scrollbar and shift page up/down will send the VT keycodes. If false then page up/down sends VT codes and shift page up/down scrolls.'
3265 ],
3266 'pass-alt-number': [
3267 hterm.PreferenceManager.categories.Keyboard, null, 'tristate',
3268 'Set whether we should pass Alt-1..9 to the browser.\n\nThis is handy when running hterm in a browser tab, so that you don\'t lose Chrome\'s "switch to tab" keyboard accelerators. When not running in a tab it\'s better to send these keys to the host so they can be used in vim or emacs.\n\nIf true, Alt-1..9 will be handled by the browser. If false, Alt-1..9 will be sent to the host. If null, autodetect based on browser platform and window type.'
3269 ],
3270 'pass-ctrl-number': [
3271 hterm.PreferenceManager.categories.Keyboard, null, 'tristate',
3272 'Set whether we should pass Ctrl-1..9 to the browser.\n\nThis is handy when running hterm in a browser tab, so that you don\'t lose Chrome\'s "switch to tab" keyboard accelerators. When not running in a tab it\'s better to send these keys to the host so they can be used in vim or emacs.\n\nIf true, Ctrl-1..9 will be handled by the browser. If false, Ctrl-1..9 will be sent to the host. If null, autodetect based on browser platform and window type.'
3273 ],
3274 'pass-meta-number': [
3275 hterm.PreferenceManager.categories.Keyboard, null, 'tristate', 'Set whether we should pass Meta-1..9 to the browser.\n\nThis is handy when running hterm in a browser tab, so that you don\'t lose Chrome\'s "switch to tab" keyboard accelerators. When not running in a tab it\'s better to send these keys to the host so they can be used in vim or emacs.\n\nIf true, Meta-1..9 will be handled by the browser. If false, Meta-1..9 will be sent to the host. If null, autodetect based on browser platform and window type.'
3276 ],
3277 'pass-meta-v': [
3278 hterm.PreferenceManager.categories.Keyboard, !0, 'bool',
3279 'Set whether meta-V gets passed to host.'
3280 ],
3281 'receive-encoding': [
3282 hterm.PreferenceManager.categories.Encoding, 'utf-8', ['utf-8', 'raw'],
3283 'Set the expected encoding for data received from the host.\n\nValid values are \'utf-8\' and \'raw\'.'
3284 ],
3285 'scroll-on-keystroke': [
3286 hterm.PreferenceManager.categories.Scrolling, !0, 'bool',
3287 'If true, scroll to the bottom on any keystroke.'
3288 ],
3289 'scroll-on-output': [
3290 hterm.PreferenceManager.categories.Scrolling, !1, 'bool',
3291 'If true, scroll to the bottom on terminal output.'
3292 ],
3293 'scrollbar-visible': [
3294 hterm.PreferenceManager.categories.Scrolling, !0, 'bool',
3295 'The vertical scrollbar mode.'
3296 ],
3297 'scroll-wheel-move-multiplier': [
3298 hterm.PreferenceManager.categories.Scrolling, 1, 'int',
3299 'The multiplier for the pixel delta in mousewheel event caused by the scroll wheel. Alters how fast the page scrolls.'
3300 ],
3301 'send-encoding': [
3302 hterm.PreferenceManager.categories.Encoding, 'utf-8', ['utf-8', 'raw'],
3303 'Set the encoding for data sent to host.'
3304 ],
3305 'shift-insert-paste': [
3306 hterm.PreferenceManager.categories.Keyboard, !0, 'bool',
3307 'Shift + Insert pastes if true, sent to host if false.'
3308 ],
3309 'user-css': [
3310 hterm.PreferenceManager.categories.Appearance, '', 'url',
3311 'URL of user stylesheet to include in the terminal document.'
3312 ]
3313 },
3314 hterm.PreferenceManager.prototype = {
3315 __proto__: lib.PreferenceManager.prototype
3316 },
3317 hterm.PubSub = function() {
3318 this.observers_ = {};
3319 };
3320, hterm.PubSub.addBehavior = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003321 var t = new hterm.PubSub;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003322 for (var r in hterm.PubSub.prototype)
3323 e[r] = hterm.PubSub.prototype[r].bind(t);
3324};
3325, hterm.PubSub.prototype.subscribe = function(e, t) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003326 e in this.observers_ || (this.observers_[e] = []), this.observers_[e].push(t);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003327};
3328, hterm.PubSub.prototype.unsubscribe = function(e, t) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003329 var r = this.observers_[e];
3330 if (!r) throw 'Invalid subject: ' + e;
3331 var o = r.indexOf(t);
3332 if (0 > o) throw 'Not subscribed: ' + e;
3333 r.splice(o, 1);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003334};
3335, hterm.PubSub.prototype.publish = function(e, t, r) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003336 function o(e) {
3337 e < i.length - 1 && setTimeout(o, 0, e + 1), i[e](t);
3338 }
3339 var i = this.observers_[e];
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003340 i && (i = [].concat(i)), r && (i ? i.push(r) : i = [r]),
3341 i && setTimeout(o, 0, 0);
3342};
3343,
3344 lib.rtdep(
3345 'lib.f', 'lib.wc', 'hterm.RowCol', 'hterm.Size',
3346 'hterm.TextAttributes'),
3347 hterm.Screen = function(e) {
3348 this.rowsArray = [], this.columnCount_ = e || 80,
3349 this.textAttributes = new hterm.TextAttributes(window.document),
3350 this.cursorPosition = new hterm.RowCol(0, 0), this.cursorRowNode_ = null,
3351 this.cursorNode_ = null, this.cursorOffset_ = null;
3352 };
3353, hterm.Screen.prototype.getSize = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003354 return new hterm.Size(this.columnCount_, this.rowsArray.length);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003355};
3356, hterm.Screen.prototype.getHeight = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003357 return this.rowsArray.length;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003358};
3359, hterm.Screen.prototype.getWidth = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003360 return this.columnCount_;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003361};
3362, hterm.Screen.prototype.setColumnCount = function(e) {
3363 this.columnCount_ = e,
3364 this.cursorPosition.column >= e &&
3365 this.setCursorPosition(this.cursorPosition.row, e - 1);
3366};
3367, hterm.Screen.prototype.shiftRow = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003368 return this.shiftRows(1)[0];
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003369};
3370, hterm.Screen.prototype.shiftRows = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003371 return this.rowsArray.splice(0, e);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003372};
3373, hterm.Screen.prototype.unshiftRow = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003374 this.rowsArray.splice(0, 0, e);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003375};
3376, hterm.Screen.prototype.unshiftRows = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003377 this.rowsArray.unshift.apply(this.rowsArray, e);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003378};
3379, hterm.Screen.prototype.popRow = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003380 return this.popRows(1)[0];
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003381};
3382, hterm.Screen.prototype.popRows = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003383 return this.rowsArray.splice(this.rowsArray.length - e, e);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003384};
3385, hterm.Screen.prototype.pushRow = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003386 this.rowsArray.push(e);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003387};
3388, hterm.Screen.prototype.pushRows = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003389 e.push.apply(this.rowsArray, e);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003390};
3391, hterm.Screen.prototype.insertRow = function(e, t) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003392 this.rowsArray.splice(e, 0, t);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003393};
3394, hterm.Screen.prototype.insertRows = function(e, t) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003395 for (var r = 0; r < t.length; r++) this.rowsArray.splice(e + r, 0, t[r]);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003396};
3397, hterm.Screen.prototype.removeRow = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003398 return this.rowsArray.splice(e, 1)[0];
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003399};
3400, hterm.Screen.prototype.removeRows = function(e, t) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003401 return this.rowsArray.splice(e, t);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003402};
3403, hterm.Screen.prototype.invalidateCursorPosition = function() {
3404 this.cursorPosition.move(0, 0), this.cursorRowNode_ = null,
3405 this.cursorNode_ = null,
3406 this.cursorOffset_ = null;
3407};
3408, hterm.Screen.prototype.clearCursorRow = function() {
3409 this.cursorRowNode_.innerHTML = '',
3410 this.cursorRowNode_.removeAttribute('line-overflow'), this.cursorOffset_ = 0,
3411 this.cursorPosition.column = 0, this.cursorPosition.overflow = !1;
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003412 var e;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003413 e = this.textAttributes.isDefault() ? '' :
3414 lib.f.getWhitespace(this.columnCount_);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003415 var t = this.textAttributes.inverse;
3416 this.textAttributes.inverse = !1, this.textAttributes.syncColors();
3417 var r = this.textAttributes.createContainer(e);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003418 this.cursorRowNode_.appendChild(r), this.cursorNode_ = r,
3419 this.textAttributes.inverse = t,
3420 this.textAttributes.syncColors();
3421};
3422, hterm.Screen.prototype.commitLineOverflow = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003423 this.cursorRowNode_.setAttribute('line-overflow', !0);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003424};
3425, hterm.Screen.prototype.setCursorPosition = function(e, t) {
3426 if (!this.rowsArray.length)
3427 return void console.warn('Attempt to set cursor position on empty screen.');
3428 e >= this.rowsArray.length ?
3429 (console.error('Row out of bounds: ' + e),
3430 e = this.rowsArray.length - 1) :
3431 0 > e && (console.error('Row out of bounds: ' + e), e = 0),
3432 t >= this.columnCount_ ?
3433 (console.error('Column out of bounds: ' + t), t = this.columnCount_ - 1) :
3434 0 > t && (console.error('Column out of bounds: ' + t), t = 0),
3435 this.cursorPosition.overflow = !1;
3436 var r = this.rowsArray[e], o = r.firstChild;
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003437 o || (o = r.ownerDocument.createTextNode(''), r.appendChild(o));
3438 var i = 0;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003439 for (r == this.cursorRowNode_ ?
3440 t >= this.cursorPosition.column - this.cursorOffset_ &&
3441 (o = this.cursorNode_,
3442 i = this.cursorPosition.column - this.cursorOffset_) :
3443 this.cursorRowNode_ = r,
3444 this.cursorPosition.move(e, t);
3445 o;) {
3446 var s = t - i, n = hterm.TextAttributes.nodeWidth(o);
3447 if (!o.nextSibling || n > s)
Gunnar Mills4ddda582018-09-04 09:18:30 -05003448 return this.cursorNode_ = o, void (this.cursorOffset_ = s);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003449 i += n, o = o.nextSibling;
3450 }
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003451};
3452, hterm.Screen.prototype.syncSelectionCaret = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003453 try {
3454 e.collapse(this.cursorNode_, this.cursorOffset_);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003455 } catch (t) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003456 }
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003457};
3458, hterm.Screen.prototype.splitNode_ = function(e, t) {
3459 var r = e.cloneNode(!1), o = e.textContent;
3460 e.textContent = hterm.TextAttributes.nodeSubstr(e, 0, t),
3461 r.textContent = lib.wc.substr(o, t),
3462 r.textContent && e.parentNode.insertBefore(r, e.nextSibling),
3463 e.textContent || e.parentNode.removeChild(e);
3464};
3465, hterm.Screen.prototype.maybeClipCurrentRow = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003466 var e = hterm.TextAttributes.nodeWidth(this.cursorRowNode_);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003467 if (e <= this.columnCount_)
Gunnar Mills4ddda582018-09-04 09:18:30 -05003468 return void (
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003469 this.cursorPosition.column >= this.columnCount_ &&
3470 (this.setCursorPosition(this.cursorPosition.row, this.columnCount_ - 1),
3471 this.cursorPosition.overflow = !0));
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003472 var t = this.cursorPosition.column;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003473 this.setCursorPosition(this.cursorPosition.row, this.columnCount_ - 1),
3474 e = hterm.TextAttributes.nodeWidth(this.cursorNode_),
3475 this.cursorOffset_ < e - 1 &&
3476 (this.cursorNode_.textContent = hterm.TextAttributes.nodeSubstr(
3477 this.cursorNode_, 0, this.cursorOffset_ + 1));
3478 for (var r = this.cursorRowNode_, o = this.cursorNode_.nextSibling; o;)
3479 r.removeChild(o), o = this.cursorNode_.nextSibling;
3480 t < this.columnCount_ ? this.setCursorPosition(this.cursorPosition.row, t) :
3481 this.cursorPosition.overflow = !0;
3482};
3483, hterm.Screen.prototype.insertString = function(e) {
3484 var t = this.cursorNode_, r = t.textContent;
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003485 this.cursorRowNode_.removeAttribute('line-overflow');
3486 var o = lib.wc.strWidth(e);
3487 this.cursorPosition.column += o;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003488 var i = this.cursorOffset_, s = hterm.TextAttributes.nodeWidth(t) - i;
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003489 if (0 > s) {
3490 var n = lib.f.getWhitespace(-s);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003491 if (this.textAttributes.underline || this.textAttributes.strikethrough ||
3492 this.textAttributes.background || this.textAttributes.wcNode ||
3493 null != this.textAttributes.tileData)
3494 if (3 != t.nodeType &&
3495 (t.wcNode || t.tileNode || t.style.textDecoration ||
3496 t.style.backgroundColor)) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003497 var a = t.ownerDocument.createTextNode(n);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003498 this.cursorRowNode_.insertBefore(a, t.nextSibling),
3499 this.cursorNode_ = t = a, this.cursorOffset_ = i = -s, r = n;
3500 } else
3501 t.textContent = r += n;
3502 else
3503 e = n + e;
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003504 s = 0;
3505 }
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003506 if (this.textAttributes.matchesContainer(t))
3507 return 0 == s ? t.textContent = r + e :
3508 0 == i ?
3509 t.textContent = e + r :
3510 t.textContent = hterm.TextAttributes.nodeSubstr(t, 0, i) +
3511 e + hterm.TextAttributes.nodeSubstr(t, i),
Gunnar Mills4ddda582018-09-04 09:18:30 -05003512 void (this.cursorOffset_ += o);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003513 if (0 == i) {
3514 var l = t.previousSibling;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003515 if (l && this.textAttributes.matchesContainer(l))
3516 return l.textContent += e,
3517 this.cursorNode_ = l,
Gunnar Mills4ddda582018-09-04 09:18:30 -05003518 void (this.cursorOffset_ = lib.wc.strWidth(l.textContent));
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003519 var h = this.textAttributes.createContainer(e);
Gunnar Mills4ddda582018-09-04 09:18:30 -05003520 return this.cursorRowNode_.insertBefore(h, t),
3521 this.cursorNode_ = h, void (this.cursorOffset_ = o);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003522 }
3523 if (0 == s) {
3524 var c = t.nextSibling;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003525 if (c && this.textAttributes.matchesContainer(c))
3526 return c.textContent = e + c.textContent, this.cursorNode_ = c,
Gunnar Mills4ddda582018-09-04 09:18:30 -05003527 void (this.cursorOffset_ = lib.wc.strWidth(e));
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003528 var h = this.textAttributes.createContainer(e);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003529 return this.cursorRowNode_.insertBefore(h, c),
3530 this.cursorNode_ = h,
Gunnar Mills4ddda582018-09-04 09:18:30 -05003531 void (this.cursorOffset_ = hterm.TextAttributes.nodeWidth(h));
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003532 }
3533 this.splitNode_(t, i);
3534 var h = this.textAttributes.createContainer(e);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003535 this.cursorRowNode_.insertBefore(h, t.nextSibling), this.cursorNode_ = h,
3536 this.cursorOffset_ = o;
3537};
3538, hterm.Screen.prototype.overwriteString = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003539 var t = this.columnCount_ - this.cursorPosition.column;
3540 if (!t) return [e];
3541 var r = lib.wc.strWidth(e);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003542 return this.textAttributes.matchesContainer(this.cursorNode_) &&
3543 this.cursorNode_.textContent.substr(this.cursorOffset_) == e ?
Gunnar Mills4ddda582018-09-04 09:18:30 -05003544 (this.cursorOffset_ += r, void (this.cursorPosition.column += r)) :
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003545 (this.deleteChars(Math.min(r, t)), void this.insertString(e));
3546};
3547, hterm.Screen.prototype.deleteChars = function(e) {
3548 var t = this.cursorNode_, r = this.cursorOffset_,
3549 o = this.cursorPosition.column;
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003550 if (e = Math.min(e, this.columnCount_ - o), !e) return 0;
3551 for (var i, s, n = e; t && e;) {
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003552 if (i = hterm.TextAttributes.nodeWidth(t),
3553 t.textContent = hterm.TextAttributes.nodeSubstr(t, 0, r) +
3554 hterm.TextAttributes.nodeSubstr(t, r + e),
3555 s = hterm.TextAttributes.nodeWidth(t), e -= i - s,
3556 i > r && s && i == s) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003557 var a = this.textAttributes.createContainer(' ');
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003558 t.parentNode.insertBefore(a, t.nextSibling), t.textContent = '', s = 0,
3559 e -= 1;
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003560 }
3561 var l = t.nextSibling;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003562 0 == s && t != this.cursorNode_ && t.parentNode.removeChild(t), t = l,
3563 r = 0;
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003564 }
3565 if (3 != this.cursorNode_.nodeType && !this.cursorNode_.textContent) {
3566 var h = this.cursorNode_;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003567 if (h.previousSibling)
3568 this.cursorNode_ = h.previousSibling,
3569 this.cursorOffset_ = hterm.TextAttributes.nodeWidth(h.previousSibling);
3570 else if (h.nextSibling)
3571 this.cursorNode_ = h.nextSibling, this.cursorOffset_ = 0;
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003572 else {
3573 var c = this.cursorRowNode_.ownerDocument.createTextNode('');
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003574 this.cursorRowNode_.appendChild(c), this.cursorNode_ = c,
3575 this.cursorOffset_ = 0;
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003576 }
3577 this.cursorRowNode_.removeChild(h);
3578 }
3579 return n;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003580};
3581, hterm.Screen.prototype.getLineStartRow_ = function(e) {
3582 for (; e.previousSibling && e.previousSibling.hasAttribute('line-overflow');)
3583 e = e.previousSibling;
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003584 return e;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003585};
3586, hterm.Screen.prototype.getLineText_ = function(e) {
3587 for (var t = ''; e && (t += e.textContent, e.hasAttribute('line-overflow'));)
3588 e = e.nextSibling;
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003589 return t;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003590};
3591, hterm.Screen.prototype.getXRowAncestor_ = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003592 for (; e && 'X-ROW' !== e.nodeName;) e = e.parentNode;
3593 return e;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003594};
3595, hterm.Screen.prototype.getPositionWithOverflow_ = function(e, t, r) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003596 if (!t) return -1;
3597 var o = this.getXRowAncestor_(t);
3598 if (!o) return -1;
3599 for (var i = 0; o != e;) {
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003600 if (i += hterm.TextAttributes.nodeWidth(e),
3601 !e.hasAttribute('line-overflow') || !e.nextSibling)
3602 return -1;
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003603 e = e.nextSibling;
3604 }
3605 return i + this.getPositionWithinRow_(e, t, r);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003606};
3607, hterm.Screen.prototype.getPositionWithinRow_ = function(e, t, r) {
3608 if (t.parentNode != e)
3609 return this.getPositionWithinRow_(t.parentNode, t, r) +
3610 this.getPositionWithinRow_(e, t.parentNode, 0);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003611 for (var o = 0, i = 0; i < e.childNodes.length; i++) {
3612 var s = e.childNodes[i];
3613 if (s == t) return o + r;
3614 o += hterm.TextAttributes.nodeWidth(s);
3615 }
3616 return -1;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003617};
3618, hterm.Screen.prototype.getNodeAndOffsetWithOverflow_ = function(e, t) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003619 for (; e && t > hterm.TextAttributes.nodeWidth(e);) {
3620 if (!e.hasAttribute('line-overflow') || !e.nextSibling) return -1;
3621 t -= hterm.TextAttributes.nodeWidth(e), e = e.nextSibling;
3622 }
3623 return this.getNodeAndOffsetWithinRow_(e, t);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003624};
3625, hterm.Screen.prototype.getNodeAndOffsetWithinRow_ = function(e, t) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003626 for (var r = 0; r < e.childNodes.length; r++) {
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003627 var o = e.childNodes[r], i = hterm.TextAttributes.nodeWidth(o);
3628 if (i >= t)
3629 return 'SPAN' === o.nodeName ? this.getNodeAndOffsetWithinRow_(o, t) :
3630 [o, t];
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003631 t -= i;
3632 }
3633 return null;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003634};
3635, hterm.Screen.prototype.setRange_ = function(e, t, r, o) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003636 var i = this.getNodeAndOffsetWithOverflow_(e, t);
3637 if (null != i) {
3638 var s = this.getNodeAndOffsetWithOverflow_(e, r);
3639 null != s && (o.setStart(i[0], i[1]), o.setEnd(s[0], s[1]));
3640 }
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003641};
3642, hterm.Screen.prototype.expandSelection = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003643 if (e) {
3644 var t = e.getRangeAt(0);
3645 if (t && !t.toString().match(/\s/)) {
3646 var r = this.getLineStartRow_(this.getXRowAncestor_(t.startContainer));
3647 if (r) {
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003648 var o =
3649 this.getPositionWithOverflow_(r, t.startContainer, t.startOffset);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003650 if (-1 != o) {
3651 var i = this.getPositionWithOverflow_(r, t.endContainer, t.endOffset);
3652 if (-1 != i) {
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003653 var s = '[^\\s\\[\\](){}<>"\'\\^!@#$%&*,;:`]',
3654 n = '[^\\s\\[\\](){}<>"\'\\^!@#$%&*,;:~.`]',
3655 a = '[^\\s\\[\\](){}<>"\'\\^]*', l = this.getLineText_(r),
3656 h = lib.wc.substring(l, 0, i), c = new RegExp(s + a + '$'),
3657 u = h.search(c);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003658 if (!(-1 == u || u > o)) {
3659 var g = lib.wc.substring(l, o, lib.wc.strWidth(l)),
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003660 d = new RegExp('^' + a + n), p = g.match(d);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003661 if (p) {
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003662 var m = o + lib.wc.strWidth(p[0]);
3663 -1 == m || i > m || (this.setRange_(r, u, m, t), e.addRange(t));
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003664 }
3665 }
3666 }
3667 }
3668 }
3669 }
3670 }
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003671};
3672, lib.rtdep('lib.f', 'hterm.PubSub', 'hterm.Size'),
3673 hterm.ScrollPort = function(e) {
3674 hterm.PubSub.addBehavior(this),
3675 this.rowProvider_ = e, this.characterSize = new hterm.Size(10, 10),
3676 this.ruler_ = null,
3677 this.selection = new hterm.ScrollPort.Selection(this),
3678 this.currentRowNodeCache_ = null, this.previousRowNodeCache_ = {},
3679 this.lastScreenWidth_ = null, this.lastScreenHeight_ = null,
3680 this.selectionEnabled_ = !0, this.lastRowCount_ = 0,
3681 this.scrollWheelMultiplier_ = 1, this.isScrolledEnd = !0,
3682 this.xrowCssRule_ = null, this.currentScrollbarWidthPx = 16,
3683 this.ctrlVPaste = !1, this.div_ = null, this.document_ = null,
3684 this.timeouts_ = {}, this.observers_ = {}, this.DEBUG_ = !1;
3685 };
3686, hterm.ScrollPort.Selection = function(e) {
3687 this.scrollPort_ = e, this.startRow = null, this.endRow = null,
3688 this.isMultiline = null, this.isCollapsed = null;
3689};
3690, hterm.ScrollPort.Selection.prototype.findFirstChild = function(e, t) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003691 for (var r = e.firstChild; r;) {
3692 if (-1 != t.indexOf(r)) return r;
3693 if (r.childNodes.length) {
3694 var o = this.findFirstChild(r, t);
3695 if (o) return o;
3696 }
3697 r = r.nextSibling;
3698 }
3699 return null;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003700};
3701, hterm.ScrollPort.Selection.prototype.sync = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003702 function e() {
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003703 r.startRow = i, r.startNode = o.anchorNode, r.startOffset = o.anchorOffset,
3704 r.endRow = s, r.endNode = o.focusNode, r.endOffset = o.focusOffset;
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003705 }
3706
3707 function t() {
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003708 r.startRow = s, r.startNode = o.focusNode, r.startOffset = o.focusOffset,
3709 r.endRow = i, r.endNode = o.anchorNode, r.endOffset = o.anchorOffset;
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003710 }
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003711 var r = this, o = this.scrollPort_.getDocument().getSelection();
3712 if (this.startRow = null, this.endRow = null, this.isMultiline = null,
3713 this.isCollapsed = !o || o.isCollapsed, !this.isCollapsed) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003714 for (var i = o.anchorNode; i && !('rowIndex' in i);) i = i.parentNode;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003715 if (!i)
3716 return void console.error(
3717 'Selection anchor is not rooted in a row node: ' +
3718 o.anchorNode.nodeName);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003719 for (var s = o.focusNode; s && !('rowIndex' in s);) s = s.parentNode;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003720 if (!s)
3721 return void console.error(
3722 'Selection focus is not rooted in a row node: ' +
3723 o.focusNode.nodeName);
3724 if (i.rowIndex < s.rowIndex)
3725 e();
3726 else if (i.rowIndex > s.rowIndex)
3727 t();
3728 else if (o.focusNode == o.anchorNode)
3729 o.anchorOffset < o.focusOffset ? e() : t();
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003730 else {
3731 var n = this.findFirstChild(i, [o.anchorNode, o.focusNode]);
3732 if (!n) throw new Error('Unexpected error syncing selection.');
3733 n == o.anchorNode ? e() : t();
3734 }
3735 this.isMultiline = i.rowIndex != s.rowIndex;
3736 }
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003737};
3738, hterm.ScrollPort.prototype.decorate = function(e) {
3739 this.div_ = e, this.iframe_ = e.ownerDocument.createElement('iframe'),
3740 this.iframe_.style.cssText =
3741 'border: 0;height: 100%;position: absolute;width: 100%',
3742 'mozInnerScreenX' in window && (this.iframe_.src = '#'),
3743 e.appendChild(this.iframe_),
3744 this.iframe_.contentWindow.addEventListener(
3745 'resize', this.onResize_.bind(this));
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003746 var t = this.document_ = this.iframe_.contentDocument;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003747 t.body.style.cssText =
3748 'margin: 0px;padding: 0px;height: 100%;width: 100%;overflow: hidden;cursor: text;-webkit-user-select: none;-moz-user-select: none;';
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003749 var r = t.createElement('style');
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003750 r.textContent = 'x-row {}', t.head.appendChild(r),
3751 this.xrowCssRule_ = t.styleSheets[0].cssRules[0],
3752 this.xrowCssRule_.style.display = 'block',
3753 this.userCssLink_ = t.createElement('link'),
3754 this.userCssLink_.setAttribute('rel', 'stylesheet'),
3755 this.screen_ = t.createElement('x-screen'),
3756 this.screen_.setAttribute('role', 'textbox'),
3757 this.screen_.setAttribute('tabindex', '-1'),
3758 this.screen_.style.cssText =
3759 'display: block;font-family: monospace;font-size: 15px;font-variant-ligatures: none;height: 100%;overflow-y: scroll; overflow-x: hidden;white-space: pre;width: 100%;outline: none !important',
3760 t.body.appendChild(this.screen_),
3761 this.screen_.addEventListener('scroll', this.onScroll_.bind(this)),
3762 this.screen_.addEventListener('mousewheel', this.onScrollWheel_.bind(this)),
3763 this.screen_.addEventListener(
3764 'DOMMouseScroll', this.onScrollWheel_.bind(this)),
3765 this.screen_.addEventListener('copy', this.onCopy_.bind(this)),
3766 this.screen_.addEventListener('paste', this.onPaste_.bind(this)),
3767 t.body.addEventListener('keydown', this.onBodyKeyDown_.bind(this)),
3768 this.rowNodes_ = t.createElement('div'),
3769 this.rowNodes_.style.cssText =
3770 'display: block;position: fixed;overflow: hidden;-webkit-user-select: text;-moz-user-select: text;',
3771 this.screen_.appendChild(this.rowNodes_),
3772 this.topSelectBag_ = t.createElement('x-select-bag'),
3773 this.topSelectBag_.style.cssText =
3774 'display: block;overflow: hidden;white-space: pre;',
3775 this.bottomSelectBag_ = this.topSelectBag_.cloneNode(),
3776 this.topFold_ = t.createElement('x-fold'),
3777 this.topFold_.style.cssText = 'display: block;',
3778 this.rowNodes_.appendChild(this.topFold_),
3779 this.bottomFold_ = this.topFold_.cloneNode(),
3780 this.rowNodes_.appendChild(this.bottomFold_),
3781 this.scrollArea_ = t.createElement('div'),
3782 this.scrollArea_.style.cssText = 'visibility: hidden',
3783 this.screen_.appendChild(this.scrollArea_);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003784 var o = 'http://www.w3.org/2000/svg';
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003785 this.svg_ = this.div_.ownerDocument.createElementNS(o, 'svg'),
3786 this.svg_.setAttribute('xmlns', o), this.svg_.setAttribute('version', '1.1'),
3787 this.svg_.style.cssText =
3788 'position: absolute;top: 0;left: 0;visibility: hidden',
3789 this.pasteTarget_ = t.createElement('textarea'),
3790 this.pasteTarget_.setAttribute('tabindex', '-1'),
3791 this.pasteTarget_.style.cssText =
3792 'position: absolute;height: 1px;width: 1px;left: 0px; bottom: 0px;opacity: 0',
3793 this.pasteTarget_.contentEditable = !0,
3794 this.screen_.appendChild(this.pasteTarget_),
3795 this.pasteTarget_.addEventListener(
3796 'textInput', this.handlePasteTargetTextInput_.bind(this)),
3797 this.resize();
3798};
3799, hterm.ScrollPort.prototype.setFontFamily = function(e, t) {
3800 this.screen_.style.fontFamily = e,
3801 t ? this.screen_.style.webkitFontSmoothing = t :
3802 this.screen_.style.webkitFontSmoothing = '',
3803 this.syncCharacterSize();
3804};
3805, hterm.ScrollPort.prototype.getFontFamily = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003806 return this.screen_.style.fontFamily;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003807};
3808, hterm.ScrollPort.prototype.setUserCss = function(e) {
3809 e ? (this.userCssLink_.setAttribute('href', e),
3810 this.userCssLink_.parentNode ||
3811 this.document_.head.appendChild(this.userCssLink_)) :
3812 this.userCssLink_.parentNode &&
3813 this.document_.head.removeChild(this.userCssLink_);
3814};
3815, hterm.ScrollPort.prototype.focus = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003816 this.iframe_.focus(), this.screen_.focus();
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003817};
3818, hterm.ScrollPort.prototype.getForegroundColor = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003819 return this.screen_.style.color;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003820};
3821, hterm.ScrollPort.prototype.setForegroundColor = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003822 this.screen_.style.color = e;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003823};
3824, hterm.ScrollPort.prototype.getBackgroundColor = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003825 return this.screen_.style.backgroundColor;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003826};
3827, hterm.ScrollPort.prototype.setBackgroundColor = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003828 this.screen_.style.backgroundColor = e;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003829};
3830, hterm.ScrollPort.prototype.setBackgroundImage = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003831 this.screen_.style.backgroundImage = e;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003832};
3833, hterm.ScrollPort.prototype.setBackgroundSize = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003834 this.screen_.style.backgroundSize = e;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003835};
3836, hterm.ScrollPort.prototype.setBackgroundPosition = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003837 this.screen_.style.backgroundPosition = e;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003838};
3839, hterm.ScrollPort.prototype.setCtrlVPaste = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003840 this.ctrlVPaste = e;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003841};
3842, hterm.ScrollPort.prototype.getScreenSize = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003843 var e = hterm.getClientSize(this.screen_);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003844 return {height: e.height, width: e.width - this.currentScrollbarWidthPx};
3845};
3846, hterm.ScrollPort.prototype.getScreenWidth = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003847 return this.getScreenSize().width;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003848};
3849, hterm.ScrollPort.prototype.getScreenHeight = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003850 return this.getScreenSize().height;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003851};
3852, hterm.ScrollPort.prototype.getDocument = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003853 return this.document_;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003854};
3855, hterm.ScrollPort.prototype.getScreenNode = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003856 return this.screen_;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003857};
3858, hterm.ScrollPort.prototype.resetCache = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003859 this.currentRowNodeCache_ = null, this.previousRowNodeCache_ = {};
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003860};
3861, hterm.ScrollPort.prototype.setRowProvider = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003862 this.resetCache(), this.rowProvider_ = e, this.scheduleRedraw();
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003863};
3864, hterm.ScrollPort.prototype.invalidate = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003865 for (var e = this.topFold_.nextSibling; e != this.bottomFold_;) {
3866 var t = e.nextSibling;
3867 e.parentElement.removeChild(e), e = t;
3868 }
3869 this.previousRowNodeCache_ = null;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003870 var r = this.getTopRowIndex(), o = this.getBottomRowIndex(r);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003871 this.drawVisibleRows_(r, o);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003872};
3873, hterm.ScrollPort.prototype.scheduleInvalidate = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003874 if (!this.timeouts_.invalidate) {
3875 var e = this;
3876 this.timeouts_.invalidate = setTimeout(function() {
3877 delete e.timeouts_.invalidate, e.invalidate();
3878 }, 0);
3879 }
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003880};
3881, hterm.ScrollPort.prototype.setFontSize = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003882 this.screen_.style.fontSize = e + 'px', this.syncCharacterSize();
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003883};
3884, hterm.ScrollPort.prototype.getFontSize = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003885 return parseInt(this.screen_.style.fontSize);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003886};
3887, hterm.ScrollPort.prototype.measureCharacterSize = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003888 var t = 100,
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003889 r = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003890 if (!this.ruler_) {
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003891 this.ruler_ = this.document_.createElement('div'),
3892 this.ruler_.style.cssText =
3893 'position: absolute;top: 0;left: 0;visibility: hidden;height: auto !important;width: auto !important;',
3894 this.rulerSpan_ = this.document_.createElement('span');
3895 for (var o = '' + r, i = 0; t - 1 > i; ++i)
3896 o += String.fromCharCode(13) + r;
3897 this.rulerSpan_.innerHTML = o, this.ruler_.appendChild(this.rulerSpan_),
3898 this.rulerBaseline_ = this.document_.createElement('span'),
3899 this.rulerBaseline_.style.fontSize = '0px',
3900 this.rulerBaseline_.textContent = 'X';
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003901 }
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003902 this.rulerSpan_.style.fontWeight = e || '',
3903 this.rowNodes_.appendChild(this.ruler_);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003904 var s = hterm.getClientSize(this.rulerSpan_),
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003905 n = new hterm.Size(s.width / r.length, s.height / t);
3906 return this.ruler_.appendChild(this.rulerBaseline_),
3907 n.baseline = this.rulerBaseline_.offsetTop,
3908 this.ruler_.removeChild(this.rulerBaseline_),
3909 this.rowNodes_.removeChild(this.ruler_),
3910 this.div_.ownerDocument.body.appendChild(this.svg_),
3911 n.zoomFactor = this.svg_.currentScale,
3912 this.div_.ownerDocument.body.removeChild(this.svg_), n;
3913};
3914, hterm.ScrollPort.prototype.syncCharacterSize = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003915 this.characterSize = this.measureCharacterSize();
3916 var e = this.characterSize.height + 'px';
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003917 this.xrowCssRule_.style.height = e, this.topSelectBag_.style.height = e,
3918 this.bottomSelectBag_.style.height = e, this.resize(),
3919 this.DEBUG_ &&
3920 (this.document_.body.style.paddingTop =
3921 this.document_.body.style.paddingBottom =
3922 3 * this.characterSize.height + 'px');
3923};
3924, hterm.ScrollPort.prototype.resize = function() {
3925 this.currentScrollbarWidthPx =
3926 hterm.getClientWidth(this.screen_) - this.screen_.clientWidth,
3927 this.syncScrollHeight(), this.syncRowNodesDimensions_();
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003928 var e = this;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003929 this.publish('resize', {scrollPort: this}, function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003930 e.scrollRowToBottom(e.rowProvider_.getRowCount()), e.scheduleRedraw();
3931 });
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003932};
3933, hterm.ScrollPort.prototype.syncRowNodesDimensions_ = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003934 var e = this.getScreenSize();
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003935 this.lastScreenWidth_ = e.width, this.lastScreenHeight_ = e.height,
3936 this.visibleRowCount =
3937 lib.f.smartFloorDivide(e.height, this.characterSize.height);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003938 var t = this.visibleRowCount * this.characterSize.height;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003939 this.visibleRowTopMargin = 0, this.visibleRowBottomMargin = e.height - t,
3940 this.topFold_.style.marginBottom = this.visibleRowTopMargin + 'px';
3941 for (var r = 0, o = this.topFold_.previousSibling; o;)
3942 r += hterm.getClientHeight(o), o = o.previousSibling;
3943 this.rowNodes_.style.width = e.width + 'px',
3944 this.rowNodes_.style.height = t + r + 'px',
3945 this.rowNodes_.style.left = this.screen_.offsetLeft + 'px',
3946 this.rowNodes_.style.top = this.screen_.offsetTop - r + 'px';
3947};
3948, hterm.ScrollPort.prototype.syncScrollHeight = function() {
3949 this.lastRowCount_ = this.rowProvider_.getRowCount(),
3950 this.scrollArea_.style.height =
3951 this.characterSize.height * this.lastRowCount_ +
3952 this.visibleRowTopMargin + this.visibleRowBottomMargin + 'px';
3953};
3954, hterm.ScrollPort.prototype.scheduleRedraw = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003955 if (!this.timeouts_.redraw) {
3956 var e = this;
3957 this.timeouts_.redraw = setTimeout(function() {
3958 delete e.timeouts_.redraw, e.redraw_();
3959 }, 0);
3960 }
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003961};
3962, hterm.ScrollPort.prototype.redraw_ = function() {
3963 this.resetSelectBags_(), this.selection.sync(), this.syncScrollHeight(),
3964 this.currentRowNodeCache_ = {};
3965 var e = this.getTopRowIndex(), t = this.getBottomRowIndex(e);
3966 this.drawTopFold_(e), this.drawBottomFold_(t), this.drawVisibleRows_(e, t),
3967 this.syncRowNodesDimensions_(),
3968 this.previousRowNodeCache_ = this.currentRowNodeCache_,
3969 this.currentRowNodeCache_ = null,
3970 this.isScrolledEnd =
3971 this.getTopRowIndex() + this.visibleRowCount >= this.lastRowCount_;
3972};
3973, hterm.ScrollPort.prototype.drawTopFold_ = function(e) {
3974 if (!this.selection.startRow || this.selection.startRow.rowIndex >= e)
Gunnar Mills4ddda582018-09-04 09:18:30 -05003975 return void (
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003976 this.rowNodes_.firstChild != this.topFold_ &&
3977 this.rowNodes_.insertBefore(this.topFold_, this.rowNodes_.firstChild));
3978 if (!this.selection.isMultiline || this.selection.endRow.rowIndex >= e)
3979 this.selection.startRow.nextSibling != this.topFold_ &&
3980 this.rowNodes_.insertBefore(
3981 this.topFold_, this.selection.startRow.nextSibling);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003982 else
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003983 for (this.selection.endRow.nextSibling != this.topFold_ &&
3984 this.rowNodes_.insertBefore(
3985 this.topFold_, this.selection.endRow.nextSibling);
3986 this.selection.startRow.nextSibling != this.selection.endRow;)
3987 this.rowNodes_.removeChild(this.selection.startRow.nextSibling);
3988 for (; this.rowNodes_.firstChild != this.selection.startRow;)
3989 this.rowNodes_.removeChild(this.rowNodes_.firstChild);
3990};
3991, hterm.ScrollPort.prototype.drawBottomFold_ = function(e) {
3992 if (!this.selection.endRow || this.selection.endRow.rowIndex <= e)
Gunnar Mills4ddda582018-09-04 09:18:30 -05003993 return void (
Andrew Geisslerd27bb132018-05-24 11:07:27 -07003994 this.rowNodes_.lastChild != this.bottomFold_ &&
3995 this.rowNodes_.appendChild(this.bottomFold_));
3996 if (!this.selection.isMultiline || this.selection.startRow.rowIndex <= e)
3997 this.bottomFold_.nextSibling != this.selection.endRow &&
3998 this.rowNodes_.insertBefore(this.bottomFold_, this.selection.endRow);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07003999 else
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004000 for (this.bottomFold_.nextSibling != this.selection.startRow &&
4001 this.rowNodes_.insertBefore(
4002 this.bottomFold_, this.selection.startRow);
4003 this.selection.startRow.nextSibling != this.selection.endRow;)
4004 this.rowNodes_.removeChild(this.selection.startRow.nextSibling);
4005 for (; this.rowNodes_.lastChild != this.selection.endRow;)
4006 this.rowNodes_.removeChild(this.rowNodes_.lastChild);
4007};
4008, hterm.ScrollPort.prototype.drawVisibleRows_ = function(e, t) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004009 function r(e, t) {
4010 for (; e != t;) {
4011 if (!e) throw 'Did not encounter target node';
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004012 if (e == o.bottomFold_)
4013 throw 'Encountered bottom fold before target node';
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004014 var r = e;
4015 e = e.nextSibling, r.parentNode.removeChild(r);
4016 }
4017 }
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004018 for (var o = this, i = this.selection.startRow, s = this.selection.endRow,
4019 n = this.bottomFold_, a = this.topFold_.nextSibling,
4020 l = Math.min(this.visibleRowCount, this.rowProvider_.getRowCount()),
4021 h = 0;
4022 l > h; h++) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004023 var c = e + h;
4024 if (a != n)
4025 if (a.rowIndex != c)
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004026 if (i && i.rowIndex == c)
4027 r(a, i), a = i.nextSibling;
4028 else if (s && s.rowIndex == c)
4029 r(a, s), a = s.nextSibling;
4030 else if (a != i && a != s) {
4031 var u = this.fetchRowNode_(c);
4032 if (!u) {
4033 console.log('Couldn\'t fetch row index: ' + c);
4034 break;
4035 }
4036 a != u ? (this.rowNodes_.insertBefore(u, a), !u.nextSibling,
4037 this.rowNodes_.removeChild(a), a = u.nextSibling) :
4038 a = a.nextSibling;
4039 } else {
4040 var u = this.fetchRowNode_(c);
4041 if (!u) {
4042 console.log('Couldn\'t fetch row index: ' + c);
4043 break;
4044 }
4045 this.rowNodes_.insertBefore(u, a);
4046 }
4047 else
4048 a = a.nextSibling;
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004049 else {
4050 var u = this.fetchRowNode_(c);
4051 if (!u) {
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004052 console.log('Couldn\'t fetch row index: ' + c);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004053 break;
4054 }
4055 this.rowNodes_.insertBefore(u, a);
4056 }
4057 }
4058 a != this.bottomFold_ && r(a, n);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004059};
4060, hterm.ScrollPort.prototype.resetSelectBags_ = function() {
4061 this.topSelectBag_.parentNode &&
4062 (this.topSelectBag_.textContent = '',
4063 this.topSelectBag_.parentNode.removeChild(this.topSelectBag_)),
4064 this.bottomSelectBag_.parentNode &&
4065 (this.bottomSelectBag_.textContent = '',
4066 this.bottomSelectBag_.parentNode.removeChild(this.bottomSelectBag_));
4067};
4068, hterm.ScrollPort.prototype.cacheRowNode_ = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004069 this.currentRowNodeCache_[e.rowIndex] = e;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004070};
4071, hterm.ScrollPort.prototype.fetchRowNode_ = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004072 var t;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004073 return t = this.previousRowNodeCache_ && e in this.previousRowNodeCache_ ?
4074 this.previousRowNodeCache_[e] :
4075 this.rowProvider_.getRowNode(e),
4076 this.currentRowNodeCache_ && this.cacheRowNode_(t), t;
4077};
4078, hterm.ScrollPort.prototype.selectAll = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004079 var e;
4080 if (0 != this.topFold_.nextSibling.rowIndex) {
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004081 for (; this.topFold_.previousSibling;)
4082 this.rowNodes_.removeChild(this.topFold_.previousSibling);
4083 e = this.fetchRowNode_(0), this.rowNodes_.insertBefore(e, this.topFold_),
4084 this.syncRowNodesDimensions_();
4085 } else
4086 e = this.topFold_.nextSibling;
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004087 var t, r = this.rowProvider_.getRowCount() - 1;
4088 if (this.bottomFold_.previousSibling.rowIndex != r) {
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004089 for (; this.bottomFold_.nextSibling;)
4090 this.rowNodes_.removeChild(this.bottomFold_.nextSibling);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004091 t = this.fetchRowNode_(r), this.rowNodes_.appendChild(t);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004092 } else
4093 t = this.bottomFold_.previousSibling.rowIndex;
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004094 var o = this.document_.getSelection();
4095 o.collapse(e, 0), o.extend(t, t.childNodes.length), this.selection.sync();
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004096};
4097, hterm.ScrollPort.prototype.getScrollMax_ = function(e) {
4098 return hterm.getClientHeight(this.scrollArea_) + this.visibleRowTopMargin +
4099 this.visibleRowBottomMargin - hterm.getClientHeight(this.screen_);
4100};
4101, hterm.ScrollPort.prototype.scrollRowToTop = function(e) {
4102 this.syncScrollHeight(),
4103 this.isScrolledEnd = e + this.visibleRowCount >= this.lastRowCount_;
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004104 var t = e * this.characterSize.height + this.visibleRowTopMargin,
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004105 r = this.getScrollMax_();
4106 t > r && (t = r),
4107 this.screen_.scrollTop != t &&
4108 (this.screen_.scrollTop = t, this.scheduleRedraw());
4109};
4110, hterm.ScrollPort.prototype.scrollRowToBottom = function(e) {
4111 this.syncScrollHeight(),
4112 this.isScrolledEnd = e + this.visibleRowCount >= this.lastRowCount_;
4113 var t = e * this.characterSize.height + this.visibleRowTopMargin +
4114 this.visibleRowBottomMargin;
4115 t -= this.visibleRowCount * this.characterSize.height, 0 > t && (t = 0),
4116 this.screen_.scrollTop != t && (this.screen_.scrollTop = t);
4117};
4118, hterm.ScrollPort.prototype.getTopRowIndex = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004119 return Math.round(this.screen_.scrollTop / this.characterSize.height);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004120};
4121, hterm.ScrollPort.prototype.getBottomRowIndex = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004122 return e + this.visibleRowCount - 1;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004123};
4124, hterm.ScrollPort.prototype.onScroll_ = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004125 var t = this.getScreenSize();
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004126 return t.width != this.lastScreenWidth_ ||
4127 t.height != this.lastScreenHeight_ ?
4128 void this.resize() :
4129 (this.redraw_(), void this.publish('scroll', {scrollPort: this}));
4130};
4131, hterm.ScrollPort.prototype.onScrollWheel = function(e) {};
4132, hterm.ScrollPort.prototype.onScrollWheel_ = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004133 if (this.onScrollWheel(e), !e.defaultPrevented) {
4134 var t = 'DOMMouseScroll' == e.type ? -1 * e.detail : e.wheelDeltaY;
4135 t *= this.scrollWheelMultiplier_;
4136 var r = this.screen_.scrollTop - t;
4137 0 > r && (r = 0);
4138 var o = this.getScrollMax_();
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004139 r > o && (r = o),
4140 r != this.screen_.scrollTop &&
4141 (this.screen_.scrollTop = r, e.preventDefault());
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004142 }
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004143};
4144, hterm.ScrollPort.prototype.onResize_ = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004145 this.syncCharacterSize(), this.resize();
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004146};
4147, hterm.ScrollPort.prototype.onCopy = function(e) {};
4148, hterm.ScrollPort.prototype.onCopy_ = function(e) {
4149 if (this.onCopy(e),
4150 !e.defaultPrevented &&
4151 (this.resetSelectBags_(), this.selection.sync(),
4152 this.selection.startRow &&
4153 !(this.selection.endRow.rowIndex -
4154 this.selection.startRow.rowIndex <
4155 2))) {
4156 var t = this.getTopRowIndex(), r = this.getBottomRowIndex(t);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004157 if (this.selection.startRow.rowIndex < t) {
4158 var o;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004159 o = this.selection.endRow.rowIndex < t ?
4160 this.selection.endRow.rowIndex :
4161 this.topFold_.nextSibling.rowIndex,
4162 this.topSelectBag_.textContent = this.rowProvider_.getRowsText(
4163 this.selection.startRow.rowIndex + 1, o),
4164 this.rowNodes_.insertBefore(
4165 this.topSelectBag_, this.selection.startRow.nextSibling),
4166 this.syncRowNodesDimensions_();
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004167 }
4168 if (this.selection.endRow.rowIndex > r) {
4169 var i;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004170 i = this.selection.startRow.rowIndex > r ?
4171 this.selection.startRow.rowIndex + 1 :
4172 this.bottomFold_.previousSibling.rowIndex + 1,
4173 this.bottomSelectBag_.textContent =
4174 this.rowProvider_.getRowsText(i, this.selection.endRow.rowIndex),
4175 this.rowNodes_.insertBefore(this.bottomSelectBag_, this.selection.endRow);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004176 }
4177 }
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004178};
4179, hterm.ScrollPort.prototype.onBodyKeyDown_ = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004180 if (this.ctrlVPaste) {
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004181 var t = String.fromCharCode(e.which), r = t.toLowerCase();
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004182 (e.ctrlKey || e.metaKey) && 'v' == r && this.pasteTarget_.focus();
4183 }
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004184};
4185, hterm.ScrollPort.prototype.onPaste_ = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004186 this.pasteTarget_.focus();
4187 var t = this;
4188 setTimeout(function() {
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004189 t.publish('paste', {text: t.pasteTarget_.value}), t.pasteTarget_.value = '',
4190 t.screen_.focus();
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004191 }, 0);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004192};
4193, hterm.ScrollPort.prototype.handlePasteTargetTextInput_ = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004194 e.stopPropagation();
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004195};
4196, hterm.ScrollPort.prototype.setScrollbarVisible = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004197 this.screen_.style.overflowY = e ? 'scroll' : 'hidden';
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004198};
4199, hterm.ScrollPort.prototype.setScrollWheelMoveMultipler = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004200 this.scrollWheelMultiplier_ = e;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004201};
4202,
4203 lib.rtdep(
4204 'lib.colors', 'lib.PreferenceManager', 'lib.resource', 'lib.wc',
4205 'lib.f', 'hterm.Keyboard', 'hterm.Options', 'hterm.PreferenceManager',
4206 'hterm.Screen', 'hterm.ScrollPort', 'hterm.Size',
4207 'hterm.TextAttributes', 'hterm.VT'),
4208 hterm.Terminal = function(e) {
4209 this.profileId_ = null, this.primaryScreen_ = new hterm.Screen,
4210 this.alternateScreen_ = new hterm.Screen,
4211 this.screen_ = this.primaryScreen_,
4212 this.screenSize = new hterm.Size(0, 0),
4213 this.scrollPort_ = new hterm.ScrollPort(this),
4214 this.scrollPort_.subscribe('resize', this.onResize_.bind(this)),
4215 this.scrollPort_.subscribe('scroll', this.onScroll_.bind(this)),
4216 this.scrollPort_.subscribe('paste', this.onPaste_.bind(this)),
4217 this.scrollPort_.onCopy = this.onCopy_.bind(this), this.div_ = null,
4218 this.document_ = window.document, this.scrollbackRows_ = [],
4219 this.tabStops_ = [], this.defaultTabStops = !0, this.vtScrollTop_ = null,
4220 this.vtScrollBottom_ = null, this.cursorNode_ = null,
4221 this.cursorShape_ = hterm.Terminal.cursorShape.BLOCK,
4222 this.cursorColor_ = null, this.cursorBlinkCycle_ = [100, 100],
4223 this.myOnCursorBlink_ = this.onCursorBlink_.bind(this),
4224 this.backgroundColor_ = null, this.foregroundColor_ = null,
4225 this.scrollOnOutput_ = null, this.scrollOnKeystroke_ = null,
4226 this.defeatMouseReports_ = !1,
4227 this.bellAudio_ = this.document_.createElement('audio'),
4228 this.bellAudio_.setAttribute('preload', 'auto'),
4229 this.bellNotificationList_ = [], this.desktopNotificationBell_ = !1,
4230 this.savedOptions_ = {}, this.options_ = new hterm.Options,
4231 this.timeouts_ = {}, this.vt = new hterm.VT(this),
4232 this.keyboard = new hterm.Keyboard(this),
4233 this.io = new hterm.Terminal.IO(this), this.enableMouseDragScroll = !0,
4234 this.copyOnSelect = null, this.mousePasteButton = null,
4235 this.useDefaultWindowCopy = !1, this.clearSelectionAfterCopy = !0,
4236 this.realizeSize_(80, 24), this.setDefaultTabStops(),
4237 this.setProfile(e || 'default', function() {
4238 this.onTerminalReady();
4239 }.bind(this));
4240 };
4241, hterm.Terminal.cursorShape = {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004242 BLOCK: 'BLOCK',
4243 BEAM: 'BEAM',
4244 UNDERLINE: 'UNDERLINE'
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004245},
4246 hterm.Terminal.prototype.onTerminalReady = function() {};
4247, hterm.Terminal.prototype.tabWidth = 8,
4248 hterm.Terminal.prototype.setProfile = function(e, t) {
4249 this.profileId_ = e.replace(/\//g, '');
4250 var r = this;
4251 this.prefs_ && this.prefs_.deactivate(),
4252 this.prefs_ = new hterm.PreferenceManager(this.profileId_),
4253 this.prefs_.addObservers(null, {
4254 'alt-gr-mode': function(e) {
4255 e = null == e ? 'en-us' == navigator.language.toLowerCase() ?
4256 'none' :
4257 'right-alt' :
4258 'string' == typeof e ? e.toLowerCase() : 'none',
4259 /^(none|ctrl-alt|left-alt|right-alt)$/.test(e) || (e = 'none'),
4260 r.keyboard.altGrMode = e;
4261 },
4262 'alt-backspace-is-meta-backspace': function(e) {
4263 r.keyboard.altBackspaceIsMetaBackspace = e;
4264 },
4265 'alt-is-meta': function(e) {
4266 r.keyboard.altIsMeta = e;
4267 },
4268 'alt-sends-what': function(e) {
4269 /^(escape|8-bit|browser-key)$/.test(e) || (e = 'escape'),
4270 r.keyboard.altSendsWhat = e;
4271 },
4272 'audible-bell-sound': function(e) {
4273 var t = e.match(/^lib-resource:(\S+)/);
4274 t ? r.bellAudio_.setAttribute(
4275 'src', lib.resource.getDataUrl(t[1])) :
4276 r.bellAudio_.setAttribute('src', e);
4277 },
4278 'desktop-notification-bell': function(e) {
4279 e && Notification ?
4280 (r.desktopNotificationBell_ =
4281 'granted' === Notification.permission,
4282 r.desktopNotificationBell_ ||
4283 console.warn(
4284 'desktop-notification-bell is true but we do not have permission to display notifications.')) :
4285 r.desktopNotificationBell_ = !1;
4286 },
4287 'background-color': function(e) {
4288 r.setBackgroundColor(e);
4289 },
4290 'background-image': function(e) {
4291 r.scrollPort_.setBackgroundImage(e);
4292 },
4293 'background-size': function(e) {
4294 r.scrollPort_.setBackgroundSize(e);
4295 },
4296 'background-position': function(e) {
4297 r.scrollPort_.setBackgroundPosition(e);
4298 },
4299 'backspace-sends-backspace': function(e) {
4300 r.keyboard.backspaceSendsBackspace = e;
4301 },
4302 'character-map-overrides': function(e) {
4303 if (!(null == e || e instanceof Object))
4304 return void console.warn(
4305 'Preference character-map-modifications is not an object: ' +
4306 e);
4307 for (var t in e) {
4308 var r = hterm.VT.CharacterMap.maps[t].glmap;
4309 for (var o in e[t]) r[o] = e[t][o];
4310 hterm.VT.CharacterMap.maps[t].reset(r);
4311 }
4312 },
4313 'cursor-blink': function(e) {
4314 r.setCursorBlink(!!e);
4315 },
4316 'cursor-blink-cycle': function(e) {
4317 e instanceof Array && 'number' == typeof e[0] &&
4318 'number' == typeof e[1] ?
4319 r.cursorBlinkCycle_ = e :
4320 'number' == typeof e ? r.cursorBlinkCycle_ = [e, e] :
4321 r.cursorBlinkCycle_ = [100, 100]
4322 },
4323 'cursor-color': function(e) {
4324 r.setCursorColor(e);
4325 },
4326 'color-palette-overrides': function(e) {
4327 if (!(null == e || e instanceof Object || e instanceof Array))
4328 return void console.warn(
4329 'Preference color-palette-overrides is not an array or object: ' +
4330 e);
4331 if (lib.colors.colorPalette = lib.colors.stockColorPalette.concat(),
4332 e)
4333 for (var t in e) {
4334 var o = parseInt(t);
4335 if (isNaN(o) || 0 > o || o > 255)
4336 console.log('Invalid value in palette: ' + t + ': ' + e[t]);
4337 else if (e[o]) {
4338 var i = lib.colors.normalizeCSS(e[o]);
4339 i && (lib.colors.colorPalette[o] = i);
4340 }
4341 }
4342 r.primaryScreen_.textAttributes.resetColorPalette(),
4343 r.alternateScreen_.textAttributes.resetColorPalette();
4344 },
4345 'copy-on-select': function(e) {
4346 r.copyOnSelect = !!e;
4347 },
4348 'use-default-window-copy': function(e) {
4349 r.useDefaultWindowCopy = !!e;
4350 },
4351 'clear-selection-after-copy': function(e) {
4352 r.clearSelectionAfterCopy = !!e;
4353 },
4354 'ctrl-plus-minus-zero-zoom': function(e) {
4355 r.keyboard.ctrlPlusMinusZeroZoom = e;
4356 },
4357 'ctrl-c-copy': function(e) {
4358 r.keyboard.ctrlCCopy = e;
4359 },
4360 'ctrl-v-paste': function(e) {
4361 r.keyboard.ctrlVPaste = e, r.scrollPort_.setCtrlVPaste(e);
4362 },
4363 'east-asian-ambiguous-as-two-column': function(e) {
4364 lib.wc.regardCjkAmbiguous = e;
4365 },
4366 'enable-8-bit-control': function(e) {
4367 r.vt.enable8BitControl = !!e;
4368 },
4369 'enable-bold': function(e) {
4370 r.syncBoldSafeState();
4371 },
4372 'enable-bold-as-bright': function(e) {
4373 r.primaryScreen_.textAttributes.enableBoldAsBright = !!e,
4374 r.alternateScreen_.textAttributes.enableBoldAsBright = !!e;
4375 },
4376 'enable-blink': function(e) {
4377 r.syncBlinkState();
4378 },
4379 'enable-clipboard-write': function(e) {
4380 r.vt.enableClipboardWrite = !!e;
4381 },
4382 'enable-dec12': function(e) {
4383 r.vt.enableDec12 = !!e;
4384 },
4385 'font-family': function(e) {
4386 r.syncFontFamily();
4387 },
4388 'font-size': function(e) {
4389 r.setFontSize(e);
4390 },
4391 'font-smoothing': function(e) {
4392 r.syncFontFamily();
4393 },
4394 'foreground-color': function(e) {
4395 r.setForegroundColor(e);
4396 },
4397 'home-keys-scroll': function(e) {
4398 r.keyboard.homeKeysScroll = e;
4399 },
4400 keybindings: function(e) {
4401 if (r.keyboard.bindings.clear(), e) {
4402 if (!(e instanceof Object))
4403 return void console.error(
4404 'Error in keybindings preference: Expected object');
4405 try {
4406 r.keyboard.bindings.addBindings(e);
4407 } catch (t) {
4408 console.error('Error in keybindings preference: ' + t);
4409 }
4410 }
4411 },
4412 'max-string-sequence': function(e) {
4413 r.vt.maxStringSequence = e;
4414 },
4415 'media-keys-are-fkeys': function(e) {
4416 r.keyboard.mediaKeysAreFKeys = e;
4417 },
4418 'meta-sends-escape': function(e) {
4419 r.keyboard.metaSendsEscape = e;
4420 },
4421 'mouse-paste-button': function(e) {
4422 r.syncMousePasteButton();
4423 },
4424 'page-keys-scroll': function(e) {
4425 r.keyboard.pageKeysScroll = e;
4426 },
4427 'pass-alt-number': function(e) {
4428 if (null == e) {
4429 var t = window.navigator.userAgent.match(/Mac OS X/);
4430 e = !t && 'popup' != hterm.windowType;
4431 }
4432 r.passAltNumber = e;
4433 },
4434 'pass-ctrl-number': function(e) {
4435 if (null == e) {
4436 var t = window.navigator.userAgent.match(/Mac OS X/);
4437 e = !t && 'popup' != hterm.windowType;
4438 }
4439 r.passCtrlNumber = e;
4440 },
4441 'pass-meta-number': function(e) {
4442 if (null == e) {
4443 var t = window.navigator.userAgent.match(/Mac OS X/);
4444 e = t && 'popup' != hterm.windowType;
4445 }
4446 r.passMetaNumber = e;
4447 },
4448 'pass-meta-v': function(e) {
4449 r.keyboard.passMetaV = e;
4450 },
4451 'receive-encoding': function(e) {
4452 /^(utf-8|raw)$/.test(e) ||
4453 (console.warn('Invalid value for "receive-encoding": ' + e),
4454 e = 'utf-8'),
4455 r.vt.characterEncoding = e;
4456 },
4457 'scroll-on-keystroke': function(e) {
4458 r.scrollOnKeystroke_ = e;
4459 },
4460 'scroll-on-output': function(e) {
4461 r.scrollOnOutput_ = e;
4462 },
4463 'scrollbar-visible': function(e) {
4464 r.setScrollbarVisible(e);
4465 },
4466 'scroll-wheel-move-multiplier': function(e) {
4467 r.setScrollWheelMoveMultipler(e);
4468 },
4469 'send-encoding': function(e) {
4470 /^(utf-8|raw)$/.test(e) ||
4471 (console.warn('Invalid value for "send-encoding": ' + e),
4472 e = 'utf-8'),
4473 r.keyboard.characterEncoding = e;
4474 },
4475 'shift-insert-paste': function(e) {
4476 r.keyboard.shiftInsertPaste = e;
4477 },
4478 'user-css': function(e) {
4479 r.scrollPort_.setUserCss(e);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004480 }
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004481 }),
4482 this.prefs_.readStorage(function() {
4483 this.prefs_.notifyAll(), t && t();
4484 }.bind(this));
4485 };
4486, hterm.Terminal.prototype.getPrefs = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004487 return this.prefs_;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004488};
4489, hterm.Terminal.prototype.setBracketedPaste = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004490 this.options_.bracketedPaste = e;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004491};
4492, hterm.Terminal.prototype.setCursorColor = function(e) {
4493 this.cursorColor_ = e, this.cursorNode_.style.backgroundColor = e,
4494 this.cursorNode_.style.borderColor = e;
4495};
4496, hterm.Terminal.prototype.getCursorColor = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004497 return this.cursorColor_;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004498};
4499, hterm.Terminal.prototype.setSelectionEnabled = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004500 this.enableMouseDragScroll = e;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004501};
4502, hterm.Terminal.prototype.setBackgroundColor = function(e) {
4503 this.backgroundColor_ = lib.colors.normalizeCSS(e),
4504 this.primaryScreen_.textAttributes.setDefaults(
4505 this.foregroundColor_, this.backgroundColor_),
4506 this.alternateScreen_.textAttributes.setDefaults(
4507 this.foregroundColor_, this.backgroundColor_),
4508 this.scrollPort_.setBackgroundColor(e);
4509};
4510, hterm.Terminal.prototype.getBackgroundColor = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004511 return this.backgroundColor_;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004512};
4513, hterm.Terminal.prototype.setForegroundColor = function(e) {
4514 this.foregroundColor_ = lib.colors.normalizeCSS(e),
4515 this.primaryScreen_.textAttributes.setDefaults(
4516 this.foregroundColor_, this.backgroundColor_),
4517 this.alternateScreen_.textAttributes.setDefaults(
4518 this.foregroundColor_, this.backgroundColor_),
4519 this.scrollPort_.setForegroundColor(e);
4520};
4521, hterm.Terminal.prototype.getForegroundColor = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004522 return this.foregroundColor_;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004523};
4524, hterm.Terminal.prototype.runCommandClass = function(e, t) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004525 var r = this.prefs_.get('environment');
4526 ('object' != typeof r || null == r) && (r = {});
4527 var o = this;
4528 this.command = new e({
4529 argString: t || '',
4530 io: this.io.push(),
4531 environment: r,
4532 onExit: function(e) {
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004533 o.io.pop(), o.uninstallKeyboard(),
4534 o.prefs_.get('close-on-exit') && window.close();
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004535 }
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004536 }),
4537 this.installKeyboard(), this.command.run();
4538};
4539, hterm.Terminal.prototype.isPrimaryScreen = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004540 return this.screen_ == this.primaryScreen_;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004541};
4542, hterm.Terminal.prototype.installKeyboard = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004543 this.keyboard.installKeyboard(this.scrollPort_.getDocument().body);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004544};
4545, hterm.Terminal.prototype.uninstallKeyboard = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004546 this.keyboard.installKeyboard(null);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004547};
4548, hterm.Terminal.prototype.setFontSize = function(e) {
4549 0 === e && (e = this.prefs_.get('font-size')),
4550 this.scrollPort_.setFontSize(e),
4551 this.wcCssRule_ &&
4552 (this.wcCssRule_.style.width =
4553 2 * this.scrollPort_.characterSize.width + 'px');
4554};
4555, hterm.Terminal.prototype.getFontSize = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004556 return this.scrollPort_.getFontSize();
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004557};
4558, hterm.Terminal.prototype.getFontFamily = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004559 return this.scrollPort_.getFontFamily();
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004560};
4561, hterm.Terminal.prototype.syncFontFamily = function() {
4562 this.scrollPort_.setFontFamily(
4563 this.prefs_.get('font-family'), this.prefs_.get('font-smoothing')),
4564 this.syncBoldSafeState();
4565};
4566, hterm.Terminal.prototype.syncMousePasteButton = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004567 var e = this.prefs_.get('mouse-paste-button');
Gunnar Mills4ddda582018-09-04 09:18:30 -05004568 if ('number' == typeof e) return void (this.mousePasteButton = e);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004569 var t = navigator.userAgent.match(/\(X11;\s+(\S+)/);
4570 t && 'CrOS' != t[2] ? this.mousePasteButton = 3 : this.mousePasteButton = 2;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004571};
4572, hterm.Terminal.prototype.syncBoldSafeState = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004573 var e = this.prefs_.get('enable-bold');
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004574 if (null !== e)
4575 return this.primaryScreen_.textAttributes.enableBold = e,
Gunnar Mills4ddda582018-09-04 09:18:30 -05004576 void (this.alternateScreen_.textAttributes.enableBold = e);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004577 var t = this.scrollPort_.measureCharacterSize(),
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004578 r = this.scrollPort_.measureCharacterSize('bold'), o = t.equals(r);
4579 o ||
4580 console.warn(
4581 'Bold characters disabled: Size of bold weight differs from normal. Font family is: ' +
4582 this.scrollPort_.getFontFamily()),
4583 this.primaryScreen_.textAttributes.enableBold = o,
4584 this.alternateScreen_.textAttributes.enableBold = o;
4585};
4586, hterm.Terminal.prototype.syncBlinkState = function() {
4587 this.document_.documentElement.style.setProperty(
4588 '--hterm-blink-node-duration',
4589 this.prefs_.get('enable-blink') ? '0.7s' : '0');
4590};
4591, hterm.Terminal.prototype.saveCursor = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004592 return this.screen_.cursorPosition.clone();
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004593};
4594, hterm.Terminal.prototype.getTextAttributes = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004595 return this.screen_.textAttributes;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004596};
4597, hterm.Terminal.prototype.setTextAttributes = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004598 this.screen_.textAttributes = e;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004599};
4600, hterm.Terminal.prototype.getZoomFactor = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004601 return this.scrollPort_.characterSize.zoomFactor;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004602};
4603, hterm.Terminal.prototype.setWindowTitle = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004604 window.document.title = e;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004605};
4606, hterm.Terminal.prototype.restoreCursor = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004607 var t = lib.f.clamp(e.row, 0, this.screenSize.height - 1),
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004608 r = lib.f.clamp(e.column, 0, this.screenSize.width - 1);
4609 this.screen_.setCursorPosition(t, r),
4610 (e.column > r || e.column == r && e.overflow) &&
4611 (this.screen_.cursorPosition.overflow = !0);
4612};
4613, hterm.Terminal.prototype.clearCursorOverflow = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004614 this.screen_.cursorPosition.overflow = !1;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004615};
4616, hterm.Terminal.prototype.setCursorShape = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004617 this.cursorShape_ = e, this.restyleCursor_();
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004618};
4619, hterm.Terminal.prototype.getCursorShape = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004620 return this.cursorShape_;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004621};
4622, hterm.Terminal.prototype.setWidth = function(e) {
4623 return null == e ?
Gunnar Mills4ddda582018-09-04 09:18:30 -05004624 void (this.div_.style.width = '100%') :
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004625 (this.div_.style.width = Math.ceil(
4626 this.scrollPort_.characterSize.width * e +
4627 this.scrollPort_.currentScrollbarWidthPx) +
4628 'px',
4629 this.realizeSize_(e, this.screenSize.height),
4630 void this.scheduleSyncCursorPosition_());
4631};
4632, hterm.Terminal.prototype.setHeight = function(e) {
Gunnar Mills4ddda582018-09-04 09:18:30 -05004633 return null == e ? void (this.div_.style.height = '100%') :
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004634 (this.div_.style.height =
4635 this.scrollPort_.characterSize.height * e + 'px',
4636 this.realizeSize_(this.screenSize.width, e),
4637 void this.scheduleSyncCursorPosition_());
4638};
4639, hterm.Terminal.prototype.realizeSize_ = function(e, t) {
4640 e != this.screenSize.width && this.realizeWidth_(e),
4641 t != this.screenSize.height && this.realizeHeight_(t),
4642 this.io.onTerminalResize_(e, t);
4643};
4644, hterm.Terminal.prototype.realizeWidth_ = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004645 if (0 >= e) throw new Error('Attempt to realize bad width: ' + e);
4646 var t = e - this.screen_.getWidth();
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004647 if (this.screenSize.width = e, this.screen_.setColumnCount(e), t > 0)
4648 this.defaultTabStops && this.setDefaultTabStops(this.screenSize.width - t);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004649 else
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004650 for (var r = this.tabStops_.length - 1; r >= 0 && !(this.tabStops_[r] < e);
4651 r--)
4652 this.tabStops_.pop();
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004653 this.screen_.setColumnCount(this.screenSize.width);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004654};
4655, hterm.Terminal.prototype.realizeHeight_ = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004656 if (0 >= e) throw new Error('Attempt to realize bad height: ' + e);
4657 var t = e - this.screen_.getHeight();
4658 this.screenSize.height = e;
4659 var r = this.saveCursor();
4660 if (0 > t) {
4661 for (t *= -1; t;) {
4662 var o = this.getRowCount() - 1;
4663 if (o - this.scrollbackRows_.length == r.row) break;
4664 if (this.getRowText(o)) break;
4665 this.screen_.popRow(), t--;
4666 }
4667 var i = this.screen_.shiftRows(t);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004668 this.scrollbackRows_.push.apply(this.scrollbackRows_, i),
4669 r.row = Math.max(r.row - t, 0);
4670 } else if (t > 0) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004671 if (t <= this.scrollbackRows_.length) {
4672 var s = Math.min(t, this.scrollbackRows_.length),
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004673 n = this.scrollbackRows_.splice(this.scrollbackRows_.length - s, s);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004674 this.screen_.unshiftRows(n), t -= s, r.row += s;
4675 }
4676 t && this.appendRows_(t);
4677 }
4678 this.setVTScrollRegion(null, null), this.restoreCursor(r);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004679};
4680, hterm.Terminal.prototype.scrollHome = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004681 this.scrollPort_.scrollRowToTop(0);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004682};
4683, hterm.Terminal.prototype.scrollEnd = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004684 this.scrollPort_.scrollRowToBottom(this.getRowCount());
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004685};
4686, hterm.Terminal.prototype.scrollPageUp = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004687 var e = this.scrollPort_.getTopRowIndex();
4688 this.scrollPort_.scrollRowToTop(e - this.screenSize.height + 1);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004689};
4690, hterm.Terminal.prototype.scrollPageDown = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004691 var e = this.scrollPort_.getTopRowIndex();
4692 this.scrollPort_.scrollRowToTop(e + this.screenSize.height - 1);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004693};
4694, hterm.Terminal.prototype.wipeContents = function() {
4695 this.scrollbackRows_.length = 0, this.scrollPort_.resetCache(),
4696 [this.primaryScreen_, this.alternateScreen_].forEach(function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004697 var t = e.getHeight();
4698 t > 0 && (this.renumberRows_(0, t), this.clearHome(e));
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004699 }.bind(this)),
4700 this.syncCursorPosition_(), this.scrollPort_.invalidate();
4701};
4702, hterm.Terminal.prototype.reset = function() {
4703 this.clearAllTabStops(), this.setDefaultTabStops(),
4704 this.clearHome(this.primaryScreen_),
4705 this.primaryScreen_.textAttributes.reset(),
4706 this.clearHome(this.alternateScreen_),
4707 this.alternateScreen_.textAttributes.reset(),
4708 this.setCursorBlink(!!this.prefs_.get('cursor-blink')), this.vt.reset(),
4709 this.softReset();
4710};
4711, hterm.Terminal.prototype.softReset = function() {
4712 this.options_ = new hterm.Options,
4713 this.options_.cursorBlink = !!this.timeouts_.cursorBlink,
4714 this.primaryScreen_.textAttributes.resetColorPalette(),
4715 this.alternateScreen_.textAttributes.resetColorPalette(),
4716 this.setVTScrollRegion(null, null), this.setCursorVisible(!0);
4717};
4718, hterm.Terminal.prototype.forwardTabStop = function() {
4719 for (var e = this.screen_.cursorPosition.column, t = 0;
4720 t < this.tabStops_.length; t++)
4721 if (this.tabStops_[t] > e)
4722 return void this.setCursorColumn(this.tabStops_[t]);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004723 var r = this.screen_.cursorPosition.overflow;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004724 this.setCursorColumn(this.screenSize.width - 1),
4725 this.screen_.cursorPosition.overflow = r;
4726};
4727, hterm.Terminal.prototype.backwardTabStop = function() {
4728 for (var e = this.screen_.cursorPosition.column,
4729 t = this.tabStops_.length - 1;
4730 t >= 0; t--)
4731 if (this.tabStops_[t] < e)
4732 return void this.setCursorColumn(this.tabStops_[t]);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004733 this.setCursorColumn(1);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004734};
4735, hterm.Terminal.prototype.setTabStop = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004736 for (var t = this.tabStops_.length - 1; t >= 0; t--) {
4737 if (this.tabStops_[t] == e) return;
4738 if (this.tabStops_[t] < e) return void this.tabStops_.splice(t + 1, 0, e);
4739 }
4740 this.tabStops_.splice(0, 0, e);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004741};
4742, hterm.Terminal.prototype.clearTabStopAtCursor = function() {
4743 var e = this.screen_.cursorPosition.column, t = this.tabStops_.indexOf(e);
4744 -1 != t && this.tabStops_.splice(t, 1);
4745};
4746, hterm.Terminal.prototype.clearAllTabStops = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004747 this.tabStops_.length = 0, this.defaultTabStops = !1;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004748};
4749, hterm.Terminal.prototype.setDefaultTabStops = function(e) {
4750 var t = e || 0, r = this.tabWidth;
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004751 t = t - 1 - (t - 1) % r + r;
4752 for (var o = t; o < this.screenSize.width; o += r) this.setTabStop(o);
4753 this.defaultTabStops = !0;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004754};
4755, hterm.Terminal.prototype.interpret = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004756 this.vt.interpret(e), this.scheduleSyncCursorPosition_();
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004757};
4758, hterm.Terminal.prototype.decorate = function(e) {
4759 this.div_ = e, this.scrollPort_.decorate(e),
4760 this.scrollPort_.setBackgroundImage(this.prefs_.get('background-image')),
4761 this.scrollPort_.setBackgroundSize(this.prefs_.get('background-size')),
4762 this.scrollPort_.setBackgroundPosition(
4763 this.prefs_.get('background-position')),
4764 this.scrollPort_.setUserCss(this.prefs_.get('user-css')),
4765 this.div_.focus = this.focus.bind(this),
4766 this.setFontSize(this.prefs_.get('font-size')), this.syncFontFamily(),
4767 this.setScrollbarVisible(this.prefs_.get('scrollbar-visible')),
4768 this.setScrollWheelMoveMultipler(
4769 this.prefs_.get('scroll-wheel-move-multiplier')),
4770 this.document_ = this.scrollPort_.getDocument(),
4771 this.document_.body.oncontextmenu = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004772 return !1;
4773 };
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004774 var t = this.onMouse_.bind(this), r = this.scrollPort_.getScreenNode();
4775 r.addEventListener('mousedown', t), r.addEventListener('mouseup', t),
4776 r.addEventListener('mousemove', t),
4777 this.scrollPort_.onScrollWheel = t,
4778 r.addEventListener('focus', this.onFocusChange_.bind(this, !0)),
4779 r.addEventListener(
4780 'mousedown',
4781 function() {
4782 setTimeout(this.onFocusChange_.bind(this, !0));
4783 }.bind(this)),
4784 r.addEventListener('blur', this.onFocusChange_.bind(this, !1));
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004785 var o = this.document_.createElement('style');
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004786 o.textContent =
4787 '.cursor-node[focus="false"] { box-sizing: border-box; background-color: transparent !important; border-width: 2px; border-style: solid;}.wc-node { display: inline-block; text-align: center; width: ' +
4788 2 * this.scrollPort_.characterSize.width +
4789 'px;}:root { --hterm-blink-node-duration: 0.7s;}@keyframes blink { from { opacity: 1.0; } to { opacity: 0.0; }}.blink-node { animation-name: blink; animation-duration: var(--hterm-blink-node-duration); animation-iteration-count: infinite; animation-timing-function: ease-in-out; animation-direction: alternate;}',
4790 this.document_.head.appendChild(o);
4791 var i = this.document_.styleSheets, s = i[i.length - 1].cssRules;
4792 this.wcCssRule_ = s[s.length - 1],
4793 this.cursorNode_ = this.document_.createElement('div'),
4794 this.cursorNode_.className = 'cursor-node',
4795 this.cursorNode_.style.cssText =
4796 'position: absolute;top: -99px;display: block;width: ' +
4797 this.scrollPort_.characterSize.width +
4798 'px;height: ' + this.scrollPort_.characterSize.height +
4799 'px;-webkit-transition: opacity, background-color 100ms linear;-moz-transition: opacity, background-color 100ms linear;',
4800 this.setCursorColor(this.prefs_.get('cursor-color')),
4801 this.setCursorBlink(!!this.prefs_.get('cursor-blink')), this.restyleCursor_(),
4802 this.document_.body.appendChild(this.cursorNode_),
4803 this.scrollBlockerNode_ = this.document_.createElement('div'),
4804 this.scrollBlockerNode_.style.cssText =
4805 'position: absolute;top: -99px;display: block;width: 10px;height: 10px;',
4806 this.document_.body.appendChild(this.scrollBlockerNode_),
4807 this.scrollPort_.onScrollWheel = t,
4808 ['mousedown', 'mouseup', 'mousemove', 'click', 'dblclick'].forEach(function(
4809 e) {
4810 this.scrollBlockerNode_.addEventListener(e, t),
4811 this.cursorNode_.addEventListener(e, t),
4812 this.document_.addEventListener(e, t);
4813 }.bind(this)),
4814 this.cursorNode_.addEventListener(
4815 'mousedown',
4816 function() {
4817 setTimeout(this.focus.bind(this));
4818 }.bind(this)),
4819 this.setReverseVideo(!1), this.scrollPort_.focus(),
4820 this.scrollPort_.scheduleRedraw();
4821};
4822, hterm.Terminal.prototype.getDocument = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004823 return this.document_;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004824};
4825, hterm.Terminal.prototype.focus = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004826 this.scrollPort_.focus();
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004827};
4828, hterm.Terminal.prototype.getRowNode = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004829 if (e < this.scrollbackRows_.length) return this.scrollbackRows_[e];
4830 var t = e - this.scrollbackRows_.length;
4831 return this.screen_.rowsArray[t];
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004832};
4833, hterm.Terminal.prototype.getRowsText = function(e, t) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004834 for (var r = [], o = e; t > o; o++) {
4835 var i = this.getRowNode(o);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004836 r.push(i.textContent),
4837 t - 1 > o && !i.getAttribute('line-overflow') && r.push('\n');
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004838 }
4839 return r.join('');
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004840};
4841, hterm.Terminal.prototype.getRowText = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004842 var t = this.getRowNode(e);
4843 return t.textContent;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004844};
4845, hterm.Terminal.prototype.getRowCount = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004846 return this.scrollbackRows_.length + this.screen_.rowsArray.length;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004847};
4848, hterm.Terminal.prototype.appendRows_ = function(e) {
4849 for (var t = this.screen_.rowsArray.length,
4850 r = this.scrollbackRows_.length + t, o = 0;
4851 e > o; o++) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004852 var i = this.document_.createElement('x-row');
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004853 i.appendChild(this.document_.createTextNode('')), i.rowIndex = r + o,
4854 this.screen_.pushRow(i);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004855 }
4856 var s = this.screen_.rowsArray.length - this.screenSize.height;
4857 if (s > 0) {
4858 var n = this.screen_.shiftRows(s);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004859 Array.prototype.push.apply(this.scrollbackRows_, n),
4860 this.scrollPort_.isScrolledEnd && this.scheduleScrollDown_();
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004861 }
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004862 t >= this.screen_.rowsArray.length && (t = this.screen_.rowsArray.length - 1),
4863 this.setAbsoluteCursorPosition(t, 0);
4864};
4865, hterm.Terminal.prototype.moveRows_ = function(e, t, r) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004866 var o = this.screen_.removeRows(e, t);
4867 this.screen_.insertRows(r, o);
4868 var i, s;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004869 r > e ? (i = e, s = r + t) : (i = r, s = e + t), this.renumberRows_(i, s),
4870 this.scrollPort_.scheduleInvalidate();
4871};
4872, hterm.Terminal.prototype.renumberRows_ = function(e, t, r) {
4873 for (var o = r || this.screen_, i = this.scrollbackRows_.length, s = e; t > s;
4874 s++)
4875 o.rowsArray[s].rowIndex = i + s;
4876};
4877, hterm.Terminal.prototype.print = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004878 for (var t = 0, r = lib.wc.strWidth(e); r > t;) {
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004879 this.options_.wraparound && this.screen_.cursorPosition.overflow &&
4880 (this.screen_.commitLineOverflow(), this.newLine());
4881 var o, i = r - t, s = !1;
4882 this.screen_.cursorPosition.column + i >= this.screenSize.width &&
4883 (s = !0,
4884 i = this.screenSize.width - this.screen_.cursorPosition.column),
4885 s && !this.options_.wraparound ?
4886 (o = lib.wc.substr(e, t, i - 1) + lib.wc.substr(e, r - 1), i = r) :
4887 o = lib.wc.substr(e, t, i);
4888 for (var n = hterm.TextAttributes.splitWidecharString(o), a = 0;
4889 a < n.length; a++)
4890 n[a].wcNode && (this.screen_.textAttributes.wcNode = !0),
4891 this.options_.insertMode ? this.screen_.insertString(n[a].str) :
4892 this.screen_.overwriteString(n[a].str),
4893 this.screen_.textAttributes.wcNode = !1;
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004894 this.screen_.maybeClipCurrentRow(), t += i;
4895 }
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004896 this.scheduleSyncCursorPosition_(),
4897 this.scrollOnOutput_ &&
4898 this.scrollPort_.scrollRowToBottom(this.getRowCount());
4899};
4900, hterm.Terminal.prototype.setVTScrollRegion = function(e, t) {
4901 0 == e && t == this.screenSize.height - 1 ?
4902 (this.vtScrollTop_ = null, this.vtScrollBottom_ = null) :
4903 (this.vtScrollTop_ = e, this.vtScrollBottom_ = t);
4904};
4905, hterm.Terminal.prototype.getVTScrollTop = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004906 return null != this.vtScrollTop_ ? this.vtScrollTop_ : 0;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004907};
4908, hterm.Terminal.prototype.getVTScrollBottom = function() {
4909 return null != this.vtScrollBottom_ ? this.vtScrollBottom_ :
4910 this.screenSize.height - 1;
4911};
4912, hterm.Terminal.prototype.newLine = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004913 var e = this.screen_.cursorPosition.row == this.screen_.rowsArray.length - 1;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004914 null != this.vtScrollBottom_ ?
4915 this.screen_.cursorPosition.row == this.vtScrollBottom_ ?
4916 (this.vtScrollUp(1),
4917 this.setAbsoluteCursorPosition(this.screen_.cursorPosition.row, 0)) :
4918 e ?
4919 this.setAbsoluteCursorPosition(this.screen_.cursorPosition.row, 0) :
4920 this.setAbsoluteCursorPosition(this.screen_.cursorPosition.row + 1, 0) :
4921 e ? this.appendRows_(1) :
4922 this.setAbsoluteCursorPosition(this.screen_.cursorPosition.row + 1, 0)
4923};
4924, hterm.Terminal.prototype.lineFeed = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004925 var e = this.screen_.cursorPosition.column;
4926 this.newLine(), this.setCursorColumn(e);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004927};
4928, hterm.Terminal.prototype.formFeed = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004929 this.options_.autoCarriageReturn ? this.newLine() : this.lineFeed();
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004930};
4931, hterm.Terminal.prototype.reverseLineFeed = function() {
4932 var e = this.getVTScrollTop(), t = this.screen_.cursorPosition.row;
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004933 t == e ? this.insertLines(1) : this.setAbsoluteCursorRow(t - 1);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004934};
4935, hterm.Terminal.prototype.eraseToLeft = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004936 var e = this.saveCursor();
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004937 this.setCursorColumn(0),
4938 this.screen_.overwriteString(lib.f.getWhitespace(e.column + 1)),
4939 this.restoreCursor(e);
4940};
4941, hterm.Terminal.prototype.eraseToRight = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004942 if (!this.screen_.cursorPosition.overflow) {
4943 var t = this.screenSize.width - this.screen_.cursorPosition.column,
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004944 r = e ? Math.min(e, t) : t;
4945 if (this.screen_.textAttributes.background ===
4946 this.screen_.textAttributes.DEFAULT_COLOR) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004947 var o = this.screen_.rowsArray[this.screen_.cursorPosition.row];
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004948 if (hterm.TextAttributes.nodeWidth(o) <=
4949 this.screen_.cursorPosition.column + r)
4950 return this.screen_.deleteChars(r), void this.clearCursorOverflow();
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004951 }
4952 var i = this.saveCursor();
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004953 this.screen_.overwriteString(lib.f.getWhitespace(r)), this.restoreCursor(i),
4954 this.clearCursorOverflow();
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004955 }
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004956};
4957, hterm.Terminal.prototype.eraseLine = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004958 var e = this.saveCursor();
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004959 this.screen_.clearCursorRow(), this.restoreCursor(e),
4960 this.clearCursorOverflow();
4961};
4962, hterm.Terminal.prototype.eraseAbove = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004963 var e = this.saveCursor();
4964 this.eraseToLeft();
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004965 for (var t = 0; t < e.row; t++)
4966 this.setAbsoluteCursorPosition(t, 0), this.screen_.clearCursorRow();
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004967 this.restoreCursor(e), this.clearCursorOverflow();
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004968};
4969, hterm.Terminal.prototype.eraseBelow = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004970 var e = this.saveCursor();
4971 this.eraseToRight();
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004972 for (var t = this.screenSize.height - 1, r = e.row + 1; t >= r; r++)
4973 this.setAbsoluteCursorPosition(r, 0), this.screen_.clearCursorRow();
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004974 this.restoreCursor(e), this.clearCursorOverflow();
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004975};
4976, hterm.Terminal.prototype.fill = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004977 var t = this.saveCursor();
4978 this.setAbsoluteCursorPosition(0, 0);
4979 for (var r = 0; r < this.screenSize.height; r++)
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004980 for (var o = 0; o < this.screenSize.width; o++)
4981 this.setAbsoluteCursorPosition(r, o), this.screen_.overwriteString(e);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004982 this.restoreCursor(t);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004983};
4984, hterm.Terminal.prototype.clearHome = function(e) {
4985 var t = e || this.screen_, r = t.getHeight();
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004986 if (0 != r) {
4987 for (var o = 0; r > o; o++) t.setCursorPosition(o, 0), t.clearCursorRow();
4988 t.setCursorPosition(0, 0);
4989 }
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004990};
4991, hterm.Terminal.prototype.clear = function(e) {
4992 var t = e || this.screen_, r = t.cursorPosition.clone();
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004993 this.clearHome(t), t.setCursorPosition(r.row, r.column);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07004994};
4995, hterm.Terminal.prototype.insertLines = function(e) {
4996 var t = this.screen_.cursorPosition.row, r = this.getVTScrollBottom();
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004997 e = Math.min(e, r - t);
4998 var o = r - t - e + 1;
4999 o && this.moveRows_(t, o, t + e);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005000 for (var i = e - 1; i >= 0; i--)
5001 this.setAbsoluteCursorPosition(t + i, 0), this.screen_.clearCursorRow();
5002};
5003, hterm.Terminal.prototype.deleteLines = function(e) {
5004 var t = this.saveCursor(), r = t.row, o = this.getVTScrollBottom(),
5005 i = o - r + 1;
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005006 e = Math.min(e, i);
5007 var s = o - e + 1;
5008 e != i && this.moveRows_(r, e, s);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005009 for (var n = 0; e > n; n++)
5010 this.setAbsoluteCursorPosition(s + n, 0), this.screen_.clearCursorRow();
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005011 this.restoreCursor(t), this.clearCursorOverflow();
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005012};
5013, hterm.Terminal.prototype.insertSpace = function(e) {
5014 var t = this.saveCursor(), r = lib.f.getWhitespace(e || 1);
5015 this.screen_.insertString(r), this.screen_.maybeClipCurrentRow(),
5016 this.restoreCursor(t), this.clearCursorOverflow();
5017};
5018, hterm.Terminal.prototype.deleteChars = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005019 var t = this.screen_.deleteChars(e);
5020 if (t && !this.screen_.textAttributes.isDefault()) {
5021 var r = this.saveCursor();
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005022 this.setCursorColumn(this.screenSize.width - t),
5023 this.screen_.insertString(lib.f.getWhitespace(t)),
5024 this.restoreCursor(r);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005025 }
5026 this.clearCursorOverflow();
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005027};
5028, hterm.Terminal.prototype.vtScrollUp = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005029 var t = this.saveCursor();
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005030 this.setAbsoluteCursorRow(this.getVTScrollTop()), this.deleteLines(e),
5031 this.restoreCursor(t);
5032};
5033, hterm.Terminal.prototype.vtScrollDown = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005034 var t = this.saveCursor();
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005035 this.setAbsoluteCursorPosition(this.getVTScrollTop(), 0), this.insertLines(e),
5036 this.restoreCursor(t);
5037};
5038, hterm.Terminal.prototype.setCursorPosition = function(e, t) {
5039 this.options_.originMode ? this.setRelativeCursorPosition(e, t) :
5040 this.setAbsoluteCursorPosition(e, t);
5041};
5042, hterm.Terminal.prototype.setRelativeCursorPosition = function(e, t) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005043 var r = this.getVTScrollTop();
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005044 e = lib.f.clamp(e + r, r, this.getVTScrollBottom()),
5045 t = lib.f.clamp(t, 0, this.screenSize.width - 1),
5046 this.screen_.setCursorPosition(e, t);
5047};
5048, hterm.Terminal.prototype.setAbsoluteCursorPosition = function(e, t) {
5049 e = lib.f.clamp(e, 0, this.screenSize.height - 1),
5050 t = lib.f.clamp(t, 0, this.screenSize.width - 1),
5051 this.screen_.setCursorPosition(e, t);
5052};
5053, hterm.Terminal.prototype.setCursorColumn = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005054 this.setAbsoluteCursorPosition(this.screen_.cursorPosition.row, e);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005055};
5056, hterm.Terminal.prototype.getCursorColumn = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005057 return this.screen_.cursorPosition.column;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005058};
5059, hterm.Terminal.prototype.setAbsoluteCursorRow = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005060 this.setAbsoluteCursorPosition(e, this.screen_.cursorPosition.column);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005061};
5062, hterm.Terminal.prototype.getCursorRow = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005063 return this.screen_.cursorPosition.row;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005064};
5065, hterm.Terminal.prototype.scheduleRedraw_ = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005066 if (!this.timeouts_.redraw) {
5067 var e = this;
5068 this.timeouts_.redraw = setTimeout(function() {
5069 delete e.timeouts_.redraw, e.scrollPort_.redraw_();
5070 }, 0);
5071 }
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005072};
5073, hterm.Terminal.prototype.scheduleScrollDown_ = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005074 if (!this.timeouts_.scrollDown) {
5075 var e = this;
5076 this.timeouts_.scrollDown = setTimeout(function() {
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005077 delete e.timeouts_.scrollDown,
5078 e.scrollPort_.scrollRowToBottom(e.getRowCount());
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005079 }, 10);
5080 }
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005081};
5082, hterm.Terminal.prototype.cursorUp = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005083 return this.cursorDown(-(e || 1));
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005084};
5085, hterm.Terminal.prototype.cursorDown = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005086 e = e || 1;
5087 var t = this.options_.originMode ? this.getVTScrollTop() : 0,
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005088 r = this.options_.originMode ? this.getVTScrollBottom() :
5089 this.screenSize.height - 1,
5090 o = lib.f.clamp(this.screen_.cursorPosition.row + e, t, r);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005091 this.setAbsoluteCursorRow(o);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005092};
5093, hterm.Terminal.prototype.cursorLeft = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005094 if (e = e || 1, !(1 > e)) {
5095 var t = this.screen_.cursorPosition.column;
5096 if (this.options_.reverseWraparound) {
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005097 if (this.screen_.cursorPosition.overflow &&
5098 (e--, this.clearCursorOverflow(), !e))
5099 return;
5100 var r = this.screen_.cursorPosition.row, o = t - e;
5101 0 > o &&
5102 (r = r - Math.floor(e / this.screenSize.width) - 1,
5103 0 > r && (r = this.screenSize.height + r % this.screenSize.height),
5104 o = this.screenSize.width + o % this.screenSize.width),
5105 this.setCursorPosition(Math.max(r, 0), o);
5106 } else {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005107 var o = Math.max(t - e, 0);
5108 this.setCursorColumn(o);
5109 }
5110 }
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005111};
5112, hterm.Terminal.prototype.cursorRight = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005113 if (e = e || 1, !(1 > e)) {
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005114 var t = lib.f.clamp(
5115 this.screen_.cursorPosition.column + e, 0, this.screenSize.width - 1);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005116 this.setCursorColumn(t);
5117 }
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005118};
5119, hterm.Terminal.prototype.setReverseVideo = function(e) {
5120 this.options_.reverseVideo = e,
5121 e ? (this.scrollPort_.setForegroundColor(this.prefs_.get('background-color')),
5122 this.scrollPort_.setBackgroundColor(
5123 this.prefs_.get('foreground-color'))) :
5124 (this.scrollPort_.setForegroundColor(this.prefs_.get('foreground-color')),
5125 this.scrollPort_.setBackgroundColor(
5126 this.prefs_.get('background-color')));
5127};
5128, hterm.Terminal.prototype.ringBell = function() {
5129 this.cursorNode_.style.backgroundColor =
5130 this.scrollPort_.getForegroundColor();
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005131 var e = this;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005132 if (setTimeout(
5133 function() {
5134 e.cursorNode_.style.backgroundColor = e.prefs_.get('cursor-color');
5135 },
5136 200),
5137 !this.bellSquelchTimeout_ &&
5138 (this.bellAudio_.getAttribute('src') ?
5139 (this.bellAudio_.play(),
5140 this.bellSequelchTimeout_ = setTimeout(
5141 function() {
5142 delete this.bellSquelchTimeout_;
5143 }.bind(this),
5144 500)) :
5145 delete this.bellSquelchTimeout_,
5146 this.desktopNotificationBell_ && !this.document_.hasFocus())) {
5147 var t = new Notification(lib.f.replaceVars(
5148 hterm.desktopNotificationTitle,
5149 {title: window.document.title || 'hterm'}));
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005150 this.bellNotificationList_.push(t), t.onclick = function() {
5151 e.closeBellNotifications_();
5152 };
5153 }
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005154};
5155, hterm.Terminal.prototype.setOriginMode = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005156 this.options_.originMode = e, this.setCursorPosition(0, 0);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005157};
5158, hterm.Terminal.prototype.setInsertMode = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005159 this.options_.insertMode = e;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005160};
5161, hterm.Terminal.prototype.setAutoCarriageReturn = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005162 this.options_.autoCarriageReturn = e;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005163};
5164, hterm.Terminal.prototype.setWraparound = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005165 this.options_.wraparound = e;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005166};
5167, hterm.Terminal.prototype.setReverseWraparound = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005168 this.options_.reverseWraparound = e;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005169};
5170, hterm.Terminal.prototype.setAlternateMode = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005171 var t = this.saveCursor();
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005172 if (this.screen_ = e ? this.alternateScreen_ : this.primaryScreen_,
5173 this.screen_.rowsArray.length &&
5174 this.screen_.rowsArray[0].rowIndex != this.scrollbackRows_.length)
5175 for (var r = this.scrollbackRows_.length, o = this.screen_.rowsArray, i = 0;
5176 i < o.length; i++)
5177 o[i].rowIndex = r + i;
5178 this.realizeWidth_(this.screenSize.width),
5179 this.realizeHeight_(this.screenSize.height),
5180 this.scrollPort_.syncScrollHeight(), this.scrollPort_.invalidate(),
5181 this.restoreCursor(t), this.scrollPort_.resize();
5182};
5183, hterm.Terminal.prototype.setCursorBlink = function(e) {
5184 this.options_.cursorBlink = e,
5185 !e && this.timeouts_.cursorBlink &&
5186 (clearTimeout(this.timeouts_.cursorBlink),
5187 delete this.timeouts_.cursorBlink),
5188 this.options_.cursorVisible && this.setCursorVisible(!0);
5189};
5190, hterm.Terminal.prototype.setCursorVisible = function(e) {
5191 if (this.options_.cursorVisible = e, !e)
5192 return this.timeouts_.cursorBlink &&
5193 (clearTimeout(this.timeouts_.cursorBlink),
5194 delete this.timeouts_.cursorBlink),
Gunnar Mills4ddda582018-09-04 09:18:30 -05005195 void (this.cursorNode_.style.opacity = '0');
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005196 if (this.syncCursorPosition_(), this.cursorNode_.style.opacity = '1',
5197 this.options_.cursorBlink) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005198 if (this.timeouts_.cursorBlink) return;
5199 this.onCursorBlink_();
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005200 } else
5201 this.timeouts_.cursorBlink &&
5202 (clearTimeout(this.timeouts_.cursorBlink),
5203 delete this.timeouts_.cursorBlink);
5204};
5205, hterm.Terminal.prototype.syncCursorPosition_ = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005206 var e = this.scrollPort_.getTopRowIndex(),
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005207 t = this.scrollPort_.getBottomRowIndex(e),
5208 r = this.scrollbackRows_.length + this.screen_.cursorPosition.row;
5209 if (r > t)
Gunnar Mills4ddda582018-09-04 09:18:30 -05005210 return void (
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005211 this.cursorNode_.style.top =
5212 -this.scrollPort_.characterSize.height + 'px');
5213 this.options_.cursorVisible && 'none' == this.cursorNode_.style.display &&
5214 (this.cursorNode_.style.display = ''),
5215 this.cursorNode_.style.top = this.scrollPort_.visibleRowTopMargin +
5216 this.scrollPort_.characterSize.height * (r - e) + 'px',
5217 this.cursorNode_.style.left = this.scrollPort_.characterSize.width *
5218 this.screen_.cursorPosition.column +
5219 'px',
5220 this.cursorNode_.setAttribute(
5221 'title',
5222 '(' + this.screen_.cursorPosition.row + ', ' +
5223 this.screen_.cursorPosition.column + ')');
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005224 var o = this.document_.getSelection();
5225 o && o.isCollapsed && this.screen_.syncSelectionCaret(o);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005226};
5227, hterm.Terminal.prototype.restyleCursor_ = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005228 var e = this.cursorShape_;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005229 'false' == this.cursorNode_.getAttribute('focus') &&
5230 (e = hterm.Terminal.cursorShape.BLOCK);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005231 var t = this.cursorNode_.style;
5232 switch (t.width = this.scrollPort_.characterSize.width + 'px', e) {
5233 case hterm.Terminal.cursorShape.BEAM:
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005234 t.height = this.scrollPort_.characterSize.height + 'px',
5235 t.backgroundColor = 'transparent', t.borderBottomStyle = null,
5236 t.borderLeftStyle = 'solid';
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005237 break;
5238 case hterm.Terminal.cursorShape.UNDERLINE:
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005239 t.height = this.scrollPort_.characterSize.baseline + 'px',
5240 t.backgroundColor = 'transparent', t.borderBottomStyle = 'solid',
5241 t.borderLeftStyle = null;
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005242 break;
5243 default:
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005244 t.height = this.scrollPort_.characterSize.height + 'px',
5245 t.backgroundColor = this.cursorColor_, t.borderBottomStyle = null,
5246 t.borderLeftStyle = null;
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005247 }
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005248};
5249, hterm.Terminal.prototype.scheduleSyncCursorPosition_ = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005250 if (!this.timeouts_.syncCursor) {
5251 var e = this;
5252 this.timeouts_.syncCursor = setTimeout(function() {
5253 e.syncCursorPosition_(), delete e.timeouts_.syncCursor;
5254 }, 0);
5255 }
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005256};
5257, hterm.Terminal.prototype.showZoomWarning_ = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005258 if (!this.zoomWarningNode_) {
5259 if (!e) return;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005260 this.zoomWarningNode_ = this.document_.createElement('div'),
5261 this.zoomWarningNode_.style.cssText =
5262 'color: black;background-color: #ff2222;font-size: large;border-radius: 8px;opacity: 0.75;padding: 0.2em 0.5em 0.2em 0.5em;top: 0.5em;right: 1.2em;position: absolute;-webkit-text-size-adjust: none;-webkit-user-select: none;-moz-text-size-adjust: none;-moz-user-select: none;',
5263 this.zoomWarningNode_.addEventListener('click', function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005264 this.parentNode.removeChild(this);
5265 });
5266 }
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005267 this.zoomWarningNode_.textContent = lib.MessageManager.replaceReferences(
5268 hterm.zoomWarningMessage,
5269 [parseInt(100 * this.scrollPort_.characterSize.zoomFactor)]),
5270 this.zoomWarningNode_.style.fontFamily = this.prefs_.get('font-family'),
5271 e ? this.zoomWarningNode_.parentNode ||
5272 this.div_.parentNode.appendChild(this.zoomWarningNode_) :
5273 this.zoomWarningNode_.parentNode &&
5274 this.zoomWarningNode_.parentNode.removeChild(this.zoomWarningNode_);
5275};
5276, hterm.Terminal.prototype.showOverlay = function(e, t) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005277 if (!this.overlayNode_) {
5278 if (!this.div_) return;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005279 this.overlayNode_ = this.document_.createElement('div'),
5280 this.overlayNode_.style.cssText =
5281 'border-radius: 15px;font-size: xx-large;opacity: 0.75;padding: 0.2em 0.5em 0.2em 0.5em;position: absolute;-webkit-user-select: none;-webkit-transition: opacity 180ms ease-in;-moz-user-select: none;-moz-transition: opacity 180ms ease-in;',
5282 this.overlayNode_.addEventListener('mousedown', function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005283 e.preventDefault(), e.stopPropagation();
5284 }, !0);
5285 }
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005286 this.overlayNode_.style.color = this.prefs_.get('background-color'),
5287 this.overlayNode_.style.backgroundColor = this.prefs_.get('foreground-color'),
5288 this.overlayNode_.style.fontFamily = this.prefs_.get('font-family'),
5289 this.overlayNode_.textContent = e, this.overlayNode_.style.opacity = '0.75',
5290 this.overlayNode_.parentNode || this.div_.appendChild(this.overlayNode_);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005291 var r = hterm.getClientSize(this.div_),
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005292 o = hterm.getClientSize(this.overlayNode_);
5293 this.overlayNode_.style.top = (r.height - o.height) / 2 + 'px',
5294 this.overlayNode_.style.left =
5295 (r.width - o.width - this.scrollPort_.currentScrollbarWidthPx) / 2 + 'px';
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005296 var i = this;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005297 this.overlayTimeout_ && clearTimeout(this.overlayTimeout_),
5298 null !== t &&
5299 (this.overlayTimeout_ = setTimeout(function() {
5300 i.overlayNode_.style.opacity = '0',
5301 i.overlayTimeout_ = setTimeout(function() {
5302 i.overlayNode_.parentNode &&
5303 i.overlayNode_.parentNode.removeChild(i.overlayNode_),
5304 i.overlayTimeout_ = null, i.overlayNode_.style.opacity = '0.75';
5305 }, 200);
5306 }, t || 1500));
5307};
5308, hterm.Terminal.prototype.paste = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005309 hterm.pasteFromClipboard(this.document_);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005310};
5311, hterm.Terminal.prototype.copyStringToClipboard = function(e) {
5312 this.prefs_.get('enable-clipboard-notice') &&
5313 setTimeout(
5314 this.showOverlay.bind(this, hterm.notifyCopyMessage, 500), 200);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005315 var t = this.document_.createElement('pre');
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005316 t.textContent = e,
5317 t.style.cssText =
5318 '-webkit-user-select: text;-moz-user-select: text;position: absolute;top: -99px',
5319 this.document_.body.appendChild(t);
5320 var r = this.document_.getSelection(), o = r.anchorNode, i = r.anchorOffset,
5321 s = r.focusNode, n = r.focusOffset;
5322 r.selectAllChildren(t), hterm.copySelectionToClipboard(this.document_),
5323 r.extend && (r.collapse(o, i), r.extend(s, n)),
5324 t.parentNode.removeChild(t);
5325};
5326, hterm.Terminal.prototype.getSelectionText = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005327 var e = this.scrollPort_.selection;
5328 if (e.sync(), e.isCollapsed) return null;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005329 var t = e.startOffset, r = e.startNode;
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005330 if ('X-ROW' != r.nodeName)
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005331 for ('#text' == r.nodeName && 'SPAN' == r.parentNode.nodeName &&
5332 (r = r.parentNode);
5333 r.previousSibling;)
5334 r = r.previousSibling, t += hterm.TextAttributes.nodeWidth(r);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005335 var o = hterm.TextAttributes.nodeWidth(e.endNode) - e.endOffset;
5336 if (r = e.endNode, 'X-ROW' != r.nodeName)
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005337 for ('#text' == r.nodeName && 'SPAN' == r.parentNode.nodeName &&
5338 (r = r.parentNode);
5339 r.nextSibling;)
5340 r = r.nextSibling, o += hterm.TextAttributes.nodeWidth(r);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005341 var i = this.getRowsText(e.startRow.rowIndex, e.endRow.rowIndex + 1);
5342 return lib.wc.substring(i, t, lib.wc.strWidth(i) - o);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005343};
5344, hterm.Terminal.prototype.copySelectionToClipboard = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005345 var e = this.getSelectionText();
5346 null != e && this.copyStringToClipboard(e);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005347};
5348, hterm.Terminal.prototype.overlaySize = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005349 this.showOverlay(this.screenSize.width + 'x' + this.screenSize.height);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005350};
5351, hterm.Terminal.prototype.onVTKeystroke = function(e) {
5352 this.scrollOnKeystroke_ &&
5353 this.scrollPort_.scrollRowToBottom(this.getRowCount()),
5354 this.io.onVTKeystroke(this.keyboard.encode(e));
5355};
5356, hterm.Terminal.prototype.openUrl = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005357 var t = window.open(e, '_blank');
5358 t.focus();
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005359};
5360, hterm.Terminal.prototype.openSelectedUrl_ = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005361 var e = this.getSelectionText();
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005362 null == e &&
5363 (this.screen_.expandSelection(this.document_.getSelection()),
5364 e = this.getSelectionText()),
5365 e.length > 2048 || e.search(/[\s\[\](){}<>"'\\^`]/) >= 0 ||
5366 (e.search('^[a-zA-Z][a-zA-Z0-9+.-]*://') < 0 && (e = 'http://' + e),
5367 this.openUrl(e));
5368};
5369, hterm.Terminal.prototype.onMouse_ = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005370 if (!e.processedByTerminalHandler_) {
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005371 var t = !this.defeatMouseReports_ &&
5372 this.vt.mouseReport != this.vt.MOUSE_REPORT_DISABLED;
5373 if (e.processedByTerminalHandler_ = !0,
5374 e.terminalRow = parseInt(
5375 (e.clientY - this.scrollPort_.visibleRowTopMargin) /
5376 this.scrollPort_.characterSize.height) +
5377 1,
5378 e.terminalColumn =
5379 parseInt(e.clientX / this.scrollPort_.characterSize.width) + 1,
5380 !('mousedown' == e.type && e.terminalColumn > this.screenSize.width)) {
5381 if (this.options_.cursorVisible && !t &&
5382 (e.terminalRow - 1 ==
5383 this.screen_.cursorPosition.row &&e.terminalColumn - 1 ==
5384 this.screen_.cursorPosition.column ?
5385 this.cursorNode_.style.display = 'none' :
5386 'none' == this.cursorNode_.style.display &&
5387 (this.cursorNode_.style.display = '')),
5388 'mousedown' == e.type &&
5389 (e.altKey || !t ?
5390 (this.defeatMouseReports_ = !0,
5391 this.setSelectionEnabled(!0)) :
5392 (this.defeatMouseReports_ = !1,
5393 this.document_.getSelection().collapseToEnd(),
5394 this.setSelectionEnabled(!1), e.preventDefault())),
5395 t)
5396 this.scrollBlockerNode_.engaged ||
5397 ('mousedown' == e.type ?
5398 (this.scrollBlockerNode_.engaged = !0,
5399 this.scrollBlockerNode_.style.top = e.clientY - 5 + 'px',
5400 this.scrollBlockerNode_.style.left = e.clientX - 5 + 'px') :
5401 'mousemove' == e.type &&
5402 (this.document_.getSelection().collapseToEnd(),
5403 e.preventDefault())),
5404 this.onMouse(e);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005405 else {
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005406 if ('dblclick' == e.type && this.copyOnSelect &&
5407 (this.screen_.expandSelection(this.document_.getSelection()),
5408 this.copySelectionToClipboard(this.document_)),
5409 'click' == e.type && !e.shiftKey && e.ctrlKey)
5410 return clearTimeout(this.timeouts_.openUrl),
Gunnar Mills4ddda582018-09-04 09:18:30 -05005411 void (
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005412 this.timeouts_.openUrl =
5413 setTimeout(this.openSelectedUrl_.bind(this), 500));
5414 'mousedown' == e.type && e.which == this.mousePasteButton &&
5415 this.paste(),
5416 'mouseup' == e.type && 1 == e.which && this.copyOnSelect &&
5417 !this.document_.getSelection().isCollapsed &&
5418 this.copySelectionToClipboard(this.document_),
5419 'mousemove' != e.type && 'mouseup' != e.type ||
5420 !this.scrollBlockerNode_.engaged ||
5421 (this.scrollBlockerNode_.engaged = !1,
5422 this.scrollBlockerNode_.style.top = '-99px');
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005423 }
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005424 'mouseup' == e.type && this.document_.getSelection().isCollapsed &&
5425 (this.defeatMouseReports_ = !1);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005426 }
5427 }
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005428};
5429, hterm.Terminal.prototype.onMouse = function(e) {};
5430, hterm.Terminal.prototype.onFocusChange_ = function(e) {
5431 this.cursorNode_.setAttribute('focus', e), this.restyleCursor_(),
5432 e === !0 && this.closeBellNotifications_();
5433};
5434, hterm.Terminal.prototype.onScroll_ = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005435 this.scheduleSyncCursorPosition_();
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005436};
5437, hterm.Terminal.prototype.onPaste_ = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005438 var t = e.text.replace(/\n/gm, '\r');
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005439 t = this.keyboard.encode(t),
5440 this.options_.bracketedPaste && (t = '[200~' + t + '[201~'),
5441 this.io.sendString(t);
5442};
5443, hterm.Terminal.prototype.onCopy_ = function(e) {
5444 this.useDefaultWindowCopy ||
5445 (e.preventDefault(),
5446 setTimeout(this.copySelectionToClipboard.bind(this), 0));
5447};
5448, hterm.Terminal.prototype.onResize_ = function() {
5449 var e = Math.floor(
5450 this.scrollPort_.getScreenWidth() /
5451 this.scrollPort_.characterSize.width) ||
5452 0,
5453 t = lib.f.smartFloorDivide(
5454 this.scrollPort_.getScreenHeight(),
5455 this.scrollPort_.characterSize.height) ||
5456 0;
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005457 if (!(0 >= e || 0 >= t)) {
5458 var r = e != this.screenSize.width || t != this.screenSize.height;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005459 this.realizeSize_(e, t),
5460 this.showZoomWarning_(1 != this.scrollPort_.characterSize.zoomFactor),
5461 r && this.overlaySize(), this.restyleCursor_(),
5462 this.scheduleSyncCursorPosition_();
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005463 }
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005464};
5465, hterm.Terminal.prototype.onCursorBlink_ = function() {
5466 return this.options_.cursorBlink ?
Gunnar Mills4ddda582018-09-04 09:18:30 -05005467 void (
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005468 'false' == this.cursorNode_.getAttribute('focus') ||
5469 '0' == this.cursorNode_.style.opacity ?
5470 (this.cursorNode_.style.opacity = '1',
5471 this.timeouts_.cursorBlink = setTimeout(
5472 this.myOnCursorBlink_, this.cursorBlinkCycle_[0])) :
5473 (this.cursorNode_.style.opacity = '0',
5474 this.timeouts_.cursorBlink = setTimeout(
5475 this.myOnCursorBlink_, this.cursorBlinkCycle_[1]))) :
5476 void delete this.timeouts_.cursorBlink;
5477};
5478, hterm.Terminal.prototype.setScrollbarVisible = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005479 this.scrollPort_.setScrollbarVisible(e);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005480};
5481, hterm.Terminal.prototype.setScrollWheelMoveMultipler = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005482 this.scrollPort_.setScrollWheelMoveMultipler(e);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005483};
5484, hterm.Terminal.prototype.closeBellNotifications_ = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005485 this.bellNotificationList_.forEach(function(e) {
5486 e.close();
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005487 }),
5488 this.bellNotificationList_.length = 0;
5489};
5490, lib.rtdep('lib.encodeUTF8'), hterm.Terminal.IO = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005491 this.terminal_ = e, this.previousIO_ = null;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005492};
5493, hterm.Terminal.IO.prototype.showOverlay = function(e, t) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005494 this.terminal_.showOverlay(e, t);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005495};
5496, hterm.Terminal.IO.prototype.createFrame = function(e, t) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005497 return new hterm.Frame(this.terminal_, e, t);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005498};
5499, hterm.Terminal.IO.prototype.setTerminalProfile = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005500 this.terminal_.setProfile(e);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005501};
5502, hterm.Terminal.IO.prototype.push = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005503 var e = new hterm.Terminal.IO(this.terminal_);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005504 return e.keyboardCaptured_ = this.keyboardCaptured_,
5505 e.columnCount = this.columnCount, e.rowCount = this.rowCount,
5506 e.previousIO_ = this.terminal_.io, this.terminal_.io = e, e;
5507};
5508, hterm.Terminal.IO.prototype.pop = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005509 this.terminal_.io = this.previousIO_;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005510};
5511, hterm.Terminal.IO.prototype.sendString = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005512 console.log('Unhandled sendString: ' + e);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005513};
5514, hterm.Terminal.IO.prototype.onVTKeystroke = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005515 console.log('Unobserverd VT keystroke: ' + JSON.stringify(e));
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005516};
5517, hterm.Terminal.IO.prototype.onTerminalResize_ = function(e, t) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005518 for (var r = this; r;) r.columnCount = e, r.rowCount = t, r = r.previousIO_;
5519 this.onTerminalResize(e, t);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005520};
5521, hterm.Terminal.IO.prototype.onTerminalResize = function(e, t) {};
5522, hterm.Terminal.IO.prototype.writeUTF8 = function(e) {
5523 if (this.terminal_.io != this)
5524 throw 'Attempt to print from inactive IO object.';
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005525 this.terminal_.interpret(e);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005526};
5527, hterm.Terminal.IO.prototype.writelnUTF8 = function(e) {
5528 if (this.terminal_.io != this)
5529 throw 'Attempt to print from inactive IO object.';
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005530 this.terminal_.interpret(e + '\r\n');
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005531};
5532,
5533 hterm.Terminal.IO.prototype.print =
5534 hterm.Terminal.IO.prototype.writeUTF16 = function(e) {
5535 this.writeUTF8(lib.encodeUTF8(e));
5536 };
5537,
5538 hterm.Terminal.IO.prototype.println =
5539 hterm.Terminal.IO.prototype.writelnUTF16 = function(e) {
5540 this.writelnUTF8(lib.encodeUTF8(e));
5541 };
5542, lib.rtdep('lib.colors'), hterm.TextAttributes = function(e) {
5543 this.document_ = e, this.foregroundSource = this.SRC_DEFAULT,
5544 this.backgroundSource = this.SRC_DEFAULT,
5545 this.foreground = this.DEFAULT_COLOR, this.background = this.DEFAULT_COLOR,
5546 this.defaultForeground = 'rgb(255, 255, 255)',
5547 this.defaultBackground = 'rgb(0, 0, 0)', this.bold = !1, this.faint = !1,
5548 this.italic = !1, this.blink = !1, this.underline = !1,
5549 this.strikethrough = !1, this.inverse = !1, this.invisible = !1,
5550 this.wcNode = !1, this.tileData = null, this.colorPalette = null,
5551 this.resetColorPalette();
5552};
5553, hterm.TextAttributes.prototype.enableBold = !0,
5554 hterm.TextAttributes.prototype.enableBoldAsBright = !0,
5555 hterm.TextAttributes.prototype.DEFAULT_COLOR = new String(''),
5556 hterm.TextAttributes.prototype.SRC_DEFAULT = 'default',
5557 hterm.TextAttributes.prototype.SRC_RGB = 'rgb',
5558 hterm.TextAttributes.prototype.setDocument = function(e) {
5559 this.document_ = e;
5560 };
5561, hterm.TextAttributes.prototype.clone = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005562 var e = new hterm.TextAttributes(null);
5563 for (var t in this) e[t] = this[t];
5564 return e.colorPalette = this.colorPalette.concat(), e;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005565};
5566, hterm.TextAttributes.prototype.reset = function() {
5567 this.foregroundSource = this.SRC_DEFAULT,
5568 this.backgroundSource = this.SRC_DEFAULT,
5569 this.foreground = this.DEFAULT_COLOR, this.background = this.DEFAULT_COLOR,
5570 this.bold = !1, this.faint = !1, this.italic = !1, this.blink = !1,
5571 this.underline = !1, this.strikethrough = !1, this.inverse = !1,
5572 this.invisible = !1, this.wcNode = !1;
5573};
5574, hterm.TextAttributes.prototype.resetColorPalette = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005575 this.colorPalette = lib.colors.colorPalette.concat(), this.syncColors();
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005576};
5577, hterm.TextAttributes.prototype.isDefault = function() {
5578 return !(
5579 this.foregroundSource != this.SRC_DEFAULT ||
5580 this.backgroundSource != this.SRC_DEFAULT || this.bold || this.faint ||
5581 this.italic || this.blink || this.underline || this.strikethrough ||
5582 this.inverse || this.invisible || this.wcNode || null != this.tileData);
5583};
5584, hterm.TextAttributes.prototype.createContainer = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005585 if (this.isDefault()) return this.document_.createTextNode(e);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005586 var t = this.document_.createElement('span'), r = t.style, o = [];
5587 this.foreground != this.DEFAULT_COLOR && (r.color = this.foreground),
5588 this.background != this.DEFAULT_COLOR &&
5589 (r.backgroundColor = this.background),
5590 this.enableBold && this.bold && (r.fontWeight = 'bold'),
5591 this.faint && (t.faint = !0), this.italic && (r.fontStyle = 'italic'),
5592 this.blink && (o.push('blink-node'), t.blinkNode = !0);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005593 var i = '';
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005594 return this.underline && (i += ' underline', t.underline = !0),
5595 this.strikethrough && (i += ' line-through', t.strikethrough = !0),
5596 i && (r.textDecoration = i),
5597 this.wcNode && (o.push('wc-node'), t.wcNode = !0),
5598 null != this.tileData &&
5599 (o.push('tile'), o.push('tile_' + this.tileData), t.tileNode = !0),
5600 e && (t.textContent = e), o.length && (t.className = o.join(' ')), t;
5601};
5602, hterm.TextAttributes.prototype.matchesContainer = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005603 if ('string' == typeof e || 3 == e.nodeType) return this.isDefault();
5604 var t = e.style;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005605 return !(
5606 this.wcNode || e.wcNode || null != this.tileData || e.tileNode ||
5607 this.foreground != t.color || this.background != t.backgroundColor ||
5608 (this.enableBold && this.bold) != !!t.fontWeight ||
5609 this.blink != e.blinkNode || this.italic != !!t.fontStyle ||
5610 !!this.underline != !!e.underline ||
5611 !!this.strikethrough != !!e.strikethrough);
5612};
5613, hterm.TextAttributes.prototype.setDefaults = function(e, t) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005614 this.defaultForeground = e, this.defaultBackground = t, this.syncColors();
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005615};
5616, hterm.TextAttributes.prototype.syncColors = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005617 function e(e) {
5618 return 8 > e ? e + 8 : e;
5619 }
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005620 var t = this.foregroundSource, r = this.backgroundSource,
5621 o = this.DEFAULT_COLOR, i = this.DEFAULT_COLOR;
5622 if (this.inverse &&
5623 (t = this.backgroundSource, r = this.foregroundSource,
5624 o = this.defaultBackground, i = this.defaultForeground),
5625 this.enableBoldAsBright && this.bold && t != this.SRC_DEFAULT &&
5626 t != this.SRC_RGB && (t = e(t)),
5627 this.invisible && (t = r, o = this.defaultBackground),
5628 t != this.SRC_RGB &&
5629 (this.foreground = t == this.SRC_DEFAULT ? o : this.colorPalette[t]),
5630 this.faint && !this.invisible) {
5631 var s = this.foreground == this.DEFAULT_COLOR ? this.defaultForeground :
5632 this.foreground;
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005633 this.foreground = lib.colors.mix(s, 'rgb(0, 0, 0)', .3333);
5634 }
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005635 r != this.SRC_RGB &&
5636 (this.background = r == this.SRC_DEFAULT ? i : this.colorPalette[r]);
5637};
5638, hterm.TextAttributes.containersMatch = function(e, t) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005639 if ('string' == typeof e) return hterm.TextAttributes.containerIsDefault(t);
5640 if (e.nodeType != t.nodeType) return !1;
5641 if (3 == e.nodeType) return !0;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005642 var r = e.style, o = t.style;
5643 return r.color == o.color && r.backgroundColor == o.backgroundColor &&
5644 r.fontWeight == o.fontWeight && r.fontStyle == o.fontStyle &&
5645 r.textDecoration == o.textDecoration;
5646};
5647, hterm.TextAttributes.containerIsDefault = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005648 return 'string' == typeof e || 3 == e.nodeType;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005649};
5650, hterm.TextAttributes.nodeWidth = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005651 return e.wcNode ? lib.wc.strWidth(e.textContent) : e.textContent.length;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005652};
5653, hterm.TextAttributes.nodeSubstr = function(e, t, r) {
5654 return e.wcNode ? lib.wc.substr(e.textContent, t, r) :
5655 e.textContent.substr(t, r);
5656};
5657, hterm.TextAttributes.nodeSubstring = function(e, t, r) {
5658 return e.wcNode ? lib.wc.substring(e.textContent, t, r) :
5659 e.textContent.substring(t, r);
5660};
5661, hterm.TextAttributes.splitWidecharString = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005662 for (var t = [], r = 0, o = 0, i = 0; i < e.length;) {
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005663 var s = e.codePointAt(i), n = 65535 >= s ? 1 : 2;
5664 128 > s || 1 == lib.wc.charWidth(s) ?
5665 o += n :
5666 (o && t.push({str: e.substr(r, o)}),
5667 t.push({str: e.substr(i, n), wcNode: !0}), r = i + n, o = 0),
5668 i += n;
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005669 }
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005670 return o && t.push({str: e.substr(r, o)}), t;
5671};
5672, lib.rtdep('lib.colors', 'lib.f', 'lib.UTF8Decoder', 'hterm.VT.CharacterMap'),
5673 hterm.VT = function(e) {
5674 this.terminal = e, e.onMouse = this.onTerminalMouse_.bind(this),
5675 this.mouseReport = this.MOUSE_REPORT_DISABLED,
5676 this.parseState_ = new hterm.VT.ParseState(this.parseUnknown_),
5677 this.leadingModifier_ = '', this.trailingModifier_ = '',
5678 this.allowColumnWidthChanges_ = !1, this.oscTimeLimit_ = 2e4;
5679 var t = Object.keys(hterm.VT.CC1)
5680 .map(function(e) {
5681 return '\\x' + lib.f.zpad(e.charCodeAt().toString(16), 2);
5682 })
5683 .join('');
5684 this.cc1Pattern_ = new RegExp('[' + t + ']'),
5685 this.utf8Decoder_ = new lib.UTF8Decoder, this.enable8BitControl = !1,
5686 this.enableClipboardWrite = !0, this.enableDec12 = !1,
5687 this.characterEncoding = 'utf-8', this.maxStringSequence = 1024,
5688 this.warnUnimplemented = !0, this.G0 = hterm.VT.CharacterMap.maps.B,
5689 this.G1 = hterm.VT.CharacterMap.maps[0],
5690 this.G2 = hterm.VT.CharacterMap.maps.B,
5691 this.G3 = hterm.VT.CharacterMap.maps.B, this.GL = 'G0', this.GR = 'G0',
5692 this.savedState_ = new hterm.VT.CursorState(this);
5693 };
5694, hterm.VT.prototype.MOUSE_REPORT_DISABLED = 0,
5695 hterm.VT.prototype.MOUSE_REPORT_CLICK = 1,
5696 hterm.VT.prototype.MOUSE_REPORT_DRAG = 3,
5697 hterm.VT.ParseState = function(e, t) {
5698 this.defaultFunction = e, this.buf = t || null, this.pos = 0, this.func = e,
5699 this.args = [];
5700 };
5701, hterm.VT.ParseState.prototype.reset = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005702 this.resetParseFunction(), this.resetBuf(e || ''), this.resetArguments();
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005703};
5704, hterm.VT.ParseState.prototype.resetParseFunction = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005705 this.func = this.defaultFunction;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005706};
5707, hterm.VT.ParseState.prototype.resetBuf = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005708 this.buf = 'string' == typeof e ? e : null, this.pos = 0;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005709};
5710, hterm.VT.ParseState.prototype.resetArguments = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005711 this.args.length = 0, 'undefined' != typeof e && (this.args[0] = e);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005712};
5713, hterm.VT.ParseState.prototype.iarg = function(e, t) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005714 var r = this.args[e];
5715 if (r) {
5716 var o = parseInt(r, 10);
5717 return 0 == o && (o = t), o;
5718 }
5719 return t;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005720};
5721, hterm.VT.ParseState.prototype.advance = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005722 this.pos += e;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005723};
5724, hterm.VT.ParseState.prototype.peekRemainingBuf = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005725 return this.buf.substr(this.pos);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005726};
5727, hterm.VT.ParseState.prototype.peekChar = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005728 return this.buf.substr(this.pos, 1);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005729};
5730, hterm.VT.ParseState.prototype.consumeChar = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005731 return this.buf.substr(this.pos++, 1);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005732};
5733, hterm.VT.ParseState.prototype.isComplete = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005734 return null == this.buf || this.buf.length <= this.pos;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005735};
5736, hterm.VT.CursorState = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005737 this.vt_ = e, this.save();
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005738};
5739, hterm.VT.CursorState.prototype.save = function() {
5740 this.cursor = this.vt_.terminal.saveCursor(),
5741 this.textAttributes = this.vt_.terminal.getTextAttributes().clone(),
5742 this.GL = this.vt_.GL, this.GR = this.vt_.GR, this.G0 = this.vt_.G0,
5743 this.G1 = this.vt_.G1, this.G2 = this.vt_.G2, this.G3 = this.vt_.G3;
5744};
5745, hterm.VT.CursorState.prototype.restore = function() {
5746 this.vt_.terminal.restoreCursor(this.cursor),
5747 this.vt_.terminal.setTextAttributes(this.textAttributes.clone()),
5748 this.vt_.GL = this.GL, this.vt_.GR = this.GR, this.vt_.G0 = this.G0,
5749 this.vt_.G1 = this.G1, this.vt_.G2 = this.G2, this.vt_.G3 = this.G3;
5750};
5751, hterm.VT.prototype.reset = function() {
5752 this.G0 = hterm.VT.CharacterMap.maps.B,
5753 this.G1 = hterm.VT.CharacterMap.maps[0],
5754 this.G2 = hterm.VT.CharacterMap.maps.B,
5755 this.G3 = hterm.VT.CharacterMap.maps.B, this.GL = 'G0', this.GR = 'G0',
5756 this.savedState_ = new hterm.VT.CursorState(this),
5757 this.mouseReport = this.MOUSE_REPORT_DISABLED;
5758};
5759, hterm.VT.prototype.onTerminalMouse_ = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005760 if (this.mouseReport != this.MOUSE_REPORT_DISABLED) {
5761 var t, r = 0;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005762 e.shiftKey && (r |= 4),
5763 (e.metaKey || this.terminal.keyboard.altIsMeta && e.altKey) && (r |= 8),
5764 e.ctrlKey && (r |= 16);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005765 var o = String.fromCharCode(lib.f.clamp(e.terminalColumn + 32, 32, 255)),
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005766 i = String.fromCharCode(lib.f.clamp(e.terminalRow + 32, 32, 255));
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005767 switch (e.type) {
5768 case 'mousewheel':
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005769 s = (e.wheelDeltaY > 0 ? 0 : 1) + 96, s |= r,
5770 t = '' + String.fromCharCode(s) + o + i, e.preventDefault();
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005771 break;
5772 case 'mousedown':
5773 var s = Math.min(e.which - 1, 2) + 32;
5774 s |= r, t = '' + String.fromCharCode(s) + o + i;
5775 break;
5776 case 'mouseup':
5777 t = '#' + o + i;
5778 break;
5779 case 'mousemove':
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005780 this.mouseReport == this.MOUSE_REPORT_DRAG && e.which &&
5781 (s = 32 + Math.min(e.which - 1, 2), s += 32, s |= r,
5782 t = '' + String.fromCharCode(s) + o + i);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005783 break;
5784 case 'click':
5785 case 'dblclick':
5786 break;
5787 default:
5788 console.error('Unknown mouse event: ' + e.type, e);
5789 }
5790 t && this.terminal.io.sendString(t);
5791 }
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005792};
5793, hterm.VT.prototype.interpret = function(e) {
5794 for (this.parseState_.resetBuf(this.decode(e));
5795 !this.parseState_.isComplete();) {
5796 var t = this.parseState_.func, r = this.parseState_.pos,
5797 e = this.parseState_.buf;
5798 if (this.parseState_.func.call(this, this.parseState_),
5799 this.parseState_.func == t && this.parseState_.pos == r &&
5800 this.parseState_.buf == e)
5801 throw 'Parser did not alter the state!';
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005802 }
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005803};
5804, hterm.VT.prototype.decode = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005805 return 'utf-8' == this.characterEncoding ? this.decodeUTF8(e) : e;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005806};
5807, hterm.VT.prototype.encodeUTF8 = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005808 return lib.encodeUTF8(e);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005809};
5810, hterm.VT.prototype.decodeUTF8 = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005811 return this.utf8Decoder_.decode(e);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005812};
5813, hterm.VT.prototype.parseUnknown_ = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005814 function t(e) {
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005815 r[r.GL].GL && (e = r[r.GL].GL(e)), r[r.GR].GR && (e = r[r.GR].GR(e)),
5816 r.terminal.print(e);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005817 }
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005818 var r = this, o = e.peekRemainingBuf(), i = o.search(this.cc1Pattern_);
5819 return 0 == i ?
5820 (this.dispatch('CC1', o.substr(0, 1), e), void e.advance(1)) :
5821 -1 == i ? (t(o), void e.reset()) :
5822 (t(o.substr(0, i)), this.dispatch('CC1', o.substr(i, 1), e),
5823 void e.advance(i + 1))
5824};
5825, hterm.VT.prototype.parseCSI_ = function(e) {
5826 var t = e.peekChar(), r = e.args;
5827 t >= '@' && '~' >= t ?
5828 (this.dispatch(
5829 'CSI', this.leadingModifier_ + this.trailingModifier_ + t, e),
5830 e.resetParseFunction()) :
5831 ';' == t ?
5832 this.trailingModifier_ ? e.resetParseFunction() :
5833 (r.length || r.push(''), r.push('')) :
5834 t >= '0' && '9' >= t ?
5835 this.trailingModifier_ ? e.resetParseFunction() :
5836 r.length ? r[r.length - 1] += t : r[0] = t :
5837 t >= ' ' && '?' >= t && ':' != t ?
5838 r.length ? this.trailingModifier_ += t : this.leadingModifier_ += t :
5839 this.cc1Pattern_.test(t) ? this.dispatch('CC1', t, e) :
5840 e.resetParseFunction(),
5841 e.advance(1);
5842};
5843, hterm.VT.prototype.parseUntilStringTerminator_ = function(e) {
5844 var t = e.peekRemainingBuf(), r = t.search(/(\x1b\\|\x07)/), o = e.args;
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005845 if (o.length || (o[0] = '', o[1] = new Date), -1 == r) {
5846 o[0] += t;
5847 var i;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005848 return o[0].length > this.maxStringSequence &&
5849 (i = 'too long: ' + o[0].length),
5850 -1 != o[0].indexOf('') &&
5851 (i = 'embedded escape: ' + o[0].indexOf('')),
5852 new Date - o[1] > this.oscTimeLimit_ &&
5853 (i = 'timeout expired: ' + new Date - o[1]),
5854 i ? (console.log(
5855 'parseUntilStringTerminator_: aborting: ' + i, o[0]),
5856 e.reset(o[0]), !1) :
5857 (e.advance(t.length), !0);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005858 }
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005859 return o[0].length + r > this.maxStringSequence ?
5860 (e.reset(o[0] + t), !1) :
5861 (o[0] += t.substr(0, r), e.resetParseFunction(),
5862 e.advance(r + ('' == t.substr(r, 1) ? 2 : 1)), !0);
5863};
5864, hterm.VT.prototype.dispatch = function(e, t, r) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005865 var o = hterm.VT[e][t];
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005866 return o ?
5867 o == hterm.VT.ignore ?
Gunnar Mills4ddda582018-09-04 09:18:30 -05005868 void (
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005869 this.warnUnimplemented &&
5870 console.warn('Ignored ' + e + ' code: ' + JSON.stringify(t))) :
5871 'CC1' == e && t > '' && !this.enable8BitControl ?
5872 void console.warn(
5873 'Ignoring 8-bit control code: 0x' + t.charCodeAt(0).toString(16)) :
5874 void o.apply(this, [r, t]) :
Gunnar Mills4ddda582018-09-04 09:18:30 -05005875 void (
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005876 this.warnUnimplemented &&
5877 console.warn('Unknown ' + e + ' code: ' + JSON.stringify(t)))
5878};
5879, hterm.VT.prototype.setANSIMode = function(e, t) {
5880 '4' == e ? this.terminal.setInsertMode(t) :
5881 '20' == e ? this.terminal.setAutoCarriageReturn(t) :
5882 this.warnUnimplemented &&
5883 console.warn('Unimplemented ANSI Mode: ' + e)
5884};
5885, hterm.VT.prototype.setDECMode = function(e, t) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005886 switch (e) {
5887 case '1':
5888 this.terminal.keyboard.applicationCursor = t;
5889 break;
5890 case '3':
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005891 this.allowColumnWidthChanges_ &&
5892 (this.terminal.setWidth(t ? 132 : 80), this.terminal.clearHome(),
5893 this.terminal.setVTScrollRegion(null, null));
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005894 break;
5895 case '5':
5896 this.terminal.setReverseVideo(t);
5897 break;
5898 case '6':
5899 this.terminal.setOriginMode(t);
5900 break;
5901 case '7':
5902 this.terminal.setWraparound(t);
5903 break;
5904 case '12':
5905 this.enableDec12 && this.terminal.setCursorBlink(t);
5906 break;
5907 case '25':
5908 this.terminal.setCursorVisible(t);
5909 break;
5910 case '40':
5911 this.terminal.allowColumnWidthChanges_ = t;
5912 break;
5913 case '45':
5914 this.terminal.setReverseWraparound(t);
5915 break;
5916 case '67':
5917 this.terminal.keyboard.backspaceSendsBackspace = t;
5918 break;
5919 case '1000':
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005920 this.mouseReport =
5921 t ? this.MOUSE_REPORT_CLICK : this.MOUSE_REPORT_DISABLED;
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005922 break;
5923 case '1002':
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005924 this.mouseReport =
5925 t ? this.MOUSE_REPORT_DRAG : this.MOUSE_REPORT_DISABLED;
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005926 break;
5927 case '1010':
5928 this.terminal.scrollOnOutput = t;
5929 break;
5930 case '1011':
5931 this.terminal.scrollOnKeystroke = t;
5932 break;
5933 case '1036':
5934 this.terminal.keyboard.metaSendsEscape = t;
5935 break;
5936 case '1039':
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005937 t ? this.terminal.keyboard.previousAltSendsWhat_ ||
5938 (this.terminal.keyboard.previousAltSendsWhat_ =
5939 this.terminal.keyboard.altSendsWhat,
5940 this.terminal.keyboard.altSendsWhat = 'escape') :
5941 this.terminal.keyboard.previousAltSendsWhat_ &&
5942 (this.terminal.keyboard.altSendsWhat =
5943 this.terminal.keyboard.previousAltSendsWhat_,
5944 this.terminal.keyboard.previousAltSendsWhat_ = null);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005945 break;
5946 case '47':
5947 case '1047':
5948 this.terminal.setAlternateMode(t);
5949 break;
5950 case '1048':
5951 this.savedState_.save();
5952 case '1049':
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005953 t ? (this.savedState_.save(), this.terminal.setAlternateMode(t),
5954 this.terminal.clear()) :
5955 (this.terminal.setAlternateMode(t), this.savedState_.restore());
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005956 break;
5957 case '2004':
5958 this.terminal.setBracketedPaste(t);
5959 break;
5960 default:
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005961 this.warnUnimplemented &&
5962 console.warn('Unimplemented DEC Private Mode: ' + e);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005963 }
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005964};
5965, hterm.VT.ignore = function() {};
5966, hterm.VT.CC1 = {}, hterm.VT.ESC = {}, hterm.VT.CSI = {}, hterm.VT.OSC = {},
5967 hterm.VT.VT52 = {}, hterm.VT.CC1['\x00'] = function() {};
5968, hterm.VT.CC1[''] = hterm.VT.ignore, hterm.VT.CC1[''] = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005969 this.terminal.ringBell();
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005970};
5971, hterm.VT.CC1['\b'] = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005972 this.terminal.cursorLeft(1);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005973};
5974, hterm.VT.CC1[' '] = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005975 this.terminal.forwardTabStop();
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005976};
5977, hterm.VT.CC1['\n'] = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005978 this.terminal.formFeed();
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005979};
5980, hterm.VT.CC1[' '] = hterm.VT.CC1['\n'], hterm.VT.CC1['\f'] = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005981 this.terminal.formFeed();
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005982};
5983, hterm.VT.CC1['\r'] = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005984 this.terminal.setCursorColumn(0);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005985};
5986, hterm.VT.CC1[''] = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005987 this.GL = 'G1';
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005988};
5989, hterm.VT.CC1[''] = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005990 this.GL = 'G0';
Andrew Geisslerd27bb132018-05-24 11:07:27 -07005991};
5992, hterm.VT.CC1[''] = hterm.VT.ignore, hterm.VT.CC1[''] = hterm.VT.ignore,
5993 hterm.VT.CC1[''] = function(e) {
5994 'G1' == this.GL && (this.GL = 'G0'), e.resetParseFunction(),
5995 this.terminal.print('?');
5996 };
5997, hterm.VT.CC1[''] = hterm.VT.CC1[''], hterm.VT.CC1[''] = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07005998 function t(e) {
5999 var r = e.consumeChar();
Andrew Geisslerd27bb132018-05-24 11:07:27 -07006000 '' != r &&
6001 (this.dispatch('ESC', r, e), e.func == t && e.resetParseFunction());
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07006002 }
6003 e.func = t;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07006004};
6005, hterm.VT.CC1[''] = hterm.VT.ignore,
6006 hterm.VT.CC1['„'] = hterm.VT.ESC.D = function() {
6007 this.terminal.lineFeed();
6008 };
6009, hterm.VT.CC1['…'] = hterm.VT.ESC.E = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07006010 this.terminal.setCursorColumn(0), this.terminal.cursorDown(1);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07006011};
6012, hterm.VT.CC1['ˆ'] = hterm.VT.ESC.H = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07006013 this.terminal.setTabStop(this.terminal.getCursorColumn());
Andrew Geisslerd27bb132018-05-24 11:07:27 -07006014};
6015, hterm.VT.CC1[''] = hterm.VT.ESC.M = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07006016 this.terminal.reverseLineFeed();
Andrew Geisslerd27bb132018-05-24 11:07:27 -07006017};
6018, hterm.VT.CC1['Ž'] = hterm.VT.ESC.N = hterm.VT.ignore,
6019 hterm.VT.CC1[''] = hterm.VT.ESC.O = hterm.VT.ignore,
6020 hterm.VT.CC1[''] = hterm.VT.ESC.P = function(e) {
6021 e.resetArguments(), e.func = this.parseUntilStringTerminator_;
6022 };
6023, hterm.VT.CC1['–'] = hterm.VT.ESC.V = hterm.VT.ignore,
6024 hterm.VT.CC1['—'] = hterm.VT.ESC.W = hterm.VT.ignore,
6025 hterm.VT.CC1['˜'] = hterm.VT.ESC.X = hterm.VT.ignore,
6026 hterm.VT.CC1['š'] = hterm.VT.ESC.Z = function() {
6027 this.terminal.io.sendString('[?1;2c');
6028 };
6029, hterm.VT.CC1['›'] = hterm.VT.ESC['['] = function(e) {
6030 e.resetArguments(), this.leadingModifier_ = '', this.trailingModifier_ = '',
6031 e.func = this.parseCSI_;
6032};
6033, hterm.VT.CC1['œ'] = hterm.VT.ESC['\\'] = hterm.VT.ignore,
6034 hterm.VT.CC1[''] = hterm.VT.ESC[']'] = function(e) {
6035 function t(e) {
6036 if (this.parseUntilStringTerminator_(e) && e.func != t) {
6037 var r = e.args[0].match(/^(\d+);(.*)$/);
6038 r ? (e.args[0] = r[2], this.dispatch('OSC', r[1], e)) :
6039 console.warn('Invalid OSC: ' + JSON.stringify(e.args[0]));
6040 }
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07006041 }
Andrew Geisslerd27bb132018-05-24 11:07:27 -07006042 e.resetArguments(), e.func = t;
6043 };
6044, hterm.VT.CC1['ž'] = hterm.VT.ESC['^'] = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07006045 e.resetArguments(), e.func = this.parseUntilStringTerminator_;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07006046};
6047, hterm.VT.CC1['Ÿ'] = hterm.VT.ESC._ = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07006048 e.resetArguments(), e.func = this.parseUntilStringTerminator_;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07006049};
6050, hterm.VT.ESC[' '] = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07006051 e.func = function(e) {
6052 var t = e.consumeChar();
Andrew Geisslerd27bb132018-05-24 11:07:27 -07006053 this.warnUnimplemented &&
6054 console.warn('Unimplemented sequence: ESC 0x20 ' + t),
6055 e.resetParseFunction();
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07006056 };
Andrew Geisslerd27bb132018-05-24 11:07:27 -07006057};
6058, hterm.VT.ESC['#'] = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07006059 e.func = function(e) {
6060 var t = e.consumeChar();
6061 '8' == t && this.terminal.fill('E'), e.resetParseFunction();
6062 };
Andrew Geisslerd27bb132018-05-24 11:07:27 -07006063};
6064, hterm.VT.ESC['%'] = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07006065 e.func = function(e) {
6066 var t = e.consumeChar();
Andrew Geisslerd27bb132018-05-24 11:07:27 -07006067 '@' != t && 'G' != t && this.warnUnimplemented &&
6068 console.warn('Unknown ESC % argument: ' + JSON.stringify(t)),
6069 e.resetParseFunction();
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07006070 };
Andrew Geisslerd27bb132018-05-24 11:07:27 -07006071};
6072,
6073 hterm.VT.ESC['('] = hterm.VT.ESC[')'] = hterm.VT.ESC['*'] =
6074 hterm.VT.ESC['+'] = hterm.VT.ESC['-'] = hterm.VT.ESC['.'] =
6075 hterm.VT.ESC['/'] = function(e, t) {
6076 e.func = function(e) {
6077 var r = e.consumeChar();
6078 return '' == r ?
6079 (e.resetParseFunction(), void e.func()) :
6080 (r in hterm.VT.CharacterMap.maps ?
6081 '(' == t ? this.G0 = hterm.VT.CharacterMap.maps[r] :
6082 ')' == t || '-' == t ?
6083 this.G1 = hterm.VT.CharacterMap.maps[r] :
6084 '*' == t || '.' == t ?
6085 this.G2 = hterm.VT.CharacterMap.maps[r] :
6086 ('+' == t || '/' == t) &&
6087 (this.G3 =
6088 hterm.VT.CharacterMap.maps[r]) :
6089 this.warnUnimplemented &&
6090 console.log(
6091 'Invalid character set for "' + t + '": ' + r),
6092 void e.resetParseFunction());
6093 };
6094 };
6095, hterm.VT.ESC[6] = hterm.VT.ignore, hterm.VT.ESC[7] = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07006096 this.savedState_.save();
Andrew Geisslerd27bb132018-05-24 11:07:27 -07006097};
6098, hterm.VT.ESC[8] = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07006099 this.savedState_.restore();
Andrew Geisslerd27bb132018-05-24 11:07:27 -07006100};
6101, hterm.VT.ESC[9] = hterm.VT.ignore, hterm.VT.ESC['='] = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07006102 this.terminal.keyboard.applicationKeypad = !0;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07006103};
6104, hterm.VT.ESC['>'] = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07006105 this.terminal.keyboard.applicationKeypad = !1;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07006106};
6107, hterm.VT.ESC.F = hterm.VT.ignore, hterm.VT.ESC.c = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07006108 this.reset(), this.terminal.reset();
Andrew Geisslerd27bb132018-05-24 11:07:27 -07006109};
6110, hterm.VT.ESC.l = hterm.VT.ESC.m = hterm.VT.ignore,
6111 hterm.VT.ESC.n = function() {
6112 this.GL = 'G2';
6113 };
6114, hterm.VT.ESC.o = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07006115 this.GL = 'G3';
Andrew Geisslerd27bb132018-05-24 11:07:27 -07006116};
6117, hterm.VT.ESC['|'] = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07006118 this.GR = 'G3';
Andrew Geisslerd27bb132018-05-24 11:07:27 -07006119};
6120, hterm.VT.ESC['}'] = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07006121 this.GR = 'G2';
Andrew Geisslerd27bb132018-05-24 11:07:27 -07006122};
6123, hterm.VT.ESC['~'] = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07006124 this.GR = 'G1';
Andrew Geisslerd27bb132018-05-24 11:07:27 -07006125};
6126, hterm.VT.OSC[0] = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07006127 this.terminal.setWindowTitle(e.args[0]);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07006128};
6129, hterm.VT.OSC[2] = hterm.VT.OSC[0], hterm.VT.OSC[4] = function(e) {
6130 for (var t = e.args[0].split(';'), r = parseInt(t.length / 2),
6131 o = this.terminal.getTextAttributes().colorPalette, i = [], s = 0;
6132 r > s; ++s) {
6133 var n = parseInt(t[2 * s]), a = t[2 * s + 1];
6134 n >= o.length ||
6135 ('?' != a ? (a = lib.colors.x11ToCSS(a), a && (o[n] = a)) :
6136 (a = lib.colors.rgbToX11(o[n]), a && i.push(n + ';' + a)));
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07006137 }
6138 i.length && this.terminal.io.sendString(']4;' + i.join(';') + '');
Andrew Geisslerd27bb132018-05-24 11:07:27 -07006139};
6140, hterm.VT.OSC[50] = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07006141 var t = e.args[0].match(/CursorShape=(.)/i);
6142 if (!t) return void console.warn('Could not parse OSC 50 args: ' + e.args[0]);
6143 switch (t[1]) {
6144 case '1':
6145 this.terminal.setCursorShape(hterm.Terminal.cursorShape.BEAM);
6146 break;
6147 case '2':
6148 this.terminal.setCursorShape(hterm.Terminal.cursorShape.UNDERLINE);
6149 break;
6150 default:
6151 this.terminal.setCursorShape(hterm.Terminal.cursorShape.BLOCK);
6152 }
Andrew Geisslerd27bb132018-05-24 11:07:27 -07006153};
6154, hterm.VT.OSC[52] = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07006155 var t = e.args[0].match(/^[cps01234567]*;(.*)/);
6156 if (t) {
6157 var r = window.atob(t[1]);
6158 r && this.terminal.copyStringToClipboard(this.decode(r));
6159 }
Andrew Geisslerd27bb132018-05-24 11:07:27 -07006160};
6161, hterm.VT.CSI['@'] = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07006162 this.terminal.insertSpace(e.iarg(0, 1));
Andrew Geisslerd27bb132018-05-24 11:07:27 -07006163};
6164, hterm.VT.CSI.A = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07006165 this.terminal.cursorUp(e.iarg(0, 1));
Andrew Geisslerd27bb132018-05-24 11:07:27 -07006166};
6167, hterm.VT.CSI.B = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07006168 this.terminal.cursorDown(e.iarg(0, 1));
Andrew Geisslerd27bb132018-05-24 11:07:27 -07006169};
6170, hterm.VT.CSI.C = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07006171 this.terminal.cursorRight(e.iarg(0, 1));
Andrew Geisslerd27bb132018-05-24 11:07:27 -07006172};
6173, hterm.VT.CSI.D = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07006174 this.terminal.cursorLeft(e.iarg(0, 1));
Andrew Geisslerd27bb132018-05-24 11:07:27 -07006175};
6176, hterm.VT.CSI.E = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07006177 this.terminal.cursorDown(e.iarg(0, 1)), this.terminal.setCursorColumn(0);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07006178};
6179, hterm.VT.CSI.F = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07006180 this.terminal.cursorUp(e.iarg(0, 1)), this.terminal.setCursorColumn(0);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07006181};
6182, hterm.VT.CSI.G = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07006183 this.terminal.setCursorColumn(e.iarg(0, 1) - 1);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07006184};
6185, hterm.VT.CSI.H = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07006186 this.terminal.setCursorPosition(e.iarg(0, 1) - 1, e.iarg(1, 1) - 1);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07006187};
6188, hterm.VT.CSI.I = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07006189 var t = e.iarg(0, 1);
6190 t = lib.f.clamp(t, 1, this.terminal.screenSize.width);
6191 for (var r = 0; t > r; r++) this.terminal.forwardTabStop();
Andrew Geisslerd27bb132018-05-24 11:07:27 -07006192};
6193, hterm.VT.CSI.J = hterm.VT.CSI['?J'] = function(e, t) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07006194 var r = e.args[0];
Andrew Geisslerd27bb132018-05-24 11:07:27 -07006195 r && '0' != r ? '1' == r ? this.terminal.eraseAbove() :
6196 '2' == r ? this.terminal.clear() :
6197 '3' == r && this.terminal.clear() :
6198 this.terminal.eraseBelow()
6199};
6200, hterm.VT.CSI.K = hterm.VT.CSI['?K'] = function(e, t) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07006201 var r = e.args[0];
Andrew Geisslerd27bb132018-05-24 11:07:27 -07006202 r && '0' != r ? '1' == r ? this.terminal.eraseToLeft() :
6203 '2' == r && this.terminal.eraseLine() :
6204 this.terminal.eraseToRight();
6205};
6206, hterm.VT.CSI.L = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07006207 this.terminal.insertLines(e.iarg(0, 1));
Andrew Geisslerd27bb132018-05-24 11:07:27 -07006208};
6209, hterm.VT.CSI.M = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07006210 this.terminal.deleteLines(e.iarg(0, 1));
Andrew Geisslerd27bb132018-05-24 11:07:27 -07006211};
6212, hterm.VT.CSI.P = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07006213 this.terminal.deleteChars(e.iarg(0, 1));
Andrew Geisslerd27bb132018-05-24 11:07:27 -07006214};
6215, hterm.VT.CSI.S = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07006216 this.terminal.vtScrollUp(e.iarg(0, 1));
Andrew Geisslerd27bb132018-05-24 11:07:27 -07006217};
6218, hterm.VT.CSI.T = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07006219 e.args.length <= 1 && this.terminal.vtScrollDown(e.iarg(0, 1));
Andrew Geisslerd27bb132018-05-24 11:07:27 -07006220};
6221, hterm.VT.CSI['>T'] = hterm.VT.ignore, hterm.VT.CSI.X = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07006222 this.terminal.eraseToRight(e.iarg(0, 1));
Andrew Geisslerd27bb132018-05-24 11:07:27 -07006223};
6224, hterm.VT.CSI.Z = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07006225 var t = e.iarg(0, 1);
6226 t = lib.f.clamp(t, 1, this.terminal.screenSize.width);
6227 for (var r = 0; t > r; r++) this.terminal.backwardTabStop();
Andrew Geisslerd27bb132018-05-24 11:07:27 -07006228};
6229, hterm.VT.CSI['`'] = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07006230 this.terminal.setCursorColumn(e.iarg(0, 1) - 1);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07006231};
6232, hterm.VT.CSI.b = hterm.VT.ignore, hterm.VT.CSI.c = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07006233 e.args[0] && '0' != e.args[0] || this.terminal.io.sendString('[?1;2c');
Andrew Geisslerd27bb132018-05-24 11:07:27 -07006234};
6235, hterm.VT.CSI['>c'] = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07006236 this.terminal.io.sendString('[>0;256;0c');
Andrew Geisslerd27bb132018-05-24 11:07:27 -07006237};
6238, hterm.VT.CSI.d = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07006239 this.terminal.setAbsoluteCursorRow(e.iarg(0, 1) - 1);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07006240};
6241, hterm.VT.CSI.f = hterm.VT.CSI.H, hterm.VT.CSI.g = function(e) {
6242 e.args[0] && '0' != e.args[0] ?
6243 '3' == e.args[0] && this.terminal.clearAllTabStops() :
6244 this.terminal.clearTabStopAtCursor(!1);
6245};
6246, hterm.VT.CSI.h = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07006247 for (var t = 0; t < e.args.length; t++) this.setANSIMode(e.args[t], !0);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07006248};
6249, hterm.VT.CSI['?h'] = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07006250 for (var t = 0; t < e.args.length; t++) this.setDECMode(e.args[t], !0);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07006251};
6252, hterm.VT.CSI.i = hterm.VT.CSI['?i'] = hterm.VT.ignore,
6253 hterm.VT.CSI.l = function(e) {
6254 for (var t = 0; t < e.args.length; t++) this.setANSIMode(e.args[t], !1);
6255 };
6256, hterm.VT.CSI['?l'] = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07006257 for (var t = 0; t < e.args.length; t++) this.setDECMode(e.args[t], !1);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07006258};
6259, hterm.VT.CSI.m = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07006260 function t(t) {
Andrew Geisslerd27bb132018-05-24 11:07:27 -07006261 return e.args.length < t + 2 || '5' != e.args[t + 1] ? null :
6262 e.iarg(t + 2, 0);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07006263 }
6264
6265 function r(t) {
6266 if (e.args.length < t + 5 || '2' != e.args[t + 1]) return null;
Andrew Geisslerd27bb132018-05-24 11:07:27 -07006267 var r = e.iarg(t + 2, 0), o = e.iarg(t + 3, 0), i = e.iarg(t + 4, 0);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07006268 return 'rgb(' + r + ' ,' + o + ' ,' + i + ')';
6269 }
6270 var o = this.terminal.getTextAttributes();
6271 if (!e.args.length) return void o.reset();
6272 for (var i = 0; i < e.args.length; i++) {
6273 var s = e.iarg(i, 0);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07006274 if (30 > s)
6275 0 == s ? o.reset() :
6276 1 == s ?
6277 o.bold = !0 :
6278 2 == s ?
6279 o.faint = !0 :
6280 3 == s ?
6281 o.italic = !0 :
6282 4 == s ?
6283 o.underline = !0 :
6284 5 == s ?
6285 o.blink = !0 :
6286 7 == s ?
6287 o.inverse = !0 :
6288 8 == s ?
6289 o.invisible = !0 :
6290 9 == s ?
6291 o.strikethrough = !0 :
6292 22 == s ?
6293 (o.bold = !1, o.faint = !1) :
6294 23 == s ?
6295 o.italic = !1 :
6296 24 == s ?
6297 o.underline = !1 :
6298 25 == s ? o.blink = !1 :
6299 27 == s ? o.inverse = !1 :
6300 28 == s ? o.invisible = !1 :
6301 29 == s && (o.strikethrough = !1);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07006302 else if (50 > s)
Andrew Geisslerd27bb132018-05-24 11:07:27 -07006303 if (38 > s)
6304 o.foregroundSource = s - 30;
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07006305 else if (38 == s) {
Andrew Geisslerd27bb132018-05-24 11:07:27 -07006306 var n = r(i);
6307 if (null != n)
6308 o.foregroundSource = o.SRC_RGB, o.foreground = n, i += 5;
6309 else {
6310 var a = t(i);
6311 if (null == a) break;
6312 if (i += 2, a >= o.colorPalette.length) continue;
6313 o.foregroundSource = a;
6314 }
6315 } else if (39 == s)
6316 o.foregroundSource = o.SRC_DEFAULT;
6317 else if (48 > s)
6318 o.backgroundSource = s - 40;
6319 else if (48 == s) {
6320 var n = r(i);
6321 if (null != n)
6322 o.backgroundSource = o.SRC_RGB, o.background = n, i += 5;
6323 else {
6324 var a = t(i);
6325 if (null == a) break;
6326 if (i += 2, a >= o.colorPalette.length) continue;
6327 o.backgroundSource = a;
6328 }
6329 } else
6330 o.backgroundSource = o.SRC_DEFAULT;
6331 else
6332 s >= 90 && 97 >= s ?
6333 o.foregroundSource = s - 90 + 8 :
6334 s >= 100 && 107 >= s && (o.backgroundSource = s - 100 + 8);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07006335 }
Andrew Geisslerd27bb132018-05-24 11:07:27 -07006336 o.setDefaults(
6337 this.terminal.getForegroundColor(), this.terminal.getBackgroundColor());
6338};
6339, hterm.VT.CSI['>m'] = hterm.VT.ignore, hterm.VT.CSI.n = function(e) {
6340 if ('5' == e.args[0])
6341 this.terminal.io.sendString('0n');
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07006342 else if ('6' == e.args[0]) {
6343 var t = this.terminal.getCursorRow() + 1,
Andrew Geisslerd27bb132018-05-24 11:07:27 -07006344 r = this.terminal.getCursorColumn() + 1;
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07006345 this.terminal.io.sendString('[' + t + ';' + r + 'R');
6346 }
Andrew Geisslerd27bb132018-05-24 11:07:27 -07006347};
6348, hterm.VT.CSI['>n'] = hterm.VT.ignore, hterm.VT.CSI['?n'] = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07006349 if ('6' == e.args[0]) {
6350 var t = this.terminal.getCursorRow() + 1,
Andrew Geisslerd27bb132018-05-24 11:07:27 -07006351 r = this.terminal.getCursorColumn() + 1;
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07006352 this.terminal.io.sendString('[' + t + ';' + r + 'R');
Andrew Geisslerd27bb132018-05-24 11:07:27 -07006353 } else
6354 '15' == e.args[0] ?
6355 this.terminal.io.sendString('[?11n') :
6356 '25' == e.args[0] ?
6357 this.terminal.io.sendString('[?21n') :
6358 '26' == e.args[0] ?
6359 this.terminal.io.sendString('[?12;1;0;0n') :
6360 '53' == e.args[0] && this.terminal.io.sendString('[?50n')
6361};
6362, hterm.VT.CSI['>p'] = hterm.VT.ignore, hterm.VT.CSI['!p'] = function() {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07006363 this.reset(), this.terminal.softReset();
Andrew Geisslerd27bb132018-05-24 11:07:27 -07006364};
6365, hterm.VT.CSI.$p = hterm.VT.ignore, hterm.VT.CSI['?$p'] = hterm.VT.ignore,
6366 hterm.VT.CSI['"p'] = hterm.VT.ignore, hterm.VT.CSI.q = hterm.VT.ignore,
6367 hterm.VT.CSI[' q'] = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07006368 var t = e.args[0];
Andrew Geisslerd27bb132018-05-24 11:07:27 -07006369 '0' == t || '1' == t ?
6370 (this.terminal.setCursorShape(hterm.Terminal.cursorShape.BLOCK),
6371 this.terminal.setCursorBlink(!0)) :
6372 '2' == t ?
6373 (this.terminal.setCursorShape(hterm.Terminal.cursorShape.BLOCK),
6374 this.terminal.setCursorBlink(!1)) :
6375 '3' == t ?
6376 (this.terminal.setCursorShape(hterm.Terminal.cursorShape.UNDERLINE),
6377 this.terminal.setCursorBlink(!0)) :
6378 '4' == t ?
6379 (this.terminal.setCursorShape(hterm.Terminal.cursorShape.UNDERLINE),
6380 this.terminal.setCursorBlink(!1)) :
6381 console.warn('Unknown cursor style: ' + t)
6382 };
6383, hterm.VT.CSI['"q'] = hterm.VT.ignore, hterm.VT.CSI.r = function(e) {
6384 var t = e.args, r = t[0] ? parseInt(t[0], 10) - 1 : null,
6385 o = t[1] ? parseInt(t[1], 10) - 1 : null;
6386 this.terminal.setVTScrollRegion(r, o), this.terminal.setCursorPosition(0, 0);
6387};
6388, hterm.VT.CSI['?r'] = hterm.VT.ignore, hterm.VT.CSI.$r = hterm.VT.ignore,
6389 hterm.VT.CSI.s = function() {
6390 this.savedState_.save();
6391 };
6392, hterm.VT.CSI['?s'] = hterm.VT.ignore, hterm.VT.CSI.t = hterm.VT.ignore,
6393 hterm.VT.CSI.$t = hterm.VT.ignore, hterm.VT.CSI['>t'] = hterm.VT.ignore,
6394 hterm.VT.CSI[' t'] = hterm.VT.ignore, hterm.VT.CSI.u = function() {
6395 this.savedState_.restore();
6396 };
6397, hterm.VT.CSI[' u'] = hterm.VT.ignore, hterm.VT.CSI.$v = hterm.VT.ignore,
6398 hterm.VT.CSI['\'w'] = hterm.VT.ignore, hterm.VT.CSI.x = hterm.VT.ignore,
6399 hterm.VT.CSI['*x'] = hterm.VT.ignore, hterm.VT.CSI.$x = hterm.VT.ignore,
6400 hterm.VT.CSI.z = function(e) {
6401 if (!(e.args.length < 1)) {
6402 var t = e.args[0];
6403 if ('0' == t) {
6404 if (e.args.length < 2) return;
6405 this.terminal.getTextAttributes().tileData = e.args[1];
6406 } else
6407 '1' == t && (this.terminal.getTextAttributes().tileData = null);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07006408 }
Andrew Geisslerd27bb132018-05-24 11:07:27 -07006409 };
6410, hterm.VT.CSI['\'z'] = hterm.VT.ignore, hterm.VT.CSI.$z = hterm.VT.ignore,
6411 hterm.VT.CSI['\'{'] = hterm.VT.ignore, hterm.VT.CSI['\'|'] = hterm.VT.ignore,
6412 hterm.VT.CSI[' }'] = hterm.VT.ignore, hterm.VT.CSI[' ~'] = hterm.VT.ignore,
6413 lib.rtdep('lib.f'), hterm.VT.CharacterMap = function(e, t) {
6414 this.name = e, this.GL = null, this.GR = null, t && this.reset(t);
6415 };
6416, hterm.VT.CharacterMap.prototype.reset = function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07006417 this.glmap = e;
6418 var t = Object.keys(this.glmap).map(function(e) {
6419 return '\\x' + lib.f.zpad(e.charCodeAt(0).toString(16));
6420 });
Andrew Geisslerd27bb132018-05-24 11:07:27 -07006421 this.glre = new RegExp('[' + t.join('') + ']', 'g'), this.grmap = {},
6422 t.forEach(function(e) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07006423 var t = String.fromCharCode(128 & e.charCodeAt(0));
6424 this.grmap[t] = this.glmap[e];
6425 }.bind(this));
6426 var r = Object.keys(this.grmap).map(function(e) {
6427 return '\\x' + lib.f.zpad(e.charCodeAt(0).toString(16), 2);
6428 });
6429 this.grre = new RegExp('[' + r.join('') + ']', 'g'), this.GL = function(e) {
6430 return e.replace(this.glre, function(e) {
6431 return this.glmap[e];
6432 }.bind(this));
6433 }.bind(this), this.GR = function(e) {
6434 return e.replace(this.grre, function(e) {
6435 return this.grmap[e];
6436 }.bind(this));
6437 }.bind(this);
Andrew Geisslerd27bb132018-05-24 11:07:27 -07006438};
6439, hterm.VT.CharacterMap.maps = {},
6440 hterm.VT.CharacterMap.maps[0] = new hterm.VT.CharacterMap('graphic', {
6441 '`': '◆',
6442 a: '▒',
6443 b: '␉',
6444 c: '␌',
6445 d: '␍',
6446 e: '␊',
6447 f: '°',
6448 g: '±',
6449 h: '␤',
6450 i: '␋',
6451 j: '┘',
6452 k: '┐',
6453 l: '┌',
6454 m: '└',
6455 n: '┼',
6456 o: '⎺',
6457 p: '⎻',
6458 q: '─',
6459 r: '⎼',
6460 s: '⎽',
6461 t: '├',
6462 u: '┤',
6463 v: '┴',
6464 w: '┬',
6465 x: '│',
6466 y: '≤',
6467 z: '≥',
6468 '{': 'π',
6469 '|': '≠',
6470 '}': '£',
6471 '~': '·'
6472 }),
6473 hterm.VT.CharacterMap.maps.A =
6474 new hterm.VT.CharacterMap('british', {'#': '£'}),
6475 hterm.VT.CharacterMap.maps.B = new hterm.VT.CharacterMap('us', null),
6476 hterm.VT.CharacterMap.maps[4] = new hterm.VT.CharacterMap('dutch', {
6477 '#': '£',
6478 '@': '¾',
6479 '[': 'IJ',
6480 '\\': '½',
6481 ']': '|',
6482 '{': '¨',
6483 '|': 'f',
6484 '}': '¼',
6485 '~': '´'
6486 }),
6487 hterm.VT.CharacterMap.maps.C = hterm.VT.CharacterMap.maps[5] =
6488 new hterm.VT.CharacterMap('finnish', {
6489 '[': 'Ä',
6490 '\\': 'Ö',
6491 ']': 'Å',
6492 '^': 'Ü',
6493 '`': 'é',
6494 '{': 'ä',
6495 '|': 'ö',
6496 '}': 'å',
6497 '~': 'ü'
6498 }),
6499 hterm.VT.CharacterMap.maps.R = new hterm.VT.CharacterMap('french', {
6500 '#': '£',
6501 '@': 'à',
6502 '[': '°',
6503 '\\': 'ç',
6504 ']': '§',
6505 '{': 'é',
6506 '|': 'ù',
6507 '}': 'è',
6508 '~': '¨'
6509 }),
6510 hterm.VT.CharacterMap.maps.Q = new hterm.VT.CharacterMap('french canadian', {
6511 '@': 'à',
6512 '[': 'â',
6513 '\\': 'ç',
6514 ']': 'ê',
6515 '^': 'î',
6516 '`': 'ô',
6517 '{': 'é',
6518 '|': 'ù',
6519 '}': 'è',
6520 '~': 'û'
6521 }),
6522 hterm.VT.CharacterMap.maps.K = new hterm.VT.CharacterMap('german', {
6523 '@': '§',
6524 '[': 'Ä',
6525 '\\': 'Ö',
6526 ']': 'Ü',
6527 '{': 'ä',
6528 '|': 'ö',
6529 '}': 'ü',
6530 '~': 'ß'
6531 }),
6532 hterm.VT.CharacterMap.maps.Y = new hterm.VT.CharacterMap('italian', {
6533 '#': '£',
6534 '@': '§',
6535 '[': '°',
6536 '\\': 'ç',
6537 ']': 'é',
6538 '`': 'ù',
6539 '{': 'à',
6540 '|': 'ò',
6541 '}': 'è',
6542 '~': 'ì'
6543 }),
6544 hterm.VT.CharacterMap.maps.E = hterm.VT.CharacterMap.maps[6] =
6545 new hterm.VT.CharacterMap('norwegian/danish', {
6546 '@': 'Ä',
6547 '[': 'Æ',
6548 '\\': 'Ø',
6549 ']': 'Å',
6550 '^': 'Ü',
6551 '`': 'ä',
6552 '{': 'æ',
6553 '|': 'ø',
6554 '}': 'å',
6555 '~': 'ü'
6556 }),
6557 hterm.VT.CharacterMap.maps.Z = new hterm.VT.CharacterMap('spanish', {
6558 '#': '£',
6559 '@': '§',
6560 '[': '¡',
6561 '\\': 'Ñ',
6562 ']': '¿',
6563 '{': '°',
6564 '|': 'ñ',
6565 '}': 'ç'
6566 }),
6567 hterm.VT.CharacterMap.maps[7] = hterm.VT.CharacterMap.maps.H =
6568 new hterm.VT.CharacterMap('swedish', {
6569 '@': 'É',
6570 '[': 'Ä',
6571 '\\': 'Ö',
6572 ']': 'Å',
6573 '^': 'Ü',
6574 '`': 'é',
6575 '{': 'ä',
6576 '|': 'ö',
6577 '}': 'å',
6578 '~': 'ü'
6579 }),
6580 hterm.VT.CharacterMap.maps['='] = new hterm.VT.CharacterMap('swiss', {
6581 '#': 'ù',
6582 '@': 'à',
6583 '[': 'é',
6584 '\\': 'ç',
6585 ']': 'ê',
6586 '^': 'î',
6587 _: 'è',
6588 '`': 'ô',
6589 '{': 'ä',
6590 '|': 'ö',
6591 '}': 'ü',
6592 '~': 'û'
6593 }),
6594 lib.resource.add(
6595 'hterm/audio/bell', 'audio/ogg;base64',
6596 'T2dnUwACAAAAAAAAAADhqW5KAAAAAMFvEjYBHgF2b3JiaXMAAAAAAYC7AAAAAAAAAHcBAAAAAAC4AU9nZ1MAAAAAAAAAAAAA4aluSgEAAAAAesI3EC3//////////////////8kDdm9yYmlzHQAAAFhpcGguT3JnIGxpYlZvcmJpcyBJIDIwMDkwNzA5AAAAAAEFdm9yYmlzKUJDVgEACAAAADFMIMWA0JBVAAAQAABgJCkOk2ZJKaWUoSh5mJRISSmllMUwiZiUicUYY4wxxhhjjDHGGGOMIDRkFQAABACAKAmOo+ZJas45ZxgnjnKgOWlOOKcgB4pR4DkJwvUmY26mtKZrbs4pJQgNWQUAAAIAQEghhRRSSCGFFGKIIYYYYoghhxxyyCGnnHIKKqigggoyyCCDTDLppJNOOumoo4466ii00EILLbTSSkwx1VZjrr0GXXxzzjnnnHPOOeecc84JQkNWAQAgAAAEQgYZZBBCCCGFFFKIKaaYcgoyyIDQkFUAACAAgAAAAABHkRRJsRTLsRzN0SRP8ixREzXRM0VTVE1VVVVVdV1XdmXXdnXXdn1ZmIVbuH1ZuIVb2IVd94VhGIZhGIZhGIZh+H3f933f930gNGQVACABAKAjOZbjKaIiGqLiOaIDhIasAgBkAAAEACAJkiIpkqNJpmZqrmmbtmirtm3LsizLsgyEhqwCAAABAAQAAAAAAKBpmqZpmqZpmqZpmqZpmqZpmqZpmmZZlmVZlmVZlmVZlmVZlmVZlmVZlmVZlmVZlmVZlmVZlmVZlmVZQGjIKgBAAgBAx3Ecx3EkRVIkx3IsBwgNWQUAyAAACABAUizFcjRHczTHczzHczxHdETJlEzN9EwPCA1ZBQAAAgAIAAAAAABAMRzFcRzJ0SRPUi3TcjVXcz3Xc03XdV1XVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVYHQkFUAAAQAACGdZpZqgAgzkGEgNGQVAIAAAAAYoQhDDAgNWQUAAAQAAIih5CCa0JrzzTkOmuWgqRSb08GJVJsnuamYm3POOeecbM4Z45xzzinKmcWgmdCac85JDJqloJnQmnPOeRKbB62p0ppzzhnnnA7GGWGcc85p0poHqdlYm3POWdCa5qi5FJtzzomUmye1uVSbc84555xzzjnnnHPOqV6czsE54Zxzzonam2u5CV2cc875ZJzuzQnhnHPOOeecc84555xzzglCQ1YBAEAAAARh2BjGnYIgfY4GYhQhpiGTHnSPDpOgMcgppB6NjkZKqYNQUhknpXSC0JBVAAAgAACEEFJIIYUUUkghhRRSSCGGGGKIIaeccgoqqKSSiirKKLPMMssss8wyy6zDzjrrsMMQQwwxtNJKLDXVVmONteaec645SGultdZaK6WUUkoppSA0ZBUAAAIAQCBkkEEGGYUUUkghhphyyimnoIIKCA1ZBQAAAgAIAAAA8CTPER3RER3RER3RER3RER3P8RxREiVREiXRMi1TMz1VVFVXdm1Zl3Xbt4Vd2HXf133f141fF4ZlWZZlWZZlWZZlWZZlWZZlCUJDVgEAIAAAAEIIIYQUUkghhZRijDHHnINOQgmB0JBVAAAgAIAAAAAAR3EUx5EcyZEkS7IkTdIszfI0T/M00RNFUTRNUxVd0RV10xZlUzZd0zVl01Vl1XZl2bZlW7d9WbZ93/d93/d93/d93/d939d1IDRkFQAgAQCgIzmSIimSIjmO40iSBISGrAIAZAAABACgKI7iOI4jSZIkWZImeZZniZqpmZ7pqaIKhIasAgAAAQAEAAAAAACgaIqnmIqniIrniI4oiZZpiZqquaJsyq7ruq7ruq7ruq7ruq7ruq7ruq7ruq7ruq7ruq7ruq7ruq7rukBoyCoAQAIAQEdyJEdyJEVSJEVyJAcIDVkFAMgAAAgAwDEcQ1Ikx7IsTfM0T/M00RM90TM9VXRFFwgNWQUAAAIACAAAAAAAwJAMS7EczdEkUVIt1VI11VItVVQ9VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV1TRN0zSB0JCVAAAZAAAjQQYZhBCKcpBCbj1YCDHmJAWhOQahxBiEpxAzDDkNInSQQSc9uJI5wwzz4FIoFURMg40lN44gDcKmXEnlOAhCQ1YEAFEAAIAxyDHEGHLOScmgRM4xCZ2UyDknpZPSSSktlhgzKSWmEmPjnKPSScmklBhLip2kEmOJrQAAgAAHAIAAC6HQkBUBQBQAAGIMUgophZRSzinmkFLKMeUcUko5p5xTzjkIHYTKMQadgxAppRxTzinHHITMQeWcg9BBKAAAIMABACDAQig0ZEUAECcA4HAkz5M0SxQlSxNFzxRl1xNN15U0zTQ1UVRVyxNV1VRV2xZNVbYlTRNNTfRUVRNFVRVV05ZNVbVtzzRl2VRV3RZV1bZl2xZ+V5Z13zNNWRZV1dZNVbV115Z9X9ZtXZg0zTQ1UVRVTRRV1VRV2zZV17Y1UXRVUVVlWVRVWXZlWfdVV9Z9SxRV1VNN2RVVVbZV2fVtVZZ94XRVXVdl2fdVWRZ+W9eF4fZ94RhV1dZN19V1VZZ9YdZlYbd13yhpmmlqoqiqmiiqqqmqtm2qrq1bouiqoqrKsmeqrqzKsq+rrmzrmiiqrqiqsiyqqiyrsqz7qizrtqiquq3KsrCbrqvrtu8LwyzrunCqrq6rsuz7qizruq3rxnHrujB8pinLpqvquqm6um7runHMtm0co6rqvirLwrDKsu/rui+0dSFRVXXdlF3jV2VZ921fd55b94WybTu/rfvKceu60vg5z28cubZtHLNuG7+t+8bzKz9hOI6lZ5q2baqqrZuqq+uybivDrOtCUVV9XZVl3zddWRdu3zeOW9eNoqrquirLvrDKsjHcxm8cuzAcXds2jlvXnbKtC31jyPcJz2vbxnH7OuP2daOvDAnHjwAAgAEHAIAAE8pAoSErAoA4AQAGIecUUxAqxSB0EFLqIKRUMQYhc05KxRyUUEpqIZTUKsYgVI5JyJyTEkpoKZTSUgehpVBKa6GU1lJrsabUYu0gpBZKaS2U0lpqqcbUWowRYxAy56RkzkkJpbQWSmktc05K56CkDkJKpaQUS0otVsxJyaCj0kFIqaQSU0mptVBKa6WkFktKMbYUW24x1hxKaS2kEltJKcYUU20txpojxiBkzknJnJMSSmktlNJa5ZiUDkJKmYOSSkqtlZJSzJyT0kFIqYOOSkkptpJKTKGU1kpKsYVSWmwx1pxSbDWU0lpJKcaSSmwtxlpbTLV1EFoLpbQWSmmttVZraq3GUEprJaUYS0qxtRZrbjHmGkppraQSW0mpxRZbji3GmlNrNabWam4x5hpbbT3WmnNKrdbUUo0txppjbb3VmnvvIKQWSmktlNJiai3G1mKtoZTWSiqxlZJabDHm2lqMOZTSYkmpxZJSjC3GmltsuaaWamwx5ppSi7Xm2nNsNfbUWqwtxppTS7XWWnOPufVWAADAgAMAQIAJZaDQkJUAQBQAAEGIUs5JaRByzDkqCULMOSepckxCKSlVzEEIJbXOOSkpxdY5CCWlFksqLcVWaykptRZrLQAAoMABACDABk2JxQEKDVkJAEQBACDGIMQYhAYZpRiD0BikFGMQIqUYc05KpRRjzknJGHMOQioZY85BKCmEUEoqKYUQSkklpQIAAAocAAACbNCUWByg0JAVAUAUAABgDGIMMYYgdFQyKhGETEonqYEQWgutddZSa6XFzFpqrbTYQAithdYySyXG1FpmrcSYWisAAOzAAQDswEIoNGQlAJAHAEAYoxRjzjlnEGLMOegcNAgx5hyEDirGnIMOQggVY85BCCGEzDkIIYQQQuYchBBCCKGDEEIIpZTSQQghhFJK6SCEEEIppXQQQgihlFIKAAAqcAAACLBRZHOCkaBCQ1YCAHkAAIAxSjkHoZRGKcYglJJSoxRjEEpJqXIMQikpxVY5B6GUlFrsIJTSWmw1dhBKaS3GWkNKrcVYa64hpdZirDXX1FqMteaaa0otxlprzbkAANwFBwCwAxtFNicYCSo0ZCUAkAcAgCCkFGOMMYYUYoox55xDCCnFmHPOKaYYc84555RijDnnnHOMMeecc845xphzzjnnHHPOOeecc44555xzzjnnnHPOOeecc84555xzzgkAACpwAAAIsFFkc4KRoEJDVgIAqQAAABFWYowxxhgbCDHGGGOMMUYSYowxxhhjbDHGGGOMMcaYYowxxhhjjDHGGGOMMcYYY4wxxhhjjDHGGGOMMcYYY4wxxhhjjDHGGGOMMcYYY4wxxhhjjDHGGFtrrbXWWmuttdZaa6211lprrQBAvwoHAP8HG1ZHOCkaCyw0ZCUAEA4AABjDmHOOOQYdhIYp6KSEDkIIoUNKOSglhFBKKSlzTkpKpaSUWkqZc1JSKiWlllLqIKTUWkottdZaByWl1lJqrbXWOgiltNRaa6212EFIKaXWWostxlBKSq212GKMNYZSUmqtxdhirDGk0lJsLcYYY6yhlNZaazHGGGstKbXWYoy1xlprSam11mKLNdZaCwDgbnAAgEiwcYaVpLPC0eBCQ1YCACEBAARCjDnnnHMQQgghUoox56CDEEIIIURKMeYcdBBCCCGEjDHnoIMQQgghhJAx5hx0EEIIIYQQOucchBBCCKGEUkrnHHQQQgghlFBC6SCEEEIIoYRSSikdhBBCKKGEUkopJYQQQgmllFJKKaWEEEIIoYQSSimllBBCCKWUUkoppZQSQgghlFJKKaWUUkIIoZRQSimllFJKCCGEUkoppZRSSgkhhFBKKaWUUkopIYQSSimllFJKKaUAAIADBwCAACPoJKPKImw04cIDUGjISgCADAAAcdhq6ynWyCDFnISWS4SQchBiLhFSijlHsWVIGcUY1ZQxpRRTUmvonGKMUU+dY0oxw6yUVkookYLScqy1dswBAAAgCAAwECEzgUABFBjIAIADhAQpAKCwwNAxXAQE5BIyCgwKx4Rz0mkDABCEyAyRiFgMEhOqgaJiOgBYXGDIB4AMjY20iwvoMsAFXdx1IIQgBCGIxQEUkICDE2544g1PuMEJOkWlDgIAAAAA4AAAHgAAkg0gIiKaOY4Ojw+QEJERkhKTE5QAAAAAALABgA8AgCQFiIiIZo6jw+MDJERkhKTE5AQlAAAAAAAAAAAACAgIAAAAAAAEAAAACAhPZ2dTAAQYOwAAAAAAAOGpbkoCAAAAmc74DRgyNjM69TAzOTk74dnLubewsbagmZiNp4d0KbsExSY/I3XUTwJgkeZdn1HY4zoj33/q9DFtv3Ui1/jmx7lCUtPt18/sYf9MkgAsAGRBd3gMGP4sU+qCPYBy9VrA3YqJosW3W2/ef1iO/u3cg8ZG/57jU+pPmbGEJUgkfnaI39DbPqxddZphbMRmCc5rKlkUMkyx8iIoug5dJv1OYH9a59c+3Gevqc7Z2XFdDjL/qHztRfjWEWxJ/aiGezjohu9HsCZdQBKbiH0VtU/3m85lDG2T/+xkZcYnX+E+aqzv/xTgOoTFG+x7SNqQ4N+oAABSxuVXw77Jd5bmmTmuJakX7509HH0kGYKvARPpwfOSAPySPAc2EkneDwB2HwAAJlQDYK5586N79GJCjx4+p6aDUd27XSvRyXLJkIC5YZ1jLv5lpOhZTz0s+DmnF1diptrnM6UDgIW11Xh8cHTd0/SmbgOAdxcyWwMAAGIrZ3fNSfZbzKiYrK4+tPqtnMVLOeWOG2kVvUY+p2PJ/hkCl5aFRO4TLGYPZcIU3vYM1hohS4jHFlnyW/2T5J7kGsShXWT8N05V+3C/GPqJ1QdWisGPxEzHqXISBPIinWDUt7IeJv/f5OtzBxpTzZZQ+CYEhHXfqG4aABQli72GJhN4oJv+hXcApAJSErAW8G2raAX4NUcABnVt77CzZAB+LsHcVe+Q4h+QB1wh/ZrJTPxSBdI8mgTeAdTsQOoFUEng9BHcVPhxSRRYkKWZJXOFYP6V4AEripJoEjXgA2wJRZHSExmJDm8F0A6gEXsg5a4ZsALItrMB7+fh7UKLvYWSdtsDwFf1mzYzS1F82N1h2Oyt2e76B1QdS0SAsQigLPMOgJS9JRC7hFXA6kUsLFNKD5cA5cTRvgSqPc3Fl99xW3QTi/MHR8DEm6WnvaVQATwRqRKjywQ9BrrhugR2AKTsPQeQckrAOgDOhbTESyrXQ50CkNpXdtWjW7W2/3UjeX3U95gIdalfRAoAmqUEiwp53hCdcCwlg47fcbfzlmQMAgaBkh7c+fcDgF+ifwDXfzegLPcLYJsAAJQArTXjnh/uXGy3v1Hk3pV6/3t5ruW81f6prfbM2Q3WNVy98BwUtbCwhFhAWuPev6Oe/4ZaFQUcgKrVs4defzh1TADA1DEh5b3VlDaECw5b+bPfkKos3tIAue3vJZOih3ga3l6O3PSfIkrLv0PAS86PPdL7g8oc2KteNFKKzKRehOv2gJoFLBPXmaXvPBQILgJon0bbWBszrYZYYwE7jl2j+vTdU7Vpk21LiU0QajPkywAAHqbUC0/YsYOdb4e6BOp7E0cCi04Ao/TgD8ZVAMid6h/A8IeBNkp6/xsAACZELEYIk+yvI6Qz1NN6lIftB/6IMWjWJNOqPTMedAmyaj6Es0QBklJpiSWWHnQ2CoYbGWAmt+0gLQBFKCBnp2QUUQZ/1thtZDBJUpFWY82z34ocorB62oX7qB5y0oPAv/foxH25wVmgIHf2xFOr8leZcBq1Kx3ZvCq9Bga639AxuHuPNL/71YCF4EywJpqHFAX6XF0sjVbuANnvvdLcrufYwOM/iDa6iA468AYAAB6mNBMXcgTD8HSRqJ4vw8CjAlCEPACASlX/APwPOJKl9xQAAAPmnev2eWp33Xgyw3Dvfz6myGk3oyP8YTKsCOvzAgALQi0o1c6Nzs2O2Pg2h4ACIJAgAGP0aNn5x0BDgVfH7u2TtyfDcRIuYAyQhBF/lvSRAttgA6TPbWZA9gaUrZWAUEAA+Dx47Q3/r87HxUUqZmB0BmUuMlojFjHt1gDunnvuX8MImsjSq5WkzSzGS62OEIlOufWWezxWpv6FBgDgJVltfXFYtNAAnqU0xQoD0YLiXo5cF5QV4CnY1tBLAkZCOABAhbk/AM+/AwSCCdlWAAAMcFjS7owb8GVDzveDiZvznbt2tF4bL5odN1YKl88TAEABCZvufq9YCTBtMwVAQUEAwGtNltzSaHvADYC3TxLVjqiRA+OZAMhzcqEgRcAOwoCgvdTxsTHLQEF6+oOb2+PAI8ciPQcXg7pOY+LjxQSv2fjmFuj34gGwz310/bGK6z3xgT887eomWULEaDd04wHetYxdjcgV2SxvSwn0VoZXJRqkRC5ASQ/muVoAUsX7AgAQMBNaVwAAlABRxT/1PmfqLqSRNDbhXb07berpB3b94jpuWEZjBCD2OcdXFpCKEgCDfcFPMw8AAADUwT4lnUm50lmwrpMMhPQIKj6u0E8fr2vGBngMNdIlrZsigjahljud6AFVg+tzXwUnXL3TJLpajaWKA4VAAAAMiFfqJgKAZ08XrtS3dxtQNYcpPvYEG8ClvrQRJgBephwnNWJjtGqmp6VEPSvBe7EBiU3qgJbQAwD4Le8LAMDMhHbNAAAlgK+tFs5O+YyJc9yCnJa3rxLPulGnxwsXV9Fsk2k4PisCAHC8FkwbGE9gJQAAoMnyksj0CdFMZLLgoz8M+FxziwYBgIx+zHiCBAKAlBKNpF1sO9JpVcyEi9ar15YlHgrut5fPJnkdJ6vEwZPyAHQBIEDUrlMcBAAd2KAS0Qq+JwRsE4AJZtMnAD6GnOYwYlOIZvtzUNdjreB7fiMkWI0CmBB6AIAKc38A9osEFlTSGECB+cbeRDC0aRpLHqNPplcK/76Lxn2rpmqyXsYJWRi/FQAAAKBQk9MCAOibrQBQADCDsqpooPutd+05Ce9g6iEdiYXgVmQAI4+4wskEBEiBloNQ6Ki0/KTQ0QjWfjxzi+AeuXKoMjEVfQOZzr0y941qLgM2AExvbZOqcxZ6J6krlrj4y2j9AdgKDx6GnJsVLhbc42uq584+ouSdNBpoCiCVHrz+WzUA/DDtD8ATgA3h0lMCAAzcFv+S+fSSNkeYWlTpb34mf2RfmqqJeMeklhHAfu7VoAEACgAApKRktL+KkQDWMwYCUAAAAHCKsp80xhp91UjqQBw3x45cetqkjQEyu3G9B6N+R650Uq8OVig7wOm6Wun0ea4lKDPoabJs6aLqgbhPzpv4KR4iODilw88ZpY7q1IOMcbASAOAVtmcCnobcrkG4KGS7/ZnskVWRNF9J0RUHKOnByy9WA8Dv6L4AAARMCQUA4GritfVM2lcZfH3Q3T/vZ47J2YHhcmBazjfdyuV25gLAzrc0cwAAAAAYCh6PdwAAAGyWjFW4yScjaWa2mGcofHxWxewKALglWBpLUvwwk+UOh5eNGyUOs1/EF+pZr+ud5OzoGwYdAABg2p52LiSgAY/ZVlOmilEgHn6G3OcwYjzI7vOj1t6xsx4S3lBY96EUQBF6AIBAmPYH4PoGYCoJAADWe+OZJZi7/x76/yH7Lzf9M5XzRKnFPmveMsilQHwVAAAAAKB3LQD8PCIAAADga0QujBLywzeJ4a6Z/ERVBAUlAEDqvoM7BQBAuAguzFqILtmjH3Kd4wfKobnOhA3z85qWoRPm9hwoOHoDAAlCbwDAA56FHAuXflHo3fe2ttG9XUDeA9YmYCBQ0oPr/1QC8IvuCwAAApbUAQCK22MmE3O78VAbHQT9PIPNoT9zNc3l2Oe7TAVLANBufT8MAQAAAGzT4PS8AQAAoELGHb2uaCwwEv1EWhFriUkbAaAZ27/fVZnTZXbWz3BwWpjUaMZKRj7dZ0J//gUeTdpVEwAAZOFsNxKAjQSgA+ABPoY8Jj5y2wje81jsXc/1TOQWTDYZBmAkNDiqVwuA2NJ9AQAAEBKAt9Vrsfs/2N19MO91S9rd8EHTZHnzC5MYmfQEACy/FBcAAADA5c4gi4z8RANs/m6FNXVo9DV46JG1BBDukqlw/Va5G7QbuGVSI+2aZaoLXJrdVj2zlC9Z5QEAEFz/5QzgVZwAAAAA/oXcxyC6WfTu+09Ve/c766J4VTAGUFmA51+VANKi/QPoPwYgYAkA715OH4S0s5KDHvj99MMq8TPFc3roKZnGOoT1bmIhVgc7XAMBAAAAAMAW1VbQw3gapzOpJd+Kd2fc4iSO62fJv9+movui1wUNPAj059N3OVxzk4gV73PmE8FIA2F5mRq37Evc76vLXfF4rD5UJJAw46hW6LZCb5sNLdx+kzMCAAB+hfy95+965ZCLP7B3/VlTHCvDEKtQhTm4KiCgAEAbrfbWTPssAAAAXpee1tVrozYYn41wD1aeYtkKfswN5/SXPO0JDnhO/4laUortv/s412fybe/nONdncoCHnBVliu0CQGBWlPY/5Kwom2L/kruPM6Q7oz4tvDQy+bZ3HzOi+gNHA4DZEgA='),
6597 lib.resource.add(
6598 'hterm/concat/date', 'text/plain', 'Tue, 25 Apr 2017 15:12:45 +0000'),
6599 lib.resource.add('hterm/changelog/version', 'text/plain', '1.62'),
6600 lib.resource.add('hterm/changelog/date', 'text/plain', '2017-04-17'),
6601 lib.resource.add('hterm/git/HEAD', 'text/plain', 'git rev-parse HEAD');