Small fix + blink

This commit is contained in:
Florian Mounier
2015-04-14 11:00:11 +02:00
parent 165b17da4e
commit 03bb84fcbe
4 changed files with 67 additions and 49 deletions

View File

@@ -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

View File

@@ -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; }

View File

@@ -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 += "</span>";
}
if (!this.equalAttr(data, this.getDefAttr())) {
if (!this.equalAttr(data, this.defAttr)) {
classes = [];
styles = [];
out += "<span ";
@@ -589,7 +588,7 @@
}
attr = data;
}
if (!this.equalAttr(attr, this.getDefAttr())) {
if (!this.equalAttr(attr, this.defAttr)) {
out += "</span>";
}
this.children[j].innerHTML = out;
@@ -610,8 +609,16 @@
};
Terminal.prototype._cursorBlink = function() {
var cursor;
var cursor, customStyle;
this.cursorState ^= 1;
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 = this.element.querySelector(".cursor");
if (!cursor) {
return;
@@ -1938,7 +1945,7 @@
Terminal.prototype.charAttributes = function(params) {
var i, l, p, results;
if (params.length === 1 && params[0] === 0) {
this.curAttr = this.getDefAttr();
this.curAttr = this.cloneAttr(this.defAttr);
return;
}
l = params.length;
@@ -1957,7 +1964,7 @@
p += 8;
this.curAttr.bg = p - 100;
} else if (p === 0) {
this.curAttr = this.getDefAttr();
this.curAttr = this.cloneAttr(this.defAttr);
} else if (p === 1) {
this.curAttr.bold = true;
} else if (p === 4) {
@@ -1981,7 +1988,7 @@
} else if (p === 28) {
this.curAttr.invisible = false;
} else if (p === 39) {
this.curAttr.fg = 0;
this.curAttr.fg = 257;
} else if (p === 49) {
this.curAttr.bg = 256;
} else if (p === 38) {
@@ -2003,7 +2010,7 @@
this.curAttr.bg = params[i] & 0xff;
}
} else if (p === 100) {
this.curAttr.fg = 0;
this.curAttr.fg = 257;
this.curAttr.bg = 256;
} else {
console.error("Unknown SGR attribute: %d.", p);

View File

@@ -118,15 +118,6 @@ class Terminal
setTimeout(@resize.bind(@), 100)
getDefAttr: ->
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 += "</span>" unless @equalAttr attr, @getDefAttr()
unless @equalAttr data, @getDefAttr()
out += "</span>" unless @equalAttr attr, @defAttr
unless @equalAttr data, @defAttr
classes = []
styles = []
out += "<span "
@@ -490,7 +490,7 @@ class Terminal
out += ch
out += "</span>" if i is x
attr = data
out += "</span>" unless @equalAttr attr, @getDefAttr()
out += "</span>" unless @equalAttr attr, @defAttr
@children[j].innerHTML = out
parent?.appendChild @element
@@ -503,6 +503,16 @@ class Terminal
_cursorBlink: ->
@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