diff --git a/butterfly/static/main.js b/butterfly/static/main.js index 556c405..2d5a397 100644 --- a/butterfly/static/main.js +++ b/butterfly/static/main.js @@ -180,7 +180,11 @@ addEventListener('keypress', this.keyPress.bind(this)); addEventListener('focus', this.focus.bind(this)); addEventListener('blur', this.blur.bind(this)); - addEventListener('resize', this.resize.bind(this)); + addEventListener('resize', (function(_this) { + return function() { + return _this.resize(); + }; + })(this)); if (typeof InstallTrigger !== "undefined") { this.body.contentEditable = 'true'; } @@ -663,8 +667,8 @@ Terminal.prototype.scroll = function() { var i, k, ref, ref1, results; if (this.normal || this.scrollTop !== 0 || this.scrollBottom !== this.rows - 1) { - this.screen.splice(this.scrollBottom + 1, 0, [this.blank_line(), true]); - this.screen.splice(this.scrollTop, 1); + this.screen.splice(this.shift + this.scrollBottom + 1, 0, [this.blank_line(), true]); + this.screen.splice(this.shift + this.scrollTop, 1); results = []; for (i = k = ref = this.scrollTop, ref1 = this.scrollBottom; ref <= ref1 ? k <= ref1 : k >= ref1; i = ref <= ref1 ? ++k : --k) { results.push(this.screen[i + this.shift][1] = true); @@ -676,6 +680,17 @@ } }; + Terminal.prototype.unscroll = function() { + var i, k, ref, ref1, results; + this.screen.splice(this.shift + this.scrollTop, 0, [this.blank_line(true), true]); + this.screen.splice(this.shift + this.scrollBottom + 1, 1); + results = []; + for (i = k = ref = this.scrollTop, ref1 = this.scrollBottom; ref <= ref1 ? k <= ref1 : k >= ref1; i = ref <= ref1 ? ++k : --k) { + results.push(this.screen[i + this.shift][1] = true); + } + return results; + }; + Terminal.prototype.native_scroll_to = function(scroll) { if (scroll == null) { scroll = 2000000000; @@ -695,8 +710,16 @@ } }; + Terminal.prototype.prev_line = function() { + this.y--; + if (this.y < this.scrollTop) { + this.y++; + return this.unscroll(); + } + }; + Terminal.prototype.write = function(data) { - var attr, ch, content, cs, i, l, pt, ref, ref1, type, valid; + var attr, c, ch, content, cs, i, k, l, len, line, m, num, pt, ref, ref1, ref2, ref3, type, valid; i = 0; l = data.length; while (i < l) { @@ -710,9 +733,6 @@ case "\n": case "\x0b": case "\x0c": - if (this.convertEol) { - this.x = 0; - } this.next_line(); break; case "\r": @@ -858,6 +878,27 @@ case "#": this.state = State.normal; i++; + num = data.charAt(i); + switch (num) { + case "3": + break; + case "4": + break; + case "5": + break; + case "6": + break; + case "8": + ref1 = this.screen; + for (k = 0, len = ref1.length; k < len; k++) { + line = ref1[k]; + line[1] = true; + for (c = m = 0, ref2 = line[0].length; 0 <= ref2 ? m <= ref2 : m >= ref2; c = 0 <= ref2 ? ++m : --m) { + line[0][c] = this.cloneAttr(this.curAttr, "E"); + } + } + this.x = this.y = 0; + } break; case "H": this.tabSet(); @@ -1111,7 +1152,7 @@ break; } pt = pt.slice(1); - ref1 = pt.split('|', 2), type = ref1[0], content = ref1[1]; + ref3 = pt.split('|', 2), type = ref3[0], content = ref3[1]; if (!content) { console.error("No type for inline DECUDK: " + pt); break; @@ -1124,14 +1165,14 @@ } attr = this.cloneAttr(this.curAttr); attr.html = "