alignment refactor.

This commit is contained in:
Christopher Jeffrey 2013-06-14 03:45:28 -05:00
parent 4f199c26aa
commit 59b13fae82

View File

@ -1047,16 +1047,13 @@ Box.prototype.render = function(stop) {
}
if (this.align === 'center' || this.align === 'right') {
//var width = this.width - (this.border ? 2 : 0);
var width = this.width;
var ncontent = content.split('\n')[0].replace(/\x1b\[[^m]*m/g, '');
var ncontent = content.split('\n')[0].replace(/\x1b\[[\d;]*m/g, '')
, width = this.width;
if (ncontent.length < width) {
var s = width - ncontent.length;
if (this.align === 'center') {
//xi_ += s / 2 | 0;
content = Array(((s / 2 | 0) - (this.border ? 1 : 0)) + 1).join(' ') + content;
} else {
//xi_ += s;
content = Array((s - (this.border ? 2 : 0)) + 1).join(' ') + content;
}
}