Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (function() {
- var callback;
- var options;
- var Request;
- var cancel;
- var stack;
- var f;
- var g;
- var memory;
- var ignore;
- /** @type {function (this:(Array.<T>|string|{length: number}), *=, *=): Array.<T>} */
- var __slice = [].slice;
- /** @type {function (this:(Array.<T>|string|{length: number}), T, number=): number} */
- var indexOf = [].indexOf || function(obj) {
- /** @type {number} */
- var i = 0;
- var l = this.length;
- for (;l > i;i++) {
- if (i in this && this[i] === obj) {
- return i;
- }
- }
- return-1;
- };
- /** @type {null} */
- stack = memory = null;
- /** @type {boolean} */
- g = false;
- /** @type {number} */
- f = (new Date).getTime();
- callback = document.querySelectorAll.bind(document);
- document.addEventListener("DOMContentLoaded", function() {
- var write;
- var draw;
- var destroy;
- var abort;
- var self;
- var ws;
- var uri;
- return abort = function(message) {
- return ws.send("S" + message);
- }, destroy = function() {
- var dig;
- var i;
- var actionArgs;
- return actionArgs = arguments[0], dig = 2 <= arguments.length ? __slice.call(arguments, 1) : [], i = dig.join(","), "Resize" === actionArgs ? ws.send("R" + i) : void 0;
- }, uri = "https:" === location.protocol ? "wss://" : "ws://", uri += document.location.host + "/ws" + location.pathname, ws = new WebSocket(uri), ws.addEventListener("open", function() {
- return console.log("WebSocket open", arguments), ws.send("R" + self.cols + "," + self.rows), f = (new Date).getTime();
- }), ws.addEventListener("error", function() {
- return console.log("WebSocket error", arguments);
- }), ws.addEventListener("message", function(msg) {
- return setTimeout(function() {
- return self.write(msg.data);
- }, 1);
- }), ws.addEventListener("close", function() {
- return console.log("WebSocket closed", arguments), setTimeout(function() {
- return self.write("Closed"), self.skipNextKey = true, self.element.classList.add("dead");
- }, 1), g = true, (new Date).getTime() - f > 6E4 ? open("", "_self").close() : void 0;
- }), self = new Request(callback("#wrapper")[0], abort, destroy), addEventListener("beforeunload", function() {
- return g ? void 0 : "This will exit the terminal session";
- }), write = function(length) {
- var s;
- var c;
- if (null == length) {
- /** @type {number} */
- length = 1E8;
- }
- /** @type {string} */
- s = "";
- for (;s.length < length;) {
- s += Math.random().toString(36).substring(2);
- }
- return c = (new Date).getTime(), self.write(s), console.log("" + length + " chars in " + ((new Date).getTime() - c) + " ms");
- }, draw = function(n) {
- var str;
- var c;
- if (null == n) {
- /** @type {number} */
- n = 1E8;
- }
- /** @type {string} */
- str = "";
- for (;str.length < n;) {
- str += "\u001b[" + (30 + parseInt(20 * Math.random())) + "m";
- str += Math.random().toString(36).substring(2);
- }
- return c = (new Date).getTime(), self.write(str), console.log("" + n + " chars + colors in " + ((new Date).getTime() - c) + " ms");
- }, self.ws = ws, window.butterfly = self;
- });
- /**
- * @param {Object} event
- * @return {?}
- */
- cancel = function(event) {
- return event.preventDefault && event.preventDefault(), event.stopPropagation && event.stopPropagation(), event.cancelBubble = true, false;
- };
- /** @type {number} */
- ignore = 0;
- options = {
- normal : ignore++,
- escaped : ignore++,
- csi : ignore++,
- osc : ignore++,
- charset : ignore++,
- dcs : ignore++,
- ignore : ignore++
- };
- Request = function() {
- /**
- * @param {Element} parent
- * @param {string} options
- * @param {string} rows
- * @return {undefined}
- */
- function Terminal(parent, options, rows) {
- var node;
- var row;
- var pixelSize;
- /** @type {Element} */
- this.parent = parent;
- /** @type {string} */
- this.out = options;
- this.ctl = null != rows ? rows : function() {
- };
- this.context = this.parent.ownerDocument.defaultView;
- this.document = this.parent.ownerDocument;
- this.body = this.document.getElementsByTagName("body")[0];
- this.element = this.document.createElement("div");
- /** @type {string} */
- this.element.className = "terminal focus";
- /** @type {string} */
- this.element.style.outline = "none";
- this.element.setAttribute("tabindex", 0);
- this.element.setAttribute("spellcheck", "false");
- this.parent.appendChild(this.element);
- node = this.document.createElement("div");
- /** @type {string} */
- node.className = "line";
- this.element.appendChild(node);
- /** @type {Array} */
- this.children = [node];
- this.compute_char_size();
- /** @type {string} */
- node.style.height = this.char_size.height + "px";
- pixelSize = this.parent.getBoundingClientRect();
- /** @type {number} */
- this.cols = Math.floor(pixelSize.width / this.char_size.width);
- /** @type {number} */
- this.rows = Math.floor(pixelSize.height / this.char_size.height);
- /** @type {number} */
- row = this.rows - 1;
- for (;row--;) {
- node = this.document.createElement("div");
- /** @type {string} */
- node.style.height = this.char_size.height + "px";
- /** @type {string} */
- node.className = "line";
- this.element.appendChild(node);
- this.children.push(node);
- }
- /** @type {number} */
- this.scrollback = 1E5;
- /** @type {number} */
- this.visualBell = 100;
- /** @type {boolean} */
- this.convertEol = false;
- /** @type {string} */
- this.termName = "xterm";
- /** @type {boolean} */
- this.cursorBlink = true;
- /** @type {number} */
- this.cursorState = 0;
- /** @type {number} */
- this.last_cc = 0;
- this.reset_vars();
- this.refresh(0, this.rows - 1);
- this.focus();
- this.startBlink();
- addEventListener("keydown", this.keyDown.bind(this));
- addEventListener("keypress", this.keyPress.bind(this));
- addEventListener("focus", this.focus.bind(this));
- addEventListener("blur", this.blur.bind(this));
- addEventListener("paste", this.paste.bind(this));
- addEventListener("resize", this.resize.bind(this));
- if ("undefined" != typeof InstallTrigger) {
- /** @type {string} */
- this.element.contentEditable = "true";
- this.element.addEventListener("mouseup", function() {
- var currentRange;
- return currentRange = getSelection().getRangeAt(0), currentRange.startOffset === currentRange.endOffset ? getSelection().removeAllRanges() : void 0;
- });
- }
- this.initmouse();
- setTimeout(this.resize.bind(this), 100);
- }
- return Terminal.prototype.reset_vars = function() {
- var _ref2;
- /** @type {number} */
- this.ybase = 0;
- /** @type {number} */
- this.ydisp = 0;
- /** @type {number} */
- this.x = 0;
- /** @type {number} */
- this.y = 0;
- /** @type {boolean} */
- this.cursorHidden = false;
- this.state = options.normal;
- /** @type {string} */
- this.queue = "";
- /** @type {number} */
- this.scrollTop = 0;
- /** @type {number} */
- this.scrollBottom = this.rows - 1;
- /** @type {boolean} */
- this.applicationKeypad = false;
- /** @type {boolean} */
- this.applicationCursor = false;
- /** @type {boolean} */
- this.originMode = false;
- /** @type {boolean} */
- this.wraparoundMode = false;
- /** @type {null} */
- this.normal = null;
- /** @type {null} */
- this.charset = null;
- /** @type {null} */
- this.gcharset = null;
- /** @type {number} */
- this.glevel = 0;
- /** @type {Array} */
- this.charsets = [null];
- /** @type {number} */
- this.defAttr = 131840;
- /** @type {number} */
- this.curAttr = this.defAttr;
- /** @type {Array} */
- this.params = [];
- /** @type {number} */
- this.currentParam = 0;
- /** @type {string} */
- this.prefix = "";
- /** @type {Array} */
- this.lines = [];
- _ref2 = this.rows;
- for (;_ref2--;) {
- this.lines.push(this.blankLine());
- }
- return this.setupStops(), this.skipNextKey = null;
- }, Terminal.prototype.compute_char_size = function() {
- var label;
- return label = document.createElement("span"), label.textContent = "0123456789", this.children[0].appendChild(label), this.char_size = {
- width : label.getBoundingClientRect().width / 10,
- height : this.children[0].getBoundingClientRect().height
- }, this.children[0].removeChild(label);
- }, Terminal.prototype.eraseAttr = function() {
- return-512 & this.defAttr | 511 & this.curAttr;
- }, Terminal.prototype.focus = function() {
- return this.sendFocus && this.send("\u001b[I"), this.showCursor(), this.element.classList.add("focus"), this.element.classList.remove("blur");
- }, Terminal.prototype.blur = function() {
- return this.cursorState = 1, this.refresh(this.y, this.y), this.sendFocus && this.send("\u001b[O"), this.element.classList.add("blur"), this.element.classList.remove("focus");
- }, Terminal.prototype.paste = function(e) {
- return e.clipboardData ? this.send(e.clipboardData.getData("text/plain")) : this.context.clipboardData && this.send(this.context.clipboardData.getData("Text")), cancel(e);
- }, Terminal.prototype.initmouse = function() {
- var randomNumber;
- var getButton;
- var getCoords;
- var target;
- var sendButton;
- var sendEvent;
- var callback;
- return target = 32, sendButton = function(ev) {
- var button;
- var pos;
- if (button = getButton(ev), pos = getCoords(ev)) {
- switch(sendEvent(button, pos), ev.type) {
- case "mousedown":
- return target = button;
- case "mouseup":
- return target = 32;
- }
- }
- }, callback = function(ev) {
- var deep;
- var pos;
- return deep = target, (pos = getCoords(ev)) ? (deep += 32, sendEvent(deep, pos)) : void 0;
- }, randomNumber = function(dataAndEvents) {
- return function(assigns, vvar) {
- return dataAndEvents.utfMouse ? 2047 === vvar ? assigns.push(0) : 127 > vvar ? assigns.push(vvar) : (vvar > 2047 && (vvar = 2047), assigns.push(192 | vvar >> 6), assigns.push(128 | 63 & vvar)) : 255 === vvar ? assigns.push(0) : (vvar > 127 && (vvar = 127), assigns.push(vvar));
- };
- }(this), sendEvent = function(self) {
- return function(max, opt_offset) {
- var applyArgs;
- return self.urxvtMouse ? (opt_offset.x -= 32, opt_offset.y -= 32, opt_offset.x++, opt_offset.y++, void self.send("\u001b[" + max + ";" + opt_offset.x + ";" + opt_offset.y + "M")) : self.sgrMouse ? (opt_offset.x -= 32, opt_offset.y -= 32, void self.send("\u001b[<" + (3 === (3 & max) ? -4 & max : max) + ";" + opt_offset.x + ";" + opt_offset.y + (3 === (3 & max) ? "m" : "M"))) : (applyArgs = [], randomNumber(applyArgs, max), randomNumber(applyArgs, opt_offset.x), randomNumber(applyArgs, opt_offset.y),
- self.send("\u001b[M" + String.fromCharCode.apply(String, applyArgs)));
- };
- }(this), getButton = function(self) {
- return function(e) {
- var c;
- var ctrl;
- var curr;
- var mod;
- var prev;
- switch(e.type) {
- case "mousedown":
- /** @type {(null|number)} */
- c = null != e.button ? +e.button : null != e.which ? e.which - 1 : null;
- break;
- case "mouseup":
- /** @type {number} */
- c = 3;
- break;
- case "wheel":
- /** @type {number} */
- c = e.deltaY < 0 ? 64 : 65;
- }
- return prev = e.shiftKey ? 4 : 0, curr = e.metaKey ? 8 : 0, ctrl = e.ctrlKey ? 16 : 0, mod = prev | curr | ctrl, self.vt200Mouse ? mod &= ctrl : self.normalMouse || (mod = 0), 32 + (mod << 2) + c;
- };
- }(this), getCoords = function(self) {
- return function(t) {
- var element;
- var h;
- var w;
- var x;
- var y;
- x = t.pageX;
- y = t.pageY;
- element = self.element;
- for (;element && element !== self.document.documentElement;) {
- x -= element.offsetLeft;
- y -= element.offsetTop;
- element = "offsetParent" in element ? element.offsetParent : element.parentNode;
- }
- return w = self.element.clientWidth, h = self.element.clientHeight, x = Math.ceil(x / w * self.cols), y = Math.ceil(y / h * self.rows), 0 > x && (x = 0), x > self.cols && (x = self.cols), 0 > y && (y = 0), y > self.rows && (y = self.rows), x += 32, y += 32, {
- x : x,
- y : y,
- type : t.type
- };
- };
- }(this), addEventListener("mousedown", function(self) {
- return function(ev) {
- var READY_STATE_CHANGE_EVENT;
- var up;
- if (self.mouseEvents) {
- return sendButton(ev), self.vt200Mouse ? (sendButton({
- __proto__ : ev,
- type : "mouseup"
- }), cancel(ev)) : (READY_STATE_CHANGE_EVENT = callback.bind(self), self.normalMouse && addEventListener("mousemove", READY_STATE_CHANGE_EVENT), self.x10Mouse || addEventListener("mouseup", up = function(ev) {
- return sendButton(ev), self.normalMouse && removeEventListener("mousemove", READY_STATE_CHANGE_EVENT), removeEventListener("mouseup", up), cancel(ev);
- }), cancel(ev));
- }
- };
- }(this)), addEventListener("wheel", function(self) {
- return function(ev) {
- if (self.mouseEvents) {
- if (self.x10Mouse) {
- return;
- }
- sendButton(ev);
- } else {
- if (self.applicationKeypad) {
- return;
- }
- self.scrollDisp(ev.deltaY > 0 ? 5 : -5);
- }
- return cancel(ev);
- };
- }(this));
- }, Terminal.prototype.refresh = function(mayParseLabeledStatementInstead, end) {
- var attr;
- var json;
- var codeSegments;
- var assigns;
- var data;
- var vvar;
- var flags;
- var i;
- var tokens;
- var xhtml;
- var parent;
- var row;
- var j;
- var lastIdx;
- var y;
- if (end - mayParseLabeledStatementInstead >= this.rows / 3) {
- parent = this.element.parentNode;
- if (null != parent) {
- parent.removeChild(this.element);
- }
- }
- j = this.cols;
- /** @type {number} */
- y = mayParseLabeledStatementInstead;
- if (end >= this.lines.length) {
- /** @type {number} */
- end = this.lines.length - 1;
- }
- for (;end >= y;) {
- row = y + this.ydisp;
- tokens = this.lines[row];
- /** @type {string} */
- xhtml = "";
- lastIdx = y !== this.y || (this.ydisp !== this.ybase && !this.selectMode || this.cursorHidden) ? -1 / 0 : this.x;
- attr = this.defAttr;
- /** @type {number} */
- i = 0;
- for (;j > i;) {
- if (data = tokens[i][0], codeSegments = tokens[i][1], data !== attr && (attr !== this.defAttr && (xhtml += "</span>"), data !== this.defAttr && (assigns = [], xhtml += "<span ", json = 511 & data, vvar = data >> 9 & 511, flags = data >> 18, 1 & flags && assigns.push("bold"), 2 & flags && assigns.push("underline"), 4 & flags && assigns.push("blink"), 8 & flags && assigns.push("reverse-video"), 16 & flags && assigns.push("invisible"), 1 & flags && (8 > vvar && (vvar += 8)), assigns.push("bg-color-" +
- json), assigns.push("fg-color-" + vvar), xhtml += 'class="', xhtml += assigns.join(" "), xhtml += '">')), i === lastIdx && (xhtml += '<span class="' + (this.cursorState ? "reverse-video " : "") + 'cursor">'), codeSegments.length > 1) {
- xhtml += codeSegments;
- } else {
- switch(codeSegments) {
- case "&":
- xhtml += "&";
- break;
- case "<":
- xhtml += "<";
- break;
- case ">":
- xhtml += ">";
- break;
- default:
- if (" " >= codeSegments) {
- xhtml += " ";
- } else {
- if (codeSegments > "\u00ef\u00bc\u20ac") {
- if ("\u00ef\u00bf\u00af" > codeSegments) {
- i++;
- }
- }
- xhtml += codeSegments;
- }
- ;
- }
- }
- if (i === lastIdx) {
- xhtml += "</span>";
- }
- attr = data;
- i++;
- }
- if (attr !== this.defAttr) {
- xhtml += "</span>";
- }
- /** @type {string} */
- this.children[y].innerHTML = xhtml;
- y++;
- }
- return null != parent ? parent.appendChild(this.element) : void 0;
- }, Terminal.prototype._cursorBlink = function() {
- var messageDOM;
- return this.cursorState ^= 1, (messageDOM = this.element.querySelector(".cursor")) ? messageDOM.classList.contains("reverse-video") ? messageDOM.classList.remove("reverse-video") : messageDOM.classList.add("reverse-video") : void 0;
- }, Terminal.prototype.showCursor = function() {
- return this.cursorState ? void 0 : (this.cursorState = 1, this.refresh(this.y, this.y));
- }, Terminal.prototype.startBlink = function() {
- return this.cursorBlink ? (this._blinker = function(dataAndEvents) {
- return function() {
- return dataAndEvents._cursorBlink();
- };
- }(this), this.t_blink = setInterval(this._blinker, 500)) : void 0;
- }, Terminal.prototype.refreshBlink = function() {
- return this.cursorBlink ? (clearInterval(this.t_blink), this.t_blink = setInterval(this._blinker, 500)) : void 0;
- }, Terminal.prototype.scroll = function() {
- var row;
- return++this.ybase === this.scrollback && (this.ybase = this.ybase / 2 | 0, this.lines = this.lines.slice(-(this.ybase + this.rows) + 1)), this.ydisp = this.ybase, row = this.ybase + this.rows - 1, row -= this.rows - 1 - this.scrollBottom, row === this.lines.length ? this.lines.push(this.blankLine()) : this.lines.splice(row, 0, this.blankLine()), 0 !== this.scrollTop && (0 !== this.ybase && (this.ybase--, this.ydisp = this.ybase), this.lines.splice(this.ybase + this.scrollTop, 1)), this.updateRange(this.scrollTop),
- this.updateRange(this.scrollBottom);
- }, Terminal.prototype.scrollDisp = function(disp) {
- return this.ydisp += disp, this.ydisp > this.ybase ? this.ydisp = this.ybase : this.ydisp < 0 && (this.ydisp = 0), this.refresh(0, this.rows - 1);
- }, Terminal.prototype.write = function(str) {
- var ch;
- var cs;
- var i;
- var row;
- var l;
- var e;
- var f;
- var frequency;
- this.refreshStart = this.y;
- this.refreshEnd = this.y;
- if (this.ybase !== this.ydisp) {
- this.ydisp = this.ybase;
- this.maxRange();
- }
- /** @type {number} */
- i = 0;
- l = str.length;
- for (;l > i;) {
- switch(ch = str[i], this.state) {
- case options.normal:
- switch(ch) {
- case "\u0007":
- this.bell();
- break;
- case "\n":
- ;
- case "\x0B":
- ;
- case "\f":
- if (this.convertEol) {
- /** @type {number} */
- this.x = 0;
- }
- this.y++;
- if (this.y > this.scrollBottom) {
- this.y--;
- this.scroll();
- }
- break;
- case "\r":
- /** @type {number} */
- this.x = 0;
- break;
- case "\b":
- if (this.x > 0) {
- this.x--;
- }
- break;
- case "\t":
- this.x = this.nextStop();
- break;
- case "\u000e":
- this.setgLevel(1);
- break;
- case "\u000f":
- this.setgLevel(0);
- break;
- case "\u001b":
- this.state = options.escaped;
- break;
- default:
- if (ch >= " " && ((null != (frequency = this.charset) ? frequency[ch] : void 0) && (ch = this.charset[ch]), this.x >= this.cols && (this.x = 0, this.y++, this.y > this.scrollBottom && (this.y--, this.scroll())), this.lines[this.y + this.ybase][this.x] = [this.curAttr, ch], this.x++, this.updateRange(this.y), ch > "\u00ef\u00bc\u20ac" && "\u00ef\u00bf\u00af" > ch)) {
- if (row = this.y + this.ybase, this.cols < 2 || this.x >= this.cols) {
- /** @type {Array} */
- this.lines[row][this.x - 1] = [this.curAttr, " "];
- break;
- }
- /** @type {Array} */
- this.lines[row][this.x] = [this.curAttr, " "];
- this.x++;
- }
- ;
- }
- break;
- case options.escaped:
- switch(ch) {
- case "[":
- /** @type {Array} */
- this.params = [];
- /** @type {number} */
- this.currentParam = 0;
- this.state = options.csi;
- break;
- case "]":
- /** @type {Array} */
- this.params = [];
- /** @type {number} */
- this.currentParam = 0;
- this.state = options.osc;
- break;
- case "P":
- /** @type {Array} */
- this.params = [];
- /** @type {number} */
- this.currentParam = 0;
- this.state = options.dcs;
- break;
- case "_":
- this.state = options.ignore;
- break;
- case "^":
- this.state = options.ignore;
- break;
- case "c":
- this.reset();
- break;
- case "E":
- /** @type {number} */
- this.x = 0;
- this.index();
- break;
- case "D":
- this.index();
- break;
- case "M":
- this.reverseIndex();
- break;
- case "%":
- this.setgLevel(0);
- this.setgCharset(0, Terminal.prototype.charsets.US);
- this.state = options.normal;
- i++;
- break;
- case "(":
- ;
- case ")":
- ;
- case "*":
- ;
- case "+":
- ;
- case "-":
- ;
- case ".":
- switch(ch) {
- case "(":
- /** @type {number} */
- this.gcharset = 0;
- break;
- case ")":
- ;
- case "-":
- /** @type {number} */
- this.gcharset = 1;
- break;
- case "*":
- ;
- case ".":
- /** @type {number} */
- this.gcharset = 2;
- break;
- case "+":
- /** @type {number} */
- this.gcharset = 3;
- }
- this.state = options.charset;
- break;
- case "/":
- /** @type {number} */
- this.gcharset = 3;
- this.state = options.charset;
- i--;
- break;
- case "n":
- this.setgLevel(2);
- break;
- case "o":
- this.setgLevel(3);
- break;
- case "|":
- this.setgLevel(3);
- break;
- case "}":
- this.setgLevel(2);
- break;
- case "~":
- this.setgLevel(1);
- break;
- case "7":
- this.saveCursor();
- this.state = options.normal;
- break;
- case "8":
- this.restoreCursor();
- this.state = options.normal;
- break;
- case "#":
- this.state = options.normal;
- i++;
- break;
- case "H":
- this.tabSet();
- break;
- case "=":
- /** @type {boolean} */
- this.applicationKeypad = true;
- this.state = options.normal;
- break;
- case ">":
- /** @type {boolean} */
- this.applicationKeypad = false;
- this.state = options.normal;
- break;
- default:
- this.state = options.normal;
- console.log("Unknown ESC control:", ch);
- }
- break;
- case options.charset:
- switch(ch) {
- case "0":
- cs = Terminal.prototype.charsets.SCLD;
- break;
- case "A":
- /** @type {null} */
- cs = Terminal.prototype.charsets.UK;
- break;
- case "B":
- /** @type {null} */
- cs = Terminal.prototype.charsets.US;
- break;
- case "4":
- /** @type {null} */
- cs = Terminal.prototype.charsets.Dutch;
- break;
- case "C":
- ;
- case "5":
- /** @type {null} */
- cs = Terminal.prototype.charsets.Finnish;
- break;
- case "R":
- /** @type {null} */
- cs = Terminal.prototype.charsets.French;
- break;
- case "Q":
- /** @type {null} */
- cs = Terminal.prototype.charsets.FrenchCanadian;
- break;
- case "K":
- /** @type {null} */
- cs = Terminal.prototype.charsets.German;
- break;
- case "Y":
- /** @type {null} */
- cs = Terminal.prototype.charsets.Italian;
- break;
- case "E":
- ;
- case "6":
- /** @type {null} */
- cs = Terminal.prototype.charsets.NorwegianDanish;
- break;
- case "Z":
- /** @type {null} */
- cs = Terminal.prototype.charsets.Spanish;
- break;
- case "H":
- ;
- case "7":
- /** @type {null} */
- cs = Terminal.prototype.charsets.Swedish;
- break;
- case "=":
- /** @type {null} */
- cs = Terminal.prototype.charsets.Swiss;
- break;
- case "/":
- /** @type {null} */
- cs = Terminal.prototype.charsets.ISOLatin;
- i++;
- break;
- default:
- /** @type {null} */
- cs = Terminal.prototype.charsets.US;
- }
- this.setgCharset(this.gcharset, cs);
- /** @type {null} */
- this.gcharset = null;
- this.state = options.normal;
- break;
- case options.osc:
- if ("\u001b" === ch || "\u0007" === ch) {
- switch("\u001b" === ch && i++, this.params.push(this.currentParam), this.params[0]) {
- case 0:
- ;
- case 1:
- ;
- case 2:
- if (this.params[1]) {
- this.title = this.params[1] + " - \u00c6\u00b8\u00d3\u0153\u00c6\u00b7 butterfly";
- this.handleTitle(this.title);
- }
- ;
- }
- /** @type {Array} */
- this.params = [];
- /** @type {number} */
- this.currentParam = 0;
- this.state = options.normal;
- } else {
- if (this.params.length) {
- this.currentParam += ch;
- } else {
- if (ch >= "0" && "9" >= ch) {
- /** @type {number} */
- this.currentParam = 10 * this.currentParam + ch.charCodeAt(0) - 48;
- } else {
- if (";" === ch) {
- this.params.push(this.currentParam);
- /** @type {string} */
- this.currentParam = "";
- }
- }
- }
- }
- break;
- case options.csi:
- if ("?" === ch || (">" === ch || "!" === ch)) {
- this.prefix = ch;
- break;
- }
- if (ch >= "0" && "9" >= ch) {
- /** @type {number} */
- this.currentParam = 10 * this.currentParam + ch.charCodeAt(0) - 48;
- break;
- }
- if ("$" === ch || ('"' === ch || (" " === ch || "'" === ch))) {
- break;
- }
- if (this.params.push(this.currentParam), this.currentParam = 0, ";" === ch) {
- break;
- }
- switch(this.state = options.normal, ch) {
- case "A":
- this.cursorUp(this.params);
- break;
- case "B":
- this.cursorDown(this.params);
- break;
- case "C":
- this.cursorForward(this.params);
- break;
- case "D":
- this.cursorBackward(this.params);
- break;
- case "H":
- this.cursorPos(this.params);
- break;
- case "J":
- this.eraseInDisplay(this.params);
- break;
- case "K":
- this.eraseInLine(this.params);
- break;
- case "m":
- if (!this.prefix) {
- this.charAttributes(this.params);
- }
- break;
- case "n":
- if (!this.prefix) {
- this.deviceStatus(this.params);
- }
- break;
- case "@":
- this.insertChars(this.params);
- break;
- case "E":
- this.cursorNextLine(this.params);
- break;
- case "F":
- this.cursorPrecedingLine(this.params);
- break;
- case "G":
- this.cursorCharAbsolute(this.params);
- break;
- case "L":
- this.insertLines(this.params);
- break;
- case "M":
- this.deleteLines(this.params);
- break;
- case "P":
- this.deleteChars(this.params);
- break;
- case "X":
- this.eraseChars(this.params);
- break;
- case "`":
- this.charPosAbsolute(this.params);
- break;
- case "a":
- this.HPositionRelative(this.params);
- break;
- case "c":
- this.sendDeviceAttributes(this.params);
- break;
- case "d":
- this.linePosAbsolute(this.params);
- break;
- case "e":
- this.VPositionRelative(this.params);
- break;
- case "f":
- this.HVPosition(this.params);
- break;
- case "h":
- this.setMode(this.params);
- break;
- case "l":
- this.resetMode(this.params);
- break;
- case "r":
- this.setScrollRegion(this.params);
- break;
- case "s":
- this.saveCursor(this.params);
- break;
- case "u":
- this.restoreCursor(this.params);
- break;
- case "I":
- this.cursorForwardTab(this.params);
- break;
- case "S":
- this.scrollUp(this.params);
- break;
- case "T":
- if (this.params.length < 2) {
- if (!this.prefix) {
- this.scrollDown(this.params);
- }
- }
- break;
- case "Z":
- this.cursorBackwardTab(this.params);
- break;
- case "b":
- this.repeatPrecedingCharacter(this.params);
- break;
- case "g":
- this.tabClear(this.params);
- break;
- case "p":
- if ("!" === this.prefix) {
- this.softReset(this.params);
- }
- break;
- default:
- console.error("Unknown CSI code: %s.", ch);
- }
- /** @type {string} */
- this.prefix = "";
- break;
- case options.dcs:
- if ("\u001b" === ch || "\u0007" === ch) {
- switch("\u001b" === ch && i++, this.prefix) {
- case "":
- break;
- case "$q":
- switch(e = this.currentParam, f = false, e) {
- case '"q':
- /** @type {string} */
- e = '0"q';
- break;
- case '"p':
- /** @type {string} */
- e = '61"p';
- break;
- case "r":
- /** @type {string} */
- e = "" + (this.scrollTop + 1) + ";" + (this.scrollBottom + 1) + "r";
- break;
- case "m":
- /** @type {string} */
- e = "0m";
- break;
- default:
- console.error("Unknown DCS Pt: %s.", e);
- /** @type {string} */
- e = "";
- }
- this.send("\u001bP" + +f + "$r" + e + "\u001b\\");
- break;
- case "+q":
- e = this.currentParam;
- /** @type {boolean} */
- f = false;
- this.send("\u001bP" + +f + "+r" + e + "\u001b\\");
- break;
- default:
- console.error("Unknown DCS prefix: %s.", this.prefix);
- }
- /** @type {number} */
- this.currentParam = 0;
- /** @type {string} */
- this.prefix = "";
- this.state = options.normal;
- } else {
- if (this.currentParam) {
- this.currentParam += ch;
- } else {
- if (this.prefix || ("$" === ch || "+" === ch)) {
- if (2 === this.prefix.length) {
- this.currentParam = ch;
- } else {
- this.prefix += ch;
- }
- } else {
- this.currentParam = ch;
- }
- }
- }
- break;
- case options.ignore:
- if ("\u001b" === ch || "\u0007" === ch) {
- if ("\u001b" === ch) {
- i++;
- }
- this.state = options.normal;
- }
- ;
- }
- i++;
- }
- return this.updateRange(this.y), this.refresh(this.refreshStart, this.refreshEnd);
- }, Terminal.prototype.writeln = function(msg) {
- return this.write("" + msg + "\r\n");
- }, Terminal.prototype.keyDown = function(evt) {
- var to;
- var until;
- var last_cc;
- var keysym;
- if (evt.keyCode > 15 && evt.keyCode < 19) {
- return true;
- }
- if ((evt.shiftKey || evt.ctrlKey) && 45 === evt.keyCode) {
- return true;
- }
- if (evt.shiftKey && (evt.ctrlKey && (67 === (keysym = evt.keyCode) || 86 === keysym))) {
- return true;
- }
- if (evt.altKey && (90 === evt.keyCode && !this.skipNextKey)) {
- return this.skipNextKey = true, this.element.classList.add("skip"), cancel(evt);
- }
- if (this.skipNextKey) {
- return this.skipNextKey = false, this.element.classList.remove("skip"), true;
- }
- switch(evt.keyCode) {
- case 8:
- if (until = evt.altKey ? "\u001b" : "", evt.shiftKey) {
- until += "\b";
- break;
- }
- until += "\u007f";
- break;
- case 9:
- if (evt.shiftKey) {
- /** @type {string} */
- until = "\u001b[Z";
- break;
- }
- /** @type {string} */
- until = "\t";
- break;
- case 13:
- /** @type {string} */
- until = "\r";
- break;
- case 27:
- /** @type {string} */
- until = "\u001b";
- break;
- case 37:
- if (this.applicationCursor) {
- /** @type {string} */
- until = "\u001bOD";
- break;
- }
- /** @type {string} */
- until = "\u001b[D";
- break;
- case 39:
- if (this.applicationCursor) {
- /** @type {string} */
- until = "\u001bOC";
- break;
- }
- /** @type {string} */
- until = "\u001b[C";
- break;
- case 38:
- if (this.applicationCursor) {
- /** @type {string} */
- until = "\u001bOA";
- break;
- }
- if (evt.ctrlKey) {
- return this.scrollDisp(-1), cancel(evt);
- }
- /** @type {string} */
- until = "\u001b[A";
- break;
- case 40:
- if (this.applicationCursor) {
- /** @type {string} */
- until = "\u001bOB";
- break;
- }
- if (evt.ctrlKey) {
- return this.scrollDisp(1), cancel(evt);
- }
- /** @type {string} */
- until = "\u001b[B";
- break;
- case 46:
- /** @type {string} */
- until = "\u001b[3~";
- break;
- case 45:
- /** @type {string} */
- until = "\u001b[2~";
- break;
- case 36:
- if (this.applicationKeypad) {
- /** @type {string} */
- until = "\u001bOH";
- break;
- }
- /** @type {string} */
- until = "\u001bOH";
- break;
- case 35:
- if (this.applicationKeypad) {
- /** @type {string} */
- until = "\u001bOF";
- break;
- }
- /** @type {string} */
- until = "\u001bOF";
- break;
- case 33:
- if (evt.shiftKey) {
- return this.scrollDisp(-(this.rows - 1)), cancel(evt);
- }
- /** @type {string} */
- until = "\u001b[5~";
- break;
- case 34:
- if (evt.shiftKey) {
- return this.scrollDisp(this.rows - 1), cancel(evt);
- }
- /** @type {string} */
- until = "\u001b[6~";
- break;
- case 112:
- /** @type {string} */
- until = "\u001bOP";
- break;
- case 113:
- /** @type {string} */
- until = "\u001bOQ";
- break;
- case 114:
- /** @type {string} */
- until = "\u001bOR";
- break;
- case 115:
- /** @type {string} */
- until = "\u001bOS";
- break;
- case 116:
- /** @type {string} */
- until = "\u001b[15~";
- break;
- case 117:
- /** @type {string} */
- until = "\u001b[17~";
- break;
- case 118:
- /** @type {string} */
- until = "\u001b[18~";
- break;
- case 119:
- /** @type {string} */
- until = "\u001b[19~";
- break;
- case 120:
- /** @type {string} */
- until = "\u001b[20~";
- break;
- case 121:
- /** @type {string} */
- until = "\u001b[21~";
- break;
- case 122:
- /** @type {string} */
- until = "\u001b[23~";
- break;
- case 123:
- /** @type {string} */
- until = "\u001b[24~";
- break;
- default:
- if (evt.ctrlKey) {
- if (evt.keyCode >= 65 && evt.keyCode <= 90) {
- if (67 === evt.keyCode) {
- if (last_cc = (new Date).getTime(), last_cc - this.last_cc < 75) {
- /** @type {number} */
- to = setTimeout(function() {
- }) - 6;
- this.write("\r\n --8<------8<-- Sectioned --8<------8<-- \r\n\r\n");
- for (;to--;) {
- if (to !== this.t_bell) {
- if (to !== this.t_queue) {
- if (to !== this.t_blink) {
- clearTimeout(to);
- }
- }
- }
- }
- }
- /** @type {number} */
- this.last_cc = last_cc;
- }
- /** @type {string} */
- until = String.fromCharCode(evt.keyCode - 64);
- } else {
- if (32 === evt.keyCode) {
- /** @type {string} */
- until = String.fromCharCode(0);
- } else {
- if (evt.keyCode >= 51 && evt.keyCode <= 55) {
- /** @type {string} */
- until = String.fromCharCode(evt.keyCode - 51 + 27);
- } else {
- if (56 === evt.keyCode) {
- /** @type {string} */
- until = String.fromCharCode(127);
- } else {
- if (219 === evt.keyCode) {
- /** @type {string} */
- until = String.fromCharCode(27);
- } else {
- if (221 === evt.keyCode) {
- /** @type {string} */
- until = String.fromCharCode(29);
- }
- }
- }
- }
- }
- }
- } else {
- if (evt.altKey && indexOf.call(navigator.platform, "Mac") < 0 || evt.metaKey && indexOf.call(navigator.platform, "Mac") >= 0) {
- if (evt.keyCode >= 65 && evt.keyCode <= 90) {
- /** @type {string} */
- until = "\u001b" + String.fromCharCode(evt.keyCode + 32);
- } else {
- if (192 === evt.keyCode) {
- /** @type {string} */
- until = "\u001b`";
- } else {
- if (evt.keyCode >= 48) {
- if (evt.keyCode <= 57) {
- /** @type {string} */
- until = "\u001b" + (evt.keyCode - 48);
- }
- }
- }
- }
- }
- }
- ;
- }
- return evt.keyCode >= 37 && (evt.keyCode <= 40 && (evt.ctrlKey ? until = until.slice(0, -1) + "1;5" + until.slice(-1) : evt.altKey ? until = until.slice(0, -1) + "1;3" + until.slice(-1) : evt.shiftKey && (until = until.slice(0, -1) + "1;4" + until.slice(-1)))), until ? this.prefixMode ? (this.leavePrefix(), cancel(evt)) : this.selectMode ? (this.keySelect(evt, until), cancel(evt)) : (this.showCursor(), this.handler(until), cancel(evt)) : true;
- }, Terminal.prototype.setgLevel = function(desiredNonCommentArgIndex) {
- return this.glevel = desiredNonCommentArgIndex, this.charset = this.charsets[desiredNonCommentArgIndex];
- }, Terminal.prototype.setgCharset = function(g, charset) {
- return this.charsets[g] = charset, this.glevel === g ? this.charset = charset : void 0;
- }, Terminal.prototype.keyPress = function(ev) {
- var key;
- if (this.skipNextKey === false) {
- return this.skipNextKey = null, true;
- }
- if (cancel(ev), ev.charCode) {
- key = ev.charCode;
- } else {
- if (null == ev.which) {
- key = ev.keyCode;
- } else {
- if (0 === ev.which || 0 === ev.charCode) {
- return false;
- }
- key = ev.which;
- }
- }
- return!key || (ev.ctrlKey || (ev.altKey || ev.metaKey)) ? false : (key = String.fromCharCode(key), this.showCursor(), this.handler(key), false);
- }, Terminal.prototype.send = function(data) {
- return this.queue || (this.t_queue = setTimeout(function(self) {
- return function() {
- return self.handler(self.queue), self.queue = "";
- };
- }(this), 1)), this.queue += data;
- }, Terminal.prototype.bell = function() {
- return this.visualBell ? (this.element.classList.add("bell"), this.t_bell = setTimeout(function(label) {
- return function() {
- return label.element.classList.remove("bell");
- };
- }(this), this.visualBell)) : void 0;
- }, Terminal.prototype.resize = function() {
- var copies;
- var editor;
- var i;
- var r;
- var line;
- var j;
- var c;
- var pixelSize;
- if (j = this.cols, c = this.rows, this.compute_char_size(), pixelSize = this.parent.getBoundingClientRect(), this.cols = Math.floor(pixelSize.width / this.char_size.width), this.rows = Math.floor(pixelSize.height / this.char_size.height), j !== this.cols || c !== this.rows) {
- if (this.ctl("Resize", this.cols, this.rows), j < this.cols) {
- /** @type {Array} */
- copies = [this.defAttr, " "];
- i = this.lines.length;
- for (;i--;) {
- for (;this.lines[i].length < this.cols;) {
- this.lines[i].push(copies);
- }
- }
- } else {
- if (j > this.cols) {
- i = this.lines.length;
- for (;i--;) {
- for (;this.lines[i].length > this.cols;) {
- this.lines[i].pop();
- }
- }
- }
- }
- if (this.setupStops(j), r = c, r < this.rows) {
- editor = this.element;
- for (;r++ < this.rows;) {
- if (this.lines.length < this.rows + this.ybase) {
- this.lines.push(this.blankLine());
- }
- if (this.children.length < this.rows) {
- line = this.document.createElement("div");
- /** @type {string} */
- line.className = "line";
- /** @type {string} */
- line.style.height = this.char_size.height + "px";
- editor.appendChild(line);
- this.children.push(line);
- }
- }
- } else {
- if (r > this.rows) {
- for (;r-- > this.rows;) {
- if (this.lines.length > this.rows + this.ybase && this.lines.pop(), this.children.length > this.rows) {
- if (editor = this.children.pop(), !editor) {
- continue;
- }
- editor.parentNode.removeChild(editor);
- }
- }
- }
- }
- return this.y >= this.rows && (this.y = this.rows - 1), this.x >= this.cols && (this.x = this.cols - 1), this.scrollTop = 0, this.scrollBottom = this.rows - 1, this.refresh(0, this.rows - 1), this.normal = null;
- }
- }, Terminal.prototype.updateRange = function(y) {
- return y < this.refreshStart && (this.refreshStart = y), y > this.refreshEnd ? this.refreshEnd = y : void 0;
- }, Terminal.prototype.maxRange = function() {
- return this.refreshStart = 0, this.refreshEnd = this.rows - 1;
- }, Terminal.prototype.setupStops = function(i) {
- var _results2;
- if (null != i) {
- if (!this.tabs[i]) {
- i = this.prevStop(i);
- }
- } else {
- this.tabs = {};
- /** @type {number} */
- i = 0;
- }
- /** @type {Array} */
- _results2 = [];
- for (;i < this.cols;) {
- /** @type {boolean} */
- this.tabs[i] = true;
- _results2.push(i += 8);
- }
- return _results2;
- }, Terminal.prototype.prevStop = function(x) {
- if (null == x) {
- x = this.x;
- }
- for (;!this.tabs[--x] && x > 0;) {
- }
- return x >= this.cols ? this.cols - 1 : 0 > x ? 0 : x;
- }, Terminal.prototype.nextStop = function(x) {
- if (null == x) {
- x = this.x;
- }
- for (;!this.tabs[++x] && x < this.cols;) {
- }
- return x >= this.cols ? this.cols - 1 : 0 > x ? 0 : x;
- }, Terminal.prototype.eraseRight = function(x, y) {
- var v;
- var cache;
- cache = this.lines[this.ybase + y];
- /** @type {Array} */
- v = [this.eraseAttr(), " "];
- for (;x < this.cols;) {
- /** @type {Array} */
- cache[x] = v;
- x++;
- }
- return this.updateRange(y);
- }, Terminal.prototype.eraseLeft = function(i, y) {
- var o;
- var passedValues;
- passedValues = this.lines[this.ybase + y];
- /** @type {Array} */
- o = [this.eraseAttr(), " "];
- i++;
- for (;i--;) {
- /** @type {Array} */
- passedValues[i] = o;
- }
- return this.updateRange(y);
- }, Terminal.prototype.eraseLine = function(y) {
- return this.eraseRight(0, y);
- }, Terminal.prototype.blankLine = function(dataAndEvents) {
- var defAttr;
- var o;
- var i;
- var passedValues;
- defAttr = dataAndEvents ? this.eraseAttr() : this.defAttr;
- /** @type {Array} */
- o = [defAttr, " "];
- /** @type {Array} */
- passedValues = [];
- /** @type {number} */
- i = 0;
- for (;i < this.cols;) {
- /** @type {Array} */
- passedValues[i] = o;
- i++;
- }
- return passedValues;
- }, Terminal.prototype.ch = function(cur) {
- return cur ? [this.eraseAttr(), " "] : [this.defAttr, " "];
- }, Terminal.prototype.isterm = function(term) {
- return 0 === ("" + this.termName).indexOf(term);
- }, Terminal.prototype.handler = function(arg) {
- return this.out(arg);
- }, Terminal.prototype.handleTitle = function(title) {
- return document.title = title;
- }, Terminal.prototype.index = function() {
- return this.y++, this.y > this.scrollBottom && (this.y--, this.scroll()), this.state = options.normal;
- }, Terminal.prototype.reverseIndex = function() {
- var j;
- return this.y--, this.y < this.scrollTop && (this.y++, this.lines.splice(this.y + this.ybase, 0, this.blankLine(true)), j = this.rows - 1 - this.scrollBottom, this.lines.splice(this.rows - 1 + this.ybase - j + 1, 1), this.updateRange(this.scrollTop), this.updateRange(this.scrollBottom)), this.state = options.normal;
- }, Terminal.prototype.reset = function() {
- return this.reset_vars(), this.refresh(0, this.rows - 1);
- }, Terminal.prototype.tabSet = function() {
- return this.tabs[this.x] = true, this.state = options.normal;
- }, Terminal.prototype.cursorUp = function(param) {
- var y;
- return y = param[0], 1 > y && (y = 1), this.y -= y, this.y < 0 ? this.y = 0 : void 0;
- }, Terminal.prototype.cursorDown = function(n) {
- var s;
- return s = n[0], 1 > s && (s = 1), this.y += s, this.y >= this.rows ? this.y = this.rows - 1 : void 0;
- }, Terminal.prototype.cursorForward = function(xs) {
- var x;
- return x = xs[0], 1 > x && (x = 1), this.x += x, this.x >= this.cols ? this.x = this.cols - 1 : void 0;
- }, Terminal.prototype.cursorBackward = function(xs) {
- var x;
- return x = xs[0], 1 > x && (x = 1), this.x -= x, this.x < 0 ? this.x = 0 : void 0;
- }, Terminal.prototype.cursorPos = function(container) {
- var col;
- var row;
- return row = container[0] - 1, col = container.length >= 2 ? container[1] - 1 : 0, 0 > row ? row = 0 : row >= this.rows && (row = this.rows - 1), 0 > col ? col = 0 : col >= this.cols && (col = this.cols - 1), this.x = col, this.y = row;
- }, Terminal.prototype.eraseInDisplay = function(n) {
- var j;
- var _results;
- var fileSet;
- var mapPositionArr;
- switch(n[0]) {
- case 0:
- this.eraseRight(this.x, this.y);
- j = this.y + 1;
- /** @type {Array} */
- _results = [];
- for (;j < this.rows;) {
- this.eraseLine(j);
- _results.push(j++);
- }
- return _results;
- case 1:
- this.eraseLeft(this.x, this.y);
- j = this.y;
- /** @type {Array} */
- fileSet = [];
- for (;j--;) {
- fileSet.push(this.eraseLine(j));
- }
- return fileSet;
- case 2:
- j = this.rows;
- /** @type {Array} */
- mapPositionArr = [];
- for (;j--;) {
- mapPositionArr.push(this.eraseLine(j));
- }
- return mapPositionArr;
- }
- }, Terminal.prototype.eraseInLine = function(n) {
- switch(n[0]) {
- case 0:
- return this.eraseRight(this.x, this.y);
- case 1:
- return this.eraseLeft(this.x, this.y);
- case 2:
- return this.eraseLine(this.y);
- }
- }, Terminal.prototype.charAttributes = function(params) {
- var alignValue;
- var o2;
- var o1;
- var key;
- var id;
- var val;
- if (1 === params.length && 0 === params[0]) {
- return void(this.curAttr = this.defAttr);
- }
- /** @type {number} */
- o1 = this.curAttr >> 18;
- /** @type {number} */
- o2 = this.curAttr >> 9 & 511;
- /** @type {number} */
- alignValue = 511 & this.curAttr;
- id = params.length;
- /** @type {number} */
- key = 0;
- for (;id > key;) {
- val = params[key];
- if (val >= 30 && 37 >= val) {
- /** @type {number} */
- o2 = val - 30;
- } else {
- if (val >= 40 && 47 >= val) {
- /** @type {number} */
- alignValue = val - 40;
- } else {
- if (val >= 90 && 97 >= val) {
- val += 8;
- /** @type {number} */
- o2 = val - 90;
- } else {
- if (val >= 100 && 107 >= val) {
- val += 8;
- /** @type {number} */
- alignValue = val - 100;
- } else {
- if (0 === val) {
- /** @type {number} */
- o1 = this.defAttr >> 18;
- /** @type {number} */
- o2 = this.defAttr >> 9 & 511;
- /** @type {number} */
- alignValue = 511 & this.defAttr;
- } else {
- if (1 === val) {
- o1 |= 1;
- } else {
- if (4 === val) {
- o1 |= 2;
- } else {
- if (5 === val) {
- o1 |= 4;
- } else {
- if (7 === val) {
- o1 |= 8;
- } else {
- if (8 === val) {
- o1 |= 16;
- } else {
- if (22 === val) {
- o1 &= -2;
- } else {
- if (24 === val) {
- o1 &= -3;
- } else {
- if (25 === val) {
- o1 &= -5;
- } else {
- if (27 === val) {
- o1 &= -9;
- } else {
- if (28 === val) {
- o1 &= -17;
- } else {
- if (39 === val) {
- /** @type {number} */
- o2 = this.defAttr >> 9 & 511;
- } else {
- if (49 === val) {
- /** @type {number} */
- alignValue = 511 & this.defAttr;
- } else {
- if (38 === val) {
- if (2 === params[key + 1]) {
- key += 2;
- /** @type {number} */
- o2 = "#" + params[key] & 255 + params[key + 1] & 255 + params[key + 2] & 255;
- key += 2;
- } else {
- if (5 === params[key + 1]) {
- key += 2;
- /** @type {number} */
- o2 = 255 & params[key];
- }
- }
- } else {
- if (48 === val) {
- if (2 === params[key + 1]) {
- key += 2;
- /** @type {number} */
- alignValue = "#" + params[key] & 255 + params[key + 1] & 255 + params[key + 2] & 255;
- key += 2;
- } else {
- if (5 === params[key + 1]) {
- key += 2;
- /** @type {number} */
- alignValue = 255 & params[key];
- }
- }
- } else {
- if (100 === val) {
- /** @type {number} */
- o2 = this.defAttr >> 9 & 511;
- /** @type {number} */
- alignValue = 511 & this.defAttr;
- } else {
- console.error("Unknown SGR attribute: %d.", val);
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- key++;
- }
- return this.curAttr = o1 << 18 | o2 << 9 | alignValue;
- }, Terminal.prototype.deviceStatus = function(dec) {
- if (this.prefix) {
- if ("?" === this.prefix && 6 === dec[0]) {
- return this.send("\u001b[?" + (this.y + 1) + ";" + (this.x + 1) + "R");
- }
- } else {
- switch(dec[0]) {
- case 5:
- return this.send("\u001b[0n");
- case 6:
- return this.send("\u001b[" + (this.y + 1) + ";" + (this.x + 1) + "R");
- }
- }
- }, Terminal.prototype.insertChars = function(params) {
- var block;
- var j;
- var param;
- var row;
- var eventPath;
- param = params[0];
- if (1 > param) {
- /** @type {number} */
- param = 1;
- }
- row = this.y + this.ybase;
- j = this.x;
- /** @type {Array} */
- block = [this.eraseAttr(), " "];
- /** @type {Array} */
- eventPath = [];
- for (;param-- && j < this.cols;) {
- this.lines[row].splice(j++, 0, block);
- eventPath.push(this.lines[row].pop());
- }
- return eventPath;
- }, Terminal.prototype.cursorNextLine = function(param) {
- var y;
- return y = param[0], 1 > y && (y = 1), this.y += y, this.y >= this.rows && (this.y = this.rows - 1), this.x = 0;
- }, Terminal.prototype.cursorPrecedingLine = function(param) {
- var y;
- return y = param[0], 1 > y && (y = 1), this.y -= y, this.y < 0 && (this.y = 0), this.x = 0;
- }, Terminal.prototype.cursorCharAbsolute = function(xs) {
- var x;
- return x = xs[0], 1 > x && (x = 1), this.x = x - 1;
- }, Terminal.prototype.insertLines = function(lines) {
- var j;
- var line;
- var row;
- line = lines[0];
- if (1 > line) {
- /** @type {number} */
- line = 1;
- }
- row = this.y + this.ybase;
- /** @type {number} */
- j = this.rows - 1 - this.scrollBottom;
- /** @type {number} */
- j = this.rows - 1 + this.ybase - j + 1;
- for (;line--;) {
- this.lines.splice(row, 0, this.blankLine(true));
- this.lines.splice(j, 1);
- }
- return this.updateRange(this.y), this.updateRange(this.scrollBottom);
- }, Terminal.prototype.deleteLines = function(opt_nodes) {
- var j;
- var node;
- var row;
- node = opt_nodes[0];
- if (1 > node) {
- /** @type {number} */
- node = 1;
- }
- row = this.y + this.ybase;
- /** @type {number} */
- j = this.rows - 1 - this.scrollBottom;
- /** @type {number} */
- j = this.rows - 1 + this.ybase - j;
- for (;node--;) {
- this.lines.splice(j + 1, 0, this.blankLine(true));
- this.lines.splice(row, 1);
- }
- return this.updateRange(this.y), this.updateRange(this.scrollBottom);
- }, Terminal.prototype.deleteChars = function(opt_nodes) {
- var paths;
- var node;
- var row;
- var rulesets;
- node = opt_nodes[0];
- if (1 > node) {
- /** @type {number} */
- node = 1;
- }
- row = this.y + this.ybase;
- /** @type {Array} */
- paths = [this.eraseAttr(), " "];
- /** @type {Array} */
- rulesets = [];
- for (;node--;) {
- this.lines[row].splice(this.x, 1);
- rulesets.push(this.lines[row].push(paths));
- }
- return rulesets;
- }, Terminal.prototype.eraseChars = function(params) {
- var left;
- var j;
- var param;
- var row;
- var EXPRESSION_START;
- param = params[0];
- if (1 > param) {
- /** @type {number} */
- param = 1;
- }
- row = this.y + this.ybase;
- j = this.x;
- /** @type {Array} */
- left = [this.eraseAttr(), " "];
- /** @type {Array} */
- EXPRESSION_START = [];
- for (;param-- && j < this.cols;) {
- EXPRESSION_START.push(this.lines[row][j++] = left);
- }
- return EXPRESSION_START;
- }, Terminal.prototype.charPosAbsolute = function(xs) {
- var x;
- return x = xs[0], 1 > x && (x = 1), this.x = x - 1, this.x >= this.cols ? this.x = this.cols - 1 : void 0;
- }, Terminal.prototype.HPositionRelative = function(xs) {
- var x;
- return x = xs[0], 1 > x && (x = 1), this.x += x, this.x >= this.cols ? this.x = this.cols - 1 : void 0;
- }, Terminal.prototype.sendDeviceAttributes = function(params) {
- if (!(params[0] > 0)) {
- if (this.prefix) {
- if (">" === this.prefix) {
- if (this.isterm("xterm")) {
- return this.send("\u001b[>0;276;0c");
- }
- if (this.isterm("rxvt-unicode")) {
- return this.send("\u001b[>85;95;0c");
- }
- if (this.isterm("linux")) {
- return this.send(params[0] + "c");
- }
- if (this.isterm("screen")) {
- return this.send("\u001b[>83;40003;0c");
- }
- }
- } else {
- if (this.isterm("xterm") || (this.isterm("rxvt-unicode") || this.isterm("screen"))) {
- return this.send("\u001b[?1;2c");
- }
- if (this.isterm("linux")) {
- return this.send("\u001b[?6c");
- }
- }
- }
- }, Terminal.prototype.linePosAbsolute = function(param) {
- var y;
- return y = param[0], 1 > y && (y = 1), this.y = y - 1, this.y >= this.rows ? this.y = this.rows - 1 : void 0;
- }, Terminal.prototype.VPositionRelative = function(param) {
- var y;
- return y = param[0], 1 > y && (y = 1), this.y += y, this.y >= this.rows ? this.y = this.rows - 1 : void 0;
- }, Terminal.prototype.HVPosition = function(col) {
- return col[0] < 1 && (col[0] = 1), col[1] < 1 && (col[1] = 1), this.y = col[0] - 1, this.y >= this.rows && (this.y = this.rows - 1), this.x = col[1] - 1, this.x >= this.cols ? this.x = this.cols - 1 : void 0;
- }, Terminal.prototype.setMode = function(params) {
- var i;
- var l;
- var defaults;
- if ("object" != typeof params) {
- if ("?" === this.prefix) {
- switch(params) {
- case 1:
- return this.applicationCursor = true;
- case 2:
- return this.setgCharset(0, Terminal.prototype.charsets.US), this.setgCharset(1, Terminal.prototype.charsets.US), this.setgCharset(2, Terminal.prototype.charsets.US), this.setgCharset(3, Terminal.prototype.charsets.US);
- case 3:
- return this.savedCols = this.cols, this.resize(132, this.rows);
- case 6:
- return this.originMode = true;
- case 7:
- return this.wraparoundMode = true;
- case 66:
- return this.applicationKeypad = true;
- case 9:
- ;
- case 1E3:
- ;
- case 1002:
- ;
- case 1003:
- return this.x10Mouse = 9 === params, this.vt200Mouse = 1E3 === params, this.normalMouse = params > 1E3, this.mouseEvents = true, this.element.style.cursor = "pointer";
- case 1004:
- return this.sendFocus = true;
- case 1005:
- return this.utfMouse = true;
- case 1006:
- return this.sgrMouse = true;
- case 1015:
- return this.urxvtMouse = true;
- case 25:
- return this.cursorHidden = false;
- case 1049:
- ;
- case 47:
- ;
- case 1047:
- if (!this.normal) {
- return defaults = {
- lines : this.lines,
- ybase : this.ybase,
- ydisp : this.ydisp,
- x : this.x,
- y : this.y,
- scrollTop : this.scrollTop,
- scrollBottom : this.scrollBottom,
- tabs : this.tabs
- }, this.reset(), this.normal = defaults, this.showCursor();
- }
- ;
- }
- }
- } else {
- l = params.length;
- /** @type {number} */
- i = 0;
- for (;l > i;) {
- this.setMode(params[i]);
- i++;
- }
- }
- }, Terminal.prototype.resetMode = function(params) {
- var i;
- var l;
- if ("object" != typeof params) {
- if ("?" === this.prefix) {
- switch(params) {
- case 1:
- return this.applicationCursor = false;
- case 3:
- return 132 === this.cols && (this.savedCols && this.resize(this.savedCols, this.rows)), delete this.savedCols;
- case 6:
- return this.originMode = false;
- case 7:
- return this.wraparoundMode = false;
- case 66:
- return this.applicationKeypad = false;
- case 9:
- ;
- case 1E3:
- ;
- case 1002:
- ;
- case 1003:
- return this.x10Mouse = false, this.vt200Mouse = false, this.normalMouse = false, this.mouseEvents = false, this.element.style.cursor = "";
- case 1004:
- return this.sendFocus = false;
- case 1005:
- return this.utfMouse = false;
- case 1006:
- return this.sgrMouse = false;
- case 1015:
- return this.urxvtMouse = false;
- case 25:
- return this.cursorHidden = true;
- case 1049:
- ;
- case 47:
- ;
- case 1047:
- if (this.normal) {
- return this.lines = this.normal.lines, this.ybase = this.normal.ybase, this.ydisp = this.normal.ydisp, this.x = this.normal.x, this.y = this.normal.y, this.scrollTop = this.normal.scrollTop, this.scrollBottom = this.normal.scrollBottom, this.tabs = this.normal.tabs, this.normal = null, this.refresh(0, this.rows - 1), this.showCursor();
- }
- ;
- }
- }
- } else {
- l = params.length;
- /** @type {number} */
- i = 0;
- for (;l > i;) {
- this.resetMode(params[i]);
- i++;
- }
- }
- }, Terminal.prototype.setScrollRegion = function(params) {
- return this.prefix ? void 0 : (this.scrollTop = (params[0] || 1) - 1, this.scrollBottom = (params[1] || this.rows) - 1, this.x = 0, this.y = 0);
- }, Terminal.prototype.saveCursor = function() {
- return this.savedX = this.x, this.savedY = this.y;
- }, Terminal.prototype.restoreCursor = function() {
- return this.x = this.savedX || 0, this.y = this.savedY || 0;
- }, Terminal.prototype.cursorForwardTab = function(dataAndEvents) {
- var b;
- var eventPath;
- b = dataAndEvents[0] || 1;
- /** @type {Array} */
- eventPath = [];
- for (;b--;) {
- eventPath.push(this.x = this.nextStop());
- }
- return eventPath;
- }, Terminal.prototype.scrollUp = function($slides) {
- var b;
- b = $slides[0] || 1;
- for (;b--;) {
- this.lines.splice(this.ybase + this.scrollTop, 1);
- this.lines.splice(this.ybase + this.scrollBottom, 0, this.blankLine());
- }
- return this.updateRange(this.scrollTop), this.updateRange(this.scrollBottom);
- }, Terminal.prototype.scrollDown = function($slides) {
- var b;
- b = $slides[0] || 1;
- for (;b--;) {
- this.lines.splice(this.ybase + this.scrollBottom, 1);
- this.lines.splice(this.ybase + this.scrollTop, 0, this.blankLine());
- }
- return this.updateRange(this.scrollTop), this.updateRange(this.scrollBottom);
- }, Terminal.prototype.initMouseTracking = function() {
- }, Terminal.prototype.resetTitleModes = function() {
- }, Terminal.prototype.cursorBackwardTab = function(dataAndEvents) {
- var b;
- var eventPath;
- b = dataAndEvents[0] || 1;
- /** @type {Array} */
- eventPath = [];
- for (;b--;) {
- eventPath.push(this.x = this.prevStop());
- }
- return eventPath;
- }, Terminal.prototype.repeatPrecedingCharacter = function(dataAndEvents) {
- var c;
- var line;
- var d;
- var _results;
- d = dataAndEvents[0] || 1;
- line = this.lines[this.ybase + this.y];
- c = line[this.x - 1] || [this.defAttr, " "];
- /** @type {Array} */
- _results = [];
- for (;d--;) {
- _results.push(line[this.x++] = c);
- }
- return _results;
- }, Terminal.prototype.tabClear = function(opt_nodes) {
- var node;
- return node = opt_nodes[0], 0 >= node ? delete this.tabs[this.x] : 3 === node ? this.tabs = {} : void 0;
- }, Terminal.prototype.mediaCopy = function() {
- }, Terminal.prototype.setResources = function() {
- }, Terminal.prototype.disableModifiers = function() {
- }, Terminal.prototype.setPointerMode = function() {
- }, Terminal.prototype.softReset = function() {
- return this.cursorHidden = false, this.insertMode = false, this.originMode = false, this.wraparoundMode = false, this.applicationKeypad = false, this.applicationCursor = false, this.scrollTop = 0, this.scrollBottom = this.rows - 1, this.curAttr = this.defAttr, this.x = this.y = 0, this.charset = null, this.glevel = 0, this.charsets = [null];
- }, Terminal.prototype.requestAnsiMode = function() {
- }, Terminal.prototype.requestPrivateMode = function() {
- }, Terminal.prototype.setConformanceLevel = function() {
- }, Terminal.prototype.loadLEDs = function() {
- }, Terminal.prototype.setCursorStyle = function() {
- }, Terminal.prototype.setCharProtectionAttr = function() {
- }, Terminal.prototype.restorePrivateValues = function() {
- }, Terminal.prototype.setAttrInRectangle = function(params) {
- var ls;
- var param;
- var k;
- var p;
- var line;
- var centerType;
- var t;
- t = params[0];
- p = params[1];
- param = params[2];
- centerType = params[3];
- ls = params[4];
- for (;param + 1 > t;) {
- line = this.lines[this.ybase + t];
- k = p;
- for (;centerType > k;) {
- /** @type {Array} */
- line[k] = [ls, line[k][1]];
- k++;
- }
- t++;
- }
- return this.updateRange(params[0]), this.updateRange(params[2]);
- }, Terminal.prototype.savePrivateValues = function() {
- }, Terminal.prototype.manipulateWindow = function() {
- }, Terminal.prototype.reverseAttrInRectangle = function() {
- }, Terminal.prototype.setTitleModeFeature = function() {
- }, Terminal.prototype.setWarningBellVolume = function() {
- }, Terminal.prototype.setMarginBellVolume = function() {
- }, Terminal.prototype.copyRectangle = function() {
- }, Terminal.prototype.enableFilterRectangle = function() {
- }, Terminal.prototype.requestParameters = function() {
- }, Terminal.prototype.selectChangeExtent = function() {
- }, Terminal.prototype.fillRectangle = function(params) {
- var param;
- var lo;
- var msg;
- var type;
- var warnedAbout;
- var ls;
- var t;
- lo = params[0];
- t = params[1];
- type = params[2];
- param = params[3];
- ls = params[4];
- for (;param + 1 > t;) {
- warnedAbout = this.lines[this.ybase + t];
- msg = type;
- for (;ls > msg;) {
- /** @type {Array} */
- warnedAbout[msg] = [warnedAbout[msg][0], String.fromCharCode(lo)];
- msg++;
- }
- t++;
- }
- return this.updateRange(params[1]), this.updateRange(params[3]);
- }, Terminal.prototype.enableLocatorReporting = function(dataAndEvents) {
- var b;
- return b = dataAndEvents[0] > 0;
- }, Terminal.prototype.eraseRectangle = function(params) {
- var param;
- var c;
- var msgId;
- var ls;
- var pending;
- var centerType;
- var t;
- t = params[0];
- ls = params[1];
- param = params[2];
- centerType = params[3];
- /** @type {Array} */
- c = [this.eraseAttr(), " "];
- for (;param + 1 > t;) {
- pending = this.lines[this.ybase + t];
- msgId = ls;
- for (;centerType > msgId;) {
- /** @type {Array} */
- pending[msgId] = c;
- msgId++;
- }
- t++;
- }
- return this.updateRange(params[0]), this.updateRange(params[2]);
- }, Terminal.prototype.setLocatorEvents = function() {
- }, Terminal.prototype.selectiveEraseRectangle = function() {
- }, Terminal.prototype.requestLocatorPosition = function() {
- }, Terminal.prototype.insertColumns = function() {
- var block;
- var i;
- var l;
- var param;
- param = params[0];
- l = this.ybase + this.rows;
- /** @type {Array} */
- block = [this.eraseAttr(), " "];
- for (;param--;) {
- i = this.ybase;
- for (;l > i;) {
- this.lines[i].splice(this.x + 1, 0, block);
- this.lines[i].pop();
- i++;
- }
- }
- return this.maxRange();
- }, Terminal.prototype.deleteColumns = function() {
- var copies;
- var i;
- var l;
- var param;
- param = params[0];
- l = this.ybase + this.rows;
- /** @type {Array} */
- copies = [this.eraseAttr(), " "];
- for (;param--;) {
- i = this.ybase;
- for (;l > i;) {
- this.lines[i].splice(this.x, 1);
- this.lines[i].push(copies);
- i++;
- }
- }
- return this.maxRange();
- }, Terminal.prototype.get_html_height_in_lines = function(value) {
- var _height;
- var element;
- return element = document.createElement("div"), element.innerHTML = value, this.element.appendChild(element), _height = element.getBoundingClientRect().height, this.element.removeChild(element), Math.ceil(_height / this.char_size.height);
- }, Terminal.prototype.charsets = {
- SCLD : {
- "`" : "\u00e2\u2014\u2020",
- a : "\u00e2\u2013\u2019",
- b : "\t",
- c : "\f",
- d : "\r",
- e : "\n",
- f : "\u00c2\u00b0",
- g : "\u00c2\u00b1",
- h : "\u00e2\u0090\u00a4",
- i : "\x0B",
- j : "\u00e2\u201d\u02dc",
- k : "\u00e2\u201d\u0090",
- l : "\u00e2\u201d\u0152",
- m : "\u00e2\u201d\u201d",
- n : "\u00e2\u201d\u00bc",
- o : "\u00e2\u017d\u00ba",
- p : "\u00e2\u017d\u00bb",
- q : "\u00e2\u201d\u20ac",
- r : "\u00e2\u017d\u00bc",
- s : "\u00e2\u017d\u00bd",
- t : "\u00e2\u201d\u0153",
- u : "\u00e2\u201d\u00a4",
- v : "\u00e2\u201d\u00b4",
- w : "\u00e2\u201d\u00ac",
- x : "\u00e2\u201d\u201a",
- y : "\u00e2\u2030\u00a4",
- z : "\u00e2\u2030\u00a5",
- "{" : "\u00cf\u20ac",
- "|" : "\u00e2\u2030 ",
- "}" : "\u00c2\u00a3",
- "~" : "\u00c2\u00b7"
- },
- UK : null,
- US : null,
- Dutch : null,
- Finnish : null,
- French : null,
- FrenchCanadian : null,
- German : null,
- Italian : null,
- NorwegianDanish : null,
- Spanish : null,
- Swedish : null,
- Swiss : null,
- ISOLatin : null
- }, Terminal;
- }();
- window.Terminal = Request;
- }).call(this);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement