Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1 | 'use strict'; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2 | if ('undefined' != typeof lib) |
| 3 | throw new Error('Global "lib" object already exists.'); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4 | var lib = {}; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5 | lib.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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 26 | var e = !0; |
| 27 | for (var t in lib.runtimeDependencies_) |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 28 | for (var r = lib.runtimeDependencies_[t], o = t.split('.'), |
| 29 | i = window || self, s = 0; |
| 30 | s < o.length; s++) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 31 | 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 Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 38 | }; |
| 39 | , lib.registerInit = function(e, t) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 40 | return lib.initCallbacks_.push([e, t]), t; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 41 | }; |
| 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 52 | lib.ensureRuntimeDependencies_(), setTimeout(o, 0); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 53 | }; |
| 54 | , lib.colors = {}, lib.colors.re_ = { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 55 | 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 Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 57 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 69 | 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 Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 71 | }, |
| 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 80 | 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 Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 86 | var r = e.length / 3, o = e.substr(0, r), i = e.substr(r, r), |
| 87 | s = e.substr(r + r, r); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 88 | return lib.colors.arrayToRGBA([o, i, s].map(t)); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 89 | }; |
| 90 | , lib.colors.x11ToCSS = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 91 | function t(e) { |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 92 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 97 | } |
| 98 | var r = e.match(lib.colors.re_.x11rgb); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 99 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 104 | 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 Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 109 | return t ? 'rgb(' + parseInt(t[1], 16) + ', ' + parseInt(t[2], 16) + ', ' + |
| 110 | parseInt(t[3], 16) + ')' : |
| 111 | null; |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 112 | } |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 113 | var r = lib.colors.re_.hex16, o = lib.colors.re_.hex24; |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 114 | if (e instanceof Array) |
| 115 | for (var i = 0; i < e.length; i++) e[i] = t(e[i]); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 116 | else |
| 117 | e = t(e); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 118 | return e; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 119 | }; |
| 120 | , lib.colors.rgbToHex = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 121 | function t(e) { |
| 122 | var t = lib.colors.crackRGB(e); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 123 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 130 | } |
| 131 | if (e instanceof Array) |
| 132 | for (var r = 0; r < e.length; r++) e[r] = t(e[r]); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 133 | else |
| 134 | e = t(e); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 135 | return e; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 136 | }; |
| 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 143 | var t = e.length > 3 ? e[3] : 1; |
| 144 | return 'rgba(' + e[0] + ', ' + e[1] + ', ' + e[2] + ', ' + t + ')'; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 145 | }; |
| 146 | , lib.colors.setAlpha = function(e, t) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 147 | var r = lib.colors.crackRGB(e); |
| 148 | return r[3] = t, lib.colors.arrayToRGBA(r); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 149 | }; |
| 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 153 | var n = i[s] - o[s]; |
| 154 | o[s] = Math.round(parseInt(o[s]) + n * r); |
| 155 | } |
| 156 | return lib.colors.arrayToRGBA(o); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 157 | }; |
| 158 | , lib.colors.crackRGB = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 159 | if ('rgba' == e.substr(0, 4)) { |
| 160 | var t = e.match(lib.colors.re_.rgba); |
| 161 | if (t) return t.shift(), t; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 162 | } else { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 163 | var t = e.match(lib.colors.re_.rgb); |
| 164 | if (t) return t.shift(), t.push(1), t; |
| 165 | } |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 166 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 889 | encodeURI: encodeURI, |
| 890 | encodeURIComponent: encodeURIComponent, |
| 891 | escapeHTML: function(e) { |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 892 | var t = |
| 893 | {'<': '<', '>': '>', '&': '&', '"': '"', '\'': '''}; |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 894 | return e.replace(/[<>&\"\']/g, function(e) { |
| 895 | return t[e]; |
| 896 | }); |
| 897 | } |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 898 | }, |
| 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 907 | return window.chrome && chrome.i18n; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 908 | }; |
| 909 | , lib.f.parseQuery = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 910 | '?' == 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 Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 916 | }; |
| 917 | , lib.f.getURL = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 918 | return lib.f.getURL.chromeSupported() ? chrome.runtime.getURL(e) : e; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 919 | }; |
| 920 | , lib.f.getURL.chromeSupported = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 921 | return window.chrome && chrome.runtime && chrome.runtime.getURL; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 922 | }; |
| 923 | , lib.f.clamp = function(e, t, r) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 924 | return t > e ? t : e > r ? r : e |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 925 | }; |
| 926 | , lib.f.lpad = function(e, t, r) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 927 | for (e = String(e), r = r || ' '; e.length < t;) e = r + e; |
| 928 | return e; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 929 | }; |
| 930 | , lib.f.zpad = function(e, t) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 931 | return lib.f.lpad(e, t, '0'); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 932 | }; |
| 933 | , lib.f.getWhitespace = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 934 | if (0 >= e) return ''; |
| 935 | var t = this.getWhitespace; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 936 | for (t.whitespace || (t.whitespace = ' '); e > t.whitespace.length;) |
| 937 | t.whitespace += t.whitespace; |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 938 | return t.whitespace.substr(0, e); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 939 | }; |
| 940 | , lib.f.alarm = function(e, t) { |
| 941 | var r = t || 5e3, o = lib.f.getStack(1); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 942 | return function() { |
| 943 | var t = setTimeout(function() { |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 944 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 953 | return 'string' == typeof e ? i : i(e); |
| 954 | }(); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 955 | }; |
| 956 | , lib.f.getStack = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 957 | var t, r = e ? e + 2 : 2; |
| 958 | try { |
| 959 | throw new Error; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 960 | } catch (o) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 961 | t = o.stack.split('\n'); |
| 962 | } |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 963 | for (var i = {}, s = r; s < t.length; s++) |
| 964 | i[s - r] = t[s].replace(/^\s*at\s+/, ''); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 965 | return i; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 966 | }; |
| 967 | , lib.f.smartFloorDivide = function(e, t) { |
| 968 | var r = e / t, o = Math.ceil(r); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 969 | return 1e-4 > o - r ? o : Math.floor(r); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 970 | }; |
| 971 | , lib.MessageManager = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 972 | this.languages_ = e.map(function(e) { |
| 973 | return e.replace(/-/g, '_'); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 974 | }), |
| 975 | -1 == this.languages_.indexOf('en') && this.languages_.unshift('en'), |
| 976 | this.messages = {}; |
| 977 | }; |
| 978 | , lib.MessageManager.prototype.addMessages = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 979 | for (var t in e) { |
| 980 | var r = e[t]; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 981 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 987 | } |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 988 | }; |
| 989 | , lib.MessageManager.prototype.findAndLoadMessages = function(e, t) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 990 | function r(e) { |
| 991 | e ? i = o.shift() : s = o.shift(), o.length ? n() : t(i, s); |
| 992 | } |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 993 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 997 | n(); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 998 | }; |
| 999 | , lib.MessageManager.prototype.loadMessages = function(e, t, r) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1000 | var o = new XMLHttpRequest; |
| 1001 | o.onloadend = function() { |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1002 | return 200 != o.status ? |
Gunnar Mills | 4ddda58 | 2018-09-04 09:18:30 -0500 | [diff] [blame] | 1003 | void (r && r(o.status)) : |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1004 | (this.addMessages(JSON.parse(o.responseText)), void t()); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1005 | }.bind(this), o.open('GET', e), o.send(); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1006 | }; |
| 1007 | , lib.MessageManager.replaceReferences = function(e, t) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1008 | return e.replace(/\$(\d+)/g, function(e, r) { |
| 1009 | return t[r - 1]; |
| 1010 | }); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1011 | }; |
| 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1027 | function t(e) { |
| 1028 | return e.replace(/-/g, '_').toUpperCase(); |
| 1029 | } |
| 1030 | for (var r = e.querySelectorAll('[i18n]'), o = 0; o < r.length; o++) { |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1031 | var i = r[o], s = i.getAttribute('i18n'); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1032 | if (s) { |
| 1033 | try { |
| 1034 | s = JSON.parse(s); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1035 | } catch (n) { |
| 1036 | throw console.error( |
| 1037 | 'Can\'t parse ' + i.tagName + '#' + i.id + ': ' + s), |
| 1038 | n; |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1039 | } |
| 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 Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1048 | }; |
| 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1052 | var r = t || '/'; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1053 | '/' != 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1069 | var t = this.observers.indexOf(e); |
| 1070 | t >= 0 && this.observers.splice(t, 1); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1071 | }; |
| 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1082 | if (!this.isActive_) throw new Error('Not activated'); |
| 1083 | this.isActive_ = !1, this.storage.removeObserver(this.storageObserver_); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1084 | }; |
| 1085 | , lib.PreferenceManager.prototype.activate = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1086 | if (this.isActive_) throw new Error('Already activated'); |
| 1087 | this.isActive_ = !0, this.storage.addObserver(this.storageObserver_); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1088 | }; |
| 1089 | , lib.PreferenceManager.prototype.readStorage = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1090 | function t() { |
| 1091 | 0 == --r && e && e(); |
| 1092 | } |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1093 | var r = 0, o = Object.keys(this.prefRecords_).map(function(e) { |
| 1094 | return this.prefix + e; |
| 1095 | }.bind(this)); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1096 | this.trace && console.log('Preferences read: ' + this.prefix), |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1097 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1111 | var o = this.prefRecords_[e]; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1112 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1125 | 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 Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1128 | if (!(r in this.prefRecords_)) |
| 1129 | throw new Error('Unknown preference: ' + r); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1130 | this.prefRecords_[r].addObserver(t[r]); |
| 1131 | } |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1132 | }; |
| 1133 | , lib.PreferenceManager.prototype.notifyAll = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1134 | for (var e in this.prefRecords_) this.notifyChange_(e); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1135 | }; |
| 1136 | , lib.PreferenceManager.prototype.notifyChange_ = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1137 | var t = this.prefRecords_[e]; |
| 1138 | if (!t) throw new Error('Unknown preference: ' + e); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1139 | for (var r = t.get(), o = 0; o < this.globalObservers_.length; o++) |
| 1140 | this.globalObservers_[o](e, r); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1141 | for (var o = 0; o < t.observers.length; o++) t.observers[o](r, e, this); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1142 | }; |
| 1143 | , lib.PreferenceManager.prototype.createChild = function(e, t, r) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1144 | var o, i = this.get(e); |
| 1145 | if (r) { |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1146 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1152 | var s = this.childFactories_[e](this, o); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1153 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1157 | var r = this.getChild(e, t); |
| 1158 | r.resetAll(); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1159 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1163 | if (!(e in this.childLists_)) throw new Error('Unknown child list: ' + e); |
| 1164 | var o = this.childLists_[e]; |
| 1165 | if (!(t in o)) { |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1166 | if ('undefined' == typeof r) |
| 1167 | throw new Error('Unknown "' + e + '" child: ' + t); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1168 | return r; |
| 1169 | } |
| 1170 | return o[t]; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1171 | }; |
| 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1177 | return r; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1178 | }; |
| 1179 | , lib.PreferenceManager.prototype.syncChildList = function(e, t) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1180 | function r() { |
| 1181 | 0 == --o && t && t(); |
| 1182 | } |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1183 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1187 | 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 Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1198 | }; |
| 1199 | , lib.PreferenceManager.prototype.reset = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1200 | var t = this.prefRecords_[e]; |
| 1201 | if (!t) throw new Error('Unknown preference: ' + e); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1202 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1207 | 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 Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1212 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1215 | 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 Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1219 | }; |
| 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1227 | var r = this.prefRecords_[e]; |
| 1228 | if (!r) throw new Error('Unknown preference: ' + e); |
| 1229 | if (this.diff(r.defaultValue, t)) { |
Gunnar Mills | 4ddda58 | 2018-09-04 09:18:30 -0500 | [diff] [blame] | 1230 | if (r.currentValue !== this.DEFAULT_VALUE) return void (r.defaultValue = t); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1231 | r.defaultValue = t, this.notifyChange_(e); |
| 1232 | } |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1233 | }; |
| 1234 | , lib.PreferenceManager.prototype.changeDefaults = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1235 | for (var t in e) this.changeDefault(t, e[t]); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1236 | }; |
| 1237 | , lib.PreferenceManager.prototype.set = function(e, t) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1238 | var r = this.prefRecords_[e]; |
| 1239 | if (!r) throw new Error('Unknown preference: ' + e); |
| 1240 | var o = r.get(); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1241 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1249 | var t = this.prefRecords_[e]; |
| 1250 | if (!t) throw new Error('Unknown preference: ' + e); |
| 1251 | return t.get(); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1252 | }; |
| 1253 | , lib.PreferenceManager.prototype.exportAsJson = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1254 | 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 Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1260 | e[t].push({id: i, json: this.getChild(t, i).exportAsJson()}); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1261 | } |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1262 | } else { |
| 1263 | var s = this.prefRecords_[t]; |
| 1264 | s.currentValue != this.DEFAULT_VALUE && (e[t] = s.currentValue); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1265 | } |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1266 | return e; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1267 | }; |
| 1268 | , lib.PreferenceManager.prototype.importFromJson = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1269 | for (var t in e) |
| 1270 | if (t in this.childLists_) |
| 1271 | for (var r = e[t], o = 0; o < r.length; o++) { |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1272 | var i = r[o].id, s = this.childLists_[t][i]; |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1273 | s || (s = this.createChild(t, null, i)), s.importFromJson(r[o].json); |
| 1274 | } |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1275 | else |
| 1276 | this.set(t, e[t]); |
| 1277 | }; |
| 1278 | , lib.PreferenceManager.prototype.onChildListChange_ = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1279 | this.syncChildList(e); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1280 | }; |
| 1281 | , lib.PreferenceManager.prototype.onStorageChange_ = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1282 | 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 Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1286 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1292 | } |
| 1293 | } |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1294 | }; |
| 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1299 | 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 Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1304 | }; |
| 1305 | , lib.resource.getData = function(e, t) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1306 | 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 Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1311 | }; |
| 1312 | , lib.resource.getDataUrl = function(e, t) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1313 | var r = lib.resource.get(e, t); |
| 1314 | return 'data:' + r.type + ',' + r.data; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1315 | }; |
| 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1321 | if (chrome.storage[t] == this.storage_) |
| 1322 | for (var r = 0; r < this.observers_.length; r++) this.observers_[r](e); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1323 | }; |
| 1324 | , lib.Storage.Chrome.prototype.addObserver = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1325 | this.observers_.push(e); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1326 | }; |
| 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1332 | this.storage_.clear(), e && setTimeout(e, 0); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1333 | }; |
| 1334 | , lib.Storage.Chrome.prototype.getItem = function(e, t) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1335 | this.storage_.get(e, t); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1336 | }; |
| 1337 | , lib.Storage.Chrome.prototype.getItems = function(e, t) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1338 | this.storage_.get(e, t); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1339 | }; |
| 1340 | , lib.Storage.Chrome.prototype.setItem = function(e, t, r) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1341 | var o = {}; |
| 1342 | o[e] = t, this.storage_.set(o, r); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1343 | }; |
| 1344 | , lib.Storage.Chrome.prototype.setItems = function(e, t) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1345 | this.storage_.set(e, t); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1346 | }; |
| 1347 | , lib.Storage.Chrome.prototype.removeItem = function(e, t) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1348 | this.storage_.remove(e, t); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1349 | }; |
| 1350 | , lib.Storage.Chrome.prototype.removeItems = function(e, t) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1351 | this.storage_.remove(e, t); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1352 | }; |
| 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1358 | if (e.storageArea == this.storage_) { |
| 1359 | var t = e.oldValue ? JSON.parse(e.oldValue) : '', |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1360 | r = e.newValue ? JSON.parse(e.newValue) : '', o = {}; |
| 1361 | o[e.key] = {oldValue: t, newValue: r}; |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1362 | for (var i = 0; i < this.observers_.length; i++) this.observers_[i](o); |
| 1363 | } |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1364 | }; |
| 1365 | , lib.Storage.Local.prototype.addObserver = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1366 | this.observers_.push(e); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1367 | }; |
| 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1373 | this.storage_.clear(), e && setTimeout(e, 0); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1374 | }; |
| 1375 | , lib.Storage.Local.prototype.getItem = function(e, t) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1376 | var r = this.storage_.getItem(e); |
| 1377 | if ('string' == typeof r) try { |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1378 | r = JSON.parse(r); |
| 1379 | } catch (o) { |
| 1380 | } |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1381 | setTimeout(t.bind(null, r), 0); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1382 | }; |
| 1383 | , lib.Storage.Local.prototype.getItems = function(e, t) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1384 | for (var r = {}, o = e.length - 1; o >= 0; o--) { |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1385 | var i = e[o], s = this.storage_.getItem(i); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1386 | if ('string' == typeof s) try { |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1387 | r[i] = JSON.parse(s); |
| 1388 | } catch (n) { |
| 1389 | r[i] = s; |
| 1390 | } |
| 1391 | else |
| 1392 | e.splice(o, 1); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1393 | } |
| 1394 | setTimeout(t.bind(null, r), 0); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1395 | }; |
| 1396 | , lib.Storage.Local.prototype.setItem = function(e, t, r) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1397 | this.storage_.setItem(e, JSON.stringify(t)), r && setTimeout(r, 0); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1398 | }; |
| 1399 | , lib.Storage.Local.prototype.setItems = function(e, t) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1400 | for (var r in e) this.storage_.setItem(r, JSON.stringify(e[r])); |
| 1401 | t && setTimeout(t, 0); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1402 | }; |
| 1403 | , lib.Storage.Local.prototype.removeItem = function(e, t) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1404 | this.storage_.removeItem(e), t && setTimeout(t, 0); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1405 | }; |
| 1406 | , lib.Storage.Local.prototype.removeItems = function(e, t) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1407 | for (var r = 0; r < e.length; r++) this.storage_.removeItem(e[r]); |
| 1408 | t && setTimeout(t, 0); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1409 | }; |
| 1410 | , lib.Storage.Memory = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1411 | this.observers_ = [], this.storage_ = {}; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1412 | }; |
| 1413 | , lib.Storage.Memory.prototype.addObserver = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1414 | this.observers_.push(e); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1415 | }; |
| 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1421 | var t = {}; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1422 | for (var r in this.storage_) |
| 1423 | t[r] = {oldValue: this.storage_[r], newValue: void 0}; |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1424 | 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 Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1427 | }; |
| 1428 | , lib.Storage.Memory.prototype.getItem = function(e, t) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1429 | var r = this.storage_[e]; |
| 1430 | if ('string' == typeof r) try { |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1431 | r = JSON.parse(r); |
| 1432 | } catch (o) { |
| 1433 | } |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1434 | setTimeout(t.bind(null, r), 0); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1435 | }; |
| 1436 | , lib.Storage.Memory.prototype.getItems = function(e, t) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1437 | for (var r = {}, o = e.length - 1; o >= 0; o--) { |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1438 | var i = e[o], s = this.storage_[i]; |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1439 | if ('string' == typeof s) try { |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1440 | r[i] = JSON.parse(s); |
| 1441 | } catch (n) { |
| 1442 | r[i] = s; |
| 1443 | } |
| 1444 | else |
| 1445 | e.splice(o, 1); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1446 | } |
| 1447 | setTimeout(t.bind(null, r), 0); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1448 | }; |
| 1449 | , lib.Storage.Memory.prototype.setItem = function(e, t, r) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1450 | var o = this.storage_[e]; |
| 1451 | this.storage_[e] = JSON.stringify(t); |
| 1452 | var i = {}; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1453 | i[e] = {oldValue: o, newValue: t}, setTimeout(function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1454 | for (var e = 0; e < this.observers_.length; e++) this.observers_[e](i); |
| 1455 | }.bind(this), 0), r && setTimeout(r, 0); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1456 | }; |
| 1457 | , lib.Storage.Memory.prototype.setItems = function(e, t) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1458 | var r = {}; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1459 | for (var o in e) |
| 1460 | r[o] = {oldValue: this.storage_[o], newValue: e[o]}, |
| 1461 | this.storage_[o] = JSON.stringify(e[o]); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1462 | setTimeout(function() { |
| 1463 | for (var e = 0; e < this.observers_.length; e++) this.observers_[e](r); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1464 | }.bind(this)), |
| 1465 | t && setTimeout(t, 0); |
| 1466 | }; |
| 1467 | , lib.Storage.Memory.prototype.removeItem = function(e, t) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1468 | delete this.storage_[e], t && setTimeout(t, 0); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1469 | }; |
| 1470 | , lib.Storage.Memory.prototype.removeItems = function(e, t) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1471 | for (var r = 0; r < e.length; r++) delete this.storage_[e[r]]; |
| 1472 | t && setTimeout(t, 0); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1473 | }; |
| 1474 | , lib.TestManager = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1475 | this.log = e || new lib.TestManager.Log; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1476 | }; |
| 1477 | , lib.TestManager.prototype.createTestRun = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1478 | return new lib.TestManager.TestRun(this, e); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1479 | }; |
| 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1484 | this.save = !1, this.data = '', this.logFunction_ = e || function(e) { |
| 1485 | this.save && (this.data += e + '\n'), console.log(e); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1486 | }; |
| 1487 | , this.pending_ = '', this.prefix_ = '', this.prefixStack_ = []; |
| 1488 | }; |
| 1489 | , lib.TestManager.Log.prototype.pushPrefix = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1490 | this.prefixStack_.push(e), this.prefix_ = this.prefixStack_.join(''); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1491 | }; |
| 1492 | , lib.TestManager.Log.prototype.popPrefix = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1493 | this.prefixStack_.pop(), this.prefix_ = this.prefixStack_.join(''); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1494 | }; |
| 1495 | , lib.TestManager.Log.prototype.print = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1496 | this.pending_ ? this.pending_ += e : this.pending_ = this.prefix_ + e; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1497 | }; |
| 1498 | , lib.TestManager.Log.prototype.println = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1499 | this.pending_ && this.flush(), this.logFunction_(this.prefix_ + e); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1500 | }; |
| 1501 | , lib.TestManager.Log.prototype.flush = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1502 | this.pending_ && (this.logFunction_(this.pending_), this.pending_ = ''); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1503 | }; |
| 1504 | , lib.TestManager.Suite = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1505 | function t(t, r) { |
| 1506 | this.testManager_ = t, this.suiteName = e, this.setup(r); |
| 1507 | } |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1508 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1523 | 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 Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1526 | }; |
| 1527 | , lib.TestManager.Suite.getTest = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1528 | return this.testMap_[e]; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1529 | }; |
| 1530 | , lib.TestManager.Suite.getTestList = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1531 | return this.testList_; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1532 | }; |
| 1533 | , lib.TestManager.Suite.prototype.setDefaults = function(e, t) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1534 | for (var r in t) this[r] = r in e ? e[r] : t[r]; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1535 | }; |
| 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1544 | try { |
| 1545 | this.testFunction_.apply(e.suite, [e, e.testRun.cx]); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1546 | } catch (t) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1547 | if (t instanceof lib.TestManager.Result.TestComplete) return; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1548 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1553 | } |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1554 | }; |
| 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1568 | var n = i[s]; |
| 1569 | if (r !== this.ALL_TESTS) |
| 1570 | if (r instanceof RegExp) { |
| 1571 | if (!r.test(n.testName)) continue; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1572 | } else if (n.testName != r) |
| 1573 | continue; |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1574 | this.selectTest(n), o++; |
| 1575 | } |
| 1576 | return o; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1577 | }; |
| 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1581 | return t || this.log.println('No tests matched selection criteria: ' + e), t; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1582 | }; |
| 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1589 | var o = 'during'; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1590 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1597 | } |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1598 | }; |
| 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1610 | try { |
| 1611 | this.testManager.testPostamble(e, this.cx), e.suite.postamble(e, this.ctx); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1612 | } catch (t) { |
| 1613 | this.log.println( |
| 1614 | 'Unexpected exception in postamble: ' + (t.stack ? t.stack : t)), |
| 1615 | this.panic = !0; |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1616 | } |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1617 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1621 | else { |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1622 | if (e.status != e.PASSED) |
| 1623 | return this.log.println( |
| 1624 | 'Unknown result status: ' + e.test.fullName + ': ' + e.status), |
| 1625 | this.panic = !0; |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1626 | this.passes.push(e); |
| 1627 | } |
| 1628 | this.runNextTest_(); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1629 | }; |
| 1630 | , lib.TestManager.TestRun.prototype.onResultReComplete = function(e, t) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1631 | 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 Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1634 | }; |
| 1635 | , lib.TestManager.TestRun.prototype.runNextTest_ = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1636 | if (this.panic || !this.testQueue_.length) return this.onTestRunComplete_(); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1637 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1641 | var e = this.testQueue_[0], |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1642 | t = this.currentResult ? this.currentResult.suite : null; |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1643 | try { |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1644 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1651 | } |
| 1652 | try { |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1653 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1663 | } |
| 1664 | try { |
| 1665 | this.currentResult.run(); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1666 | } catch (r) { |
| 1667 | this.log.println( |
| 1668 | 'Unexpected exception during test run: ' + (r.stack ? r.stack : r)), |
| 1669 | this.panic = !0; |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1670 | } |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1671 | }; |
| 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1679 | var t = (e / 1e3).toFixed(2); |
| 1680 | return t + 's'; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1681 | }; |
| 1682 | , lib.TestManager.TestRun.prototype.summarize = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1683 | if (this.failures.length) |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1684 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1714 | this.expectedErrorMessage_ = e; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1715 | }; |
| 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1734 | 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 Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1739 | }; |
| 1740 | , lib.TestManager.Result.prototype.assertEQ = function(e, t, r) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1741 | function o(e) { |
| 1742 | if ('number' == typeof e) return e; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1743 | var t = String(e), r = t.split('\n').map(function(e) { |
| 1744 | return JSON.stringify(e); |
| 1745 | }); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1746 | 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 Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1750 | this.fail( |
| 1751 | 'assertEQ' + i + ': ' + this.getCallerLocation_(1) + ': ' + o(e) + |
| 1752 | ' !== ' + o(t)); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1753 | } |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1754 | }; |
| 1755 | , lib.TestManager.Result.prototype.assert = function(e, t) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1756 | if (e !== !0) { |
| 1757 | var r = t ? '[' + t + ']' : ''; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1758 | this.fail( |
| 1759 | 'assert' + r + ': ' + this.getCallerLocation_(1) + ': ' + String(e)); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1760 | } |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1761 | }; |
| 1762 | , lib.TestManager.Result.prototype.getCallerLocation_ = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1763 | try { |
| 1764 | throw new Error; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1765 | } catch (t) { |
| 1766 | var r = t.stack.split('\n')[e + 2], o = r.match(/([^\/]+:\d+):\d+\)?$/); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1767 | return o ? o[1] : '???'; |
| 1768 | } |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1769 | }; |
| 1770 | , lib.TestManager.Result.prototype.println = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1771 | this.testRun.log.println(e); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1772 | }; |
| 1773 | , lib.TestManager.Result.prototype.fail = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1774 | arguments.length && this.println(e), this.completeTest_(this.FAILED, !0); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1775 | }; |
| 1776 | , lib.TestManager.Result.prototype.pass = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1777 | this.completeTest_(this.PASSED, !0); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1778 | }; |
| 1779 | , lib.UTF8Decoder = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1780 | this.bytesLeft = 0, this.codePoint = 0, this.lowerBound = 0; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1781 | }; |
| 1782 | , lib.UTF8Decoder.prototype.decode = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1783 | for (var t = '', r = 0; r < e.length; r++) { |
| 1784 | var o = e.charCodeAt(r); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1785 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1803 | else if (o >= 128 && 191 >= o) { |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1804 | if (this.bytesLeft--, this.codePoint = (this.codePoint << 6) + (o - 128), |
| 1805 | 0 == this.bytesLeft) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1806 | var i = this.codePoint; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1807 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1813 | } |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1814 | } else |
| 1815 | t += '�', this.bytesLeft = 0, r--; |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1816 | } |
| 1817 | return t; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1818 | }; |
| 1819 | , lib.decodeUTF8 = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1820 | return (new lib.UTF8Decoder).decode(e); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1821 | }; |
| 1822 | , lib.encodeUTF8 = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1823 | for (var t = '', r = 0; r < e.length; r++) { |
| 1824 | var o = e.charCodeAt(r); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1825 | if (o >= 56320 && 57343 >= o) |
| 1826 | o = 65533; |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1827 | else if (o >= 55296 && 56319 >= o) |
| 1828 | if (r + 1 < e.length) { |
| 1829 | var i = e.charCodeAt(r + 1); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1830 | i >= 56320 && 57343 >= i ? |
| 1831 | (o = 65536 + ((1023 & o) << 10) + (1023 & i), r++) : |
| 1832 | o = 65533; |
| 1833 | } else |
| 1834 | o = 65533; |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1835 | var s; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1836 | if (127 >= o) |
| 1837 | t += e.charAt(r); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1838 | else |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1839 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1845 | } |
| 1846 | return t; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1847 | }; |
| 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1988 | if (e < lib.wc.ambiguous[0][0] || e > lib.wc.ambiguous[o][1]) return !1; |
| 1989 | for (; o >= r;) |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1990 | if (t = Math.floor((r + o) / 2), e > lib.wc.ambiguous[t][1]) |
| 1991 | r = t + 1; |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 1992 | else { |
| 1993 | if (!(e < lib.wc.ambiguous[t][0])) return !0; |
| 1994 | o = t - 1; |
| 1995 | } |
| 1996 | return !1; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 1997 | }; |
| 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2023 | 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 Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2029 | }; |
| 2030 | , lib.wc.substr = function(e, t, r) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2031 | var o, i, s; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2032 | for (o = 0, s = 0; |
| 2033 | o < e.length && (s += lib.wc.charWidth(e.charCodeAt(o)), !(s > t)); o++) |
| 2034 | ; |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2035 | if (void 0 != r) { |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2036 | for (i = o, s = 0; i < e.length && r > s; |
| 2037 | s += lib.wc.charWidth(e.charCodeAt(i)), i++) |
| 2038 | ; |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2039 | return s > r && i--, e.substring(o, i); |
| 2040 | } |
| 2041 | return e.substr(o); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2042 | }; |
| 2043 | , lib.wc.substring = function(e, t, r) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2044 | return lib.wc.substr(e, t, r - t); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2045 | }; |
| 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2049 | var hterm = {}; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2050 | hterm.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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2062 | |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2063 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2087 | return e.getBoundingClientRect().width; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2088 | }; |
| 2089 | , hterm.getClientHeight = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2090 | return e.getBoundingClientRect().height; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2091 | }; |
| 2092 | , hterm.copySelectionToClipboard = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2093 | try { |
| 2094 | e.execCommand('copy'); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2095 | } catch (t) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2096 | } |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2097 | }; |
| 2098 | , hterm.pasteFromClipboard = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2099 | try { |
| 2100 | e.execCommand('paste'); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2101 | } catch (t) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2102 | } |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2103 | }; |
| 2104 | , hterm.Size = function(e, t) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2105 | this.width = e, this.height = t; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2106 | }; |
| 2107 | , hterm.Size.prototype.resize = function(e, t) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2108 | this.width = e, this.height = t; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2109 | }; |
| 2110 | , hterm.Size.prototype.clone = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2111 | return new hterm.Size(this.width, this.height); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2112 | }; |
| 2113 | , hterm.Size.prototype.setTo = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2114 | this.width = e.width, this.height = e.height; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2115 | }; |
| 2116 | , hterm.Size.prototype.equals = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2117 | return this.width == e.width && this.height == e.height; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2118 | }; |
| 2119 | , hterm.Size.prototype.toString = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2120 | return '[hterm.Size: ' + this.width + ', ' + this.height + ']'; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2121 | }; |
| 2122 | , hterm.RowCol = function(e, t, r) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2123 | this.row = e, this.column = t, this.overflow = !!r; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2124 | }; |
| 2125 | , hterm.RowCol.prototype.move = function(e, t, r) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2126 | this.row = e, this.column = t, this.overflow = !!r; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2127 | }; |
| 2128 | , hterm.RowCol.prototype.clone = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2129 | return new hterm.RowCol(this.row, this.column, this.overflow); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2130 | }; |
| 2131 | , hterm.RowCol.prototype.setTo = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2132 | this.row = e.row, this.column = e.column, this.overflow = e.overflow; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2133 | }; |
| 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2164 | lib.f.getAcceptLanguages(function(e) { |
| 2165 | this.postMessage('terminal-info', [{ |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2166 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2174 | }.bind(this)); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2175 | }; |
| 2176 | , hterm.Frame.prototype.onCloseClicked_ = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2177 | this.close(); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2178 | }; |
| 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2185 | if (!this.messageChannel_) throw new Error('Message channel is not set up.'); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2186 | this.messageChannel_.port1.postMessage({name: e, argv: t}); |
| 2187 | }; |
| 2188 | , hterm.Frame.prototype.show = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2189 | function e(e, r) { |
| 2190 | return e in t.options ? t.options[e] : r; |
| 2191 | } |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2192 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2203 | var l = n.createElement('div'); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2204 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2210 | var h = this.iframe_ = n.createElement('iframe'); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2211 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2238 | CANCEL: new String('CANCEL'), |
| 2239 | DEFAULT: new String('DEFAULT'), |
| 2240 | PASS: new String('PASS'), |
| 2241 | STRIP: new String('STRIP') |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2242 | }, |
| 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2248 | 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 Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2252 | e ? e.addEventListener(r[0], r[1]) : |
| 2253 | this.keyboardElement_.removeEventListener(r[0], r[1]); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2254 | } |
| 2255 | this.keyboardElement_ = e; |
| 2256 | } |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2257 | }; |
| 2258 | , hterm.Keyboard.prototype.uninstallKeyboard = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2259 | this.installKeyboard(null); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2260 | }; |
| 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2267 | 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 Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2271 | } else |
| 2272 | e.charCode >= 32 && (i = e.charCode); |
| 2273 | i && this.terminal.onVTKeystroke(String.fromCharCode(i)), |
| 2274 | e.preventDefault(), e.stopPropagation(); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2275 | } |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2276 | }; |
| 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2282 | this.altKeyPressed = 0; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2283 | }; |
| 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2290 | function t(s) { |
| 2291 | o = s; |
| 2292 | var a = r[s]; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2293 | return 'function' == typeof a && (a = a.apply(i.keyMap, [e, r])), |
| 2294 | a === n && 'normal' != s && (a = t('normal')), a; |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2295 | } |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2296 | 18 == e.keyCode && |
| 2297 | (this.altKeyPressed = this.altKeyPressed | 1 << e.location - 1), |
| 2298 | 27 == e.keyCode && this.preventChromeAppNonCtrlShiftDefault_(e); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2299 | var r = this.keyMap.keyDefs[e.keyCode]; |
| 2300 | if (!r) return void console.warn('No definition for keyCode: ' + e.keyCode); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2301 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2307 | switch (this.altGrMode) { |
| 2308 | case 'ctrl-alt': |
| 2309 | g && h && c && (h = !1, c = !1); |
| 2310 | break; |
| 2311 | case 'right-alt': |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2312 | g && 2&this.terminal.keyboard.altKeyPressed && (h = !1, c = !1); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2313 | break; |
| 2314 | case 'left-alt': |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2315 | g && 1&this.terminal.keyboard.altKeyPressed && (h = !1, c = !1); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2316 | } |
| 2317 | var d; |
| 2318 | d = t(h ? 'control' : c ? 'alt' : u ? 'meta' : 'normal'); |
| 2319 | var p = !e.maskShiftKey && e.shiftKey, |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2320 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2337 | var f; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2338 | !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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2352 | if (d === n && (d = r.keyCap.substr(p ? 1 : 0, 1), h)) { |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2353 | var y = r.keyCap.substr(0, 1), _ = y.charCodeAt(0); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2354 | _ >= 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 Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2359 | } |
| 2360 | (c && 'escape' == this.altSendsWhat || u && this.metaSendsEscape) && |
| 2361 | (d = '' + d); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2362 | } |
| 2363 | this.terminal.onVTKeystroke(d); |
| 2364 | } |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2365 | }; |
| 2366 | , hterm.Keyboard.Bindings = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2367 | this.bindings_ = {}; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2368 | }; |
| 2369 | , hterm.Keyboard.Bindings.prototype.clear = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2370 | this.bindings_ = {}; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2371 | }; |
| 2372 | , hterm.Keyboard.Bindings.prototype.addBinding_ = function(e, t) { |
| 2373 | var r = null, o = this.bindings_[e.keyCode]; |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2374 | 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 Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2380 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2389 | 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 Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2395 | } catch (i) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2396 | return void console.error(i); |
| 2397 | } |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2398 | if (!r.isComplete()) |
| 2399 | return void console.error(r.error('Expected end of sequence: ' + o)); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2400 | if ('string' == typeof t) { |
| 2401 | r.reset(t); |
| 2402 | try { |
| 2403 | t = r.parseKeyAction(); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2404 | } catch (i) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2405 | return void console.error(i); |
| 2406 | } |
| 2407 | } |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2408 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2413 | for (var t in e) this.addBinding(t, e[t]); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2414 | }; |
| 2415 | , hterm.Keyboard.Bindings.prototype.getBinding = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2416 | 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 Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2423 | }; |
| 2424 | , lib.rtdep('hterm.Keyboard.KeyActions'), hterm.Keyboard.KeyMap = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2425 | this.keyboard = e, this.keyDefs = {}, this.reset(); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2426 | }; |
| 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2442 | 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 Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2448 | var s = o.shiftKey || o.ctrlKey || o.altKey || o.metaKey || |
| 2449 | !h.keyboard.applicationCursor ? |
| 2450 | t : |
| 2451 | r; |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2452 | 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 Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2496 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2501 | } |
| 2502 | } |
| 2503 | this.keyDefs = {}; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2504 | 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 | '[H' : |
| 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 | '[F' : |
| 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2637 | function r(e) { |
| 2638 | return String.fromCharCode(e.charCodeAt(0) - 64); |
| 2639 | } |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2640 | if (this.keyboard.terminal.passCtrlNumber && !e.shiftKey) |
| 2641 | return hterm.Keyboard.KeyActions.PASS; |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2642 | 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 Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2662 | }; |
| 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2674 | var r = this.keyboard.terminal.getDocument().getSelection(); |
| 2675 | if (!r.isCollapsed) { |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2676 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2685 | } |
| 2686 | return ''; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2687 | }; |
| 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2713 | var r = this.keyboard.terminal.getDocument(); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2714 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2731 | var r = t.keyCap.substr(0, 1); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2732 | if ('0' == r) |
| 2733 | this.keyboard.terminal.setFontSize(0); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2734 | else { |
| 2735 | var o = this.keyboard.terminal.getFontSize(); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2736 | '-' == r || '[KP-]' == t.keyCap ? o -= 1 : o += 1, |
| 2737 | this.keyboard.terminal.setFontSize(o); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2738 | } |
| 2739 | return hterm.Keyboard.KeyActions.CANCEL; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2740 | }; |
| 2741 | , hterm.Keyboard.KeyPattern = function(e) { |
| 2742 | this.wildcardCount = 0, this.keyCode = e.keyCode, |
| 2743 | hterm.Keyboard.KeyPattern.modifiers.forEach(function(t) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2744 | this[t] = e[t] || !1, '*' == this[t] && this.wildcardCount++; |
| 2745 | }.bind(this)); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2746 | }; |
| 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2754 | 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 Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2759 | }.bind(this)), |
| 2760 | r; |
| 2761 | }; |
| 2762 | , hterm.Keyboard.KeyPattern.prototype.matchKeyDown = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2763 | return this.match_(e, !1); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2764 | }; |
| 2765 | , hterm.Keyboard.KeyPattern.prototype.matchKeyPattern = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2766 | return this.match_(e, !0); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2767 | }; |
| 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2780 | this.source = '', this.pos = 0, this.ch = null; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2781 | }; |
| 2782 | , hterm.Parser.prototype.error = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2783 | return new Error('Parse error at ' + this.pos + ': ' + e); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2784 | }; |
| 2785 | , hterm.Parser.prototype.isComplete = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2786 | return this.pos == this.source.length; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2787 | }; |
| 2788 | , hterm.Parser.prototype.reset = function(e, t) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2789 | this.source = e, this.pos = t || 0, this.ch = e.substr(0, 1); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2790 | }; |
| 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2795 | for (; this.pos < this.source.length;) { |
| 2796 | this.skipSpace(); |
| 2797 | var r = this.parseToken(); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2798 | if ('integer' == r.type) |
| 2799 | e.keyCode = r.value; |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2800 | else if ('identifier' == r.type) |
| 2801 | if (r.value in hterm.Parser.identifiers.modifierKeys) { |
| 2802 | var o = hterm.Parser.identifiers.modifierKeys[r.value]; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2803 | if (e[o] && '*' != e[o]) |
| 2804 | throw this.error('Duplicate modifier: ' + r.value); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2805 | e[o] = !0; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2806 | } 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2810 | } |
| 2811 | else { |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2812 | if ('symbol' != r.type) |
| 2813 | throw this.error('Expected integer or identifier'); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2814 | 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 Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2821 | if (null != e.keyCode) |
| 2822 | throw this.error('Extra definition after target key'); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2823 | this.advance(1); |
| 2824 | } |
| 2825 | if (null == e.keyCode) throw this.error('Missing target key'); |
| 2826 | return e; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2827 | }; |
| 2828 | , hterm.Parser.prototype.parseKeyAction = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2829 | this.skipSpace(); |
| 2830 | var e = this.parseToken(); |
| 2831 | if ('string' == e.type) return e.value; |
| 2832 | if ('identifier' == e.type) { |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2833 | if (e.value in hterm.Parser.identifiers.actions) |
| 2834 | return hterm.Parser.identifiers.actions[e.value]; |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2835 | throw this.error('Unknown key action: ' + e.value); |
| 2836 | } |
| 2837 | throw this.error('Expected string or identifier'); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2838 | }; |
| 2839 | , hterm.Parser.prototype.peekString = function() { |
| 2840 | return '\'' == this.ch || '"' == this.ch; |
| 2841 | }; |
| 2842 | , hterm.Parser.prototype.peekIdentifier = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2843 | return this.ch.match(/[a-z_]/i); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2844 | }; |
| 2845 | , hterm.Parser.prototype.peekInteger = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2846 | return this.ch.match(/[0-9]/); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2847 | }; |
| 2848 | , hterm.Parser.prototype.parseToken = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2849 | if ('*' == this.ch) { |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2850 | var e = {type: 'symbol', value: this.ch}; |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2851 | return this.advance(1), e; |
| 2852 | } |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2853 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2857 | throw this.error('Unexpected token'); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2858 | }; |
| 2859 | , hterm.Parser.prototype.parseIdentifier = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2860 | if (!this.peekIdentifier()) throw this.error('Expected identifier'); |
| 2861 | return this.parsePattern(/[a-z0-9_]+/gi); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2862 | }; |
| 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2872 | this.advance(1); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2873 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2880 | if (this.ch == t) return this.advance(1), e; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2881 | } else |
| 2882 | e += this.ch, this.advance(1); |
| 2883 | else |
| 2884 | this.advance(1), e += this.parseEscape(); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2885 | } |
| 2886 | throw this.error('Unterminated string literal'); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2887 | }; |
| 2888 | , hterm.Parser.prototype.parseEscape = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2889 | var e = { |
| 2890 | '"': '"', |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2891 | '\'': '\'', |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2892 | '\\': '\\', |
| 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 Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2913 | }; |
| 2914 | , hterm.Parser.prototype.parsePattern = function(e) { |
| 2915 | if (!e.global) |
| 2916 | throw this.error('Internal error: Span patterns must be global'); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2917 | e.lastIndex = this.pos; |
| 2918 | var t = e.exec(this.source); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2919 | if (!t || e.lastIndex - t[0].length != this.pos) |
| 2920 | throw this.error('Expected match for: ' + e); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2921 | return this.pos = e.lastIndex - 1, this.advance(1), t[0]; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2922 | }; |
| 2923 | , hterm.Parser.prototype.advance = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2924 | this.pos += e, this.ch = this.source.substr(this.pos, 1); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2925 | }; |
| 2926 | , hterm.Parser.prototype.skipSpace = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2927 | if (/\s/.test(this.ch)) { |
| 2928 | var t = /\s+/gm; |
| 2929 | t.lastIndex = this.pos; |
| 2930 | var r = this.source; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2931 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 2935 | } |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2936 | }; |
| 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3031 | }, |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3032 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3051 | }, |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3052 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3321 | var t = new hterm.PubSub; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3322 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3326 | e in this.observers_ || (this.observers_[e] = []), this.observers_[e].push(t); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3327 | }; |
| 3328 | , hterm.PubSub.prototype.unsubscribe = function(e, t) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3329 | 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 Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3334 | }; |
| 3335 | , hterm.PubSub.prototype.publish = function(e, t, r) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3336 | function o(e) { |
| 3337 | e < i.length - 1 && setTimeout(o, 0, e + 1), i[e](t); |
| 3338 | } |
| 3339 | var i = this.observers_[e]; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3340 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3354 | return new hterm.Size(this.columnCount_, this.rowsArray.length); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3355 | }; |
| 3356 | , hterm.Screen.prototype.getHeight = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3357 | return this.rowsArray.length; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3358 | }; |
| 3359 | , hterm.Screen.prototype.getWidth = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3360 | return this.columnCount_; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3361 | }; |
| 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3368 | return this.shiftRows(1)[0]; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3369 | }; |
| 3370 | , hterm.Screen.prototype.shiftRows = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3371 | return this.rowsArray.splice(0, e); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3372 | }; |
| 3373 | , hterm.Screen.prototype.unshiftRow = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3374 | this.rowsArray.splice(0, 0, e); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3375 | }; |
| 3376 | , hterm.Screen.prototype.unshiftRows = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3377 | this.rowsArray.unshift.apply(this.rowsArray, e); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3378 | }; |
| 3379 | , hterm.Screen.prototype.popRow = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3380 | return this.popRows(1)[0]; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3381 | }; |
| 3382 | , hterm.Screen.prototype.popRows = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3383 | return this.rowsArray.splice(this.rowsArray.length - e, e); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3384 | }; |
| 3385 | , hterm.Screen.prototype.pushRow = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3386 | this.rowsArray.push(e); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3387 | }; |
| 3388 | , hterm.Screen.prototype.pushRows = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3389 | e.push.apply(this.rowsArray, e); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3390 | }; |
| 3391 | , hterm.Screen.prototype.insertRow = function(e, t) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3392 | this.rowsArray.splice(e, 0, t); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3393 | }; |
| 3394 | , hterm.Screen.prototype.insertRows = function(e, t) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3395 | for (var r = 0; r < t.length; r++) this.rowsArray.splice(e + r, 0, t[r]); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3396 | }; |
| 3397 | , hterm.Screen.prototype.removeRow = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3398 | return this.rowsArray.splice(e, 1)[0]; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3399 | }; |
| 3400 | , hterm.Screen.prototype.removeRows = function(e, t) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3401 | return this.rowsArray.splice(e, t); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3402 | }; |
| 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3412 | var e; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3413 | e = this.textAttributes.isDefault() ? '' : |
| 3414 | lib.f.getWhitespace(this.columnCount_); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3415 | var t = this.textAttributes.inverse; |
| 3416 | this.textAttributes.inverse = !1, this.textAttributes.syncColors(); |
| 3417 | var r = this.textAttributes.createContainer(e); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3418 | this.cursorRowNode_.appendChild(r), this.cursorNode_ = r, |
| 3419 | this.textAttributes.inverse = t, |
| 3420 | this.textAttributes.syncColors(); |
| 3421 | }; |
| 3422 | , hterm.Screen.prototype.commitLineOverflow = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3423 | this.cursorRowNode_.setAttribute('line-overflow', !0); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3424 | }; |
| 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3437 | o || (o = r.ownerDocument.createTextNode(''), r.appendChild(o)); |
| 3438 | var i = 0; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3439 | 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 Mills | 4ddda58 | 2018-09-04 09:18:30 -0500 | [diff] [blame] | 3448 | return this.cursorNode_ = o, void (this.cursorOffset_ = s); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3449 | i += n, o = o.nextSibling; |
| 3450 | } |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3451 | }; |
| 3452 | , hterm.Screen.prototype.syncSelectionCaret = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3453 | try { |
| 3454 | e.collapse(this.cursorNode_, this.cursorOffset_); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3455 | } catch (t) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3456 | } |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3457 | }; |
| 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3466 | var e = hterm.TextAttributes.nodeWidth(this.cursorRowNode_); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3467 | if (e <= this.columnCount_) |
Gunnar Mills | 4ddda58 | 2018-09-04 09:18:30 -0500 | [diff] [blame] | 3468 | return void ( |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3469 | this.cursorPosition.column >= this.columnCount_ && |
| 3470 | (this.setCursorPosition(this.cursorPosition.row, this.columnCount_ - 1), |
| 3471 | this.cursorPosition.overflow = !0)); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3472 | var t = this.cursorPosition.column; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3473 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3485 | this.cursorRowNode_.removeAttribute('line-overflow'); |
| 3486 | var o = lib.wc.strWidth(e); |
| 3487 | this.cursorPosition.column += o; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3488 | var i = this.cursorOffset_, s = hterm.TextAttributes.nodeWidth(t) - i; |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3489 | if (0 > s) { |
| 3490 | var n = lib.f.getWhitespace(-s); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3491 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3497 | var a = t.ownerDocument.createTextNode(n); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3498 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3504 | s = 0; |
| 3505 | } |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3506 | 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 Mills | 4ddda58 | 2018-09-04 09:18:30 -0500 | [diff] [blame] | 3512 | void (this.cursorOffset_ += o); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3513 | if (0 == i) { |
| 3514 | var l = t.previousSibling; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3515 | if (l && this.textAttributes.matchesContainer(l)) |
| 3516 | return l.textContent += e, |
| 3517 | this.cursorNode_ = l, |
Gunnar Mills | 4ddda58 | 2018-09-04 09:18:30 -0500 | [diff] [blame] | 3518 | void (this.cursorOffset_ = lib.wc.strWidth(l.textContent)); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3519 | var h = this.textAttributes.createContainer(e); |
Gunnar Mills | 4ddda58 | 2018-09-04 09:18:30 -0500 | [diff] [blame] | 3520 | return this.cursorRowNode_.insertBefore(h, t), |
| 3521 | this.cursorNode_ = h, void (this.cursorOffset_ = o); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3522 | } |
| 3523 | if (0 == s) { |
| 3524 | var c = t.nextSibling; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3525 | if (c && this.textAttributes.matchesContainer(c)) |
| 3526 | return c.textContent = e + c.textContent, this.cursorNode_ = c, |
Gunnar Mills | 4ddda58 | 2018-09-04 09:18:30 -0500 | [diff] [blame] | 3527 | void (this.cursorOffset_ = lib.wc.strWidth(e)); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3528 | var h = this.textAttributes.createContainer(e); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3529 | return this.cursorRowNode_.insertBefore(h, c), |
| 3530 | this.cursorNode_ = h, |
Gunnar Mills | 4ddda58 | 2018-09-04 09:18:30 -0500 | [diff] [blame] | 3531 | void (this.cursorOffset_ = hterm.TextAttributes.nodeWidth(h)); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3532 | } |
| 3533 | this.splitNode_(t, i); |
| 3534 | var h = this.textAttributes.createContainer(e); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3535 | this.cursorRowNode_.insertBefore(h, t.nextSibling), this.cursorNode_ = h, |
| 3536 | this.cursorOffset_ = o; |
| 3537 | }; |
| 3538 | , hterm.Screen.prototype.overwriteString = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3539 | var t = this.columnCount_ - this.cursorPosition.column; |
| 3540 | if (!t) return [e]; |
| 3541 | var r = lib.wc.strWidth(e); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3542 | return this.textAttributes.matchesContainer(this.cursorNode_) && |
| 3543 | this.cursorNode_.textContent.substr(this.cursorOffset_) == e ? |
Gunnar Mills | 4ddda58 | 2018-09-04 09:18:30 -0500 | [diff] [blame] | 3544 | (this.cursorOffset_ += r, void (this.cursorPosition.column += r)) : |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3545 | (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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3550 | if (e = Math.min(e, this.columnCount_ - o), !e) return 0; |
| 3551 | for (var i, s, n = e; t && e;) { |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3552 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3557 | var a = this.textAttributes.createContainer(' '); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3558 | t.parentNode.insertBefore(a, t.nextSibling), t.textContent = '', s = 0, |
| 3559 | e -= 1; |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3560 | } |
| 3561 | var l = t.nextSibling; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3562 | 0 == s && t != this.cursorNode_ && t.parentNode.removeChild(t), t = l, |
| 3563 | r = 0; |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3564 | } |
| 3565 | if (3 != this.cursorNode_.nodeType && !this.cursorNode_.textContent) { |
| 3566 | var h = this.cursorNode_; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3567 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3572 | else { |
| 3573 | var c = this.cursorRowNode_.ownerDocument.createTextNode(''); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3574 | this.cursorRowNode_.appendChild(c), this.cursorNode_ = c, |
| 3575 | this.cursorOffset_ = 0; |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3576 | } |
| 3577 | this.cursorRowNode_.removeChild(h); |
| 3578 | } |
| 3579 | return n; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3580 | }; |
| 3581 | , hterm.Screen.prototype.getLineStartRow_ = function(e) { |
| 3582 | for (; e.previousSibling && e.previousSibling.hasAttribute('line-overflow');) |
| 3583 | e = e.previousSibling; |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3584 | return e; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3585 | }; |
| 3586 | , hterm.Screen.prototype.getLineText_ = function(e) { |
| 3587 | for (var t = ''; e && (t += e.textContent, e.hasAttribute('line-overflow'));) |
| 3588 | e = e.nextSibling; |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3589 | return t; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3590 | }; |
| 3591 | , hterm.Screen.prototype.getXRowAncestor_ = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3592 | for (; e && 'X-ROW' !== e.nodeName;) e = e.parentNode; |
| 3593 | return e; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3594 | }; |
| 3595 | , hterm.Screen.prototype.getPositionWithOverflow_ = function(e, t, r) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3596 | if (!t) return -1; |
| 3597 | var o = this.getXRowAncestor_(t); |
| 3598 | if (!o) return -1; |
| 3599 | for (var i = 0; o != e;) { |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3600 | if (i += hterm.TextAttributes.nodeWidth(e), |
| 3601 | !e.hasAttribute('line-overflow') || !e.nextSibling) |
| 3602 | return -1; |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3603 | e = e.nextSibling; |
| 3604 | } |
| 3605 | return i + this.getPositionWithinRow_(e, t, r); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3606 | }; |
| 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3611 | 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 Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3617 | }; |
| 3618 | , hterm.Screen.prototype.getNodeAndOffsetWithOverflow_ = function(e, t) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3619 | 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 Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3624 | }; |
| 3625 | , hterm.Screen.prototype.getNodeAndOffsetWithinRow_ = function(e, t) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3626 | for (var r = 0; r < e.childNodes.length; r++) { |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3627 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3631 | t -= i; |
| 3632 | } |
| 3633 | return null; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3634 | }; |
| 3635 | , hterm.Screen.prototype.setRange_ = function(e, t, r, o) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3636 | 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 Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3641 | }; |
| 3642 | , hterm.Screen.prototype.expandSelection = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3643 | 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 Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3648 | var o = |
| 3649 | this.getPositionWithOverflow_(r, t.startContainer, t.startOffset); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3650 | if (-1 != o) { |
| 3651 | var i = this.getPositionWithOverflow_(r, t.endContainer, t.endOffset); |
| 3652 | if (-1 != i) { |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3653 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3658 | if (!(-1 == u || u > o)) { |
| 3659 | var g = lib.wc.substring(l, o, lib.wc.strWidth(l)), |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3660 | d = new RegExp('^' + a + n), p = g.match(d); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3661 | if (p) { |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3662 | var m = o + lib.wc.strWidth(p[0]); |
| 3663 | -1 == m || i > m || (this.setRange_(r, u, m, t), e.addRange(t)); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3664 | } |
| 3665 | } |
| 3666 | } |
| 3667 | } |
| 3668 | } |
| 3669 | } |
| 3670 | } |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3671 | }; |
| 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3691 | 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 Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3700 | }; |
| 3701 | , hterm.ScrollPort.Selection.prototype.sync = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3702 | function e() { |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3703 | r.startRow = i, r.startNode = o.anchorNode, r.startOffset = o.anchorOffset, |
| 3704 | r.endRow = s, r.endNode = o.focusNode, r.endOffset = o.focusOffset; |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3705 | } |
| 3706 | |
| 3707 | function t() { |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3708 | r.startRow = s, r.startNode = o.focusNode, r.startOffset = o.focusOffset, |
| 3709 | r.endRow = i, r.endNode = o.anchorNode, r.endOffset = o.anchorOffset; |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3710 | } |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3711 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3714 | for (var i = o.anchorNode; i && !('rowIndex' in i);) i = i.parentNode; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3715 | if (!i) |
| 3716 | return void console.error( |
| 3717 | 'Selection anchor is not rooted in a row node: ' + |
| 3718 | o.anchorNode.nodeName); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3719 | for (var s = o.focusNode; s && !('rowIndex' in s);) s = s.parentNode; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3720 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3730 | 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 Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3737 | }; |
| 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3746 | var t = this.document_ = this.iframe_.contentDocument; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3747 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3749 | var r = t.createElement('style'); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3750 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3784 | var o = 'http://www.w3.org/2000/svg'; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3785 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3806 | return this.screen_.style.fontFamily; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3807 | }; |
| 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3816 | this.iframe_.focus(), this.screen_.focus(); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3817 | }; |
| 3818 | , hterm.ScrollPort.prototype.getForegroundColor = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3819 | return this.screen_.style.color; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3820 | }; |
| 3821 | , hterm.ScrollPort.prototype.setForegroundColor = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3822 | this.screen_.style.color = e; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3823 | }; |
| 3824 | , hterm.ScrollPort.prototype.getBackgroundColor = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3825 | return this.screen_.style.backgroundColor; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3826 | }; |
| 3827 | , hterm.ScrollPort.prototype.setBackgroundColor = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3828 | this.screen_.style.backgroundColor = e; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3829 | }; |
| 3830 | , hterm.ScrollPort.prototype.setBackgroundImage = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3831 | this.screen_.style.backgroundImage = e; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3832 | }; |
| 3833 | , hterm.ScrollPort.prototype.setBackgroundSize = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3834 | this.screen_.style.backgroundSize = e; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3835 | }; |
| 3836 | , hterm.ScrollPort.prototype.setBackgroundPosition = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3837 | this.screen_.style.backgroundPosition = e; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3838 | }; |
| 3839 | , hterm.ScrollPort.prototype.setCtrlVPaste = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3840 | this.ctrlVPaste = e; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3841 | }; |
| 3842 | , hterm.ScrollPort.prototype.getScreenSize = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3843 | var e = hterm.getClientSize(this.screen_); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3844 | return {height: e.height, width: e.width - this.currentScrollbarWidthPx}; |
| 3845 | }; |
| 3846 | , hterm.ScrollPort.prototype.getScreenWidth = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3847 | return this.getScreenSize().width; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3848 | }; |
| 3849 | , hterm.ScrollPort.prototype.getScreenHeight = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3850 | return this.getScreenSize().height; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3851 | }; |
| 3852 | , hterm.ScrollPort.prototype.getDocument = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3853 | return this.document_; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3854 | }; |
| 3855 | , hterm.ScrollPort.prototype.getScreenNode = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3856 | return this.screen_; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3857 | }; |
| 3858 | , hterm.ScrollPort.prototype.resetCache = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3859 | this.currentRowNodeCache_ = null, this.previousRowNodeCache_ = {}; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3860 | }; |
| 3861 | , hterm.ScrollPort.prototype.setRowProvider = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3862 | this.resetCache(), this.rowProvider_ = e, this.scheduleRedraw(); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3863 | }; |
| 3864 | , hterm.ScrollPort.prototype.invalidate = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3865 | 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 Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3870 | var r = this.getTopRowIndex(), o = this.getBottomRowIndex(r); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3871 | this.drawVisibleRows_(r, o); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3872 | }; |
| 3873 | , hterm.ScrollPort.prototype.scheduleInvalidate = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3874 | 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 Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3880 | }; |
| 3881 | , hterm.ScrollPort.prototype.setFontSize = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3882 | this.screen_.style.fontSize = e + 'px', this.syncCharacterSize(); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3883 | }; |
| 3884 | , hterm.ScrollPort.prototype.getFontSize = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3885 | return parseInt(this.screen_.style.fontSize); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3886 | }; |
| 3887 | , hterm.ScrollPort.prototype.measureCharacterSize = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3888 | var t = 100, |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3889 | r = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'; |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3890 | if (!this.ruler_) { |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3891 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3901 | } |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3902 | this.rulerSpan_.style.fontWeight = e || '', |
| 3903 | this.rowNodes_.appendChild(this.ruler_); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3904 | var s = hterm.getClientSize(this.rulerSpan_), |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3905 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3915 | this.characterSize = this.measureCharacterSize(); |
| 3916 | var e = this.characterSize.height + 'px'; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3917 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3928 | var e = this; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3929 | this.publish('resize', {scrollPort: this}, function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3930 | e.scrollRowToBottom(e.rowProvider_.getRowCount()), e.scheduleRedraw(); |
| 3931 | }); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3932 | }; |
| 3933 | , hterm.ScrollPort.prototype.syncRowNodesDimensions_ = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3934 | var e = this.getScreenSize(); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3935 | this.lastScreenWidth_ = e.width, this.lastScreenHeight_ = e.height, |
| 3936 | this.visibleRowCount = |
| 3937 | lib.f.smartFloorDivide(e.height, this.characterSize.height); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3938 | var t = this.visibleRowCount * this.characterSize.height; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3939 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3955 | 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 Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3961 | }; |
| 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 Mills | 4ddda58 | 2018-09-04 09:18:30 -0500 | [diff] [blame] | 3975 | return void ( |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3976 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3982 | else |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3983 | 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 Mills | 4ddda58 | 2018-09-04 09:18:30 -0500 | [diff] [blame] | 3993 | return void ( |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 3994 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 3999 | else |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4000 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4009 | function r(e, t) { |
| 4010 | for (; e != t;) { |
| 4011 | if (!e) throw 'Did not encounter target node'; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4012 | if (e == o.bottomFold_) |
| 4013 | throw 'Encountered bottom fold before target node'; |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4014 | var r = e; |
| 4015 | e = e.nextSibling, r.parentNode.removeChild(r); |
| 4016 | } |
| 4017 | } |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4018 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4023 | var c = e + h; |
| 4024 | if (a != n) |
| 4025 | if (a.rowIndex != c) |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4026 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4049 | else { |
| 4050 | var u = this.fetchRowNode_(c); |
| 4051 | if (!u) { |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4052 | console.log('Couldn\'t fetch row index: ' + c); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4053 | break; |
| 4054 | } |
| 4055 | this.rowNodes_.insertBefore(u, a); |
| 4056 | } |
| 4057 | } |
| 4058 | a != this.bottomFold_ && r(a, n); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4059 | }; |
| 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4069 | this.currentRowNodeCache_[e.rowIndex] = e; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4070 | }; |
| 4071 | , hterm.ScrollPort.prototype.fetchRowNode_ = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4072 | var t; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4073 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4079 | var e; |
| 4080 | if (0 != this.topFold_.nextSibling.rowIndex) { |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4081 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4087 | var t, r = this.rowProvider_.getRowCount() - 1; |
| 4088 | if (this.bottomFold_.previousSibling.rowIndex != r) { |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4089 | for (; this.bottomFold_.nextSibling;) |
| 4090 | this.rowNodes_.removeChild(this.bottomFold_.nextSibling); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4091 | t = this.fetchRowNode_(r), this.rowNodes_.appendChild(t); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4092 | } else |
| 4093 | t = this.bottomFold_.previousSibling.rowIndex; |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4094 | var o = this.document_.getSelection(); |
| 4095 | o.collapse(e, 0), o.extend(t, t.childNodes.length), this.selection.sync(); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4096 | }; |
| 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4104 | var t = e * this.characterSize.height + this.visibleRowTopMargin, |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4105 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4119 | return Math.round(this.screen_.scrollTop / this.characterSize.height); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4120 | }; |
| 4121 | , hterm.ScrollPort.prototype.getBottomRowIndex = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4122 | return e + this.visibleRowCount - 1; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4123 | }; |
| 4124 | , hterm.ScrollPort.prototype.onScroll_ = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4125 | var t = this.getScreenSize(); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4126 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4133 | 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 Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4139 | r > o && (r = o), |
| 4140 | r != this.screen_.scrollTop && |
| 4141 | (this.screen_.scrollTop = r, e.preventDefault()); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4142 | } |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4143 | }; |
| 4144 | , hterm.ScrollPort.prototype.onResize_ = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4145 | this.syncCharacterSize(), this.resize(); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4146 | }; |
| 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4157 | if (this.selection.startRow.rowIndex < t) { |
| 4158 | var o; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4159 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4167 | } |
| 4168 | if (this.selection.endRow.rowIndex > r) { |
| 4169 | var i; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4170 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4176 | } |
| 4177 | } |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4178 | }; |
| 4179 | , hterm.ScrollPort.prototype.onBodyKeyDown_ = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4180 | if (this.ctrlVPaste) { |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4181 | var t = String.fromCharCode(e.which), r = t.toLowerCase(); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4182 | (e.ctrlKey || e.metaKey) && 'v' == r && this.pasteTarget_.focus(); |
| 4183 | } |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4184 | }; |
| 4185 | , hterm.ScrollPort.prototype.onPaste_ = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4186 | this.pasteTarget_.focus(); |
| 4187 | var t = this; |
| 4188 | setTimeout(function() { |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4189 | t.publish('paste', {text: t.pasteTarget_.value}), t.pasteTarget_.value = '', |
| 4190 | t.screen_.focus(); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4191 | }, 0); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4192 | }; |
| 4193 | , hterm.ScrollPort.prototype.handlePasteTargetTextInput_ = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4194 | e.stopPropagation(); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4195 | }; |
| 4196 | , hterm.ScrollPort.prototype.setScrollbarVisible = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4197 | this.screen_.style.overflowY = e ? 'scroll' : 'hidden'; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4198 | }; |
| 4199 | , hterm.ScrollPort.prototype.setScrollWheelMoveMultipler = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4200 | this.scrollWheelMultiplier_ = e; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4201 | }; |
| 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4242 | BLOCK: 'BLOCK', |
| 4243 | BEAM: 'BEAM', |
| 4244 | UNDERLINE: 'UNDERLINE' |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4245 | }, |
| 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4480 | } |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4481 | }), |
| 4482 | this.prefs_.readStorage(function() { |
| 4483 | this.prefs_.notifyAll(), t && t(); |
| 4484 | }.bind(this)); |
| 4485 | }; |
| 4486 | , hterm.Terminal.prototype.getPrefs = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4487 | return this.prefs_; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4488 | }; |
| 4489 | , hterm.Terminal.prototype.setBracketedPaste = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4490 | this.options_.bracketedPaste = e; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4491 | }; |
| 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4497 | return this.cursorColor_; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4498 | }; |
| 4499 | , hterm.Terminal.prototype.setSelectionEnabled = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4500 | this.enableMouseDragScroll = e; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4501 | }; |
| 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4511 | return this.backgroundColor_; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4512 | }; |
| 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4522 | return this.foregroundColor_; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4523 | }; |
| 4524 | , hterm.Terminal.prototype.runCommandClass = function(e, t) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4525 | 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 Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4533 | o.io.pop(), o.uninstallKeyboard(), |
| 4534 | o.prefs_.get('close-on-exit') && window.close(); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4535 | } |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4536 | }), |
| 4537 | this.installKeyboard(), this.command.run(); |
| 4538 | }; |
| 4539 | , hterm.Terminal.prototype.isPrimaryScreen = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4540 | return this.screen_ == this.primaryScreen_; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4541 | }; |
| 4542 | , hterm.Terminal.prototype.installKeyboard = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4543 | this.keyboard.installKeyboard(this.scrollPort_.getDocument().body); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4544 | }; |
| 4545 | , hterm.Terminal.prototype.uninstallKeyboard = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4546 | this.keyboard.installKeyboard(null); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4547 | }; |
| 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4556 | return this.scrollPort_.getFontSize(); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4557 | }; |
| 4558 | , hterm.Terminal.prototype.getFontFamily = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4559 | return this.scrollPort_.getFontFamily(); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4560 | }; |
| 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4567 | var e = this.prefs_.get('mouse-paste-button'); |
Gunnar Mills | 4ddda58 | 2018-09-04 09:18:30 -0500 | [diff] [blame] | 4568 | if ('number' == typeof e) return void (this.mousePasteButton = e); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4569 | var t = navigator.userAgent.match(/\(X11;\s+(\S+)/); |
| 4570 | t && 'CrOS' != t[2] ? this.mousePasteButton = 3 : this.mousePasteButton = 2; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4571 | }; |
| 4572 | , hterm.Terminal.prototype.syncBoldSafeState = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4573 | var e = this.prefs_.get('enable-bold'); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4574 | if (null !== e) |
| 4575 | return this.primaryScreen_.textAttributes.enableBold = e, |
Gunnar Mills | 4ddda58 | 2018-09-04 09:18:30 -0500 | [diff] [blame] | 4576 | void (this.alternateScreen_.textAttributes.enableBold = e); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4577 | var t = this.scrollPort_.measureCharacterSize(), |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4578 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4592 | return this.screen_.cursorPosition.clone(); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4593 | }; |
| 4594 | , hterm.Terminal.prototype.getTextAttributes = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4595 | return this.screen_.textAttributes; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4596 | }; |
| 4597 | , hterm.Terminal.prototype.setTextAttributes = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4598 | this.screen_.textAttributes = e; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4599 | }; |
| 4600 | , hterm.Terminal.prototype.getZoomFactor = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4601 | return this.scrollPort_.characterSize.zoomFactor; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4602 | }; |
| 4603 | , hterm.Terminal.prototype.setWindowTitle = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4604 | window.document.title = e; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4605 | }; |
| 4606 | , hterm.Terminal.prototype.restoreCursor = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4607 | var t = lib.f.clamp(e.row, 0, this.screenSize.height - 1), |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4608 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4614 | this.screen_.cursorPosition.overflow = !1; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4615 | }; |
| 4616 | , hterm.Terminal.prototype.setCursorShape = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4617 | this.cursorShape_ = e, this.restyleCursor_(); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4618 | }; |
| 4619 | , hterm.Terminal.prototype.getCursorShape = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4620 | return this.cursorShape_; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4621 | }; |
| 4622 | , hterm.Terminal.prototype.setWidth = function(e) { |
| 4623 | return null == e ? |
Gunnar Mills | 4ddda58 | 2018-09-04 09:18:30 -0500 | [diff] [blame] | 4624 | void (this.div_.style.width = '100%') : |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4625 | (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 Mills | 4ddda58 | 2018-09-04 09:18:30 -0500 | [diff] [blame] | 4633 | return null == e ? void (this.div_.style.height = '100%') : |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4634 | (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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4645 | if (0 >= e) throw new Error('Attempt to realize bad width: ' + e); |
| 4646 | var t = e - this.screen_.getWidth(); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4647 | if (this.screenSize.width = e, this.screen_.setColumnCount(e), t > 0) |
| 4648 | this.defaultTabStops && this.setDefaultTabStops(this.screenSize.width - t); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4649 | else |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4650 | for (var r = this.tabStops_.length - 1; r >= 0 && !(this.tabStops_[r] < e); |
| 4651 | r--) |
| 4652 | this.tabStops_.pop(); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4653 | this.screen_.setColumnCount(this.screenSize.width); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4654 | }; |
| 4655 | , hterm.Terminal.prototype.realizeHeight_ = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4656 | 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 Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4668 | this.scrollbackRows_.push.apply(this.scrollbackRows_, i), |
| 4669 | r.row = Math.max(r.row - t, 0); |
| 4670 | } else if (t > 0) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4671 | if (t <= this.scrollbackRows_.length) { |
| 4672 | var s = Math.min(t, this.scrollbackRows_.length), |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4673 | n = this.scrollbackRows_.splice(this.scrollbackRows_.length - s, s); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4674 | 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 Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4679 | }; |
| 4680 | , hterm.Terminal.prototype.scrollHome = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4681 | this.scrollPort_.scrollRowToTop(0); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4682 | }; |
| 4683 | , hterm.Terminal.prototype.scrollEnd = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4684 | this.scrollPort_.scrollRowToBottom(this.getRowCount()); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4685 | }; |
| 4686 | , hterm.Terminal.prototype.scrollPageUp = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4687 | var e = this.scrollPort_.getTopRowIndex(); |
| 4688 | this.scrollPort_.scrollRowToTop(e - this.screenSize.height + 1); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4689 | }; |
| 4690 | , hterm.Terminal.prototype.scrollPageDown = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4691 | var e = this.scrollPort_.getTopRowIndex(); |
| 4692 | this.scrollPort_.scrollRowToTop(e + this.screenSize.height - 1); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4693 | }; |
| 4694 | , hterm.Terminal.prototype.wipeContents = function() { |
| 4695 | this.scrollbackRows_.length = 0, this.scrollPort_.resetCache(), |
| 4696 | [this.primaryScreen_, this.alternateScreen_].forEach(function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4697 | var t = e.getHeight(); |
| 4698 | t > 0 && (this.renumberRows_(0, t), this.clearHome(e)); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4699 | }.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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4723 | var r = this.screen_.cursorPosition.overflow; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4724 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4733 | this.setCursorColumn(1); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4734 | }; |
| 4735 | , hterm.Terminal.prototype.setTabStop = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4736 | 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 Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4741 | }; |
| 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4747 | this.tabStops_.length = 0, this.defaultTabStops = !1; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4748 | }; |
| 4749 | , hterm.Terminal.prototype.setDefaultTabStops = function(e) { |
| 4750 | var t = e || 0, r = this.tabWidth; |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4751 | 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 Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4754 | }; |
| 4755 | , hterm.Terminal.prototype.interpret = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4756 | this.vt.interpret(e), this.scheduleSyncCursorPosition_(); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4757 | }; |
| 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4772 | return !1; |
| 4773 | }; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4774 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4785 | var o = this.document_.createElement('style'); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4786 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4823 | return this.document_; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4824 | }; |
| 4825 | , hterm.Terminal.prototype.focus = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4826 | this.scrollPort_.focus(); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4827 | }; |
| 4828 | , hterm.Terminal.prototype.getRowNode = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4829 | if (e < this.scrollbackRows_.length) return this.scrollbackRows_[e]; |
| 4830 | var t = e - this.scrollbackRows_.length; |
| 4831 | return this.screen_.rowsArray[t]; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4832 | }; |
| 4833 | , hterm.Terminal.prototype.getRowsText = function(e, t) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4834 | for (var r = [], o = e; t > o; o++) { |
| 4835 | var i = this.getRowNode(o); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4836 | r.push(i.textContent), |
| 4837 | t - 1 > o && !i.getAttribute('line-overflow') && r.push('\n'); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4838 | } |
| 4839 | return r.join(''); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4840 | }; |
| 4841 | , hterm.Terminal.prototype.getRowText = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4842 | var t = this.getRowNode(e); |
| 4843 | return t.textContent; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4844 | }; |
| 4845 | , hterm.Terminal.prototype.getRowCount = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4846 | return this.scrollbackRows_.length + this.screen_.rowsArray.length; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4847 | }; |
| 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4852 | var i = this.document_.createElement('x-row'); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4853 | i.appendChild(this.document_.createTextNode('')), i.rowIndex = r + o, |
| 4854 | this.screen_.pushRow(i); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4855 | } |
| 4856 | var s = this.screen_.rowsArray.length - this.screenSize.height; |
| 4857 | if (s > 0) { |
| 4858 | var n = this.screen_.shiftRows(s); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4859 | Array.prototype.push.apply(this.scrollbackRows_, n), |
| 4860 | this.scrollPort_.isScrolledEnd && this.scheduleScrollDown_(); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4861 | } |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4862 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4866 | var o = this.screen_.removeRows(e, t); |
| 4867 | this.screen_.insertRows(r, o); |
| 4868 | var i, s; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4869 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4878 | for (var t = 0, r = lib.wc.strWidth(e); r > t;) { |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4879 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4894 | this.screen_.maybeClipCurrentRow(), t += i; |
| 4895 | } |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4896 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4906 | return null != this.vtScrollTop_ ? this.vtScrollTop_ : 0; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4907 | }; |
| 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4913 | var e = this.screen_.cursorPosition.row == this.screen_.rowsArray.length - 1; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4914 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4925 | var e = this.screen_.cursorPosition.column; |
| 4926 | this.newLine(), this.setCursorColumn(e); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4927 | }; |
| 4928 | , hterm.Terminal.prototype.formFeed = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4929 | this.options_.autoCarriageReturn ? this.newLine() : this.lineFeed(); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4930 | }; |
| 4931 | , hterm.Terminal.prototype.reverseLineFeed = function() { |
| 4932 | var e = this.getVTScrollTop(), t = this.screen_.cursorPosition.row; |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4933 | t == e ? this.insertLines(1) : this.setAbsoluteCursorRow(t - 1); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4934 | }; |
| 4935 | , hterm.Terminal.prototype.eraseToLeft = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4936 | var e = this.saveCursor(); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4937 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4942 | if (!this.screen_.cursorPosition.overflow) { |
| 4943 | var t = this.screenSize.width - this.screen_.cursorPosition.column, |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4944 | r = e ? Math.min(e, t) : t; |
| 4945 | if (this.screen_.textAttributes.background === |
| 4946 | this.screen_.textAttributes.DEFAULT_COLOR) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4947 | var o = this.screen_.rowsArray[this.screen_.cursorPosition.row]; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4948 | if (hterm.TextAttributes.nodeWidth(o) <= |
| 4949 | this.screen_.cursorPosition.column + r) |
| 4950 | return this.screen_.deleteChars(r), void this.clearCursorOverflow(); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4951 | } |
| 4952 | var i = this.saveCursor(); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4953 | this.screen_.overwriteString(lib.f.getWhitespace(r)), this.restoreCursor(i), |
| 4954 | this.clearCursorOverflow(); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4955 | } |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4956 | }; |
| 4957 | , hterm.Terminal.prototype.eraseLine = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4958 | var e = this.saveCursor(); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4959 | this.screen_.clearCursorRow(), this.restoreCursor(e), |
| 4960 | this.clearCursorOverflow(); |
| 4961 | }; |
| 4962 | , hterm.Terminal.prototype.eraseAbove = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4963 | var e = this.saveCursor(); |
| 4964 | this.eraseToLeft(); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4965 | for (var t = 0; t < e.row; t++) |
| 4966 | this.setAbsoluteCursorPosition(t, 0), this.screen_.clearCursorRow(); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4967 | this.restoreCursor(e), this.clearCursorOverflow(); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4968 | }; |
| 4969 | , hterm.Terminal.prototype.eraseBelow = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4970 | var e = this.saveCursor(); |
| 4971 | this.eraseToRight(); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4972 | for (var t = this.screenSize.height - 1, r = e.row + 1; t >= r; r++) |
| 4973 | this.setAbsoluteCursorPosition(r, 0), this.screen_.clearCursorRow(); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4974 | this.restoreCursor(e), this.clearCursorOverflow(); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4975 | }; |
| 4976 | , hterm.Terminal.prototype.fill = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4977 | var t = this.saveCursor(); |
| 4978 | this.setAbsoluteCursorPosition(0, 0); |
| 4979 | for (var r = 0; r < this.screenSize.height; r++) |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4980 | for (var o = 0; o < this.screenSize.width; o++) |
| 4981 | this.setAbsoluteCursorPosition(r, o), this.screen_.overwriteString(e); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4982 | this.restoreCursor(t); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4983 | }; |
| 4984 | , hterm.Terminal.prototype.clearHome = function(e) { |
| 4985 | var t = e || this.screen_, r = t.getHeight(); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4986 | if (0 != r) { |
| 4987 | for (var o = 0; r > o; o++) t.setCursorPosition(o, 0), t.clearCursorRow(); |
| 4988 | t.setCursorPosition(0, 0); |
| 4989 | } |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4990 | }; |
| 4991 | , hterm.Terminal.prototype.clear = function(e) { |
| 4992 | var t = e || this.screen_, r = t.cursorPosition.clone(); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4993 | this.clearHome(t), t.setCursorPosition(r.row, r.column); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4994 | }; |
| 4995 | , hterm.Terminal.prototype.insertLines = function(e) { |
| 4996 | var t = this.screen_.cursorPosition.row, r = this.getVTScrollBottom(); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 4997 | e = Math.min(e, r - t); |
| 4998 | var o = r - t - e + 1; |
| 4999 | o && this.moveRows_(t, o, t + e); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5000 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5006 | e = Math.min(e, i); |
| 5007 | var s = o - e + 1; |
| 5008 | e != i && this.moveRows_(r, e, s); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5009 | for (var n = 0; e > n; n++) |
| 5010 | this.setAbsoluteCursorPosition(s + n, 0), this.screen_.clearCursorRow(); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5011 | this.restoreCursor(t), this.clearCursorOverflow(); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5012 | }; |
| 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5019 | var t = this.screen_.deleteChars(e); |
| 5020 | if (t && !this.screen_.textAttributes.isDefault()) { |
| 5021 | var r = this.saveCursor(); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5022 | this.setCursorColumn(this.screenSize.width - t), |
| 5023 | this.screen_.insertString(lib.f.getWhitespace(t)), |
| 5024 | this.restoreCursor(r); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5025 | } |
| 5026 | this.clearCursorOverflow(); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5027 | }; |
| 5028 | , hterm.Terminal.prototype.vtScrollUp = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5029 | var t = this.saveCursor(); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5030 | this.setAbsoluteCursorRow(this.getVTScrollTop()), this.deleteLines(e), |
| 5031 | this.restoreCursor(t); |
| 5032 | }; |
| 5033 | , hterm.Terminal.prototype.vtScrollDown = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5034 | var t = this.saveCursor(); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5035 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5043 | var r = this.getVTScrollTop(); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5044 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5054 | this.setAbsoluteCursorPosition(this.screen_.cursorPosition.row, e); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5055 | }; |
| 5056 | , hterm.Terminal.prototype.getCursorColumn = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5057 | return this.screen_.cursorPosition.column; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5058 | }; |
| 5059 | , hterm.Terminal.prototype.setAbsoluteCursorRow = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5060 | this.setAbsoluteCursorPosition(e, this.screen_.cursorPosition.column); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5061 | }; |
| 5062 | , hterm.Terminal.prototype.getCursorRow = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5063 | return this.screen_.cursorPosition.row; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5064 | }; |
| 5065 | , hterm.Terminal.prototype.scheduleRedraw_ = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5066 | 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 Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5072 | }; |
| 5073 | , hterm.Terminal.prototype.scheduleScrollDown_ = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5074 | if (!this.timeouts_.scrollDown) { |
| 5075 | var e = this; |
| 5076 | this.timeouts_.scrollDown = setTimeout(function() { |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5077 | delete e.timeouts_.scrollDown, |
| 5078 | e.scrollPort_.scrollRowToBottom(e.getRowCount()); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5079 | }, 10); |
| 5080 | } |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5081 | }; |
| 5082 | , hterm.Terminal.prototype.cursorUp = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5083 | return this.cursorDown(-(e || 1)); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5084 | }; |
| 5085 | , hterm.Terminal.prototype.cursorDown = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5086 | e = e || 1; |
| 5087 | var t = this.options_.originMode ? this.getVTScrollTop() : 0, |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5088 | r = this.options_.originMode ? this.getVTScrollBottom() : |
| 5089 | this.screenSize.height - 1, |
| 5090 | o = lib.f.clamp(this.screen_.cursorPosition.row + e, t, r); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5091 | this.setAbsoluteCursorRow(o); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5092 | }; |
| 5093 | , hterm.Terminal.prototype.cursorLeft = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5094 | if (e = e || 1, !(1 > e)) { |
| 5095 | var t = this.screen_.cursorPosition.column; |
| 5096 | if (this.options_.reverseWraparound) { |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5097 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5107 | var o = Math.max(t - e, 0); |
| 5108 | this.setCursorColumn(o); |
| 5109 | } |
| 5110 | } |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5111 | }; |
| 5112 | , hterm.Terminal.prototype.cursorRight = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5113 | if (e = e || 1, !(1 > e)) { |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5114 | var t = lib.f.clamp( |
| 5115 | this.screen_.cursorPosition.column + e, 0, this.screenSize.width - 1); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5116 | this.setCursorColumn(t); |
| 5117 | } |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5118 | }; |
| 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5131 | var e = this; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5132 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5150 | this.bellNotificationList_.push(t), t.onclick = function() { |
| 5151 | e.closeBellNotifications_(); |
| 5152 | }; |
| 5153 | } |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5154 | }; |
| 5155 | , hterm.Terminal.prototype.setOriginMode = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5156 | this.options_.originMode = e, this.setCursorPosition(0, 0); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5157 | }; |
| 5158 | , hterm.Terminal.prototype.setInsertMode = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5159 | this.options_.insertMode = e; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5160 | }; |
| 5161 | , hterm.Terminal.prototype.setAutoCarriageReturn = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5162 | this.options_.autoCarriageReturn = e; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5163 | }; |
| 5164 | , hterm.Terminal.prototype.setWraparound = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5165 | this.options_.wraparound = e; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5166 | }; |
| 5167 | , hterm.Terminal.prototype.setReverseWraparound = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5168 | this.options_.reverseWraparound = e; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5169 | }; |
| 5170 | , hterm.Terminal.prototype.setAlternateMode = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5171 | var t = this.saveCursor(); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5172 | 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 Mills | 4ddda58 | 2018-09-04 09:18:30 -0500 | [diff] [blame] | 5195 | void (this.cursorNode_.style.opacity = '0'); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5196 | if (this.syncCursorPosition_(), this.cursorNode_.style.opacity = '1', |
| 5197 | this.options_.cursorBlink) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5198 | if (this.timeouts_.cursorBlink) return; |
| 5199 | this.onCursorBlink_(); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5200 | } else |
| 5201 | this.timeouts_.cursorBlink && |
| 5202 | (clearTimeout(this.timeouts_.cursorBlink), |
| 5203 | delete this.timeouts_.cursorBlink); |
| 5204 | }; |
| 5205 | , hterm.Terminal.prototype.syncCursorPosition_ = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5206 | var e = this.scrollPort_.getTopRowIndex(), |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5207 | t = this.scrollPort_.getBottomRowIndex(e), |
| 5208 | r = this.scrollbackRows_.length + this.screen_.cursorPosition.row; |
| 5209 | if (r > t) |
Gunnar Mills | 4ddda58 | 2018-09-04 09:18:30 -0500 | [diff] [blame] | 5210 | return void ( |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5211 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5224 | var o = this.document_.getSelection(); |
| 5225 | o && o.isCollapsed && this.screen_.syncSelectionCaret(o); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5226 | }; |
| 5227 | , hterm.Terminal.prototype.restyleCursor_ = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5228 | var e = this.cursorShape_; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5229 | 'false' == this.cursorNode_.getAttribute('focus') && |
| 5230 | (e = hterm.Terminal.cursorShape.BLOCK); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5231 | var t = this.cursorNode_.style; |
| 5232 | switch (t.width = this.scrollPort_.characterSize.width + 'px', e) { |
| 5233 | case hterm.Terminal.cursorShape.BEAM: |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5234 | t.height = this.scrollPort_.characterSize.height + 'px', |
| 5235 | t.backgroundColor = 'transparent', t.borderBottomStyle = null, |
| 5236 | t.borderLeftStyle = 'solid'; |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5237 | break; |
| 5238 | case hterm.Terminal.cursorShape.UNDERLINE: |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5239 | t.height = this.scrollPort_.characterSize.baseline + 'px', |
| 5240 | t.backgroundColor = 'transparent', t.borderBottomStyle = 'solid', |
| 5241 | t.borderLeftStyle = null; |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5242 | break; |
| 5243 | default: |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5244 | t.height = this.scrollPort_.characterSize.height + 'px', |
| 5245 | t.backgroundColor = this.cursorColor_, t.borderBottomStyle = null, |
| 5246 | t.borderLeftStyle = null; |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5247 | } |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5248 | }; |
| 5249 | , hterm.Terminal.prototype.scheduleSyncCursorPosition_ = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5250 | 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 Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5256 | }; |
| 5257 | , hterm.Terminal.prototype.showZoomWarning_ = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5258 | if (!this.zoomWarningNode_) { |
| 5259 | if (!e) return; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5260 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5264 | this.parentNode.removeChild(this); |
| 5265 | }); |
| 5266 | } |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5267 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5277 | if (!this.overlayNode_) { |
| 5278 | if (!this.div_) return; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5279 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5283 | e.preventDefault(), e.stopPropagation(); |
| 5284 | }, !0); |
| 5285 | } |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5286 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5291 | var r = hterm.getClientSize(this.div_), |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5292 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5296 | var i = this; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5297 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5309 | hterm.pasteFromClipboard(this.document_); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5310 | }; |
| 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5315 | var t = this.document_.createElement('pre'); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5316 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5327 | var e = this.scrollPort_.selection; |
| 5328 | if (e.sync(), e.isCollapsed) return null; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5329 | var t = e.startOffset, r = e.startNode; |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5330 | if ('X-ROW' != r.nodeName) |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5331 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5335 | var o = hterm.TextAttributes.nodeWidth(e.endNode) - e.endOffset; |
| 5336 | if (r = e.endNode, 'X-ROW' != r.nodeName) |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5337 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5341 | var i = this.getRowsText(e.startRow.rowIndex, e.endRow.rowIndex + 1); |
| 5342 | return lib.wc.substring(i, t, lib.wc.strWidth(i) - o); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5343 | }; |
| 5344 | , hterm.Terminal.prototype.copySelectionToClipboard = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5345 | var e = this.getSelectionText(); |
| 5346 | null != e && this.copyStringToClipboard(e); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5347 | }; |
| 5348 | , hterm.Terminal.prototype.overlaySize = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5349 | this.showOverlay(this.screenSize.width + 'x' + this.screenSize.height); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5350 | }; |
| 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5357 | var t = window.open(e, '_blank'); |
| 5358 | t.focus(); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5359 | }; |
| 5360 | , hterm.Terminal.prototype.openSelectedUrl_ = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5361 | var e = this.getSelectionText(); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5362 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5370 | if (!e.processedByTerminalHandler_) { |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5371 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5405 | else { |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5406 | 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 Mills | 4ddda58 | 2018-09-04 09:18:30 -0500 | [diff] [blame] | 5411 | void ( |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5412 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5423 | } |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5424 | 'mouseup' == e.type && this.document_.getSelection().isCollapsed && |
| 5425 | (this.defeatMouseReports_ = !1); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5426 | } |
| 5427 | } |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5428 | }; |
| 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5435 | this.scheduleSyncCursorPosition_(); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5436 | }; |
| 5437 | , hterm.Terminal.prototype.onPaste_ = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5438 | var t = e.text.replace(/\n/gm, '\r'); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5439 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5457 | if (!(0 >= e || 0 >= t)) { |
| 5458 | var r = e != this.screenSize.width || t != this.screenSize.height; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5459 | this.realizeSize_(e, t), |
| 5460 | this.showZoomWarning_(1 != this.scrollPort_.characterSize.zoomFactor), |
| 5461 | r && this.overlaySize(), this.restyleCursor_(), |
| 5462 | this.scheduleSyncCursorPosition_(); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5463 | } |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5464 | }; |
| 5465 | , hterm.Terminal.prototype.onCursorBlink_ = function() { |
| 5466 | return this.options_.cursorBlink ? |
Gunnar Mills | 4ddda58 | 2018-09-04 09:18:30 -0500 | [diff] [blame] | 5467 | void ( |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5468 | '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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5479 | this.scrollPort_.setScrollbarVisible(e); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5480 | }; |
| 5481 | , hterm.Terminal.prototype.setScrollWheelMoveMultipler = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5482 | this.scrollPort_.setScrollWheelMoveMultipler(e); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5483 | }; |
| 5484 | , hterm.Terminal.prototype.closeBellNotifications_ = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5485 | this.bellNotificationList_.forEach(function(e) { |
| 5486 | e.close(); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5487 | }), |
| 5488 | this.bellNotificationList_.length = 0; |
| 5489 | }; |
| 5490 | , lib.rtdep('lib.encodeUTF8'), hterm.Terminal.IO = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5491 | this.terminal_ = e, this.previousIO_ = null; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5492 | }; |
| 5493 | , hterm.Terminal.IO.prototype.showOverlay = function(e, t) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5494 | this.terminal_.showOverlay(e, t); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5495 | }; |
| 5496 | , hterm.Terminal.IO.prototype.createFrame = function(e, t) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5497 | return new hterm.Frame(this.terminal_, e, t); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5498 | }; |
| 5499 | , hterm.Terminal.IO.prototype.setTerminalProfile = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5500 | this.terminal_.setProfile(e); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5501 | }; |
| 5502 | , hterm.Terminal.IO.prototype.push = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5503 | var e = new hterm.Terminal.IO(this.terminal_); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5504 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5509 | this.terminal_.io = this.previousIO_; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5510 | }; |
| 5511 | , hterm.Terminal.IO.prototype.sendString = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5512 | console.log('Unhandled sendString: ' + e); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5513 | }; |
| 5514 | , hterm.Terminal.IO.prototype.onVTKeystroke = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5515 | console.log('Unobserverd VT keystroke: ' + JSON.stringify(e)); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5516 | }; |
| 5517 | , hterm.Terminal.IO.prototype.onTerminalResize_ = function(e, t) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5518 | for (var r = this; r;) r.columnCount = e, r.rowCount = t, r = r.previousIO_; |
| 5519 | this.onTerminalResize(e, t); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5520 | }; |
| 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5525 | this.terminal_.interpret(e); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5526 | }; |
| 5527 | , hterm.Terminal.IO.prototype.writelnUTF8 = function(e) { |
| 5528 | if (this.terminal_.io != this) |
| 5529 | throw 'Attempt to print from inactive IO object.'; |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5530 | this.terminal_.interpret(e + '\r\n'); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5531 | }; |
| 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5562 | 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 Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5565 | }; |
| 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5575 | this.colorPalette = lib.colors.colorPalette.concat(), this.syncColors(); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5576 | }; |
| 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5585 | if (this.isDefault()) return this.document_.createTextNode(e); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5586 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5593 | var i = ''; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5594 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5603 | if ('string' == typeof e || 3 == e.nodeType) return this.isDefault(); |
| 5604 | var t = e.style; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5605 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5614 | this.defaultForeground = e, this.defaultBackground = t, this.syncColors(); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5615 | }; |
| 5616 | , hterm.TextAttributes.prototype.syncColors = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5617 | function e(e) { |
| 5618 | return 8 > e ? e + 8 : e; |
| 5619 | } |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5620 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5633 | this.foreground = lib.colors.mix(s, 'rgb(0, 0, 0)', .3333); |
| 5634 | } |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5635 | r != this.SRC_RGB && |
| 5636 | (this.background = r == this.SRC_DEFAULT ? i : this.colorPalette[r]); |
| 5637 | }; |
| 5638 | , hterm.TextAttributes.containersMatch = function(e, t) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5639 | 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 Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5642 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5648 | return 'string' == typeof e || 3 == e.nodeType; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5649 | }; |
| 5650 | , hterm.TextAttributes.nodeWidth = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5651 | return e.wcNode ? lib.wc.strWidth(e.textContent) : e.textContent.length; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5652 | }; |
| 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5662 | for (var t = [], r = 0, o = 0, i = 0; i < e.length;) { |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5663 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5669 | } |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5670 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5702 | this.resetParseFunction(), this.resetBuf(e || ''), this.resetArguments(); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5703 | }; |
| 5704 | , hterm.VT.ParseState.prototype.resetParseFunction = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5705 | this.func = this.defaultFunction; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5706 | }; |
| 5707 | , hterm.VT.ParseState.prototype.resetBuf = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5708 | this.buf = 'string' == typeof e ? e : null, this.pos = 0; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5709 | }; |
| 5710 | , hterm.VT.ParseState.prototype.resetArguments = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5711 | this.args.length = 0, 'undefined' != typeof e && (this.args[0] = e); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5712 | }; |
| 5713 | , hterm.VT.ParseState.prototype.iarg = function(e, t) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5714 | 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 Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5720 | }; |
| 5721 | , hterm.VT.ParseState.prototype.advance = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5722 | this.pos += e; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5723 | }; |
| 5724 | , hterm.VT.ParseState.prototype.peekRemainingBuf = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5725 | return this.buf.substr(this.pos); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5726 | }; |
| 5727 | , hterm.VT.ParseState.prototype.peekChar = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5728 | return this.buf.substr(this.pos, 1); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5729 | }; |
| 5730 | , hterm.VT.ParseState.prototype.consumeChar = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5731 | return this.buf.substr(this.pos++, 1); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5732 | }; |
| 5733 | , hterm.VT.ParseState.prototype.isComplete = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5734 | return null == this.buf || this.buf.length <= this.pos; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5735 | }; |
| 5736 | , hterm.VT.CursorState = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5737 | this.vt_ = e, this.save(); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5738 | }; |
| 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5760 | if (this.mouseReport != this.MOUSE_REPORT_DISABLED) { |
| 5761 | var t, r = 0; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5762 | e.shiftKey && (r |= 4), |
| 5763 | (e.metaKey || this.terminal.keyboard.altIsMeta && e.altKey) && (r |= 8), |
| 5764 | e.ctrlKey && (r |= 16); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5765 | var o = String.fromCharCode(lib.f.clamp(e.terminalColumn + 32, 32, 255)), |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5766 | i = String.fromCharCode(lib.f.clamp(e.terminalRow + 32, 32, 255)); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5767 | switch (e.type) { |
| 5768 | case 'mousewheel': |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5769 | s = (e.wheelDeltaY > 0 ? 0 : 1) + 96, s |= r, |
| 5770 | t = '[M' + String.fromCharCode(s) + o + i, e.preventDefault(); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5771 | break; |
| 5772 | case 'mousedown': |
| 5773 | var s = Math.min(e.which - 1, 2) + 32; |
| 5774 | s |= r, t = '[M' + String.fromCharCode(s) + o + i; |
| 5775 | break; |
| 5776 | case 'mouseup': |
| 5777 | t = '[M#' + o + i; |
| 5778 | break; |
| 5779 | case 'mousemove': |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5780 | this.mouseReport == this.MOUSE_REPORT_DRAG && e.which && |
| 5781 | (s = 32 + Math.min(e.which - 1, 2), s += 32, s |= r, |
| 5782 | t = '[M' + String.fromCharCode(s) + o + i); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5783 | 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 Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5792 | }; |
| 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5802 | } |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5803 | }; |
| 5804 | , hterm.VT.prototype.decode = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5805 | return 'utf-8' == this.characterEncoding ? this.decodeUTF8(e) : e; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5806 | }; |
| 5807 | , hterm.VT.prototype.encodeUTF8 = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5808 | return lib.encodeUTF8(e); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5809 | }; |
| 5810 | , hterm.VT.prototype.decodeUTF8 = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5811 | return this.utf8Decoder_.decode(e); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5812 | }; |
| 5813 | , hterm.VT.prototype.parseUnknown_ = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5814 | function t(e) { |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5815 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5817 | } |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5818 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5845 | if (o.length || (o[0] = '', o[1] = new Date), -1 == r) { |
| 5846 | o[0] += t; |
| 5847 | var i; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5848 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5858 | } |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5859 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5865 | var o = hterm.VT[e][t]; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5866 | return o ? |
| 5867 | o == hterm.VT.ignore ? |
Gunnar Mills | 4ddda58 | 2018-09-04 09:18:30 -0500 | [diff] [blame] | 5868 | void ( |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5869 | 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 Mills | 4ddda58 | 2018-09-04 09:18:30 -0500 | [diff] [blame] | 5875 | void ( |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5876 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5886 | switch (e) { |
| 5887 | case '1': |
| 5888 | this.terminal.keyboard.applicationCursor = t; |
| 5889 | break; |
| 5890 | case '3': |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5891 | this.allowColumnWidthChanges_ && |
| 5892 | (this.terminal.setWidth(t ? 132 : 80), this.terminal.clearHome(), |
| 5893 | this.terminal.setVTScrollRegion(null, null)); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5894 | 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 Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5920 | this.mouseReport = |
| 5921 | t ? this.MOUSE_REPORT_CLICK : this.MOUSE_REPORT_DISABLED; |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5922 | break; |
| 5923 | case '1002': |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5924 | this.mouseReport = |
| 5925 | t ? this.MOUSE_REPORT_DRAG : this.MOUSE_REPORT_DISABLED; |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5926 | 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 Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5937 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5945 | 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 Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5953 | t ? (this.savedState_.save(), this.terminal.setAlternateMode(t), |
| 5954 | this.terminal.clear()) : |
| 5955 | (this.terminal.setAlternateMode(t), this.savedState_.restore()); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5956 | break; |
| 5957 | case '2004': |
| 5958 | this.terminal.setBracketedPaste(t); |
| 5959 | break; |
| 5960 | default: |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5961 | this.warnUnimplemented && |
| 5962 | console.warn('Unimplemented DEC Private Mode: ' + e); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5963 | } |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5964 | }; |
| 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5969 | this.terminal.ringBell(); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5970 | }; |
| 5971 | , hterm.VT.CC1['\b'] = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5972 | this.terminal.cursorLeft(1); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5973 | }; |
| 5974 | , hterm.VT.CC1[' '] = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5975 | this.terminal.forwardTabStop(); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5976 | }; |
| 5977 | , hterm.VT.CC1['\n'] = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5978 | this.terminal.formFeed(); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5979 | }; |
| 5980 | , hterm.VT.CC1[''] = hterm.VT.CC1['\n'], hterm.VT.CC1['\f'] = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5981 | this.terminal.formFeed(); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5982 | }; |
| 5983 | , hterm.VT.CC1['\r'] = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5984 | this.terminal.setCursorColumn(0); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5985 | }; |
| 5986 | , hterm.VT.CC1[''] = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5987 | this.GL = 'G1'; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5988 | }; |
| 5989 | , hterm.VT.CC1[''] = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5990 | this.GL = 'G0'; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 5991 | }; |
| 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 5998 | function t(e) { |
| 5999 | var r = e.consumeChar(); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 6000 | '' != r && |
| 6001 | (this.dispatch('ESC', r, e), e.func == t && e.resetParseFunction()); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 6002 | } |
| 6003 | e.func = t; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 6004 | }; |
| 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 6010 | this.terminal.setCursorColumn(0), this.terminal.cursorDown(1); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 6011 | }; |
| 6012 | , hterm.VT.CC1[''] = hterm.VT.ESC.H = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 6013 | this.terminal.setTabStop(this.terminal.getCursorColumn()); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 6014 | }; |
| 6015 | , hterm.VT.CC1[''] = hterm.VT.ESC.M = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 6016 | this.terminal.reverseLineFeed(); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 6017 | }; |
| 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 6041 | } |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 6042 | e.resetArguments(), e.func = t; |
| 6043 | }; |
| 6044 | , hterm.VT.CC1[''] = hterm.VT.ESC['^'] = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 6045 | e.resetArguments(), e.func = this.parseUntilStringTerminator_; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 6046 | }; |
| 6047 | , hterm.VT.CC1[''] = hterm.VT.ESC._ = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 6048 | e.resetArguments(), e.func = this.parseUntilStringTerminator_; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 6049 | }; |
| 6050 | , hterm.VT.ESC[' '] = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 6051 | e.func = function(e) { |
| 6052 | var t = e.consumeChar(); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 6053 | this.warnUnimplemented && |
| 6054 | console.warn('Unimplemented sequence: ESC 0x20 ' + t), |
| 6055 | e.resetParseFunction(); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 6056 | }; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 6057 | }; |
| 6058 | , hterm.VT.ESC['#'] = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 6059 | e.func = function(e) { |
| 6060 | var t = e.consumeChar(); |
| 6061 | '8' == t && this.terminal.fill('E'), e.resetParseFunction(); |
| 6062 | }; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 6063 | }; |
| 6064 | , hterm.VT.ESC['%'] = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 6065 | e.func = function(e) { |
| 6066 | var t = e.consumeChar(); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 6067 | '@' != t && 'G' != t && this.warnUnimplemented && |
| 6068 | console.warn('Unknown ESC % argument: ' + JSON.stringify(t)), |
| 6069 | e.resetParseFunction(); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 6070 | }; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 6071 | }; |
| 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 6096 | this.savedState_.save(); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 6097 | }; |
| 6098 | , hterm.VT.ESC[8] = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 6099 | this.savedState_.restore(); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 6100 | }; |
| 6101 | , hterm.VT.ESC[9] = hterm.VT.ignore, hterm.VT.ESC['='] = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 6102 | this.terminal.keyboard.applicationKeypad = !0; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 6103 | }; |
| 6104 | , hterm.VT.ESC['>'] = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 6105 | this.terminal.keyboard.applicationKeypad = !1; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 6106 | }; |
| 6107 | , hterm.VT.ESC.F = hterm.VT.ignore, hterm.VT.ESC.c = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 6108 | this.reset(), this.terminal.reset(); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 6109 | }; |
| 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 6115 | this.GL = 'G3'; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 6116 | }; |
| 6117 | , hterm.VT.ESC['|'] = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 6118 | this.GR = 'G3'; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 6119 | }; |
| 6120 | , hterm.VT.ESC['}'] = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 6121 | this.GR = 'G2'; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 6122 | }; |
| 6123 | , hterm.VT.ESC['~'] = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 6124 | this.GR = 'G1'; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 6125 | }; |
| 6126 | , hterm.VT.OSC[0] = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 6127 | this.terminal.setWindowTitle(e.args[0]); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 6128 | }; |
| 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 6137 | } |
| 6138 | i.length && this.terminal.io.sendString(']4;' + i.join(';') + ''); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 6139 | }; |
| 6140 | , hterm.VT.OSC[50] = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 6141 | 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 Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 6153 | }; |
| 6154 | , hterm.VT.OSC[52] = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 6155 | 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 Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 6160 | }; |
| 6161 | , hterm.VT.CSI['@'] = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 6162 | this.terminal.insertSpace(e.iarg(0, 1)); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 6163 | }; |
| 6164 | , hterm.VT.CSI.A = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 6165 | this.terminal.cursorUp(e.iarg(0, 1)); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 6166 | }; |
| 6167 | , hterm.VT.CSI.B = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 6168 | this.terminal.cursorDown(e.iarg(0, 1)); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 6169 | }; |
| 6170 | , hterm.VT.CSI.C = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 6171 | this.terminal.cursorRight(e.iarg(0, 1)); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 6172 | }; |
| 6173 | , hterm.VT.CSI.D = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 6174 | this.terminal.cursorLeft(e.iarg(0, 1)); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 6175 | }; |
| 6176 | , hterm.VT.CSI.E = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 6177 | this.terminal.cursorDown(e.iarg(0, 1)), this.terminal.setCursorColumn(0); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 6178 | }; |
| 6179 | , hterm.VT.CSI.F = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 6180 | this.terminal.cursorUp(e.iarg(0, 1)), this.terminal.setCursorColumn(0); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 6181 | }; |
| 6182 | , hterm.VT.CSI.G = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 6183 | this.terminal.setCursorColumn(e.iarg(0, 1) - 1); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 6184 | }; |
| 6185 | , hterm.VT.CSI.H = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 6186 | this.terminal.setCursorPosition(e.iarg(0, 1) - 1, e.iarg(1, 1) - 1); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 6187 | }; |
| 6188 | , hterm.VT.CSI.I = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 6189 | 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 Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 6192 | }; |
| 6193 | , hterm.VT.CSI.J = hterm.VT.CSI['?J'] = function(e, t) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 6194 | var r = e.args[0]; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 6195 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 6201 | var r = e.args[0]; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 6202 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 6207 | this.terminal.insertLines(e.iarg(0, 1)); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 6208 | }; |
| 6209 | , hterm.VT.CSI.M = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 6210 | this.terminal.deleteLines(e.iarg(0, 1)); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 6211 | }; |
| 6212 | , hterm.VT.CSI.P = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 6213 | this.terminal.deleteChars(e.iarg(0, 1)); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 6214 | }; |
| 6215 | , hterm.VT.CSI.S = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 6216 | this.terminal.vtScrollUp(e.iarg(0, 1)); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 6217 | }; |
| 6218 | , hterm.VT.CSI.T = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 6219 | e.args.length <= 1 && this.terminal.vtScrollDown(e.iarg(0, 1)); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 6220 | }; |
| 6221 | , hterm.VT.CSI['>T'] = hterm.VT.ignore, hterm.VT.CSI.X = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 6222 | this.terminal.eraseToRight(e.iarg(0, 1)); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 6223 | }; |
| 6224 | , hterm.VT.CSI.Z = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 6225 | 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 Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 6228 | }; |
| 6229 | , hterm.VT.CSI['`'] = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 6230 | this.terminal.setCursorColumn(e.iarg(0, 1) - 1); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 6231 | }; |
| 6232 | , hterm.VT.CSI.b = hterm.VT.ignore, hterm.VT.CSI.c = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 6233 | e.args[0] && '0' != e.args[0] || this.terminal.io.sendString('[?1;2c'); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 6234 | }; |
| 6235 | , hterm.VT.CSI['>c'] = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 6236 | this.terminal.io.sendString('[>0;256;0c'); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 6237 | }; |
| 6238 | , hterm.VT.CSI.d = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 6239 | this.terminal.setAbsoluteCursorRow(e.iarg(0, 1) - 1); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 6240 | }; |
| 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 6247 | for (var t = 0; t < e.args.length; t++) this.setANSIMode(e.args[t], !0); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 6248 | }; |
| 6249 | , hterm.VT.CSI['?h'] = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 6250 | for (var t = 0; t < e.args.length; t++) this.setDECMode(e.args[t], !0); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 6251 | }; |
| 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 6257 | for (var t = 0; t < e.args.length; t++) this.setDECMode(e.args[t], !1); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 6258 | }; |
| 6259 | , hterm.VT.CSI.m = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 6260 | function t(t) { |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 6261 | return e.args.length < t + 2 || '5' != e.args[t + 1] ? null : |
| 6262 | e.iarg(t + 2, 0); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 6263 | } |
| 6264 | |
| 6265 | function r(t) { |
| 6266 | if (e.args.length < t + 5 || '2' != e.args[t + 1]) return null; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 6267 | var r = e.iarg(t + 2, 0), o = e.iarg(t + 3, 0), i = e.iarg(t + 4, 0); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 6268 | 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 Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 6274 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 6302 | else if (50 > s) |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 6303 | if (38 > s) |
| 6304 | o.foregroundSource = s - 30; |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 6305 | else if (38 == s) { |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 6306 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 6335 | } |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 6336 | 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 6342 | else if ('6' == e.args[0]) { |
| 6343 | var t = this.terminal.getCursorRow() + 1, |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 6344 | r = this.terminal.getCursorColumn() + 1; |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 6345 | this.terminal.io.sendString('[' + t + ';' + r + 'R'); |
| 6346 | } |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 6347 | }; |
| 6348 | , hterm.VT.CSI['>n'] = hterm.VT.ignore, hterm.VT.CSI['?n'] = function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 6349 | if ('6' == e.args[0]) { |
| 6350 | var t = this.terminal.getCursorRow() + 1, |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 6351 | r = this.terminal.getCursorColumn() + 1; |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 6352 | this.terminal.io.sendString('[' + t + ';' + r + 'R'); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 6353 | } 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 6363 | this.reset(), this.terminal.softReset(); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 6364 | }; |
| 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 6368 | var t = e.args[0]; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 6369 | '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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 6408 | } |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 6409 | }; |
| 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 Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 6417 | 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 Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 6421 | this.glre = new RegExp('[' + t.join('') + ']', 'g'), this.grmap = {}, |
| 6422 | t.forEach(function(e) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 6423 | 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 Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 6438 | }; |
| 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'); |