2
0
mirror of https://github.com/embarklabs/neo-blessed.git synced 2025-01-13 12:35:05 +00:00

fixes for Log and Table elements.

This commit is contained in:
Christopher Jeffrey 2015-03-30 05:05:57 -07:00
parent 91bc189ba3
commit bc94be742e

@ -6766,6 +6766,7 @@ function Log(options) {
this.on('set content', function() {
nextTick(function() {
self.setScrollPerc(100);
self.screen.render();
});
});
}
@ -6824,8 +6825,8 @@ Table.prototype.setData = function(rows) {
this.rows.forEach(function(row) {
row.forEach(function(cell, i) {
if (!maxes[i] || maxes[i] < cell.length + self.pad) {
maxes[i] = cell.length + self.pad;
if (!maxes[i] || maxes[i] < self._cellLength(cell) + self.pad) {
maxes[i] = self._cellLength(cell) + self.pad;
}
});
});
@ -6859,17 +6860,17 @@ Table.prototype.setData = function(rows) {
text += generateTags(self.style.border, '\u2502'); // '│'
}
while (cell.length < width) {
while (self._cellLength(cell) < width) {
cell = ' ' + cell + ' ';
}
if (cell.length > width) {
if (self._cellLength(cell) > width) {
// cell = cell.slice(0, -1);
cell = cell.substring(1);
}
// XXX Workaround
if (!self.options.tags) {
if (!self.options.tags && !self.options.parseTags) {
cell = helpers.escape(cell);
}
@ -6894,6 +6895,13 @@ Table.prototype.setData = function(rows) {
return this.setContent(text);
};
Table.prototype._cellLength = function(text) {
if (!this.options.tags && !this.options.parseTags) {
return text.length;
}
return text.replace(/{(\/?)([\w\-,;!#]*)}/g, '').length;
};
/**
* Terminal
*/