diff --git a/Gruntfile.coffee b/Gruntfile.coffee
index dbbb4b5..bb60154 100644
--- a/Gruntfile.coffee
+++ b/Gruntfile.coffee
@@ -12,11 +12,15 @@ module.exports = (grunt) ->
butterfly:
files:
'butterfly/static/main.min.js': 'butterfly/static/main.js'
+ 'butterfly/static/ext.min.js': 'butterfly/static/ext.js'
sass:
+ options:
+ includePaths: ['butterfly/sass/']
+
butterfly:
expand: true
- cwd: 'butterfly/sass'
+ cwd: 'butterfly/sass/'
src: '*.sass'
dest: 'butterfly/static/'
ext: '.css'
@@ -27,12 +31,8 @@ module.exports = (grunt) ->
butterfly:
files:
- 'butterfly/static/main.js': [
- 'coffees/term.coffee'
- 'coffees/selection.coffee'
- 'coffees/virtual_input.coffee'
- 'coffees/main.coffee'
- ]
+ 'butterfly/static/main.js': 'coffees/*.coffee'
+ 'butterfly/static/ext.js': 'coffees/ext/*.coffee'
coffeelint:
butterfly:
@@ -43,6 +43,7 @@ module.exports = (grunt) ->
livereload: true
coffee:
files: [
+ 'coffees/ext/*.coffee'
'coffees/*.coffee'
'Gruntfile.coffee'
]
diff --git a/butterfly/__init__.py b/butterfly/__init__.py
index 5b5de48..0da6bb8 100644
--- a/butterfly/__init__.py
+++ b/butterfly/__init__.py
@@ -14,7 +14,7 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
-__version__ = '1.5.4'
+__version__ = '1.5.5'
import os
diff --git a/sass/_16_colors.sass b/butterfly/sass/_16_colors.sass
similarity index 100%
rename from sass/_16_colors.sass
rename to butterfly/sass/_16_colors.sass
diff --git a/sass/_256_colors.sass b/butterfly/sass/_256_colors.sass
similarity index 100%
rename from sass/_256_colors.sass
rename to butterfly/sass/_256_colors.sass
diff --git a/sass/_colors.sass b/butterfly/sass/_colors.sass
similarity index 100%
rename from sass/_colors.sass
rename to butterfly/sass/_colors.sass
diff --git a/sass/_cursor.sass b/butterfly/sass/_cursor.sass
similarity index 100%
rename from sass/_cursor.sass
rename to butterfly/sass/_cursor.sass
diff --git a/sass/_font.sass b/butterfly/sass/_font.sass
similarity index 100%
rename from sass/_font.sass
rename to butterfly/sass/_font.sass
diff --git a/sass/_fx.sass b/butterfly/sass/_fx.sass
similarity index 87%
rename from sass/_fx.sass
rename to butterfly/sass/_fx.sass
index 6244070..070321e 100644
--- a/sass/_fx.sass
+++ b/butterfly/sass/_fx.sass
@@ -25,15 +25,23 @@ $shadow-alpha: .5 !default
&.bell
-webkit-filter: blur(2px)
+ filter: blur(2px)
&.skip
-webkit-filter: sepia(1)
+ filter: sepia(1)
&.selection
-webkit-filter: unquote("saturate(2)")
+ filter: unquote("saturate(2)")
+
+ &.alarm
+ -webkit-filter: hue-rotate(150deg)
+ filter: hue-rotate(150deg)
&.dead
-webkit-filter: unquote("grayscale(1)")
+ filter: unquote("grayscale(1)")
&:after
content: "CLOSED"
diff --git a/sass/_layout.sass b/butterfly/sass/_layout.sass
similarity index 100%
rename from sass/_layout.sass
rename to butterfly/sass/_layout.sass
diff --git a/sass/_term_styles.sass b/butterfly/sass/_term_styles.sass
similarity index 100%
rename from sass/_term_styles.sass
rename to butterfly/sass/_term_styles.sass
diff --git a/sass/main.sass b/butterfly/sass/main.sass
similarity index 84%
rename from sass/main.sass
rename to butterfly/sass/main.sass
index 7a58316..4bdd97e 100644
--- a/sass/main.sass
+++ b/butterfly/sass/main.sass
@@ -15,11 +15,11 @@
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see . */
-@import 'font'
-@import 'layout'
-@import 'fx'
-@import 'colors'
-@import '16_colors'
-@import '256_colors'
-@import 'cursor'
-@import 'term_styles'
+@import font
+@import layout
+@import fx
+@import colors
+@import 16_colors
+@import 256_colors
+@import cursor
+@import term_styles
diff --git a/butterfly/static/ext.js b/butterfly/static/ext.js
new file mode 100644
index 0000000..4ec1ee0
--- /dev/null
+++ b/butterfly/static/ext.js
@@ -0,0 +1,445 @@
+(function() {
+ var Selection, alt, cancel, ctrl, first, next_leaf, previous_leaf, selection, set_alarm, virtual_input,
+ __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
+
+ set_alarm = function(notification) {
+ var alarm;
+ alarm = function(data) {
+ var note;
+ butterfly.element.classList.remove('alarm');
+ note = "New activity on butterfly terminal [" + butterfly.title + "]";
+ if (notification) {
+ new Notification(note, {
+ body: data.data,
+ icon: '/static/images/favicon.png'
+ });
+ } else {
+ alert(note + '\n' + data.data);
+ }
+ return butterfly.ws.removeEventListener('message', alarm);
+ };
+ butterfly.ws.addEventListener('message', alarm);
+ return butterfly.element.classList.add('alarm');
+ };
+
+ cancel = function(ev) {
+ if (ev.preventDefault) {
+ ev.preventDefault();
+ }
+ if (ev.stopPropagation) {
+ ev.stopPropagation();
+ }
+ ev.cancelBubble = true;
+ return false;
+ };
+
+ document.addEventListener('keydown', function(e) {
+ if (!(e.altKey && e.keyCode === 65)) {
+ return true;
+ }
+ if (Notification && Notification.permission === 'default') {
+ Notification.requestPermission(function() {
+ return set_alarm(Notification.permission === 'granted');
+ });
+ } else {
+ set_alarm(Notification.permission === 'granted');
+ }
+ return cancel(e);
+ });
+
+ selection = null;
+
+ cancel = function(ev) {
+ if (ev.preventDefault) {
+ ev.preventDefault();
+ }
+ if (ev.stopPropagation) {
+ ev.stopPropagation();
+ }
+ ev.cancelBubble = true;
+ return false;
+ };
+
+ previous_leaf = function(node) {
+ var previous;
+ previous = node.previousSibling;
+ if (!previous) {
+ previous = node.parentNode.previousSibling;
+ }
+ if (!previous) {
+ previous = node.parentNode.parentNode.previousSibling;
+ }
+ while (previous.lastChild) {
+ previous = previous.lastChild;
+ }
+ return previous;
+ };
+
+ next_leaf = function(node) {
+ var next;
+ next = node.nextSibling;
+ if (!next) {
+ next = node.parentNode.nextSibling;
+ }
+ if (!next) {
+ next = node.parentNode.parentNode.nextSibling;
+ }
+ while (next.firstChild) {
+ next = next.firstChild;
+ }
+ return next;
+ };
+
+ Selection = (function() {
+ function Selection() {
+ butterfly.element.classList.add('selection');
+ this.selection = getSelection();
+ }
+
+ Selection.prototype.reset = function() {
+ var fake_range, _ref, _results;
+ this.selection = getSelection();
+ fake_range = document.createRange();
+ fake_range.setStart(this.selection.anchorNode, this.selection.anchorOffset);
+ fake_range.setEnd(this.selection.focusNode, this.selection.focusOffset);
+ this.start = {
+ node: this.selection.anchorNode,
+ offset: this.selection.anchorOffset
+ };
+ this.end = {
+ node: this.selection.focusNode,
+ offset: this.selection.focusOffset
+ };
+ if (fake_range.collapsed) {
+ _ref = [this.end, this.start], this.start = _ref[0], this.end = _ref[1];
+ }
+ this.start_line = this.start.node;
+ while (!this.start_line.classList || __indexOf.call(this.start_line.classList, 'line') < 0) {
+ this.start_line = this.start_line.parentNode;
+ }
+ this.end_line = this.end.node;
+ _results = [];
+ while (!this.end_line.classList || __indexOf.call(this.end_line.classList, 'line') < 0) {
+ _results.push(this.end_line = this.end_line.parentNode);
+ }
+ return _results;
+ };
+
+ Selection.prototype.clear = function() {
+ return this.selection.removeAllRanges();
+ };
+
+ Selection.prototype.destroy = function() {
+ butterfly.element.classList.remove('selection');
+ return this.clear();
+ };
+
+ Selection.prototype.text = function() {
+ return this.selection.toString();
+ };
+
+ Selection.prototype.up = function() {
+ return this.go(-1);
+ };
+
+ Selection.prototype.down = function() {
+ return this.go(+1);
+ };
+
+ Selection.prototype.go = function(n) {
+ var index;
+ index = butterfly.children.indexOf(this.start_line) + n;
+ if (!((0 <= index && index < butterfly.children.length))) {
+ return;
+ }
+ while (!butterfly.children[index].textContent.match(/\S/)) {
+ index += n;
+ if (!((0 <= index && index < butterfly.children.length))) {
+ return;
+ }
+ }
+ return this.select_line(index);
+ };
+
+ Selection.prototype.apply = function() {
+ var range;
+ this.clear();
+ range = document.createRange();
+ range.setStart(this.start.node, this.start.offset);
+ range.setEnd(this.end.node, this.end.offset);
+ return this.selection.addRange(range);
+ };
+
+ Selection.prototype.select_line = function(index) {
+ var line, line_end, line_start;
+ line = butterfly.children[index];
+ line_start = {
+ node: line.firstChild,
+ offset: 0
+ };
+ line_end = {
+ node: line.lastChild,
+ offset: line.lastChild.textContent.length
+ };
+ this.start = this.walk(line_start, /\S/);
+ return this.end = this.walk(line_end, /\S/, true);
+ };
+
+ Selection.prototype.collapsed = function(start, end) {
+ var fake_range;
+ fake_range = document.createRange();
+ fake_range.setStart(start.node, start.offset);
+ fake_range.setEnd(end.node, end.offset);
+ return fake_range.collapsed;
+ };
+
+ Selection.prototype.shrink_right = function() {
+ var end, node;
+ node = this.walk(this.end, /\s/, true);
+ end = this.walk(node, /\S/, true);
+ if (!this.collapsed(this.start, end)) {
+ return this.end = end;
+ }
+ };
+
+ Selection.prototype.shrink_left = function() {
+ var node, start;
+ node = this.walk(this.start, /\s/);
+ start = this.walk(node, /\S/);
+ if (!this.collapsed(start, this.end)) {
+ return this.start = start;
+ }
+ };
+
+ Selection.prototype.expand_right = function() {
+ var node;
+ node = this.walk(this.end, /\S/);
+ return this.end = this.walk(node, /\s/);
+ };
+
+ Selection.prototype.expand_left = function() {
+ var node;
+ node = this.walk(this.start, /\S/, true);
+ return this.start = this.walk(node, /\s/, true);
+ };
+
+ Selection.prototype.walk = function(needle, til, backward) {
+ var i, node, text;
+ if (backward == null) {
+ backward = false;
+ }
+ if (needle.node.firstChild) {
+ node = needle.node.firstChild;
+ } else {
+ node = needle.node;
+ }
+ text = node.textContent;
+ i = needle.offset;
+ if (backward) {
+ while (node) {
+ while (i > 0) {
+ if (text[--i].match(til)) {
+ return {
+ node: node,
+ offset: i + 1
+ };
+ }
+ }
+ node = previous_leaf(node);
+ text = node.textContent;
+ i = text.length;
+ }
+ } else {
+ while (node) {
+ while (i < text.length) {
+ if (text[i++].match(til)) {
+ return {
+ node: node,
+ offset: i - 1
+ };
+ }
+ }
+ node = next_leaf(node);
+ text = node.textContent;
+ i = 0;
+ }
+ }
+ return needle;
+ };
+
+ return Selection;
+
+ })();
+
+ document.addEventListener('keydown', function(e) {
+ var _ref, _ref1;
+ if (_ref = e.keyCode, __indexOf.call([16, 17, 18, 19], _ref) >= 0) {
+ return true;
+ }
+ if (e.shiftKey && e.keyCode === 13 && !selection && !getSelection().isCollapsed) {
+ butterfly.handler(getSelection().toString());
+ getSelection().removeAllRanges();
+ return cancel(e);
+ }
+ if (selection) {
+ selection.reset();
+ if (!e.ctrlKey && e.shiftKey && (37 <= (_ref1 = e.keyCode) && _ref1 <= 40)) {
+ return true;
+ }
+ if (e.shiftKey && e.ctrlKey) {
+ if (e.keyCode === 38) {
+ selection.up();
+ } else if (e.keyCode === 40) {
+ selection.down();
+ }
+ } else if (e.keyCode === 39) {
+ selection.shrink_left();
+ } else if (e.keyCode === 38) {
+ selection.expand_left();
+ } else if (e.keyCode === 37) {
+ selection.shrink_right();
+ } else if (e.keyCode === 40) {
+ selection.expand_right();
+ } else {
+ return cancel(e);
+ }
+ if (selection != null) {
+ selection.apply();
+ }
+ return cancel(e);
+ }
+ if (!selection && e.ctrlKey && e.shiftKey && e.keyCode === 38) {
+ selection = new Selection();
+ selection.select_line(butterfly.y - 1);
+ selection.apply();
+ return cancel(e);
+ }
+ return true;
+ });
+
+ document.addEventListener('keyup', function(e) {
+ var _ref, _ref1;
+ if (_ref = e.keyCode, __indexOf.call([16, 17, 18, 19], _ref) >= 0) {
+ return true;
+ }
+ if (selection) {
+ if (e.keyCode === 13) {
+ butterfly.handler(selection.text());
+ selection.destroy();
+ selection = null;
+ return cancel(e);
+ }
+ if (_ref1 = e.keyCode, __indexOf.call([37, 38, 39, 40], _ref1) < 0) {
+ selection.destroy();
+ selection = null;
+ return true;
+ }
+ }
+ return true;
+ });
+
+ document.addEventListener('dblclick', function(e) {
+ var anchorNode, anchorOffset, new_range, range, sel;
+ if (e.ctrlKey || e.altkey) {
+ return;
+ }
+ sel = getSelection();
+ if (sel.isCollapsed || sel.toString().match(/\s/)) {
+ return;
+ }
+ range = document.createRange();
+ range.setStart(sel.anchorNode, sel.anchorOffset);
+ range.setEnd(sel.focusNode, sel.focusOffset);
+ if (range.collapsed) {
+ sel.removeAllRanges();
+ new_range = document.createRange();
+ new_range.setStart(sel.focusNode, sel.focusOffset);
+ new_range.setEnd(sel.anchorNode, sel.anchorOffset);
+ sel.addRange(new_range);
+ }
+ range.detach();
+ while (!(sel.toString().match(/\s/) || !sel.toString())) {
+ sel.modify('extend', 'forward', 'character');
+ }
+ sel.modify('extend', 'backward', 'character');
+ anchorNode = sel.anchorNode;
+ anchorOffset = sel.anchorOffset;
+ sel.collapseToEnd();
+ sel.extend(anchorNode, anchorOffset);
+ while (!(sel.toString().match(/\s/) || !sel.toString())) {
+ sel.modify('extend', 'backward', 'character');
+ }
+ return sel.modify('extend', 'forward', 'character');
+ });
+
+ if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
+ ctrl = false;
+ alt = false;
+ first = true;
+ virtual_input = document.createElement('input');
+ virtual_input.type = 'password';
+ virtual_input.style.position = 'fixed';
+ virtual_input.style.top = 0;
+ virtual_input.style.left = 0;
+ virtual_input.style.border = 'none';
+ virtual_input.style.outline = 'none';
+ virtual_input.style.opacity = 0;
+ virtual_input.value = '0';
+ document.body.appendChild(virtual_input);
+ virtual_input.addEventListener('blur', function() {
+ return setTimeout(((function(_this) {
+ return function() {
+ return _this.focus();
+ };
+ })(this)), 10);
+ });
+ addEventListener('click', function() {
+ return virtual_input.focus();
+ });
+ addEventListener('touchstart', function(e) {
+ if (e.touches.length === 2) {
+ return ctrl = true;
+ } else if (e.touches.length === 3) {
+ ctrl = false;
+ return alt = true;
+ } else if (e.touches.length === 4) {
+ ctrl = true;
+ return alt = true;
+ }
+ });
+ virtual_input.addEventListener('keydown', function(e) {
+ butterfly.keyDown(e);
+ return true;
+ });
+ virtual_input.addEventListener('input', function(e) {
+ var len;
+ len = this.value.length;
+ if (len === 0) {
+ e.keyCode = 8;
+ butterfly.keyDown(e);
+ this.value = '0';
+ return true;
+ }
+ e.keyCode = this.value.charAt(1).charCodeAt(0);
+ if ((ctrl || alt) && !first) {
+ e.keyCode = this.value.charAt(1).charCodeAt(0);
+ e.ctrlKey = ctrl;
+ e.altKey = alt;
+ if (e.keyCode >= 97 && e.keyCode <= 122) {
+ e.keyCode -= 32;
+ }
+ butterfly.keyDown(e);
+ this.value = '0';
+ ctrl = alt = false;
+ return true;
+ }
+ butterfly.keyPress(e);
+ first = false;
+ this.value = '0';
+ return true;
+ });
+ }
+
+}).call(this);
+
+//# sourceMappingURL=ext.js.map
diff --git a/butterfly/static/ext.min.js b/butterfly/static/ext.min.js
new file mode 100644
index 0000000..80539f6
--- /dev/null
+++ b/butterfly/static/ext.min.js
@@ -0,0 +1,4 @@
+/*! butterfly 2014-07-18 */
+
+(function(){var a,b,c,d,e,f,g,h,i,j,k=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};i=function(a){var b;return b=function(c){var d;return butterfly.element.classList.remove("alarm"),d="New activity on butterfly terminal ["+butterfly.title+"]",a?new Notification(d,{body:c.data,icon:"/static/images/favicon.png"}):alert(d+"\n"+c.data),butterfly.ws.removeEventListener("message",b)},butterfly.ws.addEventListener("message",b),butterfly.element.classList.add("alarm")},c=function(a){return a.preventDefault&&a.preventDefault(),a.stopPropagation&&a.stopPropagation(),a.cancelBubble=!0,!1},document.addEventListener("keydown",function(a){return a.altKey&&65===a.keyCode?(Notification&&"default"===Notification.permission?Notification.requestPermission(function(){return i("granted"===Notification.permission)}):i("granted"===Notification.permission),c(a)):!0}),h=null,c=function(a){return a.preventDefault&&a.preventDefault(),a.stopPropagation&&a.stopPropagation(),a.cancelBubble=!0,!1},g=function(a){var b;for(b=a.previousSibling,b||(b=a.parentNode.previousSibling),b||(b=a.parentNode.parentNode.previousSibling);b.lastChild;)b=b.lastChild;return b},f=function(a){var b;for(b=a.nextSibling,b||(b=a.parentNode.nextSibling),b||(b=a.parentNode.parentNode.nextSibling);b.firstChild;)b=b.firstChild;return b},a=function(){function a(){butterfly.element.classList.add("selection"),this.selection=getSelection()}return a.prototype.reset=function(){var a,b,c;for(this.selection=getSelection(),a=document.createRange(),a.setStart(this.selection.anchorNode,this.selection.anchorOffset),a.setEnd(this.selection.focusNode,this.selection.focusOffset),this.start={node:this.selection.anchorNode,offset:this.selection.anchorOffset},this.end={node:this.selection.focusNode,offset:this.selection.focusOffset},a.collapsed&&(b=[this.end,this.start],this.start=b[0],this.end=b[1]),this.start_line=this.start.node;!this.start_line.classList||k.call(this.start_line.classList,"line")<0;)this.start_line=this.start_line.parentNode;for(this.end_line=this.end.node,c=[];!this.end_line.classList||k.call(this.end_line.classList,"line")<0;)c.push(this.end_line=this.end_line.parentNode);return c},a.prototype.clear=function(){return this.selection.removeAllRanges()},a.prototype.destroy=function(){return butterfly.element.classList.remove("selection"),this.clear()},a.prototype.text=function(){return this.selection.toString()},a.prototype.up=function(){return this.go(-1)},a.prototype.down=function(){return this.go(1)},a.prototype.go=function(a){var b;if(b=butterfly.children.indexOf(this.start_line)+a,b>=0&&b=0&&b0;)if(h[--d].match(b))return{node:e,offset:d+1};e=g(e),h=e.textContent,d=h.length}else for(;e;){for(;d=0)return!0;if(b.shiftKey&&13===b.keyCode&&!h&&!getSelection().isCollapsed)return butterfly.handler(getSelection().toString()),getSelection().removeAllRanges(),c(b);if(h){if(h.reset(),!b.ctrlKey&&b.shiftKey&&37<=(e=b.keyCode)&&40>=e)return!0;if(b.shiftKey&&b.ctrlKey)38===b.keyCode?h.up():40===b.keyCode&&h.down();else if(39===b.keyCode)h.shrink_left();else if(38===b.keyCode)h.expand_left();else if(37===b.keyCode)h.shrink_right();else{if(40!==b.keyCode)return c(b);h.expand_right()}return null!=h&&h.apply(),c(b)}return!h&&b.ctrlKey&&b.shiftKey&&38===b.keyCode?(h=new a,h.select_line(butterfly.y-1),h.apply(),c(b)):!0}),document.addEventListener("keyup",function(a){var b,d;if(b=a.keyCode,k.call([16,17,18,19],b)>=0)return!0;if(h){if(13===a.keyCode)return butterfly.handler(h.text()),h.destroy(),h=null,c(a);if(d=a.keyCode,k.call([37,38,39,40],d)<0)return h.destroy(),h=null,!0}return!0}),document.addEventListener("dblclick",function(a){var b,c,d,e,f;if(!(a.ctrlKey||a.altkey||(f=getSelection(),f.isCollapsed||f.toString().match(/\s/)))){for(e=document.createRange(),e.setStart(f.anchorNode,f.anchorOffset),e.setEnd(f.focusNode,f.focusOffset),e.collapsed&&(f.removeAllRanges(),d=document.createRange(),d.setStart(f.focusNode,f.focusOffset),d.setEnd(f.anchorNode,f.anchorOffset),f.addRange(d)),e.detach();!f.toString().match(/\s/)&&f.toString();)f.modify("extend","forward","character");for(f.modify("extend","backward","character"),b=f.anchorNode,c=f.anchorOffset,f.collapseToEnd(),f.extend(b,c);!f.toString().match(/\s/)&&f.toString();)f.modify("extend","backward","character");return f.modify("extend","forward","character")}}),/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)&&(d=!1,b=!1,e=!0,j=document.createElement("input"),j.type="password",j.style.position="fixed",j.style.top=0,j.style.left=0,j.style.border="none",j.style.outline="none",j.style.opacity=0,j.value="0",document.body.appendChild(j),j.addEventListener("blur",function(){return setTimeout(function(a){return function(){return a.focus()}}(this),10)}),addEventListener("click",function(){return j.focus()}),addEventListener("touchstart",function(a){return 2===a.touches.length?d=!0:3===a.touches.length?(d=!1,b=!0):4===a.touches.length?(d=!0,b=!0):void 0}),j.addEventListener("keydown",function(a){return butterfly.keyDown(a),!0}),j.addEventListener("input",function(a){var c;return c=this.value.length,0===c?(a.keyCode=8,butterfly.keyDown(a),this.value="0",!0):(a.keyCode=this.value.charAt(1).charCodeAt(0),!d&&!b||e?(butterfly.keyPress(a),e=!1,this.value="0",!0):(a.keyCode=this.value.charAt(1).charCodeAt(0),a.ctrlKey=d,a.altKey=b,a.keyCode>=97&&a.keyCode<=122&&(a.keyCode-=32),butterfly.keyDown(a),this.value="0",d=b=!1,!0))}))}).call(this);
+//# sourceMappingURL=ext.min.js.map
\ No newline at end of file
diff --git a/butterfly/static/main.css b/butterfly/static/main.css
index 2c878ab..cbdc9e8 100644
--- a/butterfly/static/main.css
+++ b/butterfly/static/main.css
@@ -1,3 +1,29 @@
+/* *-* coding: utf-8 *-* */
+/* This file is part of butterfly */
+/* butterfly Copyright (C) 2014 Florian Mounier */
+/* This program is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 3 of the License, or */
+/* (at your option) any later version. */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see . */
+/* *-* coding: utf-8 *-* */
+/* This file is part of butterfly */
+/* butterfly Copyright (C) 2014 Florian Mounier */
+/* This program is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 3 of the License, or */
+/* (at your option) any later version. */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see . */
@font-face {
font-family: "SourceCodePro";
src: url("/static/fonts/SourceCodePro-ExtraLight.otf") format("woff");
@@ -37,6 +63,19 @@ body {
font-family: "SourceCodePro";
line-height: 1.2; }
+/* *-* coding: utf-8 *-* */
+/* This file is part of butterfly */
+/* butterfly Copyright (C) 2014 Florian Mounier */
+/* This program is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 3 of the License, or */
+/* (at your option) any later version. */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see . */
html, body {
height: 100%;
margin: 0;
@@ -51,17 +90,37 @@ html, body {
.terminal {
outline: none; }
+/* *-* coding: utf-8 *-* */
+/* This file is part of butterfly */
+/* butterfly Copyright (C) 2014 Florian Mounier */
+/* This program is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 3 of the License, or */
+/* (at your option) any later version. */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see . */
.terminal {
text-shadow: 0 0 6px rgba(255, 255, 255, 0.5);
transition: 200ms; }
.terminal.bell {
- -webkit-filter: blur(2px); }
+ -webkit-filter: blur(2px);
+ filter: blur(2px); }
.terminal.skip {
- -webkit-filter: sepia(1); }
+ -webkit-filter: sepia(1);
+ filter: sepia(1); }
.terminal.selection {
- -webkit-filter: saturate(2); }
+ -webkit-filter: saturate(2);
+ filter: saturate(2); }
+ .terminal.alarm {
+ -webkit-filter: hue-rotate(150deg);
+ filter: hue-rotate(150deg); }
.terminal.dead {
- -webkit-filter: grayscale(1); }
+ -webkit-filter: grayscale(1);
+ filter: grayscale(1); }
.terminal.dead:after {
content: "CLOSED";
font-size: 15em;
@@ -77,6 +136,19 @@ html, body {
opacity: 0.2;
font-weight: 900; }
+/* *-* coding: utf-8 *-* */
+/* This file is part of butterfly */
+/* butterfly Copyright (C) 2014 Florian Mounier */
+/* This program is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 3 of the License, or */
+/* (at your option) any later version. */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see . */
#wrapper {
background-color: #110f13; }
@@ -84,6 +156,20 @@ html, body {
background-color: #110f13;
color: #f4ead5; }
+/* *-* coding: utf-8 *-* */
+/* This file is part of butterfly */
+/* butterfly Copyright (C) 2014 Florian Mounier */
+/* This program is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 3 of the License, or */
+/* (at your option) any later version. */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see . */
+/* Here are the 16 "normal" colors for theming */
.bg-color-0 {
background-color: #2e3436; }
.bg-color-0.reverse-video {
@@ -260,6 +346,21 @@ html, body {
.fg-color-15.reverse-video {
background-color: #eeeeec !important; }
+/* *-* coding: utf-8 *-* */
+/* This file is part of butterfly */
+/* butterfly Copyright (C) 2014 Florian Mounier */
+/* This program is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 3 of the License, or */
+/* (at your option) any later version. */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see . */
+/* Here are the 240 xterm colors */
+/* See http://upload.wikimedia.org/wikipedia/en/1/15/Xterm_256color_chart.svg */
.bg-color-16 {
background-color: black; }
.bg-color-16.reverse-video {
@@ -2922,12 +3023,38 @@ html, body {
.fg-color-257.reverse-video {
background-color: #f4ead5 !important; }
+/* *-* coding: utf-8 *-* */
+/* This file is part of butterfly */
+/* butterfly Copyright (C) 2014 Florian Mounier */
+/* This program is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 3 of the License, or */
+/* (at your option) any later version. */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see . */
.focus .cursor {
transition: 300ms; }
.cursor.reverse-video {
box-shadow: 0 0 0.5 #f4ead5; }
+/* *-* coding: utf-8 *-* */
+/* This file is part of butterfly */
+/* butterfly Copyright (C) 2014 Florian Mounier */
+/* This program is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 3 of the License, or */
+/* (at your option) any later version. */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see . */
.bold {
font-weight: bold; }
diff --git a/butterfly/static/main.js b/butterfly/static/main.js
index 1f6660a..a67183b 100644
--- a/butterfly/static/main.js
+++ b/butterfly/static/main.js
@@ -1,7 +1,97 @@
(function() {
- var $, Selection, State, Terminal, alt, bench, cancel, cbench, cols, ctl, ctrl, first, next_leaf, open_ts, previous_leaf, quit, rows, s, selection, send, term, virtual_input, ws, ws_url,
- __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; },
- __slice = [].slice;
+ var $, State, Terminal, cancel, cols, open_ts, quit, rows, s,
+ __slice = [].slice,
+ __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
+
+ cols = rows = null;
+
+ quit = false;
+
+ open_ts = (new Date()).getTime();
+
+ $ = document.querySelectorAll.bind(document);
+
+ document.addEventListener('DOMContentLoaded', function() {
+ var bench, cbench, ctl, send, term, ws, ws_url;
+ send = function(data) {
+ return ws.send('S' + data);
+ };
+ ctl = function() {
+ var args, params, type;
+ type = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
+ params = args.join(',');
+ if (type === 'Resize') {
+ return ws.send('R' + params);
+ }
+ };
+ if (location.protocol === 'https:') {
+ ws_url = 'wss://';
+ } else {
+ ws_url = 'ws://';
+ }
+ ws_url += document.location.host + '/ws' + location.pathname;
+ ws = new WebSocket(ws_url);
+ ws.addEventListener('open', function() {
+ console.log("WebSocket open", arguments);
+ ws.send('R' + term.cols + ',' + term.rows);
+ return open_ts = (new Date()).getTime();
+ });
+ ws.addEventListener('error', function() {
+ return console.log("WebSocket error", arguments);
+ });
+ ws.addEventListener('message', function(e) {
+ return setTimeout(function() {
+ return term.write(e.data);
+ }, 1);
+ });
+ ws.addEventListener('close', function() {
+ console.log("WebSocket closed", arguments);
+ setTimeout(function() {
+ term.write('Closed');
+ term.skipNextKey = true;
+ return term.element.classList.add('dead');
+ }, 1);
+ quit = true;
+ if ((new Date()).getTime() - open_ts > 60 * 1000) {
+ return open('', '_self').close();
+ }
+ });
+ term = new Terminal($('#wrapper')[0], send, ctl);
+ addEventListener('beforeunload', function() {
+ if (!quit) {
+ return 'This will exit the terminal session';
+ }
+ });
+ bench = function(n) {
+ var rnd, t0;
+ if (n == null) {
+ n = 100000000;
+ }
+ rnd = '';
+ while (rnd.length < n) {
+ rnd += Math.random().toString(36).substring(2);
+ }
+ t0 = (new Date()).getTime();
+ term.write(rnd);
+ return console.log("" + n + " chars in " + ((new Date()).getTime() - t0) + " ms");
+ };
+ cbench = function(n) {
+ var rnd, t0;
+ if (n == null) {
+ n = 100000000;
+ }
+ rnd = '';
+ while (rnd.length < n) {
+ rnd += "\x1b[" + (30 + parseInt(Math.random() * 20)) + "m";
+ rnd += Math.random().toString(36).substring(2);
+ }
+ t0 = (new Date()).getTime();
+ term.write(rnd);
+ return console.log("" + n + " chars + colors in " + ((new Date()).getTime() - t0) + " ms");
+ };
+ term.ws = ws;
+ return window.butterfly = term;
+ });
cancel = function(ev) {
if (ev.preventDefault) {
@@ -39,6 +129,7 @@
this.element.className = 'terminal focus';
this.element.style.outline = 'none';
this.element.setAttribute('tabindex', 0);
+ this.element.setAttribute('spellcheck', 'false');
this.parent.appendChild(this.element);
div = this.document.createElement('div');
div.className = 'line';
@@ -2405,486 +2496,7 @@
})();
- selection = null;
-
- previous_leaf = function(node) {
- var previous;
- previous = node.previousSibling;
- if (!previous) {
- previous = node.parentNode.previousSibling;
- }
- if (!previous) {
- previous = node.parentNode.parentNode.previousSibling;
- }
- while (previous.lastChild) {
- previous = previous.lastChild;
- }
- return previous;
- };
-
- next_leaf = function(node) {
- var next;
- next = node.nextSibling;
- if (!next) {
- next = node.parentNode.nextSibling;
- }
- if (!next) {
- next = node.parentNode.parentNode.nextSibling;
- }
- while (next.firstChild) {
- next = next.firstChild;
- }
- return next;
- };
-
- Selection = (function() {
- function Selection() {
- term.element.classList.add('selection');
- this.selection = getSelection();
- }
-
- Selection.prototype.reset = function() {
- var fake_range, _ref, _results;
- this.selection = getSelection();
- fake_range = document.createRange();
- fake_range.setStart(this.selection.anchorNode, this.selection.anchorOffset);
- fake_range.setEnd(this.selection.focusNode, this.selection.focusOffset);
- this.start = {
- node: this.selection.anchorNode,
- offset: this.selection.anchorOffset
- };
- this.end = {
- node: this.selection.focusNode,
- offset: this.selection.focusOffset
- };
- if (fake_range.collapsed) {
- _ref = [this.end, this.start], this.start = _ref[0], this.end = _ref[1];
- }
- this.start_line = this.start.node;
- while (!this.start_line.classList || __indexOf.call(this.start_line.classList, 'line') < 0) {
- this.start_line = this.start_line.parentNode;
- }
- this.end_line = this.end.node;
- _results = [];
- while (!this.end_line.classList || __indexOf.call(this.end_line.classList, 'line') < 0) {
- _results.push(this.end_line = this.end_line.parentNode);
- }
- return _results;
- };
-
- Selection.prototype.clear = function() {
- return this.selection.removeAllRanges();
- };
-
- Selection.prototype.destroy = function() {
- term.element.classList.remove('selection');
- return this.clear();
- };
-
- Selection.prototype.text = function() {
- return this.selection.toString();
- };
-
- Selection.prototype.up = function() {
- return this.go(-1);
- };
-
- Selection.prototype.down = function() {
- return this.go(+1);
- };
-
- Selection.prototype.go = function(n) {
- var index;
- index = term.children.indexOf(this.start_line) + n;
- if (!((0 <= index && index < term.children.length))) {
- return;
- }
- while (!term.children[index].textContent.match(/\S/)) {
- index += n;
- if (!((0 <= index && index < term.children.length))) {
- return;
- }
- }
- return this.select_line(index);
- };
-
- Selection.prototype.apply = function() {
- var range;
- this.clear();
- range = document.createRange();
- range.setStart(this.start.node, this.start.offset);
- range.setEnd(this.end.node, this.end.offset);
- return this.selection.addRange(range);
- };
-
- Selection.prototype.select_line = function(index) {
- var line, line_end, line_start;
- line = term.children[index];
- line_start = {
- node: line.firstChild,
- offset: 0
- };
- line_end = {
- node: line.lastChild,
- offset: line.lastChild.textContent.length
- };
- this.start = this.walk(line_start, /\S/);
- return this.end = this.walk(line_end, /\S/, true);
- };
-
- Selection.prototype.collapsed = function(start, end) {
- var fake_range;
- fake_range = document.createRange();
- fake_range.setStart(start.node, start.offset);
- fake_range.setEnd(end.node, end.offset);
- return fake_range.collapsed;
- };
-
- Selection.prototype.shrink_right = function() {
- var end, node;
- node = this.walk(this.end, /\s/, true);
- end = this.walk(node, /\S/, true);
- if (!this.collapsed(this.start, end)) {
- return this.end = end;
- }
- };
-
- Selection.prototype.shrink_left = function() {
- var node, start;
- node = this.walk(this.start, /\s/);
- start = this.walk(node, /\S/);
- if (!this.collapsed(start, this.end)) {
- return this.start = start;
- }
- };
-
- Selection.prototype.expand_right = function() {
- var node;
- node = this.walk(this.end, /\S/);
- return this.end = this.walk(node, /\s/);
- };
-
- Selection.prototype.expand_left = function() {
- var node;
- node = this.walk(this.start, /\S/, true);
- return this.start = this.walk(node, /\s/, true);
- };
-
- Selection.prototype.walk = function(needle, til, backward) {
- var i, node, text;
- if (backward == null) {
- backward = false;
- }
- if (needle.node.firstChild) {
- node = needle.node.firstChild;
- } else {
- node = needle.node;
- }
- text = node.textContent;
- i = needle.offset;
- if (backward) {
- while (node) {
- while (i > 0) {
- if (text[--i].match(til)) {
- return {
- node: node,
- offset: i + 1
- };
- }
- }
- node = previous_leaf(node);
- text = node.textContent;
- i = text.length;
- }
- } else {
- while (node) {
- while (i < text.length) {
- if (text[i++].match(til)) {
- return {
- node: node,
- offset: i - 1
- };
- }
- }
- node = next_leaf(node);
- text = node.textContent;
- i = 0;
- }
- }
- return needle;
- };
-
- return Selection;
-
- })();
-
- document.addEventListener('keydown', function(e) {
- var _ref, _ref1;
- if (_ref = e.keyCode, __indexOf.call([16, 17, 18, 19], _ref) >= 0) {
- return true;
- }
- if (e.shiftKey && e.keyCode === 13 && !selection && !getSelection().isCollapsed) {
- term.handler(getSelection().toString());
- getSelection().removeAllRanges();
- return cancel(e);
- }
- if (selection) {
- selection.reset();
- if (!e.ctrlKey && e.shiftKey && (37 <= (_ref1 = e.keyCode) && _ref1 <= 40)) {
- return true;
- }
- if (e.shiftKey && e.ctrlKey) {
- if (e.keyCode === 38) {
- selection.up();
- } else if (e.keyCode === 40) {
- selection.down();
- }
- } else if (e.keyCode === 39) {
- selection.shrink_left();
- } else if (e.keyCode === 38) {
- selection.expand_left();
- } else if (e.keyCode === 37) {
- selection.shrink_right();
- } else if (e.keyCode === 40) {
- selection.expand_right();
- } else {
- return cancel(e);
- }
- if (selection != null) {
- selection.apply();
- }
- return cancel(e);
- }
- if (!selection && e.ctrlKey && e.shiftKey && e.keyCode === 38) {
- selection = new Selection();
- selection.select_line(term.y - 1);
- selection.apply();
- return cancel(e);
- }
- return true;
- });
-
- document.addEventListener('keyup', function(e) {
- var _ref, _ref1;
- if (_ref = e.keyCode, __indexOf.call([16, 17, 18, 19], _ref) >= 0) {
- return true;
- }
- if (selection) {
- if (e.keyCode === 13) {
- term.handler(selection.text());
- selection.destroy();
- selection = null;
- return cancel(e);
- }
- if (_ref1 = e.keyCode, __indexOf.call([37, 38, 39, 40], _ref1) < 0) {
- selection.destroy();
- selection = null;
- return true;
- }
- }
- return true;
- });
-
- document.addEventListener('dblclick', function(e) {
- var anchorNode, anchorOffset, new_range, range, sel;
- if (e.ctrlKey || e.altkey) {
- return;
- }
- sel = getSelection();
- if (sel.isCollapsed || sel.toString().match(/\s/)) {
- return;
- }
- range = document.createRange();
- range.setStart(sel.anchorNode, sel.anchorOffset);
- range.setEnd(sel.focusNode, sel.focusOffset);
- if (range.collapsed) {
- sel.removeAllRanges();
- new_range = document.createRange();
- new_range.setStart(sel.focusNode, sel.focusOffset);
- new_range.setEnd(sel.anchorNode, sel.anchorOffset);
- sel.addRange(new_range);
- }
- range.detach();
- while (!(sel.toString().match(/\s/) || !sel.toString())) {
- sel.modify('extend', 'forward', 'character');
- }
- sel.modify('extend', 'backward', 'character');
- anchorNode = sel.anchorNode;
- anchorOffset = sel.anchorOffset;
- sel.collapseToEnd();
- sel.extend(anchorNode, anchorOffset);
- while (!(sel.toString().match(/\s/) || !sel.toString())) {
- sel.modify('extend', 'backward', 'character');
- }
- return sel.modify('extend', 'forward', 'character');
- });
-
- if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
- ctrl = false;
- alt = false;
- first = true;
- virtual_input = document.createElement('input');
- virtual_input.type = 'password';
- virtual_input.style.position = 'fixed';
- virtual_input.style.top = 0;
- virtual_input.style.left = 0;
- virtual_input.style.border = 'none';
- virtual_input.style.outline = 'none';
- virtual_input.style.opacity = 0;
- virtual_input.value = '0';
- document.body.appendChild(virtual_input);
- virtual_input.addEventListener('blur', function() {
- return setTimeout(((function(_this) {
- return function() {
- return _this.focus();
- };
- })(this)), 10);
- });
- addEventListener('click', function() {
- return virtual_input.focus();
- });
- addEventListener('touchstart', function(e) {
- if (e.touches.length === 2) {
- return ctrl = true;
- } else if (e.touches.length === 3) {
- ctrl = false;
- return alt = true;
- } else if (e.touches.length === 4) {
- ctrl = true;
- return alt = true;
- }
- });
- virtual_input.addEventListener('keydown', function(e) {
- term.keyDown(e);
- return true;
- });
- virtual_input.addEventListener('input', function(e) {
- var len;
- len = this.value.length;
- if (len === 0) {
- e.keyCode = 8;
- term.keyDown(e);
- this.value = '0';
- return true;
- }
- e.keyCode = this.value.charAt(1).charCodeAt(0);
- if ((ctrl || alt) && !first) {
- e.keyCode = this.value.charAt(1).charCodeAt(0);
- e.ctrlKey = ctrl;
- e.altKey = alt;
- if (e.keyCode >= 97 && e.keyCode <= 122) {
- e.keyCode -= 32;
- }
- term.keyDown(e);
- this.value = '0';
- ctrl = alt = false;
- return true;
- }
- term.keyPress(e);
- first = false;
- this.value = '0';
- return true;
- });
- }
-
- cols = rows = null;
-
- quit = false;
-
- open_ts = (new Date()).getTime();
-
- $ = document.querySelectorAll.bind(document);
-
- send = function(data) {
- return ws.send('S' + data);
- };
-
- ctl = function() {
- var args, params, type;
- type = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
- params = args.join(',');
- if (type === 'Resize') {
- return ws.send('R' + params);
- }
- };
-
- if (location.protocol === 'https:') {
- ws_url = 'wss://';
- } else {
- ws_url = 'ws://';
- }
-
- ws_url += document.location.host + '/ws' + location.pathname;
-
- ws = new WebSocket(ws_url);
-
- ws.addEventListener('open', function() {
- console.log("WebSocket open", arguments);
- ws.send('R' + term.cols + ',' + term.rows);
- return open_ts = (new Date()).getTime();
- });
-
- ws.addEventListener('error', function() {
- return console.log("WebSocket error", arguments);
- });
-
- ws.addEventListener('message', function(e) {
- return setTimeout(function() {
- return term.write(e.data);
- }, 1);
- });
-
- ws.addEventListener('close', function() {
- console.log("WebSocket closed", arguments);
- setTimeout(function() {
- term.write('Closed');
- term.skipNextKey = true;
- return term.element.classList.add('dead');
- }, 1);
- quit = true;
- if ((new Date()).getTime() - open_ts > 60 * 1000) {
- return open('', '_self').close();
- }
- });
-
- term = new Terminal($('#wrapper')[0], send, ctl);
-
- addEventListener('beforeunload', function() {
- if (!quit) {
- return 'This will exit the terminal session';
- }
- });
-
- bench = function(n) {
- var rnd, t0;
- if (n == null) {
- n = 100000000;
- }
- rnd = '';
- while (rnd.length < n) {
- rnd += Math.random().toString(36).substring(2);
- }
- t0 = (new Date()).getTime();
- term.write(rnd);
- return console.log("" + n + " chars in " + ((new Date()).getTime() - t0) + " ms");
- };
-
- cbench = function(n) {
- var rnd, t0;
- if (n == null) {
- n = 100000000;
- }
- rnd = '';
- while (rnd.length < n) {
- rnd += "\x1b[" + (30 + parseInt(Math.random() * 20)) + "m";
- rnd += Math.random().toString(36).substring(2);
- }
- t0 = (new Date()).getTime();
- term.write(rnd);
- return console.log("" + n + " chars + colors in " + ((new Date()).getTime() - t0) + " ms");
- };
-
- window.butterfly = term;
+ window.Terminal = Terminal;
}).call(this);
diff --git a/butterfly/static/main.min.js b/butterfly/static/main.min.js
index ac893c7..799f8b3 100644
--- a/butterfly/static/main.min.js
+++ b/butterfly/static/main.min.js
@@ -1,5 +1,5 @@
/*! butterfly 2014-07-18 */
-(function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1},z=[].slice;g=function(a){return a.preventDefault&&a.preventDefault(),a.stopPropagation&&a.stopPropagation(),a.cancelBubble=!0,!1},r=0,c={normal:r++,escaped:r++,csi:r++,osc:r++,charset:r++,dcs:r++,ignore:r++},d=function(){function a(a,b,c){var d,e,f;for(this.parent=a,this.out=b,this.ctl=null!=c?c:function(){},this.context=this.parent.ownerDocument.defaultView,this.document=this.parent.ownerDocument,this.body=this.document.getElementsByTagName("body")[0],this.element=this.document.createElement("div"),this.element.className="terminal focus",this.element.style.outline="none",this.element.setAttribute("tabindex",0),this.parent.appendChild(this.element),d=this.document.createElement("div"),d.className="line",this.element.appendChild(d),this.children=[d],this.compute_char_size(),d.style.height=this.char_size.height+"px",f=this.parent.getBoundingClientRect(),this.cols=Math.floor(f.width/this.char_size.width),this.rows=Math.floor(f.height/this.char_size.height),e=this.rows-1;e--;)d=this.document.createElement("div"),d.style.height=this.char_size.height+"px",d.className="line",this.element.appendChild(d),this.children.push(d);this.scrollback=1e5,this.visualBell=100,this.convertEol=!1,this.termName="xterm",this.cursorBlink=!0,this.cursorState=0,this.last_cc=0,this.reset_vars(),this.refresh(0,this.rows-1),this.focus(),this.startBlink(),addEventListener("keydown",this.keyDown.bind(this)),addEventListener("keypress",this.keyPress.bind(this)),addEventListener("focus",this.focus.bind(this)),addEventListener("blur",this.blur.bind(this)),addEventListener("paste",this.paste.bind(this)),addEventListener("resize",this.resize.bind(this)),"undefined"!=typeof InstallTrigger&&(this.element.contentEditable="true",this.element.addEventListener("mouseup",function(){var a;return a=getSelection().getRangeAt(0),a.startOffset===a.endOffset?getSelection().removeAllRanges():void 0})),this.initmouse(),setTimeout(this.resize.bind(this),100)}return a.prototype.reset_vars=function(){var a;for(this.ybase=0,this.ydisp=0,this.x=0,this.y=0,this.cursorHidden=!1,this.state=c.normal,this.queue="",this.scrollTop=0,this.scrollBottom=this.rows-1,this.applicationKeypad=!1,this.applicationCursor=!1,this.originMode=!1,this.wraparoundMode=!1,this.normal=null,this.charset=null,this.gcharset=null,this.glevel=0,this.charsets=[null],this.defAttr=131840,this.curAttr=this.defAttr,this.params=[],this.currentParam=0,this.prefix="",this.lines=[],a=this.rows;a--;)this.lines.push(this.blankLine());return this.setupStops(),this.skipNextKey=null},a.prototype.compute_char_size=function(){var a;return a=document.createElement("span"),a.textContent="0123456789",this.children[0].appendChild(a),this.char_size={width:a.getBoundingClientRect().width/10,height:this.children[0].getBoundingClientRect().height},this.children[0].removeChild(a)},a.prototype.eraseAttr=function(){return-512&this.defAttr|511&this.curAttr},a.prototype.focus=function(){return this.sendFocus&&this.send("[I"),this.showCursor(),this.element.classList.add("focus"),this.element.classList.remove("blur")},a.prototype.blur=function(){return this.cursorState=1,this.refresh(this.y,this.y),this.sendFocus&&this.send("[O"),this.element.classList.add("blur"),this.element.classList.remove("focus")},a.prototype.paste=function(a){return a.clipboardData?this.send(a.clipboardData.getData("text/plain")):this.context.clipboardData&&this.send(this.context.clipboardData.getData("Text")),g(a)},a.prototype.initmouse=function(){var a,b,c,d,e,f,h;return d=32,e=function(a){var e,g;if(e=b(a),g=c(a))switch(f(e,g),a.type){case"mousedown":return d=e;case"mouseup":return d=32}},h=function(a){var b,e;return b=d,(e=c(a))?(b+=32,f(b,e)):void 0},a=function(a){return function(b,c){return a.utfMouse?2047===c?b.push(0):127>c?b.push(c):(c>2047&&(c=2047),b.push(192|c>>6),b.push(128|63&c)):255===c?b.push(0):(c>127&&(c=127),b.push(c))}}(this),f=function(b){return function(c,d){var e;return b.urxvtMouse?(d.x-=32,d.y-=32,d.x++,d.y++,void b.send("["+c+";"+d.x+";"+d.y+"M")):b.sgrMouse?(d.x-=32,d.y-=32,void b.send("[<"+(3===(3&c)?-4&c:c)+";"+d.x+";"+d.y+(3===(3&c)?"m":"M"))):(e=[],a(e,c),a(e,d.x),a(e,d.y),b.send("[M"+String.fromCharCode.apply(String,e)))}}(this),b=function(a){return function(b){var c,d,e,f,g;switch(b.type){case"mousedown":c=null!=b.button?+b.button:null!=b.which?b.which-1:null;break;case"mouseup":c=3;break;case"wheel":c=b.deltaY<0?64:65}return g=b.shiftKey?4:0,e=b.metaKey?8:0,d=b.ctrlKey?16:0,f=g|e|d,a.vt200Mouse?f&=d:a.normalMouse||(f=0),32+(f<<2)+c}}(this),c=function(a){return function(b){var c,d,e,f,g;for(f=b.pageX,g=b.pageY,c=a.element;c&&c!==a.document.documentElement;)f-=c.offsetLeft,g-=c.offsetTop,c="offsetParent"in c?c.offsetParent:c.parentNode;return e=a.element.clientWidth,d=a.element.clientHeight,f=Math.ceil(f/e*a.cols),g=Math.ceil(g/d*a.rows),0>f&&(f=0),f>a.cols&&(f=a.cols),0>g&&(g=0),g>a.rows&&(g=a.rows),f+=32,g+=32,{x:f,y:g,type:b.type}}}(this),addEventListener("mousedown",function(a){return function(b){var c,d;if(a.mouseEvents)return e(b),a.vt200Mouse?(e({__proto__:b,type:"mouseup"}),g(b)):(c=h.bind(a),a.normalMouse&&addEventListener("mousemove",c),a.x10Mouse||addEventListener("mouseup",d=function(b){return e(b),a.normalMouse&&removeEventListener("mousemove",c),removeEventListener("mouseup",d),g(b)}),g(b))}}(this)),addEventListener("wheel",function(a){return function(b){if(a.mouseEvents){if(a.x10Mouse)return;e(b)}else{if(a.applicationKeypad)return;a.scrollDisp(b.deltaY>0?5:-5)}return g(b)}}(this))},a.prototype.refresh=function(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q;for(b-a>=this.rows/3&&(m=this.element.parentNode,null!=m&&m.removeChild(this.element)),o=this.cols,q=a,b>=this.lines.length&&(b=this.lines.length-1);b>=q;){for(n=q+this.ydisp,k=this.lines[n],l="",p=q!==this.y||this.ydisp!==this.ybase&&!this.selectMode||this.cursorHidden?-1/0:this.x,c=this.defAttr,j=0;o>j;){if(g=k[j][0],e=k[j][1],g!==c&&(c!==this.defAttr&&(l+=""),g!==this.defAttr&&(f=[],l+=">9&511,i=g>>18,1&i&&f.push("bold"),2&i&&f.push("underline"),4&i&&f.push("blink"),8&i&&f.push("reverse-video"),16&i&&f.push("invisible"),1&i&&8>h&&(h+=8),f.push("bg-color-"+d),f.push("fg-color-"+h),l+='class="',l+=f.join(" "),l+='">')),j===p&&(l+=''),e.length>1)l+=e;else switch(e){case"&":l+="&";break;case"<":l+="<";break;case">":l+=">";break;default:" ">=e?l+=" ":(e>""&&"">e&&j++,l+=e)}j===p&&(l+=""),c=g,j++}c!==this.defAttr&&(l+=""),this.children[q].innerHTML=l,q++}return null!=m?m.appendChild(this.element):void 0},a.prototype._cursorBlink=function(){var a;return this.cursorState^=1,(a=this.element.querySelector(".cursor"))?a.classList.contains("reverse-video")?a.classList.remove("reverse-video"):a.classList.add("reverse-video"):void 0},a.prototype.showCursor=function(){return this.cursorState?void 0:(this.cursorState=1,this.refresh(this.y,this.y))},a.prototype.startBlink=function(){return this.cursorBlink?(this._blinker=function(a){return function(){return a._cursorBlink()}}(this),this.t_blink=setInterval(this._blinker,500)):void 0},a.prototype.refreshBlink=function(){return this.cursorBlink?(clearInterval(this.t_blink),this.t_blink=setInterval(this._blinker,500)):void 0},a.prototype.scroll=function(){var a;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,a=this.ybase+this.rows-1,a-=this.rows-1-this.scrollBottom,a===this.lines.length?this.lines.push(this.blankLine()):this.lines.splice(a,0,this.blankLine()),0!==this.scrollTop&&(0!==this.ybase&&(this.ybase--,this.ydisp=this.ybase),this.lines.splice(this.ybase+this.scrollTop,1)),this.updateRange(this.scrollTop),this.updateRange(this.scrollBottom)},a.prototype.scrollDisp=function(a){return this.ydisp+=a,this.ydisp>this.ybase?this.ydisp=this.ybase:this.ydisp<0&&(this.ydisp=0),this.refresh(0,this.rows-1)},a.prototype.write=function(b){var d,e,f,g,h,i,j,k;for(this.refreshStart=this.y,this.refreshEnd=this.y,this.ybase!==this.ydisp&&(this.ydisp=this.ybase,this.maxRange()),f=0,h=b.length;h>f;){switch(d=b[f],this.state){case c.normal:switch(d){case"":this.bell();break;case"\n":case"":case"\f":this.convertEol&&(this.x=0),this.y++,this.y>this.scrollBottom&&(this.y--,this.scroll());break;case"\r":this.x=0;break;case"\b":this.x>0&&this.x--;break;case" ":this.x=this.nextStop();break;case"":this.setgLevel(1);break;case"":this.setgLevel(0);break;case"":this.state=c.escaped;break;default:if(d>=" "&&((null!=(k=this.charset)?k[d]:void 0)&&(d=this.charset[d]),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,d],this.x++,this.updateRange(this.y),d>""&&"">d)){if(g=this.y+this.ybase,this.cols<2||this.x>=this.cols){this.lines[g][this.x-1]=[this.curAttr," "];break}this.lines[g][this.x]=[this.curAttr," "],this.x++}}break;case c.escaped:switch(d){case"[":this.params=[],this.currentParam=0,this.state=c.csi;break;case"]":this.params=[],this.currentParam=0,this.state=c.osc;break;case"P":this.params=[],this.currentParam=0,this.state=c.dcs;break;case"_":this.state=c.ignore;break;case"^":this.state=c.ignore;break;case"c":this.reset();break;case"E":this.x=0,this.index();break;case"D":this.index();break;case"M":this.reverseIndex();break;case"%":this.setgLevel(0),this.setgCharset(0,a.prototype.charsets.US),this.state=c.normal,f++;break;case"(":case")":case"*":case"+":case"-":case".":switch(d){case"(":this.gcharset=0;break;case")":case"-":this.gcharset=1;break;case"*":case".":this.gcharset=2;break;case"+":this.gcharset=3}this.state=c.charset;break;case"/":this.gcharset=3,this.state=c.charset,f--;break;case"n":this.setgLevel(2);break;case"o":this.setgLevel(3);break;case"|":this.setgLevel(3);break;case"}":this.setgLevel(2);break;case"~":this.setgLevel(1);break;case"7":this.saveCursor(),this.state=c.normal;break;case"8":this.restoreCursor(),this.state=c.normal;break;case"#":this.state=c.normal,f++;break;case"H":this.tabSet();break;case"=":this.applicationKeypad=!0,this.state=c.normal;break;case">":this.applicationKeypad=!1,this.state=c.normal;break;default:this.state=c.normal,console.log("Unknown ESC control:",d)}break;case c.charset:switch(d){case"0":e=a.prototype.charsets.SCLD;break;case"A":e=a.prototype.charsets.UK;break;case"B":e=a.prototype.charsets.US;break;case"4":e=a.prototype.charsets.Dutch;break;case"C":case"5":e=a.prototype.charsets.Finnish;break;case"R":e=a.prototype.charsets.French;break;case"Q":e=a.prototype.charsets.FrenchCanadian;break;case"K":e=a.prototype.charsets.German;break;case"Y":e=a.prototype.charsets.Italian;break;case"E":case"6":e=a.prototype.charsets.NorwegianDanish;break;case"Z":e=a.prototype.charsets.Spanish;break;case"H":case"7":e=a.prototype.charsets.Swedish;break;case"=":e=a.prototype.charsets.Swiss;break;case"/":e=a.prototype.charsets.ISOLatin,f++;break;default:e=a.prototype.charsets.US}this.setgCharset(this.gcharset,e),this.gcharset=null,this.state=c.normal;break;case c.osc:if(""===d||""===d){switch(""===d&&f++,this.params.push(this.currentParam),this.params[0]){case 0:case 1:case 2:this.params[1]&&(this.title=this.params[1]+" - ƸӜƷ butterfly",this.handleTitle(this.title))}this.params=[],this.currentParam=0,this.state=c.normal}else this.params.length?this.currentParam+=d:d>="0"&&"9">=d?this.currentParam=10*this.currentParam+d.charCodeAt(0)-48:";"===d&&(this.params.push(this.currentParam),this.currentParam="");break;case c.csi:if("?"===d||">"===d||"!"===d){this.prefix=d;break}if(d>="0"&&"9">=d){this.currentParam=10*this.currentParam+d.charCodeAt(0)-48;break}if("$"===d||'"'===d||" "===d||"'"===d)break;if(this.params.push(this.currentParam),this.currentParam=0,";"===d)break;switch(this.state=c.normal,d){case"A":this.cursorUp(this.params);break;case"B":this.cursorDown(this.params);break;case"C":this.cursorForward(this.params);break;case"D":this.cursorBackward(this.params);break;case"H":this.cursorPos(this.params);break;case"J":this.eraseInDisplay(this.params);break;case"K":this.eraseInLine(this.params);break;case"m":this.prefix||this.charAttributes(this.params);break;case"n":this.prefix||this.deviceStatus(this.params);break;case"@":this.insertChars(this.params);break;case"E":this.cursorNextLine(this.params);break;case"F":this.cursorPrecedingLine(this.params);break;case"G":this.cursorCharAbsolute(this.params);break;case"L":this.insertLines(this.params);break;case"M":this.deleteLines(this.params);break;case"P":this.deleteChars(this.params);break;case"X":this.eraseChars(this.params);break;case"`":this.charPosAbsolute(this.params);break;case"a":this.HPositionRelative(this.params);break;case"c":this.sendDeviceAttributes(this.params);break;case"d":this.linePosAbsolute(this.params);break;case"e":this.VPositionRelative(this.params);break;case"f":this.HVPosition(this.params);break;case"h":this.setMode(this.params);break;case"l":this.resetMode(this.params);break;case"r":this.setScrollRegion(this.params);break;case"s":this.saveCursor(this.params);break;case"u":this.restoreCursor(this.params);break;case"I":this.cursorForwardTab(this.params);break;case"S":this.scrollUp(this.params);break;case"T":this.params.length<2&&!this.prefix&&this.scrollDown(this.params);break;case"Z":this.cursorBackwardTab(this.params);break;case"b":this.repeatPrecedingCharacter(this.params);break;case"g":this.tabClear(this.params);break;case"p":"!"===this.prefix&&this.softReset(this.params);break;default:console.error("Unknown CSI code: %s.",d)}this.prefix="";break;case c.dcs:if(""===d||""===d){switch(""===d&&f++,this.prefix){case"":break;case"$q":switch(i=this.currentParam,j=!1,i){case'"q':i='0"q';break;case'"p':i='61"p';break;case"r":i=""+(this.scrollTop+1)+";"+(this.scrollBottom+1)+"r";break;case"m":i="0m";break;default:console.error("Unknown DCS Pt: %s.",i),i=""}this.send("P"+ +j+"$r"+i+"\\");break;case"+q":i=this.currentParam,j=!1,this.send("P"+ +j+"+r"+i+"\\");break;default:console.error("Unknown DCS prefix: %s.",this.prefix)}this.currentParam=0,this.prefix="",this.state=c.normal}else this.currentParam?this.currentParam+=d:this.prefix||"$"===d||"+"===d?2===this.prefix.length?this.currentParam=d:this.prefix+=d:this.currentParam=d;break;case c.ignore:(""===d||""===d)&&(""===d&&f++,this.state=c.normal)}f++}return this.updateRange(this.y),this.refresh(this.refreshStart,this.refreshEnd)},a.prototype.writeln=function(a){return this.write(""+a+"\r\n")},a.prototype.keyDown=function(a){var b,c,d,e;if(a.keyCode>15&&a.keyCode<19)return!0;if((a.shiftKey||a.ctrlKey)&&45===a.keyCode)return!0;if(a.shiftKey&&a.ctrlKey&&(67===(e=a.keyCode)||86===e))return!0;if(a.altKey&&90===a.keyCode&&!this.skipNextKey)return this.skipNextKey=!0,this.element.classList.add("skip"),g(a);if(this.skipNextKey)return this.skipNextKey=!1,this.element.classList.remove("skip"),!0;switch(a.keyCode){case 8:if(c=a.altKey?"":"",a.shiftKey){c+="\b";break}c+="";break;case 9:if(a.shiftKey){c="[Z";break}c=" ";break;case 13:c="\r";break;case 27:c="";break;case 37:if(this.applicationCursor){c="OD";break}c="[D";break;case 39:if(this.applicationCursor){c="OC";break}c="[C";break;case 38:if(this.applicationCursor){c="OA";break}if(a.ctrlKey)return this.scrollDisp(-1),g(a);c="[A";break;case 40:if(this.applicationCursor){c="OB";break}if(a.ctrlKey)return this.scrollDisp(1),g(a);c="[B";break;case 46:c="[3~";break;case 45:c="[2~";break;case 36:if(this.applicationKeypad){c="OH";break}c="OH";break;case 35:if(this.applicationKeypad){c="OF";break}c="OF";break;case 33:if(a.shiftKey)return this.scrollDisp(-(this.rows-1)),g(a);c="[5~";break;case 34:if(a.shiftKey)return this.scrollDisp(this.rows-1),g(a);c="[6~";break;case 112:c="OP";break;case 113:c="OQ";break;case 114:c="OR";break;case 115:c="OS";break;case 116:c="[15~";break;case 117:c="[17~";break;case 118:c="[18~";break;case 119:c="[19~";break;case 120:c="[20~";break;case 121:c="[21~";break;case 122:c="[23~";break;case 123:c="[24~";break;default:if(a.ctrlKey)if(a.keyCode>=65&&a.keyCode<=90){if(67===a.keyCode){if(d=(new Date).getTime(),d-this.last_cc<75)for(b=setTimeout(function(){})-6,this.write("\r\n --8<------8<-- Sectioned --8<------8<-- \r\n\r\n");b--;)b!==this.t_bell&&b!==this.t_queue&&b!==this.t_blink&&clearTimeout(b);this.last_cc=d}c=String.fromCharCode(a.keyCode-64)}else 32===a.keyCode?c=String.fromCharCode(0):a.keyCode>=51&&a.keyCode<=55?c=String.fromCharCode(a.keyCode-51+27):56===a.keyCode?c=String.fromCharCode(127):219===a.keyCode?c=String.fromCharCode(27):221===a.keyCode&&(c=String.fromCharCode(29));else(a.altKey&&y.call(navigator.platform,"Mac")<0||a.metaKey&&y.call(navigator.platform,"Mac")>=0)&&(a.keyCode>=65&&a.keyCode<=90?c=""+String.fromCharCode(a.keyCode+32):192===a.keyCode?c="`":a.keyCode>=48&&a.keyCode<=57&&(c=""+(a.keyCode-48)))}return a.keyCode>=37&&a.keyCode<=40&&(a.ctrlKey?c=c.slice(0,-1)+"1;5"+c.slice(-1):a.altKey?c=c.slice(0,-1)+"1;3"+c.slice(-1):a.shiftKey&&(c=c.slice(0,-1)+"1;4"+c.slice(-1))),c?this.prefixMode?(this.leavePrefix(),g(a)):this.selectMode?(this.keySelect(a,c),g(a)):(this.showCursor(),this.handler(c),g(a)):!0},a.prototype.setgLevel=function(a){return this.glevel=a,this.charset=this.charsets[a]},a.prototype.setgCharset=function(a,b){return this.charsets[a]=b,this.glevel===a?this.charset=b:void 0},a.prototype.keyPress=function(a){var b;if(this.skipNextKey===!1)return this.skipNextKey=null,!0;if(g(a),a.charCode)b=a.charCode;else if(null==a.which)b=a.keyCode;else{if(0===a.which||0===a.charCode)return!1;b=a.which}return!b||a.ctrlKey||a.altKey||a.metaKey?!1:(b=String.fromCharCode(b),this.showCursor(),this.handler(b),!1)},a.prototype.send=function(a){return this.queue||(this.t_queue=setTimeout(function(a){return function(){return a.handler(a.queue),a.queue=""}}(this),1)),this.queue+=a},a.prototype.bell=function(){return this.visualBell?(this.element.classList.add("bell"),this.t_bell=setTimeout(function(a){return function(){return a.element.classList.remove("bell")}}(this),this.visualBell)):void 0},a.prototype.resize=function(){var a,b,c,d,e,f,g,h;if(f=this.cols,g=this.rows,this.compute_char_size(),h=this.parent.getBoundingClientRect(),this.cols=Math.floor(h.width/this.char_size.width),this.rows=Math.floor(h.height/this.char_size.height),f!==this.cols||g!==this.rows){if(this.ctl("Resize",this.cols,this.rows),fthis.cols)for(c=this.lines.length;c--;)for(;this.lines[c].length>this.cols;)this.lines[c].pop();if(this.setupStops(f),d=g,dthis.rows)for(;d-->this.rows;)if(this.lines.length>this.rows+this.ybase&&this.lines.pop(),this.children.length>this.rows){if(b=this.children.pop(),!b)continue;b.parentNode.removeChild(b)}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}},a.prototype.updateRange=function(a){return athis.refreshEnd?this.refreshEnd=a:void 0},a.prototype.maxRange=function(){return this.refreshStart=0,this.refreshEnd=this.rows-1},a.prototype.setupStops=function(a){var b;for(null!=a?this.tabs[a]||(a=this.prevStop(a)):(this.tabs={},a=0),b=[];a0;);return a>=this.cols?this.cols-1:0>a?0:a},a.prototype.nextStop=function(a){for(null==a&&(a=this.x);!this.tabs[++a]&&a=this.cols?this.cols-1:0>a?0:a},a.prototype.eraseRight=function(a,b){var c,d;for(d=this.lines[this.ybase+b],c=[this.eraseAttr()," "];athis.scrollBottom&&(this.y--,this.scroll()),this.state=c.normal},a.prototype.reverseIndex=function(){var a;return this.y--,this.yb&&(b=1),this.y-=b,this.y<0?this.y=0:void 0},a.prototype.cursorDown=function(a){var b;return b=a[0],1>b&&(b=1),this.y+=b,this.y>=this.rows?this.y=this.rows-1:void 0},a.prototype.cursorForward=function(a){var b;return b=a[0],1>b&&(b=1),this.x+=b,this.x>=this.cols?this.x=this.cols-1:void 0},a.prototype.cursorBackward=function(a){var b;return b=a[0],1>b&&(b=1),this.x-=b,this.x<0?this.x=0:void 0},a.prototype.cursorPos=function(a){var b,c;return c=a[0]-1,b=a.length>=2?a[1]-1:0,0>c?c=0:c>=this.rows&&(c=this.rows-1),0>b?b=0:b>=this.cols&&(b=this.cols-1),this.x=b,this.y=c},a.prototype.eraseInDisplay=function(a){var b,c,d,e;switch(a[0]){case 0:for(this.eraseRight(this.x,this.y),b=this.y+1,c=[];b>18,c=this.curAttr>>9&511,b=511&this.curAttr,f=a.length,e=0;f>e;)g=a[e],g>=30&&37>=g?c=g-30:g>=40&&47>=g?b=g-40:g>=90&&97>=g?(g+=8,c=g-90):g>=100&&107>=g?(g+=8,b=g-100):0===g?(d=this.defAttr>>18,c=this.defAttr>>9&511,b=511&this.defAttr):1===g?d|=1:4===g?d|=2:5===g?d|=4:7===g?d|=8:8===g?d|=16:22===g?d&=-2:24===g?d&=-3:25===g?d&=-5:27===g?d&=-9:28===g?d&=-17:39===g?c=this.defAttr>>9&511:49===g?b=511&this.defAttr:38===g?2===a[e+1]?(e+=2,c="#"+a[e]&255+a[e+1]&255+a[e+2]&255,e+=2):5===a[e+1]&&(e+=2,c=255&a[e]):48===g?2===a[e+1]?(e+=2,b="#"+a[e]&255+a[e+1]&255+a[e+2]&255,e+=2):5===a[e+1]&&(e+=2,b=255&a[e]):100===g?(c=this.defAttr>>9&511,b=511&this.defAttr):console.error("Unknown SGR attribute: %d.",g),e++;return this.curAttr=d<<18|c<<9|b},a.prototype.deviceStatus=function(a){if(this.prefix){if("?"===this.prefix&&6===a[0])return this.send("[?"+(this.y+1)+";"+(this.x+1)+"R")}else switch(a[0]){case 5:return this.send("[0n");case 6:return this.send("["+(this.y+1)+";"+(this.x+1)+"R")}},a.prototype.insertChars=function(a){var b,c,d,e,f;for(d=a[0],1>d&&(d=1),e=this.y+this.ybase,c=this.x,b=[this.eraseAttr()," "],f=[];d--&&cb&&(b=1),this.y+=b,this.y>=this.rows&&(this.y=this.rows-1),this.x=0},a.prototype.cursorPrecedingLine=function(a){var b;return b=a[0],1>b&&(b=1),this.y-=b,this.y<0&&(this.y=0),this.x=0},a.prototype.cursorCharAbsolute=function(a){var b;return b=a[0],1>b&&(b=1),this.x=b-1},a.prototype.insertLines=function(a){var b,c,d;for(c=a[0],1>c&&(c=1),d=this.y+this.ybase,b=this.rows-1-this.scrollBottom,b=this.rows-1+this.ybase-b+1;c--;)this.lines.splice(d,0,this.blankLine(!0)),this.lines.splice(b,1);return this.updateRange(this.y),this.updateRange(this.scrollBottom)},a.prototype.deleteLines=function(a){var b,c,d;for(c=a[0],1>c&&(c=1),d=this.y+this.ybase,b=this.rows-1-this.scrollBottom,b=this.rows-1+this.ybase-b;c--;)this.lines.splice(b+1,0,this.blankLine(!0)),this.lines.splice(d,1);return this.updateRange(this.y),this.updateRange(this.scrollBottom)},a.prototype.deleteChars=function(a){var b,c,d,e;for(c=a[0],1>c&&(c=1),d=this.y+this.ybase,b=[this.eraseAttr()," "],e=[];c--;)this.lines[d].splice(this.x,1),e.push(this.lines[d].push(b));return e},a.prototype.eraseChars=function(a){var b,c,d,e,f;for(d=a[0],1>d&&(d=1),e=this.y+this.ybase,c=this.x,b=[this.eraseAttr()," "],f=[];d--&&cb&&(b=1),this.x=b-1,this.x>=this.cols?this.x=this.cols-1:void 0},a.prototype.HPositionRelative=function(a){var b;return b=a[0],1>b&&(b=1),this.x+=b,this.x>=this.cols?this.x=this.cols-1:void 0},a.prototype.sendDeviceAttributes=function(a){if(!(a[0]>0))if(this.prefix){if(">"===this.prefix){if(this.isterm("xterm"))return this.send("[>0;276;0c");if(this.isterm("rxvt-unicode"))return this.send("[>85;95;0c");if(this.isterm("linux"))return this.send(a[0]+"c");if(this.isterm("screen"))return this.send("[>83;40003;0c")}}else{if(this.isterm("xterm")||this.isterm("rxvt-unicode")||this.isterm("screen"))return this.send("[?1;2c");if(this.isterm("linux"))return this.send("[?6c")}},a.prototype.linePosAbsolute=function(a){var b;return b=a[0],1>b&&(b=1),this.y=b-1,this.y>=this.rows?this.y=this.rows-1:void 0},a.prototype.VPositionRelative=function(a){var b;return b=a[0],1>b&&(b=1),this.y+=b,this.y>=this.rows?this.y=this.rows-1:void 0},a.prototype.HVPosition=function(a){return a[0]<1&&(a[0]=1),a[1]<1&&(a[1]=1),this.y=a[0]-1,this.y>=this.rows&&(this.y=this.rows-1),this.x=a[1]-1,this.x>=this.cols?this.x=this.cols-1:void 0},a.prototype.setMode=function(b){var c,d,e;if("object"!=typeof b){if("?"===this.prefix)switch(b){case 1:return this.applicationCursor=!0;case 2:return this.setgCharset(0,a.prototype.charsets.US),this.setgCharset(1,a.prototype.charsets.US),this.setgCharset(2,a.prototype.charsets.US),this.setgCharset(3,a.prototype.charsets.US);case 3:return this.savedCols=this.cols,this.resize(132,this.rows);case 6:return this.originMode=!0;case 7:return this.wraparoundMode=!0;case 66:return this.applicationKeypad=!0;case 9:case 1e3:case 1002:case 1003:return this.x10Mouse=9===b,this.vt200Mouse=1e3===b,this.normalMouse=b>1e3,this.mouseEvents=!0,this.element.style.cursor="pointer";case 1004:return this.sendFocus=!0;case 1005:return this.utfMouse=!0;case 1006:return this.sgrMouse=!0;case 1015:return this.urxvtMouse=!0;case 25:return this.cursorHidden=!1;case 1049:case 47:case 1047:if(!this.normal)return e={lines:this.lines,ybase:this.ybase,ydisp:this.ydisp,x:this.x,y:this.y,scrollTop:this.scrollTop,scrollBottom:this.scrollBottom,tabs:this.tabs},this.reset(),this.normal=e,this.showCursor()}}else for(d=b.length,c=0;d>c;)this.setMode(b[c]),c++},a.prototype.resetMode=function(a){var b,c;if("object"!=typeof a){if("?"===this.prefix)switch(a){case 1:return this.applicationCursor=!1;case 3:return 132===this.cols&&this.savedCols&&this.resize(this.savedCols,this.rows),delete this.savedCols;case 6:return this.originMode=!1;case 7:return this.wraparoundMode=!1;case 66:return this.applicationKeypad=!1;case 9:case 1e3:case 1002:case 1003:return this.x10Mouse=!1,this.vt200Mouse=!1,this.normalMouse=!1,this.mouseEvents=!1,this.element.style.cursor="";case 1004:return this.sendFocus=!1;case 1005:return this.utfMouse=!1;case 1006:return this.sgrMouse=!1;case 1015:return this.urxvtMouse=!1;case 25:return this.cursorHidden=!0;case 1049:case 47:case 1047:if(this.normal)return this.lines=this.normal.lines,this.ybase=this.normal.ybase,this.ydisp=this.normal.ydisp,this.x=this.normal.x,this.y=this.normal.y,this.scrollTop=this.normal.scrollTop,this.scrollBottom=this.normal.scrollBottom,this.tabs=this.normal.tabs,this.normal=null,this.refresh(0,this.rows-1),this.showCursor()}}else for(c=a.length,b=0;c>b;)this.resetMode(a[b]),b++},a.prototype.setScrollRegion=function(a){return this.prefix?void 0:(this.scrollTop=(a[0]||1)-1,this.scrollBottom=(a[1]||this.rows)-1,this.x=0,this.y=0)},a.prototype.saveCursor=function(){return this.savedX=this.x,this.savedY=this.y},a.prototype.restoreCursor=function(){return this.x=this.savedX||0,this.y=this.savedY||0},a.prototype.cursorForwardTab=function(a){var b,c;for(b=a[0]||1,c=[];b--;)c.push(this.x=this.nextStop());return c},a.prototype.scrollUp=function(a){var b;for(b=a[0]||1;b--;)this.lines.splice(this.ybase+this.scrollTop,1),this.lines.splice(this.ybase+this.scrollBottom,0,this.blankLine());return this.updateRange(this.scrollTop),this.updateRange(this.scrollBottom)},a.prototype.scrollDown=function(a){var b;for(b=a[0]||1;b--;)this.lines.splice(this.ybase+this.scrollBottom,1),this.lines.splice(this.ybase+this.scrollTop,0,this.blankLine());return this.updateRange(this.scrollTop),this.updateRange(this.scrollBottom)},a.prototype.initMouseTracking=function(){},a.prototype.resetTitleModes=function(){},a.prototype.cursorBackwardTab=function(a){var b,c;for(b=a[0]||1,c=[];b--;)c.push(this.x=this.prevStop());return c},a.prototype.repeatPrecedingCharacter=function(a){var b,c,d,e;for(d=a[0]||1,c=this.lines[this.ybase+this.y],b=c[this.x-1]||[this.defAttr," "],e=[];d--;)e.push(c[this.x++]=b);return e},a.prototype.tabClear=function(a){var b;return b=a[0],0>=b?delete this.tabs[this.x]:3===b?this.tabs={}:void 0},a.prototype.mediaCopy=function(){},a.prototype.setResources=function(){},a.prototype.disableModifiers=function(){},a.prototype.setPointerMode=function(){},a.prototype.softReset=function(){return this.cursorHidden=!1,this.insertMode=!1,this.originMode=!1,this.wraparoundMode=!1,this.applicationKeypad=!1,this.applicationCursor=!1,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]},a.prototype.requestAnsiMode=function(){},a.prototype.requestPrivateMode=function(){},a.prototype.setConformanceLevel=function(){},a.prototype.loadLEDs=function(){},a.prototype.setCursorStyle=function(){},a.prototype.setCharProtectionAttr=function(){},a.prototype.restorePrivateValues=function(){},a.prototype.setAttrInRectangle=function(a){var b,c,d,e,f,g,h;for(h=a[0],e=a[1],c=a[2],g=a[3],b=a[4];c+1>h;){for(f=this.lines[this.ybase+h],d=e;g>d;)f[d]=[b,f[d][1]],d++;h++}return this.updateRange(a[0]),this.updateRange(a[2])},a.prototype.savePrivateValues=function(){},a.prototype.manipulateWindow=function(){},a.prototype.reverseAttrInRectangle=function(){},a.prototype.setTitleModeFeature=function(){},a.prototype.setWarningBellVolume=function(){},a.prototype.setMarginBellVolume=function(){},a.prototype.copyRectangle=function(){},a.prototype.enableFilterRectangle=function(){},a.prototype.requestParameters=function(){},a.prototype.selectChangeExtent=function(){},a.prototype.fillRectangle=function(a){var b,c,d,e,f,g,h;for(c=a[0],h=a[1],e=a[2],b=a[3],g=a[4];b+1>h;){for(f=this.lines[this.ybase+h],d=e;g>d;)f[d]=[f[d][0],String.fromCharCode(c)],d++;h++}return this.updateRange(a[1]),this.updateRange(a[3])},a.prototype.enableLocatorReporting=function(a){var b;return b=a[0]>0},a.prototype.eraseRectangle=function(a){var b,c,d,e,f,g,h;for(h=a[0],e=a[1],b=a[2],g=a[3],c=[this.eraseAttr()," "];b+1>h;){for(f=this.lines[this.ybase+h],d=e;g>d;)f[d]=c,d++;
-h++}return this.updateRange(a[0]),this.updateRange(a[2])},a.prototype.setLocatorEvents=function(){},a.prototype.selectiveEraseRectangle=function(){},a.prototype.requestLocatorPosition=function(){},a.prototype.insertColumns=function(){var a,b,c,d;for(d=params[0],c=this.ybase+this.rows,a=[this.eraseAttr()," "];d--;)for(b=this.ybase;c>b;)this.lines[b].splice(this.x+1,0,a),this.lines[b].pop(),b++;return this.maxRange()},a.prototype.deleteColumns=function(){var a,b,c,d;for(d=params[0],c=this.ybase+this.rows,a=[this.eraseAttr()," "];d--;)for(b=this.ybase;c>b;)this.lines[b].splice(this.x,1),this.lines[b].push(a),b++;return this.maxRange()},a.prototype.get_html_height_in_lines=function(a){var b,c;return c=document.createElement("div"),c.innerHTML=a,this.element.appendChild(c),b=c.getBoundingClientRect().height,this.element.removeChild(c),Math.ceil(b/this.char_size.height)},a.prototype.charsets={SCLD:{"`":"◆",a:"▒",b:" ",c:"\f",d:"\r",e:"\n",f:"°",g:"±",h:"",i:"",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"},UK:null,US:null,Dutch:null,Finnish:null,French:null,FrenchCanadian:null,German:null,Italian:null,NorwegianDanish:null,Spanish:null,Swedish:null,Swiss:null,ISOLatin:null},a}(),s=null,o=function(a){var b;for(b=a.previousSibling,b||(b=a.parentNode.previousSibling),b||(b=a.parentNode.parentNode.previousSibling);b.lastChild;)b=b.lastChild;return b},m=function(a){var b;for(b=a.nextSibling,b||(b=a.parentNode.nextSibling),b||(b=a.parentNode.parentNode.nextSibling);b.firstChild;)b=b.firstChild;return b},b=function(){function a(){u.element.classList.add("selection"),this.selection=getSelection()}return a.prototype.reset=function(){var a,b,c;for(this.selection=getSelection(),a=document.createRange(),a.setStart(this.selection.anchorNode,this.selection.anchorOffset),a.setEnd(this.selection.focusNode,this.selection.focusOffset),this.start={node:this.selection.anchorNode,offset:this.selection.anchorOffset},this.end={node:this.selection.focusNode,offset:this.selection.focusOffset},a.collapsed&&(b=[this.end,this.start],this.start=b[0],this.end=b[1]),this.start_line=this.start.node;!this.start_line.classList||y.call(this.start_line.classList,"line")<0;)this.start_line=this.start_line.parentNode;for(this.end_line=this.end.node,c=[];!this.end_line.classList||y.call(this.end_line.classList,"line")<0;)c.push(this.end_line=this.end_line.parentNode);return c},a.prototype.clear=function(){return this.selection.removeAllRanges()},a.prototype.destroy=function(){return u.element.classList.remove("selection"),this.clear()},a.prototype.text=function(){return this.selection.toString()},a.prototype.up=function(){return this.go(-1)},a.prototype.down=function(){return this.go(1)},a.prototype.go=function(a){var b;if(b=u.children.indexOf(this.start_line)+a,b>=0&&b=0&&b0;)if(f[--d].match(b))return{node:e,offset:d+1};e=o(e),f=e.textContent,d=f.length}else for(;e;){for(;d=0)return!0;if(a.shiftKey&&13===a.keyCode&&!s&&!getSelection().isCollapsed)return u.handler(getSelection().toString()),getSelection().removeAllRanges(),g(a);if(s){if(s.reset(),!a.ctrlKey&&a.shiftKey&&37<=(d=a.keyCode)&&40>=d)return!0;if(a.shiftKey&&a.ctrlKey)38===a.keyCode?s.up():40===a.keyCode&&s.down();else if(39===a.keyCode)s.shrink_left();else if(38===a.keyCode)s.expand_left();else if(37===a.keyCode)s.shrink_right();else{if(40!==a.keyCode)return g(a);s.expand_right()}return null!=s&&s.apply(),g(a)}return!s&&a.ctrlKey&&a.shiftKey&&38===a.keyCode?(s=new b,s.select_line(u.y-1),s.apply(),g(a)):!0}),document.addEventListener("keyup",function(a){var b,c;if(b=a.keyCode,y.call([16,17,18,19],b)>=0)return!0;if(s){if(13===a.keyCode)return u.handler(s.text()),s.destroy(),s=null,g(a);if(c=a.keyCode,y.call([37,38,39,40],c)<0)return s.destroy(),s=null,!0}return!0}),document.addEventListener("dblclick",function(a){var b,c,d,e,f;if(!(a.ctrlKey||a.altkey||(f=getSelection(),f.isCollapsed||f.toString().match(/\s/)))){for(e=document.createRange(),e.setStart(f.anchorNode,f.anchorOffset),e.setEnd(f.focusNode,f.focusOffset),e.collapsed&&(f.removeAllRanges(),d=document.createRange(),d.setStart(f.focusNode,f.focusOffset),d.setEnd(f.anchorNode,f.anchorOffset),f.addRange(d)),e.detach();!f.toString().match(/\s/)&&f.toString();)f.modify("extend","forward","character");for(f.modify("extend","backward","character"),b=f.anchorNode,c=f.anchorOffset,f.collapseToEnd(),f.extend(b,c);!f.toString().match(/\s/)&&f.toString();)f.modify("extend","backward","character");return f.modify("extend","forward","character")}}),/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)&&(k=!1,e=!1,l=!0,v=document.createElement("input"),v.type="password",v.style.position="fixed",v.style.top=0,v.style.left=0,v.style.border="none",v.style.outline="none",v.style.opacity=0,v.value="0",document.body.appendChild(v),v.addEventListener("blur",function(){return setTimeout(function(a){return function(){return a.focus()}}(this),10)}),addEventListener("click",function(){return v.focus()}),addEventListener("touchstart",function(a){return 2===a.touches.length?k=!0:3===a.touches.length?(k=!1,e=!0):4===a.touches.length?(k=!0,e=!0):void 0}),v.addEventListener("keydown",function(a){return u.keyDown(a),!0}),v.addEventListener("input",function(a){var b;return b=this.value.length,0===b?(a.keyCode=8,u.keyDown(a),this.value="0",!0):(a.keyCode=this.value.charAt(1).charCodeAt(0),!k&&!e||l?(u.keyPress(a),l=!1,this.value="0",!0):(a.keyCode=this.value.charAt(1).charCodeAt(0),a.ctrlKey=k,a.altKey=e,a.keyCode>=97&&a.keyCode<=122&&(a.keyCode-=32),u.keyDown(a),this.value="0",k=e=!1,!0))})),i=q=null,p=!1,n=(new Date).getTime(),a=document.querySelectorAll.bind(document),t=function(a){return w.send("S"+a)},j=function(){var a,b,c;return c=arguments[0],a=2<=arguments.length?z.call(arguments,1):[],b=a.join(","),"Resize"===c?w.send("R"+b):void 0},x="https:"===location.protocol?"wss://":"ws://",x+=document.location.host+"/ws"+location.pathname,w=new WebSocket(x),w.addEventListener("open",function(){return console.log("WebSocket open",arguments),w.send("R"+u.cols+","+u.rows),n=(new Date).getTime()}),w.addEventListener("error",function(){return console.log("WebSocket error",arguments)}),w.addEventListener("message",function(a){return setTimeout(function(){return u.write(a.data)},1)}),w.addEventListener("close",function(){return console.log("WebSocket closed",arguments),setTimeout(function(){return u.write("Closed"),u.skipNextKey=!0,u.element.classList.add("dead")},1),p=!0,(new Date).getTime()-n>6e4?open("","_self").close():void 0}),u=new d(a("#wrapper")[0],t,j),addEventListener("beforeunload",function(){return p?void 0:"This will exit the terminal session"}),f=function(a){var b,c;for(null==a&&(a=1e8),b="";b.lengthb;b++)if(b in this&&this[b]===a)return b;return-1};e=h=null,g=!1,f=(new Date).getTime(),a=document.querySelectorAll.bind(document),document.addEventListener("DOMContentLoaded",function(){var b,d,e,h,i,k,l;return h=function(a){return k.send("S"+a)},e=function(){var a,b,c;return c=arguments[0],a=2<=arguments.length?j.call(arguments,1):[],b=a.join(","),"Resize"===c?k.send("R"+b):void 0},l="https:"===location.protocol?"wss://":"ws://",l+=document.location.host+"/ws"+location.pathname,k=new WebSocket(l),k.addEventListener("open",function(){return console.log("WebSocket open",arguments),k.send("R"+i.cols+","+i.rows),f=(new Date).getTime()}),k.addEventListener("error",function(){return console.log("WebSocket error",arguments)}),k.addEventListener("message",function(a){return setTimeout(function(){return i.write(a.data)},1)}),k.addEventListener("close",function(){return console.log("WebSocket closed",arguments),setTimeout(function(){return i.write("Closed"),i.skipNextKey=!0,i.element.classList.add("dead")},1),g=!0,(new Date).getTime()-f>6e4?open("","_self").close():void 0}),i=new c(a("#wrapper")[0],h,e),addEventListener("beforeunload",function(){return g?void 0:"This will exit the terminal session"}),b=function(a){var b,c;for(null==a&&(a=1e8),b="";b.lengthc?b.push(c):(c>2047&&(c=2047),b.push(192|c>>6),b.push(128|63&c)):255===c?b.push(0):(c>127&&(c=127),b.push(c))}}(this),g=function(b){return function(c,d){var e;return b.urxvtMouse?(d.x-=32,d.y-=32,d.x++,d.y++,void b.send("["+c+";"+d.x+";"+d.y+"M")):b.sgrMouse?(d.x-=32,d.y-=32,void b.send("[<"+(3===(3&c)?-4&c:c)+";"+d.x+";"+d.y+(3===(3&c)?"m":"M"))):(e=[],a(e,c),a(e,d.x),a(e,d.y),b.send("[M"+String.fromCharCode.apply(String,e)))}}(this),b=function(a){return function(b){var c,d,e,f,g;switch(b.type){case"mousedown":c=null!=b.button?+b.button:null!=b.which?b.which-1:null;break;case"mouseup":c=3;break;case"wheel":c=b.deltaY<0?64:65}return g=b.shiftKey?4:0,e=b.metaKey?8:0,d=b.ctrlKey?16:0,f=g|e|d,a.vt200Mouse?f&=d:a.normalMouse||(f=0),32+(f<<2)+c}}(this),c=function(a){return function(b){var c,d,e,f,g;for(f=b.pageX,g=b.pageY,c=a.element;c&&c!==a.document.documentElement;)f-=c.offsetLeft,g-=c.offsetTop,c="offsetParent"in c?c.offsetParent:c.parentNode;return e=a.element.clientWidth,d=a.element.clientHeight,f=Math.ceil(f/e*a.cols),g=Math.ceil(g/d*a.rows),0>f&&(f=0),f>a.cols&&(f=a.cols),0>g&&(g=0),g>a.rows&&(g=a.rows),f+=32,g+=32,{x:f,y:g,type:b.type}}}(this),addEventListener("mousedown",function(a){return function(b){var c,e;if(a.mouseEvents)return f(b),a.vt200Mouse?(f({__proto__:b,type:"mouseup"}),d(b)):(c=h.bind(a),a.normalMouse&&addEventListener("mousemove",c),a.x10Mouse||addEventListener("mouseup",e=function(b){return f(b),a.normalMouse&&removeEventListener("mousemove",c),removeEventListener("mouseup",e),d(b)}),d(b))}}(this)),addEventListener("wheel",function(a){return function(b){if(a.mouseEvents){if(a.x10Mouse)return;f(b)}else{if(a.applicationKeypad)return;a.scrollDisp(b.deltaY>0?5:-5)}return d(b)}}(this))},a.prototype.refresh=function(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q;for(b-a>=this.rows/3&&(m=this.element.parentNode,null!=m&&m.removeChild(this.element)),o=this.cols,q=a,b>=this.lines.length&&(b=this.lines.length-1);b>=q;){for(n=q+this.ydisp,k=this.lines[n],l="",p=q!==this.y||this.ydisp!==this.ybase&&!this.selectMode||this.cursorHidden?-1/0:this.x,c=this.defAttr,j=0;o>j;){if(g=k[j][0],e=k[j][1],g!==c&&(c!==this.defAttr&&(l+=""),g!==this.defAttr&&(f=[],l+=">9&511,i=g>>18,1&i&&f.push("bold"),2&i&&f.push("underline"),4&i&&f.push("blink"),8&i&&f.push("reverse-video"),16&i&&f.push("invisible"),1&i&&8>h&&(h+=8),f.push("bg-color-"+d),f.push("fg-color-"+h),l+='class="',l+=f.join(" "),l+='">')),j===p&&(l+=''),e.length>1)l+=e;else switch(e){case"&":l+="&";break;case"<":l+="<";break;case">":l+=">";break;default:" ">=e?l+=" ":(e>""&&"">e&&j++,l+=e)}j===p&&(l+=""),c=g,j++}c!==this.defAttr&&(l+=""),this.children[q].innerHTML=l,q++}return null!=m?m.appendChild(this.element):void 0},a.prototype._cursorBlink=function(){var a;return this.cursorState^=1,(a=this.element.querySelector(".cursor"))?a.classList.contains("reverse-video")?a.classList.remove("reverse-video"):a.classList.add("reverse-video"):void 0},a.prototype.showCursor=function(){return this.cursorState?void 0:(this.cursorState=1,this.refresh(this.y,this.y))},a.prototype.startBlink=function(){return this.cursorBlink?(this._blinker=function(a){return function(){return a._cursorBlink()}}(this),this.t_blink=setInterval(this._blinker,500)):void 0},a.prototype.refreshBlink=function(){return this.cursorBlink?(clearInterval(this.t_blink),this.t_blink=setInterval(this._blinker,500)):void 0},a.prototype.scroll=function(){var a;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,a=this.ybase+this.rows-1,a-=this.rows-1-this.scrollBottom,a===this.lines.length?this.lines.push(this.blankLine()):this.lines.splice(a,0,this.blankLine()),0!==this.scrollTop&&(0!==this.ybase&&(this.ybase--,this.ydisp=this.ybase),this.lines.splice(this.ybase+this.scrollTop,1)),this.updateRange(this.scrollTop),this.updateRange(this.scrollBottom)},a.prototype.scrollDisp=function(a){return this.ydisp+=a,this.ydisp>this.ybase?this.ydisp=this.ybase:this.ydisp<0&&(this.ydisp=0),this.refresh(0,this.rows-1)},a.prototype.write=function(c){var d,e,f,g,h,i,j,k;for(this.refreshStart=this.y,this.refreshEnd=this.y,this.ybase!==this.ydisp&&(this.ydisp=this.ybase,this.maxRange()),f=0,h=c.length;h>f;){switch(d=c[f],this.state){case b.normal:switch(d){case"":this.bell();break;case"\n":case"":case"\f":this.convertEol&&(this.x=0),this.y++,this.y>this.scrollBottom&&(this.y--,this.scroll());break;case"\r":this.x=0;break;case"\b":this.x>0&&this.x--;break;case" ":this.x=this.nextStop();break;case"":this.setgLevel(1);break;case"":this.setgLevel(0);break;case"":this.state=b.escaped;break;default:if(d>=" "&&((null!=(k=this.charset)?k[d]:void 0)&&(d=this.charset[d]),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,d],this.x++,this.updateRange(this.y),d>""&&"">d)){if(g=this.y+this.ybase,this.cols<2||this.x>=this.cols){this.lines[g][this.x-1]=[this.curAttr," "];break}this.lines[g][this.x]=[this.curAttr," "],this.x++}}break;case b.escaped:switch(d){case"[":this.params=[],this.currentParam=0,this.state=b.csi;break;case"]":this.params=[],this.currentParam=0,this.state=b.osc;break;case"P":this.params=[],this.currentParam=0,this.state=b.dcs;break;case"_":this.state=b.ignore;break;case"^":this.state=b.ignore;break;case"c":this.reset();break;case"E":this.x=0,this.index();break;case"D":this.index();break;case"M":this.reverseIndex();break;case"%":this.setgLevel(0),this.setgCharset(0,a.prototype.charsets.US),this.state=b.normal,f++;break;case"(":case")":case"*":case"+":case"-":case".":switch(d){case"(":this.gcharset=0;break;case")":case"-":this.gcharset=1;break;case"*":case".":this.gcharset=2;break;case"+":this.gcharset=3}this.state=b.charset;break;case"/":this.gcharset=3,this.state=b.charset,f--;break;case"n":this.setgLevel(2);break;case"o":this.setgLevel(3);break;case"|":this.setgLevel(3);break;case"}":this.setgLevel(2);break;case"~":this.setgLevel(1);break;case"7":this.saveCursor(),this.state=b.normal;break;case"8":this.restoreCursor(),this.state=b.normal;break;case"#":this.state=b.normal,f++;break;case"H":this.tabSet();break;case"=":this.applicationKeypad=!0,this.state=b.normal;break;case">":this.applicationKeypad=!1,this.state=b.normal;break;default:this.state=b.normal,console.log("Unknown ESC control:",d)}break;case b.charset:switch(d){case"0":e=a.prototype.charsets.SCLD;break;case"A":e=a.prototype.charsets.UK;break;case"B":e=a.prototype.charsets.US;break;case"4":e=a.prototype.charsets.Dutch;break;case"C":case"5":e=a.prototype.charsets.Finnish;break;case"R":e=a.prototype.charsets.French;break;case"Q":e=a.prototype.charsets.FrenchCanadian;break;case"K":e=a.prototype.charsets.German;break;case"Y":e=a.prototype.charsets.Italian;break;case"E":case"6":e=a.prototype.charsets.NorwegianDanish;break;case"Z":e=a.prototype.charsets.Spanish;break;case"H":case"7":e=a.prototype.charsets.Swedish;break;case"=":e=a.prototype.charsets.Swiss;break;case"/":e=a.prototype.charsets.ISOLatin,f++;break;default:e=a.prototype.charsets.US}this.setgCharset(this.gcharset,e),this.gcharset=null,this.state=b.normal;break;case b.osc:if(""===d||""===d){switch(""===d&&f++,this.params.push(this.currentParam),this.params[0]){case 0:case 1:case 2:this.params[1]&&(this.title=this.params[1]+" - ƸӜƷ butterfly",this.handleTitle(this.title))}this.params=[],this.currentParam=0,this.state=b.normal}else this.params.length?this.currentParam+=d:d>="0"&&"9">=d?this.currentParam=10*this.currentParam+d.charCodeAt(0)-48:";"===d&&(this.params.push(this.currentParam),this.currentParam="");break;case b.csi:if("?"===d||">"===d||"!"===d){this.prefix=d;break}if(d>="0"&&"9">=d){this.currentParam=10*this.currentParam+d.charCodeAt(0)-48;break}if("$"===d||'"'===d||" "===d||"'"===d)break;if(this.params.push(this.currentParam),this.currentParam=0,";"===d)break;switch(this.state=b.normal,d){case"A":this.cursorUp(this.params);break;case"B":this.cursorDown(this.params);break;case"C":this.cursorForward(this.params);break;case"D":this.cursorBackward(this.params);break;case"H":this.cursorPos(this.params);break;case"J":this.eraseInDisplay(this.params);break;case"K":this.eraseInLine(this.params);break;case"m":this.prefix||this.charAttributes(this.params);break;case"n":this.prefix||this.deviceStatus(this.params);break;case"@":this.insertChars(this.params);break;case"E":this.cursorNextLine(this.params);break;case"F":this.cursorPrecedingLine(this.params);break;case"G":this.cursorCharAbsolute(this.params);break;case"L":this.insertLines(this.params);break;case"M":this.deleteLines(this.params);break;case"P":this.deleteChars(this.params);break;case"X":this.eraseChars(this.params);break;case"`":this.charPosAbsolute(this.params);break;case"a":this.HPositionRelative(this.params);break;case"c":this.sendDeviceAttributes(this.params);break;case"d":this.linePosAbsolute(this.params);break;case"e":this.VPositionRelative(this.params);break;case"f":this.HVPosition(this.params);break;case"h":this.setMode(this.params);break;case"l":this.resetMode(this.params);break;case"r":this.setScrollRegion(this.params);break;case"s":this.saveCursor(this.params);break;case"u":this.restoreCursor(this.params);break;case"I":this.cursorForwardTab(this.params);break;case"S":this.scrollUp(this.params);break;case"T":this.params.length<2&&!this.prefix&&this.scrollDown(this.params);break;case"Z":this.cursorBackwardTab(this.params);break;case"b":this.repeatPrecedingCharacter(this.params);break;case"g":this.tabClear(this.params);break;case"p":"!"===this.prefix&&this.softReset(this.params);break;default:console.error("Unknown CSI code: %s.",d)}this.prefix="";break;case b.dcs:if(""===d||""===d){switch(""===d&&f++,this.prefix){case"":break;case"$q":switch(i=this.currentParam,j=!1,i){case'"q':i='0"q';break;case'"p':i='61"p';break;case"r":i=""+(this.scrollTop+1)+";"+(this.scrollBottom+1)+"r";break;case"m":i="0m";break;default:console.error("Unknown DCS Pt: %s.",i),i=""}this.send("P"+ +j+"$r"+i+"\\");break;case"+q":i=this.currentParam,j=!1,this.send("P"+ +j+"+r"+i+"\\");break;default:console.error("Unknown DCS prefix: %s.",this.prefix)}this.currentParam=0,this.prefix="",this.state=b.normal}else this.currentParam?this.currentParam+=d:this.prefix||"$"===d||"+"===d?2===this.prefix.length?this.currentParam=d:this.prefix+=d:this.currentParam=d;break;case b.ignore:(""===d||""===d)&&(""===d&&f++,this.state=b.normal)}f++}return this.updateRange(this.y),this.refresh(this.refreshStart,this.refreshEnd)},a.prototype.writeln=function(a){return this.write(""+a+"\r\n")},a.prototype.keyDown=function(a){var b,c,e,f;if(a.keyCode>15&&a.keyCode<19)return!0;if((a.shiftKey||a.ctrlKey)&&45===a.keyCode)return!0;if(a.shiftKey&&a.ctrlKey&&(67===(f=a.keyCode)||86===f))return!0;if(a.altKey&&90===a.keyCode&&!this.skipNextKey)return this.skipNextKey=!0,this.element.classList.add("skip"),d(a);if(this.skipNextKey)return this.skipNextKey=!1,this.element.classList.remove("skip"),!0;switch(a.keyCode){case 8:if(c=a.altKey?"":"",a.shiftKey){c+="\b";break}c+="";break;case 9:if(a.shiftKey){c="[Z";break}c=" ";break;case 13:c="\r";break;case 27:c="";break;case 37:if(this.applicationCursor){c="OD";break}c="[D";break;case 39:if(this.applicationCursor){c="OC";break}c="[C";break;case 38:if(this.applicationCursor){c="OA";break}if(a.ctrlKey)return this.scrollDisp(-1),d(a);c="[A";break;case 40:if(this.applicationCursor){c="OB";break}if(a.ctrlKey)return this.scrollDisp(1),d(a);c="[B";break;case 46:c="[3~";break;case 45:c="[2~";break;case 36:if(this.applicationKeypad){c="OH";break}c="OH";break;case 35:if(this.applicationKeypad){c="OF";break}c="OF";break;case 33:if(a.shiftKey)return this.scrollDisp(-(this.rows-1)),d(a);c="[5~";break;case 34:if(a.shiftKey)return this.scrollDisp(this.rows-1),d(a);c="[6~";break;case 112:c="OP";break;case 113:c="OQ";break;case 114:c="OR";break;case 115:c="OS";break;case 116:c="[15~";break;case 117:c="[17~";break;case 118:c="[18~";break;case 119:c="[19~";break;case 120:c="[20~";break;case 121:c="[21~";break;case 122:c="[23~";break;case 123:c="[24~";break;default:if(a.ctrlKey)if(a.keyCode>=65&&a.keyCode<=90){if(67===a.keyCode){if(e=(new Date).getTime(),e-this.last_cc<75)for(b=setTimeout(function(){})-6,this.write("\r\n --8<------8<-- Sectioned --8<------8<-- \r\n\r\n");b--;)b!==this.t_bell&&b!==this.t_queue&&b!==this.t_blink&&clearTimeout(b);this.last_cc=e}c=String.fromCharCode(a.keyCode-64)}else 32===a.keyCode?c=String.fromCharCode(0):a.keyCode>=51&&a.keyCode<=55?c=String.fromCharCode(a.keyCode-51+27):56===a.keyCode?c=String.fromCharCode(127):219===a.keyCode?c=String.fromCharCode(27):221===a.keyCode&&(c=String.fromCharCode(29));else(a.altKey&&k.call(navigator.platform,"Mac")<0||a.metaKey&&k.call(navigator.platform,"Mac")>=0)&&(a.keyCode>=65&&a.keyCode<=90?c=""+String.fromCharCode(a.keyCode+32):192===a.keyCode?c="`":a.keyCode>=48&&a.keyCode<=57&&(c=""+(a.keyCode-48)))}return a.keyCode>=37&&a.keyCode<=40&&(a.ctrlKey?c=c.slice(0,-1)+"1;5"+c.slice(-1):a.altKey?c=c.slice(0,-1)+"1;3"+c.slice(-1):a.shiftKey&&(c=c.slice(0,-1)+"1;4"+c.slice(-1))),c?this.prefixMode?(this.leavePrefix(),d(a)):this.selectMode?(this.keySelect(a,c),d(a)):(this.showCursor(),this.handler(c),d(a)):!0},a.prototype.setgLevel=function(a){return this.glevel=a,this.charset=this.charsets[a]},a.prototype.setgCharset=function(a,b){return this.charsets[a]=b,this.glevel===a?this.charset=b:void 0},a.prototype.keyPress=function(a){var b;if(this.skipNextKey===!1)return this.skipNextKey=null,!0;if(d(a),a.charCode)b=a.charCode;else if(null==a.which)b=a.keyCode;else{if(0===a.which||0===a.charCode)return!1;b=a.which}return!b||a.ctrlKey||a.altKey||a.metaKey?!1:(b=String.fromCharCode(b),this.showCursor(),this.handler(b),!1)},a.prototype.send=function(a){return this.queue||(this.t_queue=setTimeout(function(a){return function(){return a.handler(a.queue),a.queue=""}}(this),1)),this.queue+=a},a.prototype.bell=function(){return this.visualBell?(this.element.classList.add("bell"),this.t_bell=setTimeout(function(a){return function(){return a.element.classList.remove("bell")}}(this),this.visualBell)):void 0},a.prototype.resize=function(){var a,b,c,d,e,f,g,h;if(f=this.cols,g=this.rows,this.compute_char_size(),h=this.parent.getBoundingClientRect(),this.cols=Math.floor(h.width/this.char_size.width),this.rows=Math.floor(h.height/this.char_size.height),f!==this.cols||g!==this.rows){if(this.ctl("Resize",this.cols,this.rows),fthis.cols)for(c=this.lines.length;c--;)for(;this.lines[c].length>this.cols;)this.lines[c].pop();if(this.setupStops(f),d=g,dthis.rows)for(;d-->this.rows;)if(this.lines.length>this.rows+this.ybase&&this.lines.pop(),this.children.length>this.rows){if(b=this.children.pop(),!b)continue;b.parentNode.removeChild(b)}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}},a.prototype.updateRange=function(a){return athis.refreshEnd?this.refreshEnd=a:void 0},a.prototype.maxRange=function(){return this.refreshStart=0,this.refreshEnd=this.rows-1},a.prototype.setupStops=function(a){var b;for(null!=a?this.tabs[a]||(a=this.prevStop(a)):(this.tabs={},a=0),b=[];a0;);return a>=this.cols?this.cols-1:0>a?0:a},a.prototype.nextStop=function(a){for(null==a&&(a=this.x);!this.tabs[++a]&&a=this.cols?this.cols-1:0>a?0:a},a.prototype.eraseRight=function(a,b){var c,d;for(d=this.lines[this.ybase+b],c=[this.eraseAttr()," "];athis.scrollBottom&&(this.y--,this.scroll()),this.state=b.normal},a.prototype.reverseIndex=function(){var a;return this.y--,this.yb&&(b=1),this.y-=b,this.y<0?this.y=0:void 0},a.prototype.cursorDown=function(a){var b;return b=a[0],1>b&&(b=1),this.y+=b,this.y>=this.rows?this.y=this.rows-1:void 0},a.prototype.cursorForward=function(a){var b;return b=a[0],1>b&&(b=1),this.x+=b,this.x>=this.cols?this.x=this.cols-1:void 0},a.prototype.cursorBackward=function(a){var b;return b=a[0],1>b&&(b=1),this.x-=b,this.x<0?this.x=0:void 0},a.prototype.cursorPos=function(a){var b,c;return c=a[0]-1,b=a.length>=2?a[1]-1:0,0>c?c=0:c>=this.rows&&(c=this.rows-1),0>b?b=0:b>=this.cols&&(b=this.cols-1),this.x=b,this.y=c},a.prototype.eraseInDisplay=function(a){var b,c,d,e;switch(a[0]){case 0:for(this.eraseRight(this.x,this.y),b=this.y+1,c=[];b>18,c=this.curAttr>>9&511,b=511&this.curAttr,f=a.length,e=0;f>e;)g=a[e],g>=30&&37>=g?c=g-30:g>=40&&47>=g?b=g-40:g>=90&&97>=g?(g+=8,c=g-90):g>=100&&107>=g?(g+=8,b=g-100):0===g?(d=this.defAttr>>18,c=this.defAttr>>9&511,b=511&this.defAttr):1===g?d|=1:4===g?d|=2:5===g?d|=4:7===g?d|=8:8===g?d|=16:22===g?d&=-2:24===g?d&=-3:25===g?d&=-5:27===g?d&=-9:28===g?d&=-17:39===g?c=this.defAttr>>9&511:49===g?b=511&this.defAttr:38===g?2===a[e+1]?(e+=2,c="#"+a[e]&255+a[e+1]&255+a[e+2]&255,e+=2):5===a[e+1]&&(e+=2,c=255&a[e]):48===g?2===a[e+1]?(e+=2,b="#"+a[e]&255+a[e+1]&255+a[e+2]&255,e+=2):5===a[e+1]&&(e+=2,b=255&a[e]):100===g?(c=this.defAttr>>9&511,b=511&this.defAttr):console.error("Unknown SGR attribute: %d.",g),e++;return this.curAttr=d<<18|c<<9|b},a.prototype.deviceStatus=function(a){if(this.prefix){if("?"===this.prefix&&6===a[0])return this.send("[?"+(this.y+1)+";"+(this.x+1)+"R")}else switch(a[0]){case 5:return this.send("[0n");case 6:return this.send("["+(this.y+1)+";"+(this.x+1)+"R")}},a.prototype.insertChars=function(a){var b,c,d,e,f;for(d=a[0],1>d&&(d=1),e=this.y+this.ybase,c=this.x,b=[this.eraseAttr()," "],f=[];d--&&cb&&(b=1),this.y+=b,this.y>=this.rows&&(this.y=this.rows-1),this.x=0},a.prototype.cursorPrecedingLine=function(a){var b;return b=a[0],1>b&&(b=1),this.y-=b,this.y<0&&(this.y=0),this.x=0},a.prototype.cursorCharAbsolute=function(a){var b;return b=a[0],1>b&&(b=1),this.x=b-1},a.prototype.insertLines=function(a){var b,c,d;for(c=a[0],1>c&&(c=1),d=this.y+this.ybase,b=this.rows-1-this.scrollBottom,b=this.rows-1+this.ybase-b+1;c--;)this.lines.splice(d,0,this.blankLine(!0)),this.lines.splice(b,1);return this.updateRange(this.y),this.updateRange(this.scrollBottom)},a.prototype.deleteLines=function(a){var b,c,d;for(c=a[0],1>c&&(c=1),d=this.y+this.ybase,b=this.rows-1-this.scrollBottom,b=this.rows-1+this.ybase-b;c--;)this.lines.splice(b+1,0,this.blankLine(!0)),this.lines.splice(d,1);return this.updateRange(this.y),this.updateRange(this.scrollBottom)},a.prototype.deleteChars=function(a){var b,c,d,e;for(c=a[0],1>c&&(c=1),d=this.y+this.ybase,b=[this.eraseAttr()," "],e=[];c--;)this.lines[d].splice(this.x,1),e.push(this.lines[d].push(b));return e},a.prototype.eraseChars=function(a){var b,c,d,e,f;for(d=a[0],1>d&&(d=1),e=this.y+this.ybase,c=this.x,b=[this.eraseAttr()," "],f=[];d--&&cb&&(b=1),this.x=b-1,this.x>=this.cols?this.x=this.cols-1:void 0},a.prototype.HPositionRelative=function(a){var b;return b=a[0],1>b&&(b=1),this.x+=b,this.x>=this.cols?this.x=this.cols-1:void 0},a.prototype.sendDeviceAttributes=function(a){if(!(a[0]>0))if(this.prefix){if(">"===this.prefix){if(this.isterm("xterm"))return this.send("[>0;276;0c");if(this.isterm("rxvt-unicode"))return this.send("[>85;95;0c");if(this.isterm("linux"))return this.send(a[0]+"c");if(this.isterm("screen"))return this.send("[>83;40003;0c")}}else{if(this.isterm("xterm")||this.isterm("rxvt-unicode")||this.isterm("screen"))return this.send("[?1;2c");if(this.isterm("linux"))return this.send("[?6c")}},a.prototype.linePosAbsolute=function(a){var b;return b=a[0],1>b&&(b=1),this.y=b-1,this.y>=this.rows?this.y=this.rows-1:void 0},a.prototype.VPositionRelative=function(a){var b;return b=a[0],1>b&&(b=1),this.y+=b,this.y>=this.rows?this.y=this.rows-1:void 0},a.prototype.HVPosition=function(a){return a[0]<1&&(a[0]=1),a[1]<1&&(a[1]=1),this.y=a[0]-1,this.y>=this.rows&&(this.y=this.rows-1),this.x=a[1]-1,this.x>=this.cols?this.x=this.cols-1:void 0},a.prototype.setMode=function(b){var c,d,e;if("object"!=typeof b){if("?"===this.prefix)switch(b){case 1:return this.applicationCursor=!0;case 2:return this.setgCharset(0,a.prototype.charsets.US),this.setgCharset(1,a.prototype.charsets.US),this.setgCharset(2,a.prototype.charsets.US),this.setgCharset(3,a.prototype.charsets.US);case 3:return this.savedCols=this.cols,this.resize(132,this.rows);case 6:return this.originMode=!0;case 7:return this.wraparoundMode=!0;case 66:return this.applicationKeypad=!0;case 9:case 1e3:case 1002:case 1003:return this.x10Mouse=9===b,this.vt200Mouse=1e3===b,this.normalMouse=b>1e3,this.mouseEvents=!0,this.element.style.cursor="pointer";case 1004:return this.sendFocus=!0;case 1005:return this.utfMouse=!0;case 1006:return this.sgrMouse=!0;case 1015:return this.urxvtMouse=!0;case 25:return this.cursorHidden=!1;case 1049:case 47:case 1047:if(!this.normal)return e={lines:this.lines,ybase:this.ybase,ydisp:this.ydisp,x:this.x,y:this.y,scrollTop:this.scrollTop,scrollBottom:this.scrollBottom,tabs:this.tabs},this.reset(),this.normal=e,this.showCursor()}}else for(d=b.length,c=0;d>c;)this.setMode(b[c]),c++},a.prototype.resetMode=function(a){var b,c;if("object"!=typeof a){if("?"===this.prefix)switch(a){case 1:return this.applicationCursor=!1;case 3:return 132===this.cols&&this.savedCols&&this.resize(this.savedCols,this.rows),delete this.savedCols;case 6:return this.originMode=!1;case 7:return this.wraparoundMode=!1;case 66:return this.applicationKeypad=!1;case 9:case 1e3:case 1002:case 1003:return this.x10Mouse=!1,this.vt200Mouse=!1,this.normalMouse=!1,this.mouseEvents=!1,this.element.style.cursor="";case 1004:return this.sendFocus=!1;case 1005:return this.utfMouse=!1;case 1006:return this.sgrMouse=!1;case 1015:return this.urxvtMouse=!1;case 25:return this.cursorHidden=!0;case 1049:case 47:case 1047:if(this.normal)return this.lines=this.normal.lines,this.ybase=this.normal.ybase,this.ydisp=this.normal.ydisp,this.x=this.normal.x,this.y=this.normal.y,this.scrollTop=this.normal.scrollTop,this.scrollBottom=this.normal.scrollBottom,this.tabs=this.normal.tabs,this.normal=null,this.refresh(0,this.rows-1),this.showCursor()}}else for(c=a.length,b=0;c>b;)this.resetMode(a[b]),b++},a.prototype.setScrollRegion=function(a){return this.prefix?void 0:(this.scrollTop=(a[0]||1)-1,this.scrollBottom=(a[1]||this.rows)-1,this.x=0,this.y=0)},a.prototype.saveCursor=function(){return this.savedX=this.x,this.savedY=this.y},a.prototype.restoreCursor=function(){return this.x=this.savedX||0,this.y=this.savedY||0},a.prototype.cursorForwardTab=function(a){var b,c;for(b=a[0]||1,c=[];b--;)c.push(this.x=this.nextStop());return c},a.prototype.scrollUp=function(a){var b;for(b=a[0]||1;b--;)this.lines.splice(this.ybase+this.scrollTop,1),this.lines.splice(this.ybase+this.scrollBottom,0,this.blankLine());return this.updateRange(this.scrollTop),this.updateRange(this.scrollBottom)},a.prototype.scrollDown=function(a){var b;for(b=a[0]||1;b--;)this.lines.splice(this.ybase+this.scrollBottom,1),this.lines.splice(this.ybase+this.scrollTop,0,this.blankLine());return this.updateRange(this.scrollTop),this.updateRange(this.scrollBottom)},a.prototype.initMouseTracking=function(){},a.prototype.resetTitleModes=function(){},a.prototype.cursorBackwardTab=function(a){var b,c;for(b=a[0]||1,c=[];b--;)c.push(this.x=this.prevStop());return c},a.prototype.repeatPrecedingCharacter=function(a){var b,c,d,e;for(d=a[0]||1,c=this.lines[this.ybase+this.y],b=c[this.x-1]||[this.defAttr," "],e=[];d--;)e.push(c[this.x++]=b);return e},a.prototype.tabClear=function(a){var b;return b=a[0],0>=b?delete this.tabs[this.x]:3===b?this.tabs={}:void 0},a.prototype.mediaCopy=function(){},a.prototype.setResources=function(){},a.prototype.disableModifiers=function(){},a.prototype.setPointerMode=function(){},a.prototype.softReset=function(){return this.cursorHidden=!1,this.insertMode=!1,this.originMode=!1,this.wraparoundMode=!1,this.applicationKeypad=!1,this.applicationCursor=!1,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]
+},a.prototype.requestAnsiMode=function(){},a.prototype.requestPrivateMode=function(){},a.prototype.setConformanceLevel=function(){},a.prototype.loadLEDs=function(){},a.prototype.setCursorStyle=function(){},a.prototype.setCharProtectionAttr=function(){},a.prototype.restorePrivateValues=function(){},a.prototype.setAttrInRectangle=function(a){var b,c,d,e,f,g,h;for(h=a[0],e=a[1],c=a[2],g=a[3],b=a[4];c+1>h;){for(f=this.lines[this.ybase+h],d=e;g>d;)f[d]=[b,f[d][1]],d++;h++}return this.updateRange(a[0]),this.updateRange(a[2])},a.prototype.savePrivateValues=function(){},a.prototype.manipulateWindow=function(){},a.prototype.reverseAttrInRectangle=function(){},a.prototype.setTitleModeFeature=function(){},a.prototype.setWarningBellVolume=function(){},a.prototype.setMarginBellVolume=function(){},a.prototype.copyRectangle=function(){},a.prototype.enableFilterRectangle=function(){},a.prototype.requestParameters=function(){},a.prototype.selectChangeExtent=function(){},a.prototype.fillRectangle=function(a){var b,c,d,e,f,g,h;for(c=a[0],h=a[1],e=a[2],b=a[3],g=a[4];b+1>h;){for(f=this.lines[this.ybase+h],d=e;g>d;)f[d]=[f[d][0],String.fromCharCode(c)],d++;h++}return this.updateRange(a[1]),this.updateRange(a[3])},a.prototype.enableLocatorReporting=function(a){var b;return b=a[0]>0},a.prototype.eraseRectangle=function(a){var b,c,d,e,f,g,h;for(h=a[0],e=a[1],b=a[2],g=a[3],c=[this.eraseAttr()," "];b+1>h;){for(f=this.lines[this.ybase+h],d=e;g>d;)f[d]=c,d++;h++}return this.updateRange(a[0]),this.updateRange(a[2])},a.prototype.setLocatorEvents=function(){},a.prototype.selectiveEraseRectangle=function(){},a.prototype.requestLocatorPosition=function(){},a.prototype.insertColumns=function(){var a,b,c,d;for(d=params[0],c=this.ybase+this.rows,a=[this.eraseAttr()," "];d--;)for(b=this.ybase;c>b;)this.lines[b].splice(this.x+1,0,a),this.lines[b].pop(),b++;return this.maxRange()},a.prototype.deleteColumns=function(){var a,b,c,d;for(d=params[0],c=this.ybase+this.rows,a=[this.eraseAttr()," "];d--;)for(b=this.ybase;c>b;)this.lines[b].splice(this.x,1),this.lines[b].push(a),b++;return this.maxRange()},a.prototype.get_html_height_in_lines=function(a){var b,c;return c=document.createElement("div"),c.innerHTML=a,this.element.appendChild(c),b=c.getBoundingClientRect().height,this.element.removeChild(c),Math.ceil(b/this.char_size.height)},a.prototype.charsets={SCLD:{"`":"◆",a:"▒",b:" ",c:"\f",d:"\r",e:"\n",f:"°",g:"±",h:"",i:"",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"},UK:null,US:null,Dutch:null,Finnish:null,French:null,FrenchCanadian:null,German:null,Italian:null,NorwegianDanish:null,Spanish:null,Swedish:null,Swiss:null,ISOLatin:null},a}(),window.Terminal=c}).call(this);
//# sourceMappingURL=main.min.js.map
\ No newline at end of file
diff --git a/butterfly/templates/index.html b/butterfly/templates/index.html
index 48cdb7e..469f325 100644
--- a/butterfly/templates/index.html
+++ b/butterfly/templates/index.html
@@ -17,5 +17,7 @@
+