Advertisement
Guest User

Pouet

a guest
Sep 30th, 2014
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (function() {
  2.   var callback;
  3.   var options;
  4.   var Request;
  5.   var cancel;
  6.   var stack;
  7.   var f;
  8.   var g;
  9.   var memory;
  10.   var ignore;
  11.   /** @type {function (this:(Array.<T>|string|{length: number}), *=, *=): Array.<T>} */
  12.   var __slice = [].slice;
  13.   /** @type {function (this:(Array.<T>|string|{length: number}), T, number=): number} */
  14.   var indexOf = [].indexOf || function(obj) {
  15.     /** @type {number} */
  16.     var i = 0;
  17.     var l = this.length;
  18.     for (;l > i;i++) {
  19.       if (i in this && this[i] === obj) {
  20.         return i;
  21.       }
  22.     }
  23.     return-1;
  24.   };
  25.   /** @type {null} */
  26.   stack = memory = null;
  27.   /** @type {boolean} */
  28.   g = false;
  29.   /** @type {number} */
  30.   f = (new Date).getTime();
  31.   callback = document.querySelectorAll.bind(document);
  32.   document.addEventListener("DOMContentLoaded", function() {
  33.     var write;
  34.     var draw;
  35.     var destroy;
  36.     var abort;
  37.     var self;
  38.     var ws;
  39.     var uri;
  40.     return abort = function(message) {
  41.       return ws.send("S" + message);
  42.     }, destroy = function() {
  43.       var dig;
  44.       var i;
  45.       var actionArgs;
  46.       return actionArgs = arguments[0], dig = 2 <= arguments.length ? __slice.call(arguments, 1) : [], i = dig.join(","), "Resize" === actionArgs ? ws.send("R" + i) : void 0;
  47.     }, uri = "https:" === location.protocol ? "wss://" : "ws://", uri += document.location.host + "/ws" + location.pathname, ws = new WebSocket(uri), ws.addEventListener("open", function() {
  48.       return console.log("WebSocket open", arguments), ws.send("R" + self.cols + "," + self.rows), f = (new Date).getTime();
  49.     }), ws.addEventListener("error", function() {
  50.       return console.log("WebSocket error", arguments);
  51.     }), ws.addEventListener("message", function(msg) {
  52.       return setTimeout(function() {
  53.         return self.write(msg.data);
  54.       }, 1);
  55.     }), ws.addEventListener("close", function() {
  56.       return console.log("WebSocket closed", arguments), setTimeout(function() {
  57.         return self.write("Closed"), self.skipNextKey = true, self.element.classList.add("dead");
  58.       }, 1), g = true, (new Date).getTime() - f > 6E4 ? open("", "_self").close() : void 0;
  59.     }), self = new Request(callback("#wrapper")[0], abort, destroy), addEventListener("beforeunload", function() {
  60.       return g ? void 0 : "This will exit the terminal session";
  61.     }), write = function(length) {
  62.       var s;
  63.       var c;
  64.       if (null == length) {
  65.         /** @type {number} */
  66.         length = 1E8;
  67.       }
  68.       /** @type {string} */
  69.       s = "";
  70.       for (;s.length < length;) {
  71.         s += Math.random().toString(36).substring(2);
  72.       }
  73.       return c = (new Date).getTime(), self.write(s), console.log("" + length + " chars in " + ((new Date).getTime() - c) + " ms");
  74.     }, draw = function(n) {
  75.       var str;
  76.       var c;
  77.       if (null == n) {
  78.         /** @type {number} */
  79.         n = 1E8;
  80.       }
  81.       /** @type {string} */
  82.       str = "";
  83.       for (;str.length < n;) {
  84.         str += "\u001b[" + (30 + parseInt(20 * Math.random())) + "m";
  85.         str += Math.random().toString(36).substring(2);
  86.       }
  87.       return c = (new Date).getTime(), self.write(str), console.log("" + n + " chars + colors in " + ((new Date).getTime() - c) + " ms");
  88.     }, self.ws = ws, window.butterfly = self;
  89.   });
  90.   /**
  91.    * @param {Object} event
  92.    * @return {?}
  93.    */
  94.   cancel = function(event) {
  95.     return event.preventDefault && event.preventDefault(), event.stopPropagation && event.stopPropagation(), event.cancelBubble = true, false;
  96.   };
  97.   /** @type {number} */
  98.   ignore = 0;
  99.   options = {
  100.     normal : ignore++,
  101.     escaped : ignore++,
  102.     csi : ignore++,
  103.     osc : ignore++,
  104.     charset : ignore++,
  105.     dcs : ignore++,
  106.     ignore : ignore++
  107.   };
  108.   Request = function() {
  109.     /**
  110.      * @param {Element} parent
  111.      * @param {string} options
  112.      * @param {string} rows
  113.      * @return {undefined}
  114.      */
  115.     function Terminal(parent, options, rows) {
  116.       var node;
  117.       var row;
  118.       var pixelSize;
  119.       /** @type {Element} */
  120.       this.parent = parent;
  121.       /** @type {string} */
  122.       this.out = options;
  123.       this.ctl = null != rows ? rows : function() {
  124.       };
  125.       this.context = this.parent.ownerDocument.defaultView;
  126.       this.document = this.parent.ownerDocument;
  127.       this.body = this.document.getElementsByTagName("body")[0];
  128.       this.element = this.document.createElement("div");
  129.       /** @type {string} */
  130.       this.element.className = "terminal focus";
  131.       /** @type {string} */
  132.       this.element.style.outline = "none";
  133.       this.element.setAttribute("tabindex", 0);
  134.       this.element.setAttribute("spellcheck", "false");
  135.       this.parent.appendChild(this.element);
  136.       node = this.document.createElement("div");
  137.       /** @type {string} */
  138.       node.className = "line";
  139.       this.element.appendChild(node);
  140.       /** @type {Array} */
  141.       this.children = [node];
  142.       this.compute_char_size();
  143.       /** @type {string} */
  144.       node.style.height = this.char_size.height + "px";
  145.       pixelSize = this.parent.getBoundingClientRect();
  146.       /** @type {number} */
  147.       this.cols = Math.floor(pixelSize.width / this.char_size.width);
  148.       /** @type {number} */
  149.       this.rows = Math.floor(pixelSize.height / this.char_size.height);
  150.       /** @type {number} */
  151.       row = this.rows - 1;
  152.       for (;row--;) {
  153.         node = this.document.createElement("div");
  154.         /** @type {string} */
  155.         node.style.height = this.char_size.height + "px";
  156.         /** @type {string} */
  157.         node.className = "line";
  158.         this.element.appendChild(node);
  159.         this.children.push(node);
  160.       }
  161.       /** @type {number} */
  162.       this.scrollback = 1E5;
  163.       /** @type {number} */
  164.       this.visualBell = 100;
  165.       /** @type {boolean} */
  166.       this.convertEol = false;
  167.       /** @type {string} */
  168.       this.termName = "xterm";
  169.       /** @type {boolean} */
  170.       this.cursorBlink = true;
  171.       /** @type {number} */
  172.       this.cursorState = 0;
  173.       /** @type {number} */
  174.       this.last_cc = 0;
  175.       this.reset_vars();
  176.       this.refresh(0, this.rows - 1);
  177.       this.focus();
  178.       this.startBlink();
  179.       addEventListener("keydown", this.keyDown.bind(this));
  180.       addEventListener("keypress", this.keyPress.bind(this));
  181.       addEventListener("focus", this.focus.bind(this));
  182.       addEventListener("blur", this.blur.bind(this));
  183.       addEventListener("paste", this.paste.bind(this));
  184.       addEventListener("resize", this.resize.bind(this));
  185.       if ("undefined" != typeof InstallTrigger) {
  186.         /** @type {string} */
  187.         this.element.contentEditable = "true";
  188.         this.element.addEventListener("mouseup", function() {
  189.           var currentRange;
  190.           return currentRange = getSelection().getRangeAt(0), currentRange.startOffset === currentRange.endOffset ? getSelection().removeAllRanges() : void 0;
  191.         });
  192.       }
  193.       this.initmouse();
  194.       setTimeout(this.resize.bind(this), 100);
  195.     }
  196.     return Terminal.prototype.reset_vars = function() {
  197.       var _ref2;
  198.       /** @type {number} */
  199.       this.ybase = 0;
  200.       /** @type {number} */
  201.       this.ydisp = 0;
  202.       /** @type {number} */
  203.       this.x = 0;
  204.       /** @type {number} */
  205.       this.y = 0;
  206.       /** @type {boolean} */
  207.       this.cursorHidden = false;
  208.       this.state = options.normal;
  209.       /** @type {string} */
  210.       this.queue = "";
  211.       /** @type {number} */
  212.       this.scrollTop = 0;
  213.       /** @type {number} */
  214.       this.scrollBottom = this.rows - 1;
  215.       /** @type {boolean} */
  216.       this.applicationKeypad = false;
  217.       /** @type {boolean} */
  218.       this.applicationCursor = false;
  219.       /** @type {boolean} */
  220.       this.originMode = false;
  221.       /** @type {boolean} */
  222.       this.wraparoundMode = false;
  223.       /** @type {null} */
  224.       this.normal = null;
  225.       /** @type {null} */
  226.       this.charset = null;
  227.       /** @type {null} */
  228.       this.gcharset = null;
  229.       /** @type {number} */
  230.       this.glevel = 0;
  231.       /** @type {Array} */
  232.       this.charsets = [null];
  233.       /** @type {number} */
  234.       this.defAttr = 131840;
  235.       /** @type {number} */
  236.       this.curAttr = this.defAttr;
  237.       /** @type {Array} */
  238.       this.params = [];
  239.       /** @type {number} */
  240.       this.currentParam = 0;
  241.       /** @type {string} */
  242.       this.prefix = "";
  243.       /** @type {Array} */
  244.       this.lines = [];
  245.       _ref2 = this.rows;
  246.       for (;_ref2--;) {
  247.         this.lines.push(this.blankLine());
  248.       }
  249.       return this.setupStops(), this.skipNextKey = null;
  250.     }, Terminal.prototype.compute_char_size = function() {
  251.       var label;
  252.       return label = document.createElement("span"), label.textContent = "0123456789", this.children[0].appendChild(label), this.char_size = {
  253.         width : label.getBoundingClientRect().width / 10,
  254.         height : this.children[0].getBoundingClientRect().height
  255.       }, this.children[0].removeChild(label);
  256.     }, Terminal.prototype.eraseAttr = function() {
  257.       return-512 & this.defAttr | 511 & this.curAttr;
  258.     }, Terminal.prototype.focus = function() {
  259.       return this.sendFocus && this.send("\u001b[I"), this.showCursor(), this.element.classList.add("focus"), this.element.classList.remove("blur");
  260.     }, Terminal.prototype.blur = function() {
  261.       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");
  262.     }, Terminal.prototype.paste = function(e) {
  263.       return e.clipboardData ? this.send(e.clipboardData.getData("text/plain")) : this.context.clipboardData && this.send(this.context.clipboardData.getData("Text")), cancel(e);
  264.     }, Terminal.prototype.initmouse = function() {
  265.       var randomNumber;
  266.       var getButton;
  267.       var getCoords;
  268.       var target;
  269.       var sendButton;
  270.       var sendEvent;
  271.       var callback;
  272.       return target = 32, sendButton = function(ev) {
  273.         var button;
  274.         var pos;
  275.         if (button = getButton(ev), pos = getCoords(ev)) {
  276.           switch(sendEvent(button, pos), ev.type) {
  277.             case "mousedown":
  278.               return target = button;
  279.             case "mouseup":
  280.               return target = 32;
  281.           }
  282.         }
  283.       }, callback = function(ev) {
  284.         var deep;
  285.         var pos;
  286.         return deep = target, (pos = getCoords(ev)) ? (deep += 32, sendEvent(deep, pos)) : void 0;
  287.       }, randomNumber = function(dataAndEvents) {
  288.         return function(assigns, vvar) {
  289.           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));
  290.         };
  291.       }(this), sendEvent = function(self) {
  292.         return function(max, opt_offset) {
  293.           var applyArgs;
  294.           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),
  295.           self.send("\u001b[M" + String.fromCharCode.apply(String, applyArgs)));
  296.         };
  297.       }(this), getButton = function(self) {
  298.         return function(e) {
  299.           var c;
  300.           var ctrl;
  301.           var curr;
  302.           var mod;
  303.           var prev;
  304.           switch(e.type) {
  305.             case "mousedown":
  306.               /** @type {(null|number)} */
  307.               c = null != e.button ? +e.button : null != e.which ? e.which - 1 : null;
  308.               break;
  309.             case "mouseup":
  310.               /** @type {number} */
  311.               c = 3;
  312.               break;
  313.             case "wheel":
  314.               /** @type {number} */
  315.               c = e.deltaY < 0 ? 64 : 65;
  316.           }
  317.           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;
  318.         };
  319.       }(this), getCoords = function(self) {
  320.         return function(t) {
  321.           var element;
  322.           var h;
  323.           var w;
  324.           var x;
  325.           var y;
  326.           x = t.pageX;
  327.           y = t.pageY;
  328.           element = self.element;
  329.           for (;element && element !== self.document.documentElement;) {
  330.             x -= element.offsetLeft;
  331.             y -= element.offsetTop;
  332.             element = "offsetParent" in element ? element.offsetParent : element.parentNode;
  333.           }
  334.           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, {
  335.             x : x,
  336.             y : y,
  337.             type : t.type
  338.           };
  339.         };
  340.       }(this), addEventListener("mousedown", function(self) {
  341.         return function(ev) {
  342.           var READY_STATE_CHANGE_EVENT;
  343.           var up;
  344.           if (self.mouseEvents) {
  345.             return sendButton(ev), self.vt200Mouse ? (sendButton({
  346.               __proto__ : ev,
  347.               type : "mouseup"
  348.             }), cancel(ev)) : (READY_STATE_CHANGE_EVENT = callback.bind(self), self.normalMouse && addEventListener("mousemove", READY_STATE_CHANGE_EVENT), self.x10Mouse || addEventListener("mouseup", up = function(ev) {
  349.               return sendButton(ev), self.normalMouse && removeEventListener("mousemove", READY_STATE_CHANGE_EVENT), removeEventListener("mouseup", up), cancel(ev);
  350.             }), cancel(ev));
  351.           }
  352.         };
  353.       }(this)), addEventListener("wheel", function(self) {
  354.         return function(ev) {
  355.           if (self.mouseEvents) {
  356.             if (self.x10Mouse) {
  357.               return;
  358.             }
  359.             sendButton(ev);
  360.           } else {
  361.             if (self.applicationKeypad) {
  362.               return;
  363.             }
  364.             self.scrollDisp(ev.deltaY > 0 ? 5 : -5);
  365.           }
  366.           return cancel(ev);
  367.         };
  368.       }(this));
  369.     }, Terminal.prototype.refresh = function(mayParseLabeledStatementInstead, end) {
  370.       var attr;
  371.       var json;
  372.       var codeSegments;
  373.       var assigns;
  374.       var data;
  375.       var vvar;
  376.       var flags;
  377.       var i;
  378.       var tokens;
  379.       var xhtml;
  380.       var parent;
  381.       var row;
  382.       var j;
  383.       var lastIdx;
  384.       var y;
  385.       if (end - mayParseLabeledStatementInstead >= this.rows / 3) {
  386.         parent = this.element.parentNode;
  387.         if (null != parent) {
  388.           parent.removeChild(this.element);
  389.         }
  390.       }
  391.       j = this.cols;
  392.       /** @type {number} */
  393.       y = mayParseLabeledStatementInstead;
  394.       if (end >= this.lines.length) {
  395.         /** @type {number} */
  396.         end = this.lines.length - 1;
  397.       }
  398.       for (;end >= y;) {
  399.         row = y + this.ydisp;
  400.         tokens = this.lines[row];
  401.         /** @type {string} */
  402.         xhtml = "";
  403.         lastIdx = y !== this.y || (this.ydisp !== this.ybase && !this.selectMode || this.cursorHidden) ? -1 / 0 : this.x;
  404.         attr = this.defAttr;
  405.         /** @type {number} */
  406.         i = 0;
  407.         for (;j > i;) {
  408.           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-" +
  409.           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) {
  410.             xhtml += codeSegments;
  411.           } else {
  412.             switch(codeSegments) {
  413.               case "&":
  414.                 xhtml += "&amp;";
  415.                 break;
  416.               case "<":
  417.                 xhtml += "&lt;";
  418.                 break;
  419.               case ">":
  420.                 xhtml += "&gt;";
  421.                 break;
  422.               default:
  423.                 if (" " >= codeSegments) {
  424.                   xhtml += "&nbsp;";
  425.                 } else {
  426.                   if (codeSegments > "\u00ef\u00bc\u20ac") {
  427.                     if ("\u00ef\u00bf\u00af" > codeSegments) {
  428.                       i++;
  429.                     }
  430.                   }
  431.                   xhtml += codeSegments;
  432.                 }
  433.               ;
  434.             }
  435.           }
  436.           if (i === lastIdx) {
  437.             xhtml += "</span>";
  438.           }
  439.           attr = data;
  440.           i++;
  441.         }
  442.         if (attr !== this.defAttr) {
  443.           xhtml += "</span>";
  444.         }
  445.         /** @type {string} */
  446.         this.children[y].innerHTML = xhtml;
  447.         y++;
  448.       }
  449.       return null != parent ? parent.appendChild(this.element) : void 0;
  450.     }, Terminal.prototype._cursorBlink = function() {
  451.       var messageDOM;
  452.       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;
  453.     }, Terminal.prototype.showCursor = function() {
  454.       return this.cursorState ? void 0 : (this.cursorState = 1, this.refresh(this.y, this.y));
  455.     }, Terminal.prototype.startBlink = function() {
  456.       return this.cursorBlink ? (this._blinker = function(dataAndEvents) {
  457.         return function() {
  458.           return dataAndEvents._cursorBlink();
  459.         };
  460.       }(this), this.t_blink = setInterval(this._blinker, 500)) : void 0;
  461.     }, Terminal.prototype.refreshBlink = function() {
  462.       return this.cursorBlink ? (clearInterval(this.t_blink), this.t_blink = setInterval(this._blinker, 500)) : void 0;
  463.     }, Terminal.prototype.scroll = function() {
  464.       var row;
  465.       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),
  466.       this.updateRange(this.scrollBottom);
  467.     }, Terminal.prototype.scrollDisp = function(disp) {
  468.       return this.ydisp += disp, this.ydisp > this.ybase ? this.ydisp = this.ybase : this.ydisp < 0 && (this.ydisp = 0), this.refresh(0, this.rows - 1);
  469.     }, Terminal.prototype.write = function(str) {
  470.       var ch;
  471.       var cs;
  472.       var i;
  473.       var row;
  474.       var l;
  475.       var e;
  476.       var f;
  477.       var frequency;
  478.       this.refreshStart = this.y;
  479.       this.refreshEnd = this.y;
  480.       if (this.ybase !== this.ydisp) {
  481.         this.ydisp = this.ybase;
  482.         this.maxRange();
  483.       }
  484.       /** @type {number} */
  485.       i = 0;
  486.       l = str.length;
  487.       for (;l > i;) {
  488.         switch(ch = str[i], this.state) {
  489.           case options.normal:
  490.             switch(ch) {
  491.               case "\u0007":
  492.                 this.bell();
  493.                 break;
  494.               case "\n":
  495.               ;
  496.               case "\x0B":
  497.               ;
  498.               case "\f":
  499.                 if (this.convertEol) {
  500.                   /** @type {number} */
  501.                   this.x = 0;
  502.                 }
  503.                 this.y++;
  504.                 if (this.y > this.scrollBottom) {
  505.                   this.y--;
  506.                   this.scroll();
  507.                 }
  508.                 break;
  509.               case "\r":
  510.                 /** @type {number} */
  511.                 this.x = 0;
  512.                 break;
  513.               case "\b":
  514.                 if (this.x > 0) {
  515.                   this.x--;
  516.                 }
  517.                 break;
  518.               case "\t":
  519.                 this.x = this.nextStop();
  520.                 break;
  521.               case "\u000e":
  522.                 this.setgLevel(1);
  523.                 break;
  524.               case "\u000f":
  525.                 this.setgLevel(0);
  526.                 break;
  527.               case "\u001b":
  528.                 this.state = options.escaped;
  529.                 break;
  530.               default:
  531.                 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)) {
  532.                   if (row = this.y + this.ybase, this.cols < 2 || this.x >= this.cols) {
  533.                     /** @type {Array} */
  534.                     this.lines[row][this.x - 1] = [this.curAttr, " "];
  535.                     break;
  536.                   }
  537.                   /** @type {Array} */
  538.                   this.lines[row][this.x] = [this.curAttr, " "];
  539.                   this.x++;
  540.                 }
  541.               ;
  542.             }
  543.             break;
  544.           case options.escaped:
  545.             switch(ch) {
  546.               case "[":
  547.                 /** @type {Array} */
  548.                 this.params = [];
  549.                 /** @type {number} */
  550.                 this.currentParam = 0;
  551.                 this.state = options.csi;
  552.                 break;
  553.               case "]":
  554.                 /** @type {Array} */
  555.                 this.params = [];
  556.                 /** @type {number} */
  557.                 this.currentParam = 0;
  558.                 this.state = options.osc;
  559.                 break;
  560.               case "P":
  561.                 /** @type {Array} */
  562.                 this.params = [];
  563.                 /** @type {number} */
  564.                 this.currentParam = 0;
  565.                 this.state = options.dcs;
  566.                 break;
  567.               case "_":
  568.                 this.state = options.ignore;
  569.                 break;
  570.               case "^":
  571.                 this.state = options.ignore;
  572.                 break;
  573.               case "c":
  574.                 this.reset();
  575.                 break;
  576.               case "E":
  577.                 /** @type {number} */
  578.                 this.x = 0;
  579.                 this.index();
  580.                 break;
  581.               case "D":
  582.                 this.index();
  583.                 break;
  584.               case "M":
  585.                 this.reverseIndex();
  586.                 break;
  587.               case "%":
  588.                 this.setgLevel(0);
  589.                 this.setgCharset(0, Terminal.prototype.charsets.US);
  590.                 this.state = options.normal;
  591.                 i++;
  592.                 break;
  593.               case "(":
  594.               ;
  595.               case ")":
  596.               ;
  597.               case "*":
  598.               ;
  599.               case "+":
  600.               ;
  601.               case "-":
  602.               ;
  603.               case ".":
  604.                 switch(ch) {
  605.                   case "(":
  606.                     /** @type {number} */
  607.                     this.gcharset = 0;
  608.                     break;
  609.                   case ")":
  610.                   ;
  611.                   case "-":
  612.                     /** @type {number} */
  613.                     this.gcharset = 1;
  614.                     break;
  615.                   case "*":
  616.                   ;
  617.                   case ".":
  618.                     /** @type {number} */
  619.                     this.gcharset = 2;
  620.                     break;
  621.                   case "+":
  622.                     /** @type {number} */
  623.                     this.gcharset = 3;
  624.                 }
  625.                 this.state = options.charset;
  626.                 break;
  627.               case "/":
  628.                 /** @type {number} */
  629.                 this.gcharset = 3;
  630.                 this.state = options.charset;
  631.                 i--;
  632.                 break;
  633.               case "n":
  634.                 this.setgLevel(2);
  635.                 break;
  636.               case "o":
  637.                 this.setgLevel(3);
  638.                 break;
  639.               case "|":
  640.                 this.setgLevel(3);
  641.                 break;
  642.               case "}":
  643.                 this.setgLevel(2);
  644.                 break;
  645.               case "~":
  646.                 this.setgLevel(1);
  647.                 break;
  648.               case "7":
  649.                 this.saveCursor();
  650.                 this.state = options.normal;
  651.                 break;
  652.               case "8":
  653.                 this.restoreCursor();
  654.                 this.state = options.normal;
  655.                 break;
  656.               case "#":
  657.                 this.state = options.normal;
  658.                 i++;
  659.                 break;
  660.               case "H":
  661.                 this.tabSet();
  662.                 break;
  663.               case "=":
  664.                 /** @type {boolean} */
  665.                 this.applicationKeypad = true;
  666.                 this.state = options.normal;
  667.                 break;
  668.               case ">":
  669.                 /** @type {boolean} */
  670.                 this.applicationKeypad = false;
  671.                 this.state = options.normal;
  672.                 break;
  673.               default:
  674.                 this.state = options.normal;
  675.                 console.log("Unknown ESC control:", ch);
  676.             }
  677.             break;
  678.           case options.charset:
  679.             switch(ch) {
  680.               case "0":
  681.                 cs = Terminal.prototype.charsets.SCLD;
  682.                 break;
  683.               case "A":
  684.                 /** @type {null} */
  685.                 cs = Terminal.prototype.charsets.UK;
  686.                 break;
  687.               case "B":
  688.                 /** @type {null} */
  689.                 cs = Terminal.prototype.charsets.US;
  690.                 break;
  691.               case "4":
  692.                 /** @type {null} */
  693.                 cs = Terminal.prototype.charsets.Dutch;
  694.                 break;
  695.               case "C":
  696.               ;
  697.               case "5":
  698.                 /** @type {null} */
  699.                 cs = Terminal.prototype.charsets.Finnish;
  700.                 break;
  701.               case "R":
  702.                 /** @type {null} */
  703.                 cs = Terminal.prototype.charsets.French;
  704.                 break;
  705.               case "Q":
  706.                 /** @type {null} */
  707.                 cs = Terminal.prototype.charsets.FrenchCanadian;
  708.                 break;
  709.               case "K":
  710.                 /** @type {null} */
  711.                 cs = Terminal.prototype.charsets.German;
  712.                 break;
  713.               case "Y":
  714.                 /** @type {null} */
  715.                 cs = Terminal.prototype.charsets.Italian;
  716.                 break;
  717.               case "E":
  718.               ;
  719.               case "6":
  720.                 /** @type {null} */
  721.                 cs = Terminal.prototype.charsets.NorwegianDanish;
  722.                 break;
  723.               case "Z":
  724.                 /** @type {null} */
  725.                 cs = Terminal.prototype.charsets.Spanish;
  726.                 break;
  727.               case "H":
  728.               ;
  729.               case "7":
  730.                 /** @type {null} */
  731.                 cs = Terminal.prototype.charsets.Swedish;
  732.                 break;
  733.               case "=":
  734.                 /** @type {null} */
  735.                 cs = Terminal.prototype.charsets.Swiss;
  736.                 break;
  737.               case "/":
  738.                 /** @type {null} */
  739.                 cs = Terminal.prototype.charsets.ISOLatin;
  740.                 i++;
  741.                 break;
  742.               default:
  743.                 /** @type {null} */
  744.                 cs = Terminal.prototype.charsets.US;
  745.             }
  746.             this.setgCharset(this.gcharset, cs);
  747.             /** @type {null} */
  748.             this.gcharset = null;
  749.             this.state = options.normal;
  750.             break;
  751.           case options.osc:
  752.             if ("\u001b" === ch || "\u0007" === ch) {
  753.               switch("\u001b" === ch && i++, this.params.push(this.currentParam), this.params[0]) {
  754.                 case 0:
  755.                 ;
  756.                 case 1:
  757.                 ;
  758.                 case 2:
  759.                   if (this.params[1]) {
  760.                     this.title = this.params[1] + " - \u00c6\u00b8\u00d3\u0153\u00c6\u00b7 butterfly";
  761.                     this.handleTitle(this.title);
  762.                   }
  763.                 ;
  764.               }
  765.               /** @type {Array} */
  766.               this.params = [];
  767.               /** @type {number} */
  768.               this.currentParam = 0;
  769.               this.state = options.normal;
  770.             } else {
  771.               if (this.params.length) {
  772.                 this.currentParam += ch;
  773.               } else {
  774.                 if (ch >= "0" && "9" >= ch) {
  775.                   /** @type {number} */
  776.                   this.currentParam = 10 * this.currentParam + ch.charCodeAt(0) - 48;
  777.                 } else {
  778.                   if (";" === ch) {
  779.                     this.params.push(this.currentParam);
  780.                     /** @type {string} */
  781.                     this.currentParam = "";
  782.                   }
  783.                 }
  784.               }
  785.             }
  786.             break;
  787.           case options.csi:
  788.             if ("?" === ch || (">" === ch || "!" === ch)) {
  789.               this.prefix = ch;
  790.               break;
  791.             }
  792.             if (ch >= "0" && "9" >= ch) {
  793.               /** @type {number} */
  794.               this.currentParam = 10 * this.currentParam + ch.charCodeAt(0) - 48;
  795.               break;
  796.             }
  797.             if ("$" === ch || ('"' === ch || (" " === ch || "'" === ch))) {
  798.               break;
  799.             }
  800.             if (this.params.push(this.currentParam), this.currentParam = 0, ";" === ch) {
  801.               break;
  802.             }
  803.             switch(this.state = options.normal, ch) {
  804.               case "A":
  805.                 this.cursorUp(this.params);
  806.                 break;
  807.               case "B":
  808.                 this.cursorDown(this.params);
  809.                 break;
  810.               case "C":
  811.                 this.cursorForward(this.params);
  812.                 break;
  813.               case "D":
  814.                 this.cursorBackward(this.params);
  815.                 break;
  816.               case "H":
  817.                 this.cursorPos(this.params);
  818.                 break;
  819.               case "J":
  820.                 this.eraseInDisplay(this.params);
  821.                 break;
  822.               case "K":
  823.                 this.eraseInLine(this.params);
  824.                 break;
  825.               case "m":
  826.                 if (!this.prefix) {
  827.                   this.charAttributes(this.params);
  828.                 }
  829.                 break;
  830.               case "n":
  831.                 if (!this.prefix) {
  832.                   this.deviceStatus(this.params);
  833.                 }
  834.                 break;
  835.               case "@":
  836.                 this.insertChars(this.params);
  837.                 break;
  838.               case "E":
  839.                 this.cursorNextLine(this.params);
  840.                 break;
  841.               case "F":
  842.                 this.cursorPrecedingLine(this.params);
  843.                 break;
  844.               case "G":
  845.                 this.cursorCharAbsolute(this.params);
  846.                 break;
  847.               case "L":
  848.                 this.insertLines(this.params);
  849.                 break;
  850.               case "M":
  851.                 this.deleteLines(this.params);
  852.                 break;
  853.               case "P":
  854.                 this.deleteChars(this.params);
  855.                 break;
  856.               case "X":
  857.                 this.eraseChars(this.params);
  858.                 break;
  859.               case "`":
  860.                 this.charPosAbsolute(this.params);
  861.                 break;
  862.               case "a":
  863.                 this.HPositionRelative(this.params);
  864.                 break;
  865.               case "c":
  866.                 this.sendDeviceAttributes(this.params);
  867.                 break;
  868.               case "d":
  869.                 this.linePosAbsolute(this.params);
  870.                 break;
  871.               case "e":
  872.                 this.VPositionRelative(this.params);
  873.                 break;
  874.               case "f":
  875.                 this.HVPosition(this.params);
  876.                 break;
  877.               case "h":
  878.                 this.setMode(this.params);
  879.                 break;
  880.               case "l":
  881.                 this.resetMode(this.params);
  882.                 break;
  883.               case "r":
  884.                 this.setScrollRegion(this.params);
  885.                 break;
  886.               case "s":
  887.                 this.saveCursor(this.params);
  888.                 break;
  889.               case "u":
  890.                 this.restoreCursor(this.params);
  891.                 break;
  892.               case "I":
  893.                 this.cursorForwardTab(this.params);
  894.                 break;
  895.               case "S":
  896.                 this.scrollUp(this.params);
  897.                 break;
  898.               case "T":
  899.                 if (this.params.length < 2) {
  900.                   if (!this.prefix) {
  901.                     this.scrollDown(this.params);
  902.                   }
  903.                 }
  904.                 break;
  905.               case "Z":
  906.                 this.cursorBackwardTab(this.params);
  907.                 break;
  908.               case "b":
  909.                 this.repeatPrecedingCharacter(this.params);
  910.                 break;
  911.               case "g":
  912.                 this.tabClear(this.params);
  913.                 break;
  914.               case "p":
  915.                 if ("!" === this.prefix) {
  916.                   this.softReset(this.params);
  917.                 }
  918.                 break;
  919.               default:
  920.                 console.error("Unknown CSI code: %s.", ch);
  921.             }
  922.             /** @type {string} */
  923.             this.prefix = "";
  924.             break;
  925.           case options.dcs:
  926.             if ("\u001b" === ch || "\u0007" === ch) {
  927.               switch("\u001b" === ch && i++, this.prefix) {
  928.                 case "":
  929.                   break;
  930.                 case "$q":
  931.                   switch(e = this.currentParam, f = false, e) {
  932.                     case '"q':
  933.                       /** @type {string} */
  934.                       e = '0"q';
  935.                       break;
  936.                     case '"p':
  937.                       /** @type {string} */
  938.                       e = '61"p';
  939.                       break;
  940.                     case "r":
  941.                       /** @type {string} */
  942.                       e = "" + (this.scrollTop + 1) + ";" + (this.scrollBottom + 1) + "r";
  943.                       break;
  944.                     case "m":
  945.                       /** @type {string} */
  946.                       e = "0m";
  947.                       break;
  948.                     default:
  949.                       console.error("Unknown DCS Pt: %s.", e);
  950.                       /** @type {string} */
  951.                       e = "";
  952.                   }
  953.                   this.send("\u001bP" + +f + "$r" + e + "\u001b\\");
  954.                   break;
  955.                 case "+q":
  956.                   e = this.currentParam;
  957.                   /** @type {boolean} */
  958.                   f = false;
  959.                   this.send("\u001bP" + +f + "+r" + e + "\u001b\\");
  960.                   break;
  961.                 default:
  962.                   console.error("Unknown DCS prefix: %s.", this.prefix);
  963.               }
  964.               /** @type {number} */
  965.               this.currentParam = 0;
  966.               /** @type {string} */
  967.               this.prefix = "";
  968.               this.state = options.normal;
  969.             } else {
  970.               if (this.currentParam) {
  971.                 this.currentParam += ch;
  972.               } else {
  973.                 if (this.prefix || ("$" === ch || "+" === ch)) {
  974.                   if (2 === this.prefix.length) {
  975.                     this.currentParam = ch;
  976.                   } else {
  977.                     this.prefix += ch;
  978.                   }
  979.                 } else {
  980.                   this.currentParam = ch;
  981.                 }
  982.               }
  983.             }
  984.             break;
  985.           case options.ignore:
  986.             if ("\u001b" === ch || "\u0007" === ch) {
  987.               if ("\u001b" === ch) {
  988.                 i++;
  989.               }
  990.               this.state = options.normal;
  991.             }
  992.           ;
  993.         }
  994.         i++;
  995.       }
  996.       return this.updateRange(this.y), this.refresh(this.refreshStart, this.refreshEnd);
  997.     }, Terminal.prototype.writeln = function(msg) {
  998.       return this.write("" + msg + "\r\n");
  999.     }, Terminal.prototype.keyDown = function(evt) {
  1000.       var to;
  1001.       var until;
  1002.       var last_cc;
  1003.       var keysym;
  1004.       if (evt.keyCode > 15 && evt.keyCode < 19) {
  1005.         return true;
  1006.       }
  1007.       if ((evt.shiftKey || evt.ctrlKey) && 45 === evt.keyCode) {
  1008.         return true;
  1009.       }
  1010.       if (evt.shiftKey && (evt.ctrlKey && (67 === (keysym = evt.keyCode) || 86 === keysym))) {
  1011.         return true;
  1012.       }
  1013.       if (evt.altKey && (90 === evt.keyCode && !this.skipNextKey)) {
  1014.         return this.skipNextKey = true, this.element.classList.add("skip"), cancel(evt);
  1015.       }
  1016.       if (this.skipNextKey) {
  1017.         return this.skipNextKey = false, this.element.classList.remove("skip"), true;
  1018.       }
  1019.       switch(evt.keyCode) {
  1020.         case 8:
  1021.           if (until = evt.altKey ? "\u001b" : "", evt.shiftKey) {
  1022.             until += "\b";
  1023.             break;
  1024.           }
  1025.           until += "\u007f";
  1026.           break;
  1027.         case 9:
  1028.           if (evt.shiftKey) {
  1029.             /** @type {string} */
  1030.             until = "\u001b[Z";
  1031.             break;
  1032.           }
  1033.           /** @type {string} */
  1034.           until = "\t";
  1035.           break;
  1036.         case 13:
  1037.           /** @type {string} */
  1038.           until = "\r";
  1039.           break;
  1040.         case 27:
  1041.           /** @type {string} */
  1042.           until = "\u001b";
  1043.           break;
  1044.         case 37:
  1045.           if (this.applicationCursor) {
  1046.             /** @type {string} */
  1047.             until = "\u001bOD";
  1048.             break;
  1049.           }
  1050.           /** @type {string} */
  1051.           until = "\u001b[D";
  1052.           break;
  1053.         case 39:
  1054.           if (this.applicationCursor) {
  1055.             /** @type {string} */
  1056.             until = "\u001bOC";
  1057.             break;
  1058.           }
  1059.           /** @type {string} */
  1060.           until = "\u001b[C";
  1061.           break;
  1062.         case 38:
  1063.           if (this.applicationCursor) {
  1064.             /** @type {string} */
  1065.             until = "\u001bOA";
  1066.             break;
  1067.           }
  1068.           if (evt.ctrlKey) {
  1069.             return this.scrollDisp(-1), cancel(evt);
  1070.           }
  1071.           /** @type {string} */
  1072.           until = "\u001b[A";
  1073.           break;
  1074.         case 40:
  1075.           if (this.applicationCursor) {
  1076.             /** @type {string} */
  1077.             until = "\u001bOB";
  1078.             break;
  1079.           }
  1080.           if (evt.ctrlKey) {
  1081.             return this.scrollDisp(1), cancel(evt);
  1082.           }
  1083.           /** @type {string} */
  1084.           until = "\u001b[B";
  1085.           break;
  1086.         case 46:
  1087.           /** @type {string} */
  1088.           until = "\u001b[3~";
  1089.           break;
  1090.         case 45:
  1091.           /** @type {string} */
  1092.           until = "\u001b[2~";
  1093.           break;
  1094.         case 36:
  1095.           if (this.applicationKeypad) {
  1096.             /** @type {string} */
  1097.             until = "\u001bOH";
  1098.             break;
  1099.           }
  1100.           /** @type {string} */
  1101.           until = "\u001bOH";
  1102.           break;
  1103.         case 35:
  1104.           if (this.applicationKeypad) {
  1105.             /** @type {string} */
  1106.             until = "\u001bOF";
  1107.             break;
  1108.           }
  1109.           /** @type {string} */
  1110.           until = "\u001bOF";
  1111.           break;
  1112.         case 33:
  1113.           if (evt.shiftKey) {
  1114.             return this.scrollDisp(-(this.rows - 1)), cancel(evt);
  1115.           }
  1116.           /** @type {string} */
  1117.           until = "\u001b[5~";
  1118.           break;
  1119.         case 34:
  1120.           if (evt.shiftKey) {
  1121.             return this.scrollDisp(this.rows - 1), cancel(evt);
  1122.           }
  1123.           /** @type {string} */
  1124.           until = "\u001b[6~";
  1125.           break;
  1126.         case 112:
  1127.           /** @type {string} */
  1128.           until = "\u001bOP";
  1129.           break;
  1130.         case 113:
  1131.           /** @type {string} */
  1132.           until = "\u001bOQ";
  1133.           break;
  1134.         case 114:
  1135.           /** @type {string} */
  1136.           until = "\u001bOR";
  1137.           break;
  1138.         case 115:
  1139.           /** @type {string} */
  1140.           until = "\u001bOS";
  1141.           break;
  1142.         case 116:
  1143.           /** @type {string} */
  1144.           until = "\u001b[15~";
  1145.           break;
  1146.         case 117:
  1147.           /** @type {string} */
  1148.           until = "\u001b[17~";
  1149.           break;
  1150.         case 118:
  1151.           /** @type {string} */
  1152.           until = "\u001b[18~";
  1153.           break;
  1154.         case 119:
  1155.           /** @type {string} */
  1156.           until = "\u001b[19~";
  1157.           break;
  1158.         case 120:
  1159.           /** @type {string} */
  1160.           until = "\u001b[20~";
  1161.           break;
  1162.         case 121:
  1163.           /** @type {string} */
  1164.           until = "\u001b[21~";
  1165.           break;
  1166.         case 122:
  1167.           /** @type {string} */
  1168.           until = "\u001b[23~";
  1169.           break;
  1170.         case 123:
  1171.           /** @type {string} */
  1172.           until = "\u001b[24~";
  1173.           break;
  1174.         default:
  1175.           if (evt.ctrlKey) {
  1176.             if (evt.keyCode >= 65 && evt.keyCode <= 90) {
  1177.               if (67 === evt.keyCode) {
  1178.                 if (last_cc = (new Date).getTime(), last_cc - this.last_cc < 75) {
  1179.                   /** @type {number} */
  1180.                   to = setTimeout(function() {
  1181.                   }) - 6;
  1182.                   this.write("\r\n --8<------8<-- Sectioned --8<------8<-- \r\n\r\n");
  1183.                   for (;to--;) {
  1184.                     if (to !== this.t_bell) {
  1185.                       if (to !== this.t_queue) {
  1186.                         if (to !== this.t_blink) {
  1187.                           clearTimeout(to);
  1188.                         }
  1189.                       }
  1190.                     }
  1191.                   }
  1192.                 }
  1193.                 /** @type {number} */
  1194.                 this.last_cc = last_cc;
  1195.               }
  1196.               /** @type {string} */
  1197.               until = String.fromCharCode(evt.keyCode - 64);
  1198.             } else {
  1199.               if (32 === evt.keyCode) {
  1200.                 /** @type {string} */
  1201.                 until = String.fromCharCode(0);
  1202.               } else {
  1203.                 if (evt.keyCode >= 51 && evt.keyCode <= 55) {
  1204.                   /** @type {string} */
  1205.                   until = String.fromCharCode(evt.keyCode - 51 + 27);
  1206.                 } else {
  1207.                   if (56 === evt.keyCode) {
  1208.                     /** @type {string} */
  1209.                     until = String.fromCharCode(127);
  1210.                   } else {
  1211.                     if (219 === evt.keyCode) {
  1212.                       /** @type {string} */
  1213.                       until = String.fromCharCode(27);
  1214.                     } else {
  1215.                       if (221 === evt.keyCode) {
  1216.                         /** @type {string} */
  1217.                         until = String.fromCharCode(29);
  1218.                       }
  1219.                     }
  1220.                   }
  1221.                 }
  1222.               }
  1223.             }
  1224.           } else {
  1225.             if (evt.altKey && indexOf.call(navigator.platform, "Mac") < 0 || evt.metaKey && indexOf.call(navigator.platform, "Mac") >= 0) {
  1226.               if (evt.keyCode >= 65 && evt.keyCode <= 90) {
  1227.                 /** @type {string} */
  1228.                 until = "\u001b" + String.fromCharCode(evt.keyCode + 32);
  1229.               } else {
  1230.                 if (192 === evt.keyCode) {
  1231.                   /** @type {string} */
  1232.                   until = "\u001b`";
  1233.                 } else {
  1234.                   if (evt.keyCode >= 48) {
  1235.                     if (evt.keyCode <= 57) {
  1236.                       /** @type {string} */
  1237.                       until = "\u001b" + (evt.keyCode - 48);
  1238.                     }
  1239.                   }
  1240.                 }
  1241.               }
  1242.             }
  1243.           }
  1244.         ;
  1245.       }
  1246.       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;
  1247.     }, Terminal.prototype.setgLevel = function(desiredNonCommentArgIndex) {
  1248.       return this.glevel = desiredNonCommentArgIndex, this.charset = this.charsets[desiredNonCommentArgIndex];
  1249.     }, Terminal.prototype.setgCharset = function(g, charset) {
  1250.       return this.charsets[g] = charset, this.glevel === g ? this.charset = charset : void 0;
  1251.     }, Terminal.prototype.keyPress = function(ev) {
  1252.       var key;
  1253.       if (this.skipNextKey === false) {
  1254.         return this.skipNextKey = null, true;
  1255.       }
  1256.       if (cancel(ev), ev.charCode) {
  1257.         key = ev.charCode;
  1258.       } else {
  1259.         if (null == ev.which) {
  1260.           key = ev.keyCode;
  1261.         } else {
  1262.           if (0 === ev.which || 0 === ev.charCode) {
  1263.             return false;
  1264.           }
  1265.           key = ev.which;
  1266.         }
  1267.       }
  1268.       return!key || (ev.ctrlKey || (ev.altKey || ev.metaKey)) ? false : (key = String.fromCharCode(key), this.showCursor(), this.handler(key), false);
  1269.     }, Terminal.prototype.send = function(data) {
  1270.       return this.queue || (this.t_queue = setTimeout(function(self) {
  1271.         return function() {
  1272.           return self.handler(self.queue), self.queue = "";
  1273.         };
  1274.       }(this), 1)), this.queue += data;
  1275.     }, Terminal.prototype.bell = function() {
  1276.       return this.visualBell ? (this.element.classList.add("bell"), this.t_bell = setTimeout(function(label) {
  1277.         return function() {
  1278.           return label.element.classList.remove("bell");
  1279.         };
  1280.       }(this), this.visualBell)) : void 0;
  1281.     }, Terminal.prototype.resize = function() {
  1282.       var copies;
  1283.       var editor;
  1284.       var i;
  1285.       var r;
  1286.       var line;
  1287.       var j;
  1288.       var c;
  1289.       var pixelSize;
  1290.       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) {
  1291.         if (this.ctl("Resize", this.cols, this.rows), j < this.cols) {
  1292.           /** @type {Array} */
  1293.           copies = [this.defAttr, " "];
  1294.           i = this.lines.length;
  1295.           for (;i--;) {
  1296.             for (;this.lines[i].length < this.cols;) {
  1297.               this.lines[i].push(copies);
  1298.             }
  1299.           }
  1300.         } else {
  1301.           if (j > this.cols) {
  1302.             i = this.lines.length;
  1303.             for (;i--;) {
  1304.               for (;this.lines[i].length > this.cols;) {
  1305.                 this.lines[i].pop();
  1306.               }
  1307.             }
  1308.           }
  1309.         }
  1310.         if (this.setupStops(j), r = c, r < this.rows) {
  1311.           editor = this.element;
  1312.           for (;r++ < this.rows;) {
  1313.             if (this.lines.length < this.rows + this.ybase) {
  1314.               this.lines.push(this.blankLine());
  1315.             }
  1316.             if (this.children.length < this.rows) {
  1317.               line = this.document.createElement("div");
  1318.               /** @type {string} */
  1319.               line.className = "line";
  1320.               /** @type {string} */
  1321.               line.style.height = this.char_size.height + "px";
  1322.               editor.appendChild(line);
  1323.               this.children.push(line);
  1324.             }
  1325.           }
  1326.         } else {
  1327.           if (r > this.rows) {
  1328.             for (;r-- > this.rows;) {
  1329.               if (this.lines.length > this.rows + this.ybase && this.lines.pop(), this.children.length > this.rows) {
  1330.                 if (editor = this.children.pop(), !editor) {
  1331.                   continue;
  1332.                 }
  1333.                 editor.parentNode.removeChild(editor);
  1334.               }
  1335.             }
  1336.           }
  1337.         }
  1338.         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;
  1339.       }
  1340.     }, Terminal.prototype.updateRange = function(y) {
  1341.       return y < this.refreshStart && (this.refreshStart = y), y > this.refreshEnd ? this.refreshEnd = y : void 0;
  1342.     }, Terminal.prototype.maxRange = function() {
  1343.       return this.refreshStart = 0, this.refreshEnd = this.rows - 1;
  1344.     }, Terminal.prototype.setupStops = function(i) {
  1345.       var _results2;
  1346.       if (null != i) {
  1347.         if (!this.tabs[i]) {
  1348.           i = this.prevStop(i);
  1349.         }
  1350.       } else {
  1351.         this.tabs = {};
  1352.         /** @type {number} */
  1353.         i = 0;
  1354.       }
  1355.       /** @type {Array} */
  1356.       _results2 = [];
  1357.       for (;i < this.cols;) {
  1358.         /** @type {boolean} */
  1359.         this.tabs[i] = true;
  1360.         _results2.push(i += 8);
  1361.       }
  1362.       return _results2;
  1363.     }, Terminal.prototype.prevStop = function(x) {
  1364.       if (null == x) {
  1365.         x = this.x;
  1366.       }
  1367.       for (;!this.tabs[--x] && x > 0;) {
  1368.       }
  1369.       return x >= this.cols ? this.cols - 1 : 0 > x ? 0 : x;
  1370.     }, Terminal.prototype.nextStop = function(x) {
  1371.       if (null == x) {
  1372.         x = this.x;
  1373.       }
  1374.       for (;!this.tabs[++x] && x < this.cols;) {
  1375.       }
  1376.       return x >= this.cols ? this.cols - 1 : 0 > x ? 0 : x;
  1377.     }, Terminal.prototype.eraseRight = function(x, y) {
  1378.       var v;
  1379.       var cache;
  1380.       cache = this.lines[this.ybase + y];
  1381.       /** @type {Array} */
  1382.       v = [this.eraseAttr(), " "];
  1383.       for (;x < this.cols;) {
  1384.         /** @type {Array} */
  1385.         cache[x] = v;
  1386.         x++;
  1387.       }
  1388.       return this.updateRange(y);
  1389.     }, Terminal.prototype.eraseLeft = function(i, y) {
  1390.       var o;
  1391.       var passedValues;
  1392.       passedValues = this.lines[this.ybase + y];
  1393.       /** @type {Array} */
  1394.       o = [this.eraseAttr(), " "];
  1395.       i++;
  1396.       for (;i--;) {
  1397.         /** @type {Array} */
  1398.         passedValues[i] = o;
  1399.       }
  1400.       return this.updateRange(y);
  1401.     }, Terminal.prototype.eraseLine = function(y) {
  1402.       return this.eraseRight(0, y);
  1403.     }, Terminal.prototype.blankLine = function(dataAndEvents) {
  1404.       var defAttr;
  1405.       var o;
  1406.       var i;
  1407.       var passedValues;
  1408.       defAttr = dataAndEvents ? this.eraseAttr() : this.defAttr;
  1409.       /** @type {Array} */
  1410.       o = [defAttr, " "];
  1411.       /** @type {Array} */
  1412.       passedValues = [];
  1413.       /** @type {number} */
  1414.       i = 0;
  1415.       for (;i < this.cols;) {
  1416.         /** @type {Array} */
  1417.         passedValues[i] = o;
  1418.         i++;
  1419.       }
  1420.       return passedValues;
  1421.     }, Terminal.prototype.ch = function(cur) {
  1422.       return cur ? [this.eraseAttr(), " "] : [this.defAttr, " "];
  1423.     }, Terminal.prototype.isterm = function(term) {
  1424.       return 0 === ("" + this.termName).indexOf(term);
  1425.     }, Terminal.prototype.handler = function(arg) {
  1426.       return this.out(arg);
  1427.     }, Terminal.prototype.handleTitle = function(title) {
  1428.       return document.title = title;
  1429.     }, Terminal.prototype.index = function() {
  1430.       return this.y++, this.y > this.scrollBottom && (this.y--, this.scroll()), this.state = options.normal;
  1431.     }, Terminal.prototype.reverseIndex = function() {
  1432.       var j;
  1433.       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;
  1434.     }, Terminal.prototype.reset = function() {
  1435.       return this.reset_vars(), this.refresh(0, this.rows - 1);
  1436.     }, Terminal.prototype.tabSet = function() {
  1437.       return this.tabs[this.x] = true, this.state = options.normal;
  1438.     }, Terminal.prototype.cursorUp = function(param) {
  1439.       var y;
  1440.       return y = param[0], 1 > y && (y = 1), this.y -= y, this.y < 0 ? this.y = 0 : void 0;
  1441.     }, Terminal.prototype.cursorDown = function(n) {
  1442.       var s;
  1443.       return s = n[0], 1 > s && (s = 1), this.y += s, this.y >= this.rows ? this.y = this.rows - 1 : void 0;
  1444.     }, Terminal.prototype.cursorForward = function(xs) {
  1445.       var x;
  1446.       return x = xs[0], 1 > x && (x = 1), this.x += x, this.x >= this.cols ? this.x = this.cols - 1 : void 0;
  1447.     }, Terminal.prototype.cursorBackward = function(xs) {
  1448.       var x;
  1449.       return x = xs[0], 1 > x && (x = 1), this.x -= x, this.x < 0 ? this.x = 0 : void 0;
  1450.     }, Terminal.prototype.cursorPos = function(container) {
  1451.       var col;
  1452.       var row;
  1453.       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;
  1454.     }, Terminal.prototype.eraseInDisplay = function(n) {
  1455.       var j;
  1456.       var _results;
  1457.       var fileSet;
  1458.       var mapPositionArr;
  1459.       switch(n[0]) {
  1460.         case 0:
  1461.           this.eraseRight(this.x, this.y);
  1462.           j = this.y + 1;
  1463.           /** @type {Array} */
  1464.           _results = [];
  1465.           for (;j < this.rows;) {
  1466.             this.eraseLine(j);
  1467.             _results.push(j++);
  1468.           }
  1469.           return _results;
  1470.         case 1:
  1471.           this.eraseLeft(this.x, this.y);
  1472.           j = this.y;
  1473.           /** @type {Array} */
  1474.           fileSet = [];
  1475.           for (;j--;) {
  1476.             fileSet.push(this.eraseLine(j));
  1477.           }
  1478.           return fileSet;
  1479.         case 2:
  1480.           j = this.rows;
  1481.           /** @type {Array} */
  1482.           mapPositionArr = [];
  1483.           for (;j--;) {
  1484.             mapPositionArr.push(this.eraseLine(j));
  1485.           }
  1486.           return mapPositionArr;
  1487.       }
  1488.     }, Terminal.prototype.eraseInLine = function(n) {
  1489.       switch(n[0]) {
  1490.         case 0:
  1491.           return this.eraseRight(this.x, this.y);
  1492.         case 1:
  1493.           return this.eraseLeft(this.x, this.y);
  1494.         case 2:
  1495.           return this.eraseLine(this.y);
  1496.       }
  1497.     }, Terminal.prototype.charAttributes = function(params) {
  1498.       var alignValue;
  1499.       var o2;
  1500.       var o1;
  1501.       var key;
  1502.       var id;
  1503.       var val;
  1504.       if (1 === params.length && 0 === params[0]) {
  1505.         return void(this.curAttr = this.defAttr);
  1506.       }
  1507.       /** @type {number} */
  1508.       o1 = this.curAttr >> 18;
  1509.       /** @type {number} */
  1510.       o2 = this.curAttr >> 9 & 511;
  1511.       /** @type {number} */
  1512.       alignValue = 511 & this.curAttr;
  1513.       id = params.length;
  1514.       /** @type {number} */
  1515.       key = 0;
  1516.       for (;id > key;) {
  1517.         val = params[key];
  1518.         if (val >= 30 && 37 >= val) {
  1519.           /** @type {number} */
  1520.           o2 = val - 30;
  1521.         } else {
  1522.           if (val >= 40 && 47 >= val) {
  1523.             /** @type {number} */
  1524.             alignValue = val - 40;
  1525.           } else {
  1526.             if (val >= 90 && 97 >= val) {
  1527.               val += 8;
  1528.               /** @type {number} */
  1529.               o2 = val - 90;
  1530.             } else {
  1531.               if (val >= 100 && 107 >= val) {
  1532.                 val += 8;
  1533.                 /** @type {number} */
  1534.                 alignValue = val - 100;
  1535.               } else {
  1536.                 if (0 === val) {
  1537.                   /** @type {number} */
  1538.                   o1 = this.defAttr >> 18;
  1539.                   /** @type {number} */
  1540.                   o2 = this.defAttr >> 9 & 511;
  1541.                   /** @type {number} */
  1542.                   alignValue = 511 & this.defAttr;
  1543.                 } else {
  1544.                   if (1 === val) {
  1545.                     o1 |= 1;
  1546.                   } else {
  1547.                     if (4 === val) {
  1548.                       o1 |= 2;
  1549.                     } else {
  1550.                       if (5 === val) {
  1551.                         o1 |= 4;
  1552.                       } else {
  1553.                         if (7 === val) {
  1554.                           o1 |= 8;
  1555.                         } else {
  1556.                           if (8 === val) {
  1557.                             o1 |= 16;
  1558.                           } else {
  1559.                             if (22 === val) {
  1560.                               o1 &= -2;
  1561.                             } else {
  1562.                               if (24 === val) {
  1563.                                 o1 &= -3;
  1564.                               } else {
  1565.                                 if (25 === val) {
  1566.                                   o1 &= -5;
  1567.                                 } else {
  1568.                                   if (27 === val) {
  1569.                                     o1 &= -9;
  1570.                                   } else {
  1571.                                     if (28 === val) {
  1572.                                       o1 &= -17;
  1573.                                     } else {
  1574.                                       if (39 === val) {
  1575.                                         /** @type {number} */
  1576.                                         o2 = this.defAttr >> 9 & 511;
  1577.                                       } else {
  1578.                                         if (49 === val) {
  1579.                                           /** @type {number} */
  1580.                                           alignValue = 511 & this.defAttr;
  1581.                                         } else {
  1582.                                           if (38 === val) {
  1583.                                             if (2 === params[key + 1]) {
  1584.                                               key += 2;
  1585.                                               /** @type {number} */
  1586.                                               o2 = "#" + params[key] & 255 + params[key + 1] & 255 + params[key + 2] & 255;
  1587.                                               key += 2;
  1588.                                             } else {
  1589.                                               if (5 === params[key + 1]) {
  1590.                                                 key += 2;
  1591.                                                 /** @type {number} */
  1592.                                                 o2 = 255 & params[key];
  1593.                                               }
  1594.                                             }
  1595.                                           } else {
  1596.                                             if (48 === val) {
  1597.                                               if (2 === params[key + 1]) {
  1598.                                                 key += 2;
  1599.                                                 /** @type {number} */
  1600.                                                 alignValue = "#" + params[key] & 255 + params[key + 1] & 255 + params[key + 2] & 255;
  1601.                                                 key += 2;
  1602.                                               } else {
  1603.                                                 if (5 === params[key + 1]) {
  1604.                                                   key += 2;
  1605.                                                   /** @type {number} */
  1606.                                                   alignValue = 255 & params[key];
  1607.                                                 }
  1608.                                               }
  1609.                                             } else {
  1610.                                               if (100 === val) {
  1611.                                                 /** @type {number} */
  1612.                                                 o2 = this.defAttr >> 9 & 511;
  1613.                                                 /** @type {number} */
  1614.                                                 alignValue = 511 & this.defAttr;
  1615.                                               } else {
  1616.                                                 console.error("Unknown SGR attribute: %d.", val);
  1617.                                               }
  1618.                                             }
  1619.                                           }
  1620.                                         }
  1621.                                       }
  1622.                                     }
  1623.                                   }
  1624.                                 }
  1625.                               }
  1626.                             }
  1627.                           }
  1628.                         }
  1629.                       }
  1630.                     }
  1631.                   }
  1632.                 }
  1633.               }
  1634.             }
  1635.           }
  1636.         }
  1637.         key++;
  1638.       }
  1639.       return this.curAttr = o1 << 18 | o2 << 9 | alignValue;
  1640.     }, Terminal.prototype.deviceStatus = function(dec) {
  1641.       if (this.prefix) {
  1642.         if ("?" === this.prefix && 6 === dec[0]) {
  1643.           return this.send("\u001b[?" + (this.y + 1) + ";" + (this.x + 1) + "R");
  1644.         }
  1645.       } else {
  1646.         switch(dec[0]) {
  1647.           case 5:
  1648.             return this.send("\u001b[0n");
  1649.           case 6:
  1650.             return this.send("\u001b[" + (this.y + 1) + ";" + (this.x + 1) + "R");
  1651.         }
  1652.       }
  1653.     }, Terminal.prototype.insertChars = function(params) {
  1654.       var block;
  1655.       var j;
  1656.       var param;
  1657.       var row;
  1658.       var eventPath;
  1659.       param = params[0];
  1660.       if (1 > param) {
  1661.         /** @type {number} */
  1662.         param = 1;
  1663.       }
  1664.       row = this.y + this.ybase;
  1665.       j = this.x;
  1666.       /** @type {Array} */
  1667.       block = [this.eraseAttr(), " "];
  1668.       /** @type {Array} */
  1669.       eventPath = [];
  1670.       for (;param-- && j < this.cols;) {
  1671.         this.lines[row].splice(j++, 0, block);
  1672.         eventPath.push(this.lines[row].pop());
  1673.       }
  1674.       return eventPath;
  1675.     }, Terminal.prototype.cursorNextLine = function(param) {
  1676.       var y;
  1677.       return y = param[0], 1 > y && (y = 1), this.y += y, this.y >= this.rows && (this.y = this.rows - 1), this.x = 0;
  1678.     }, Terminal.prototype.cursorPrecedingLine = function(param) {
  1679.       var y;
  1680.       return y = param[0], 1 > y && (y = 1), this.y -= y, this.y < 0 && (this.y = 0), this.x = 0;
  1681.     }, Terminal.prototype.cursorCharAbsolute = function(xs) {
  1682.       var x;
  1683.       return x = xs[0], 1 > x && (x = 1), this.x = x - 1;
  1684.     }, Terminal.prototype.insertLines = function(lines) {
  1685.       var j;
  1686.       var line;
  1687.       var row;
  1688.       line = lines[0];
  1689.       if (1 > line) {
  1690.         /** @type {number} */
  1691.         line = 1;
  1692.       }
  1693.       row = this.y + this.ybase;
  1694.       /** @type {number} */
  1695.       j = this.rows - 1 - this.scrollBottom;
  1696.       /** @type {number} */
  1697.       j = this.rows - 1 + this.ybase - j + 1;
  1698.       for (;line--;) {
  1699.         this.lines.splice(row, 0, this.blankLine(true));
  1700.         this.lines.splice(j, 1);
  1701.       }
  1702.       return this.updateRange(this.y), this.updateRange(this.scrollBottom);
  1703.     }, Terminal.prototype.deleteLines = function(opt_nodes) {
  1704.       var j;
  1705.       var node;
  1706.       var row;
  1707.       node = opt_nodes[0];
  1708.       if (1 > node) {
  1709.         /** @type {number} */
  1710.         node = 1;
  1711.       }
  1712.       row = this.y + this.ybase;
  1713.       /** @type {number} */
  1714.       j = this.rows - 1 - this.scrollBottom;
  1715.       /** @type {number} */
  1716.       j = this.rows - 1 + this.ybase - j;
  1717.       for (;node--;) {
  1718.         this.lines.splice(j + 1, 0, this.blankLine(true));
  1719.         this.lines.splice(row, 1);
  1720.       }
  1721.       return this.updateRange(this.y), this.updateRange(this.scrollBottom);
  1722.     }, Terminal.prototype.deleteChars = function(opt_nodes) {
  1723.       var paths;
  1724.       var node;
  1725.       var row;
  1726.       var rulesets;
  1727.       node = opt_nodes[0];
  1728.       if (1 > node) {
  1729.         /** @type {number} */
  1730.         node = 1;
  1731.       }
  1732.       row = this.y + this.ybase;
  1733.       /** @type {Array} */
  1734.       paths = [this.eraseAttr(), " "];
  1735.       /** @type {Array} */
  1736.       rulesets = [];
  1737.       for (;node--;) {
  1738.         this.lines[row].splice(this.x, 1);
  1739.         rulesets.push(this.lines[row].push(paths));
  1740.       }
  1741.       return rulesets;
  1742.     }, Terminal.prototype.eraseChars = function(params) {
  1743.       var left;
  1744.       var j;
  1745.       var param;
  1746.       var row;
  1747.       var EXPRESSION_START;
  1748.       param = params[0];
  1749.       if (1 > param) {
  1750.         /** @type {number} */
  1751.         param = 1;
  1752.       }
  1753.       row = this.y + this.ybase;
  1754.       j = this.x;
  1755.       /** @type {Array} */
  1756.       left = [this.eraseAttr(), " "];
  1757.       /** @type {Array} */
  1758.       EXPRESSION_START = [];
  1759.       for (;param-- && j < this.cols;) {
  1760.         EXPRESSION_START.push(this.lines[row][j++] = left);
  1761.       }
  1762.       return EXPRESSION_START;
  1763.     }, Terminal.prototype.charPosAbsolute = function(xs) {
  1764.       var x;
  1765.       return x = xs[0], 1 > x && (x = 1), this.x = x - 1, this.x >= this.cols ? this.x = this.cols - 1 : void 0;
  1766.     }, Terminal.prototype.HPositionRelative = function(xs) {
  1767.       var x;
  1768.       return x = xs[0], 1 > x && (x = 1), this.x += x, this.x >= this.cols ? this.x = this.cols - 1 : void 0;
  1769.     }, Terminal.prototype.sendDeviceAttributes = function(params) {
  1770.       if (!(params[0] > 0)) {
  1771.         if (this.prefix) {
  1772.           if (">" === this.prefix) {
  1773.             if (this.isterm("xterm")) {
  1774.               return this.send("\u001b[>0;276;0c");
  1775.             }
  1776.             if (this.isterm("rxvt-unicode")) {
  1777.               return this.send("\u001b[>85;95;0c");
  1778.             }
  1779.             if (this.isterm("linux")) {
  1780.               return this.send(params[0] + "c");
  1781.             }
  1782.             if (this.isterm("screen")) {
  1783.               return this.send("\u001b[>83;40003;0c");
  1784.             }
  1785.           }
  1786.         } else {
  1787.           if (this.isterm("xterm") || (this.isterm("rxvt-unicode") || this.isterm("screen"))) {
  1788.             return this.send("\u001b[?1;2c");
  1789.           }
  1790.           if (this.isterm("linux")) {
  1791.             return this.send("\u001b[?6c");
  1792.           }
  1793.         }
  1794.       }
  1795.     }, Terminal.prototype.linePosAbsolute = function(param) {
  1796.       var y;
  1797.       return y = param[0], 1 > y && (y = 1), this.y = y - 1, this.y >= this.rows ? this.y = this.rows - 1 : void 0;
  1798.     }, Terminal.prototype.VPositionRelative = function(param) {
  1799.       var y;
  1800.       return y = param[0], 1 > y && (y = 1), this.y += y, this.y >= this.rows ? this.y = this.rows - 1 : void 0;
  1801.     }, Terminal.prototype.HVPosition = function(col) {
  1802.       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;
  1803.     }, Terminal.prototype.setMode = function(params) {
  1804.       var i;
  1805.       var l;
  1806.       var defaults;
  1807.       if ("object" != typeof params) {
  1808.         if ("?" === this.prefix) {
  1809.           switch(params) {
  1810.             case 1:
  1811.               return this.applicationCursor = true;
  1812.             case 2:
  1813.               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);
  1814.             case 3:
  1815.               return this.savedCols = this.cols, this.resize(132, this.rows);
  1816.             case 6:
  1817.               return this.originMode = true;
  1818.             case 7:
  1819.               return this.wraparoundMode = true;
  1820.             case 66:
  1821.               return this.applicationKeypad = true;
  1822.             case 9:
  1823.             ;
  1824.             case 1E3:
  1825.             ;
  1826.             case 1002:
  1827.             ;
  1828.             case 1003:
  1829.               return this.x10Mouse = 9 === params, this.vt200Mouse = 1E3 === params, this.normalMouse = params > 1E3, this.mouseEvents = true, this.element.style.cursor = "pointer";
  1830.             case 1004:
  1831.               return this.sendFocus = true;
  1832.             case 1005:
  1833.               return this.utfMouse = true;
  1834.             case 1006:
  1835.               return this.sgrMouse = true;
  1836.             case 1015:
  1837.               return this.urxvtMouse = true;
  1838.             case 25:
  1839.               return this.cursorHidden = false;
  1840.             case 1049:
  1841.             ;
  1842.             case 47:
  1843.             ;
  1844.             case 1047:
  1845.               if (!this.normal) {
  1846.                 return defaults = {
  1847.                   lines : this.lines,
  1848.                   ybase : this.ybase,
  1849.                   ydisp : this.ydisp,
  1850.                   x : this.x,
  1851.                   y : this.y,
  1852.                   scrollTop : this.scrollTop,
  1853.                   scrollBottom : this.scrollBottom,
  1854.                   tabs : this.tabs
  1855.                 }, this.reset(), this.normal = defaults, this.showCursor();
  1856.               }
  1857.             ;
  1858.           }
  1859.         }
  1860.       } else {
  1861.         l = params.length;
  1862.         /** @type {number} */
  1863.         i = 0;
  1864.         for (;l > i;) {
  1865.           this.setMode(params[i]);
  1866.           i++;
  1867.         }
  1868.       }
  1869.     }, Terminal.prototype.resetMode = function(params) {
  1870.       var i;
  1871.       var l;
  1872.       if ("object" != typeof params) {
  1873.         if ("?" === this.prefix) {
  1874.           switch(params) {
  1875.             case 1:
  1876.               return this.applicationCursor = false;
  1877.             case 3:
  1878.               return 132 === this.cols && (this.savedCols && this.resize(this.savedCols, this.rows)), delete this.savedCols;
  1879.             case 6:
  1880.               return this.originMode = false;
  1881.             case 7:
  1882.               return this.wraparoundMode = false;
  1883.             case 66:
  1884.               return this.applicationKeypad = false;
  1885.             case 9:
  1886.             ;
  1887.             case 1E3:
  1888.             ;
  1889.             case 1002:
  1890.             ;
  1891.             case 1003:
  1892.               return this.x10Mouse = false, this.vt200Mouse = false, this.normalMouse = false, this.mouseEvents = false, this.element.style.cursor = "";
  1893.             case 1004:
  1894.               return this.sendFocus = false;
  1895.             case 1005:
  1896.               return this.utfMouse = false;
  1897.             case 1006:
  1898.               return this.sgrMouse = false;
  1899.             case 1015:
  1900.               return this.urxvtMouse = false;
  1901.             case 25:
  1902.               return this.cursorHidden = true;
  1903.             case 1049:
  1904.             ;
  1905.             case 47:
  1906.             ;
  1907.             case 1047:
  1908.               if (this.normal) {
  1909.                 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();
  1910.               }
  1911.             ;
  1912.           }
  1913.         }
  1914.       } else {
  1915.         l = params.length;
  1916.         /** @type {number} */
  1917.         i = 0;
  1918.         for (;l > i;) {
  1919.           this.resetMode(params[i]);
  1920.           i++;
  1921.         }
  1922.       }
  1923.     }, Terminal.prototype.setScrollRegion = function(params) {
  1924.       return this.prefix ? void 0 : (this.scrollTop = (params[0] || 1) - 1, this.scrollBottom = (params[1] || this.rows) - 1, this.x = 0, this.y = 0);
  1925.     }, Terminal.prototype.saveCursor = function() {
  1926.       return this.savedX = this.x, this.savedY = this.y;
  1927.     }, Terminal.prototype.restoreCursor = function() {
  1928.       return this.x = this.savedX || 0, this.y = this.savedY || 0;
  1929.     }, Terminal.prototype.cursorForwardTab = function(dataAndEvents) {
  1930.       var b;
  1931.       var eventPath;
  1932.       b = dataAndEvents[0] || 1;
  1933.       /** @type {Array} */
  1934.       eventPath = [];
  1935.       for (;b--;) {
  1936.         eventPath.push(this.x = this.nextStop());
  1937.       }
  1938.       return eventPath;
  1939.     }, Terminal.prototype.scrollUp = function($slides) {
  1940.       var b;
  1941.       b = $slides[0] || 1;
  1942.       for (;b--;) {
  1943.         this.lines.splice(this.ybase + this.scrollTop, 1);
  1944.         this.lines.splice(this.ybase + this.scrollBottom, 0, this.blankLine());
  1945.       }
  1946.       return this.updateRange(this.scrollTop), this.updateRange(this.scrollBottom);
  1947.     }, Terminal.prototype.scrollDown = function($slides) {
  1948.       var b;
  1949.       b = $slides[0] || 1;
  1950.       for (;b--;) {
  1951.         this.lines.splice(this.ybase + this.scrollBottom, 1);
  1952.         this.lines.splice(this.ybase + this.scrollTop, 0, this.blankLine());
  1953.       }
  1954.       return this.updateRange(this.scrollTop), this.updateRange(this.scrollBottom);
  1955.     }, Terminal.prototype.initMouseTracking = function() {
  1956.     }, Terminal.prototype.resetTitleModes = function() {
  1957.     }, Terminal.prototype.cursorBackwardTab = function(dataAndEvents) {
  1958.       var b;
  1959.       var eventPath;
  1960.       b = dataAndEvents[0] || 1;
  1961.       /** @type {Array} */
  1962.       eventPath = [];
  1963.       for (;b--;) {
  1964.         eventPath.push(this.x = this.prevStop());
  1965.       }
  1966.       return eventPath;
  1967.     }, Terminal.prototype.repeatPrecedingCharacter = function(dataAndEvents) {
  1968.       var c;
  1969.       var line;
  1970.       var d;
  1971.       var _results;
  1972.       d = dataAndEvents[0] || 1;
  1973.       line = this.lines[this.ybase + this.y];
  1974.       c = line[this.x - 1] || [this.defAttr, " "];
  1975.       /** @type {Array} */
  1976.       _results = [];
  1977.       for (;d--;) {
  1978.         _results.push(line[this.x++] = c);
  1979.       }
  1980.       return _results;
  1981.     }, Terminal.prototype.tabClear = function(opt_nodes) {
  1982.       var node;
  1983.       return node = opt_nodes[0], 0 >= node ? delete this.tabs[this.x] : 3 === node ? this.tabs = {} : void 0;
  1984.     }, Terminal.prototype.mediaCopy = function() {
  1985.     }, Terminal.prototype.setResources = function() {
  1986.     }, Terminal.prototype.disableModifiers = function() {
  1987.     }, Terminal.prototype.setPointerMode = function() {
  1988.     }, Terminal.prototype.softReset = function() {
  1989.       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];
  1990.     }, Terminal.prototype.requestAnsiMode = function() {
  1991.     }, Terminal.prototype.requestPrivateMode = function() {
  1992.     }, Terminal.prototype.setConformanceLevel = function() {
  1993.     }, Terminal.prototype.loadLEDs = function() {
  1994.     }, Terminal.prototype.setCursorStyle = function() {
  1995.     }, Terminal.prototype.setCharProtectionAttr = function() {
  1996.     }, Terminal.prototype.restorePrivateValues = function() {
  1997.     }, Terminal.prototype.setAttrInRectangle = function(params) {
  1998.       var ls;
  1999.       var param;
  2000.       var k;
  2001.       var p;
  2002.       var line;
  2003.       var centerType;
  2004.       var t;
  2005.       t = params[0];
  2006.       p = params[1];
  2007.       param = params[2];
  2008.       centerType = params[3];
  2009.       ls = params[4];
  2010.       for (;param + 1 > t;) {
  2011.         line = this.lines[this.ybase + t];
  2012.         k = p;
  2013.         for (;centerType > k;) {
  2014.           /** @type {Array} */
  2015.           line[k] = [ls, line[k][1]];
  2016.           k++;
  2017.         }
  2018.         t++;
  2019.       }
  2020.       return this.updateRange(params[0]), this.updateRange(params[2]);
  2021.     }, Terminal.prototype.savePrivateValues = function() {
  2022.     }, Terminal.prototype.manipulateWindow = function() {
  2023.     }, Terminal.prototype.reverseAttrInRectangle = function() {
  2024.     }, Terminal.prototype.setTitleModeFeature = function() {
  2025.     }, Terminal.prototype.setWarningBellVolume = function() {
  2026.     }, Terminal.prototype.setMarginBellVolume = function() {
  2027.     }, Terminal.prototype.copyRectangle = function() {
  2028.     }, Terminal.prototype.enableFilterRectangle = function() {
  2029.     }, Terminal.prototype.requestParameters = function() {
  2030.     }, Terminal.prototype.selectChangeExtent = function() {
  2031.     }, Terminal.prototype.fillRectangle = function(params) {
  2032.       var param;
  2033.       var lo;
  2034.       var msg;
  2035.       var type;
  2036.       var warnedAbout;
  2037.       var ls;
  2038.       var t;
  2039.       lo = params[0];
  2040.       t = params[1];
  2041.       type = params[2];
  2042.       param = params[3];
  2043.       ls = params[4];
  2044.       for (;param + 1 > t;) {
  2045.         warnedAbout = this.lines[this.ybase + t];
  2046.         msg = type;
  2047.         for (;ls > msg;) {
  2048.           /** @type {Array} */
  2049.           warnedAbout[msg] = [warnedAbout[msg][0], String.fromCharCode(lo)];
  2050.           msg++;
  2051.         }
  2052.         t++;
  2053.       }
  2054.       return this.updateRange(params[1]), this.updateRange(params[3]);
  2055.     }, Terminal.prototype.enableLocatorReporting = function(dataAndEvents) {
  2056.       var b;
  2057.       return b = dataAndEvents[0] > 0;
  2058.     }, Terminal.prototype.eraseRectangle = function(params) {
  2059.       var param;
  2060.       var c;
  2061.       var msgId;
  2062.       var ls;
  2063.       var pending;
  2064.       var centerType;
  2065.       var t;
  2066.       t = params[0];
  2067.       ls = params[1];
  2068.       param = params[2];
  2069.       centerType = params[3];
  2070.       /** @type {Array} */
  2071.       c = [this.eraseAttr(), " "];
  2072.       for (;param + 1 > t;) {
  2073.         pending = this.lines[this.ybase + t];
  2074.         msgId = ls;
  2075.         for (;centerType > msgId;) {
  2076.           /** @type {Array} */
  2077.           pending[msgId] = c;
  2078.           msgId++;
  2079.         }
  2080.         t++;
  2081.       }
  2082.       return this.updateRange(params[0]), this.updateRange(params[2]);
  2083.     }, Terminal.prototype.setLocatorEvents = function() {
  2084.     }, Terminal.prototype.selectiveEraseRectangle = function() {
  2085.     }, Terminal.prototype.requestLocatorPosition = function() {
  2086.     }, Terminal.prototype.insertColumns = function() {
  2087.       var block;
  2088.       var i;
  2089.       var l;
  2090.       var param;
  2091.       param = params[0];
  2092.       l = this.ybase + this.rows;
  2093.       /** @type {Array} */
  2094.       block = [this.eraseAttr(), " "];
  2095.       for (;param--;) {
  2096.         i = this.ybase;
  2097.         for (;l > i;) {
  2098.           this.lines[i].splice(this.x + 1, 0, block);
  2099.           this.lines[i].pop();
  2100.           i++;
  2101.         }
  2102.       }
  2103.       return this.maxRange();
  2104.     }, Terminal.prototype.deleteColumns = function() {
  2105.       var copies;
  2106.       var i;
  2107.       var l;
  2108.       var param;
  2109.       param = params[0];
  2110.       l = this.ybase + this.rows;
  2111.       /** @type {Array} */
  2112.       copies = [this.eraseAttr(), " "];
  2113.       for (;param--;) {
  2114.         i = this.ybase;
  2115.         for (;l > i;) {
  2116.           this.lines[i].splice(this.x, 1);
  2117.           this.lines[i].push(copies);
  2118.           i++;
  2119.         }
  2120.       }
  2121.       return this.maxRange();
  2122.     }, Terminal.prototype.get_html_height_in_lines = function(value) {
  2123.       var _height;
  2124.       var element;
  2125.       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);
  2126.     }, Terminal.prototype.charsets = {
  2127.       SCLD : {
  2128.         "`" : "\u00e2\u2014\u2020",
  2129.         a : "\u00e2\u2013\u2019",
  2130.         b : "\t",
  2131.         c : "\f",
  2132.         d : "\r",
  2133.         e : "\n",
  2134.         f : "\u00c2\u00b0",
  2135.         g : "\u00c2\u00b1",
  2136.         h : "\u00e2\u0090\u00a4",
  2137.         i : "\x0B",
  2138.         j : "\u00e2\u201d\u02dc",
  2139.         k : "\u00e2\u201d\u0090",
  2140.         l : "\u00e2\u201d\u0152",
  2141.         m : "\u00e2\u201d\u201d",
  2142.         n : "\u00e2\u201d\u00bc",
  2143.         o : "\u00e2\u017d\u00ba",
  2144.         p : "\u00e2\u017d\u00bb",
  2145.         q : "\u00e2\u201d\u20ac",
  2146.         r : "\u00e2\u017d\u00bc",
  2147.         s : "\u00e2\u017d\u00bd",
  2148.         t : "\u00e2\u201d\u0153",
  2149.         u : "\u00e2\u201d\u00a4",
  2150.         v : "\u00e2\u201d\u00b4",
  2151.         w : "\u00e2\u201d\u00ac",
  2152.         x : "\u00e2\u201d\u201a",
  2153.         y : "\u00e2\u2030\u00a4",
  2154.         z : "\u00e2\u2030\u00a5",
  2155.         "{" : "\u00cf\u20ac",
  2156.         "|" : "\u00e2\u2030 ",
  2157.         "}" : "\u00c2\u00a3",
  2158.         "~" : "\u00c2\u00b7"
  2159.       },
  2160.       UK : null,
  2161.       US : null,
  2162.       Dutch : null,
  2163.       Finnish : null,
  2164.       French : null,
  2165.       FrenchCanadian : null,
  2166.       German : null,
  2167.       Italian : null,
  2168.       NorwegianDanish : null,
  2169.       Spanish : null,
  2170.       Swedish : null,
  2171.       Swiss : null,
  2172.       ISOLatin : null
  2173.     }, Terminal;
  2174.   }();
  2175.   window.Terminal = Request;
  2176. }).call(this);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement