diff --git a/butterfly/sass/_term_styles.sass b/butterfly/sass/_term_styles.sass index cca7f74..69e9be0 100644 --- a/butterfly/sass/_term_styles.sass +++ b/butterfly/sass/_term_styles.sass @@ -25,8 +25,9 @@ $bg: #000 !default .underline text-decoration: underline -.blink - text-decoration: blink +/* Not supported, emulated +/* .blink +/* text-decoration: blink .invisible visibility: hidden diff --git a/butterfly/static/main.css b/butterfly/static/main.css index d132bae..78b004a 100644 --- a/butterfly/static/main.css +++ b/butterfly/static/main.css @@ -3078,9 +3078,9 @@ body[data-native-scroll="yes"] ::-webkit-scrollbar-thumb { .underline, .nbsp { text-decoration: underline; } -.blink { - text-decoration: blink; } - +/* Not supported, emulated */ +/* .blink */ +/* text-decoration: blink */ .invisible { visibility: hidden; } diff --git a/butterfly/static/main.js b/butterfly/static/main.js index 31722d6..0a49b69 100644 --- a/butterfly/static/main.js +++ b/butterfly/static/main.js @@ -205,18 +205,6 @@ setTimeout(this.resize.bind(this), 100); } - Terminal.prototype.getDefAttr = function() { - return { - bg: 256, - fg: 0, - bold: false, - underline: false, - blink: false, - inverse: false, - invisible: false - }; - }; - Terminal.prototype.cloneAttr = function(a) { return { bg: a.bg, @@ -253,8 +241,16 @@ this.gcharset = null; this.glevel = 0; this.charsets = [null]; - this.defAttr = this.getDefAttr(); - this.curAttr = this.getDefAttr(); + this.defAttr = { + bg: 256, + fg: 257, + bold: false, + underline: false, + blink: false, + inverse: false, + invisible: false + }; + this.curAttr = this.cloneAttr(this.defAttr); this.params = []; this.currentParam = 0; this.prefix = ""; @@ -280,7 +276,10 @@ }; Terminal.prototype.eraseAttr = function() { - return (this.defAttr & ~0x1ff) | (this.curAttr & 0x1ff); + var erased; + erased = this.cloneAttr(this.defAttr); + erased.bg = this.curAttr.bg; + return erased; }; Terminal.prototype.focus = function() { @@ -503,15 +502,15 @@ } else { x = -Infinity; } - attr = this.getDefAttr(); + attr = this.cloneAttr(this.defAttr); for (i = m = 0, ref2 = this.cols - 1; 0 <= ref2 ? m <= ref2 : m >= ref2; i = 0 <= ref2 ? ++m : --m) { data = line[i][0]; ch = line[i][1]; if (!this.equalAttr(data, attr)) { - if (!this.equalAttr(attr, this.getDefAttr())) { + if (!this.equalAttr(attr, this.defAttr)) { out += ""; } - if (!this.equalAttr(data, this.getDefAttr())) { + if (!this.equalAttr(data, this.defAttr)) { classes = []; styles = []; out += " - bg: 256 - fg: 0 - bold: false - underline: false - blink: false - inverse: false - invisible: false - cloneAttr: (a) -> bg: a.bg fg: a.fg @@ -167,9 +158,16 @@ class Terminal @charsets = [null] # stream - @defAttr = @getDefAttr() + @defAttr = + bg: 256 + fg: 257 + bold: false + underline: false + blink: false + inverse: false + invisible: false - @curAttr = @getDefAttr() + @curAttr = @cloneAttr @defAttr @params = [] @currentParam = 0 @prefix = "" @@ -189,7 +187,9 @@ class Terminal @children[0].removeChild(test_span) eraseAttr: -> - (@defAttr & ~0x1ff) | (@curAttr & 0x1ff) + erased = @cloneAttr @defAttr + erased.bg = @curAttr.bg + erased focus: -> @send('\x1b[I') if @sendFocus @@ -421,13 +421,13 @@ class Terminal else x = -Infinity - attr = @getDefAttr() + attr = @cloneAttr @defAttr for i in [0..@cols - 1] data = line[i][0] ch = line[i][1] unless @equalAttr data, attr - out += "" unless @equalAttr attr, @getDefAttr() - unless @equalAttr data, @getDefAttr() + out += "" unless @equalAttr attr, @defAttr + unless @equalAttr data, @defAttr classes = [] styles = [] out += " @cursorState ^= 1 + # Restore blink text ! + if document.getElementById "blink" + document.getElementById("blink").remove() + else + customStyle = document.createElement("style") + customStyle.id = 'blink' + document.head.appendChild customStyle + customStyle.sheet.insertRule( + "#wrapper .blink { color: transparent !important }", 0) + cursor = @element.querySelector(".cursor") return unless cursor if cursor.classList.contains("reverse-video") @@ -1872,7 +1882,7 @@ class Terminal charAttributes: (params) -> # Optimize a single SGR0. if params.length is 1 and params[0] is 0 - @curAttr = @getDefAttr() + @curAttr = @cloneAttr @defAttr return l = params.length i = 0 @@ -1894,7 +1904,7 @@ class Terminal @curAttr.bg = p - 100 else if p is 0 # default - @curAttr = @getDefAttr() + @curAttr = @cloneAttr @defAttr else if p is 1 # bold text @curAttr.bold = true @@ -1931,7 +1941,7 @@ class Terminal @curAttr.invisible = false else if p is 39 # reset fg - @curAttr.fg = 0 + @curAttr.fg = 257 else if p is 49 # reset bg @curAttr.bg = 256 @@ -1957,7 +1967,7 @@ class Terminal @curAttr.bg = params[i] & 0xff else if p is 100 # reset fg/bg - @curAttr.fg = 0 + @curAttr.fg = 257 @curAttr.bg = 256 else console.error "Unknown SGR attribute: %d.", p