optimize shrink width.
This commit is contained in:
parent
9cc1f53d9a
commit
f236898f73
|
@ -1979,8 +1979,7 @@ Element.prototype._align = function(line, width, align) {
|
|||
};
|
||||
|
||||
Element.prototype._wrapContent = function(content, width) {
|
||||
var self = this
|
||||
, tags = this.parseTags
|
||||
var tags = this.parseTags
|
||||
, state = this.align
|
||||
, wrap = this.wrap
|
||||
, margin = 0
|
||||
|
@ -1989,6 +1988,7 @@ Element.prototype._wrapContent = function(content, width) {
|
|||
, fake = []
|
||||
, out = []
|
||||
, no = 0
|
||||
, mwidth = 0
|
||||
, line
|
||||
, align
|
||||
, cap
|
||||
|
@ -2064,9 +2064,10 @@ main:
|
|||
part = line.substring(0, i);
|
||||
line = line.substring(i);
|
||||
|
||||
out.push(self._align(part, width, align));
|
||||
out.push(this._align(part, width, align));
|
||||
ftor[no].push(out.length - 1);
|
||||
rtof.push(no);
|
||||
if (part.length > mwidth) mwidth = part.length;
|
||||
|
||||
// Make sure we didn't wrap the line to the very end, otherwise
|
||||
// we get a pointless empty line after a newline.
|
||||
|
@ -2079,15 +2080,17 @@ main:
|
|||
}
|
||||
}
|
||||
|
||||
out.push(self._align(line, width, align));
|
||||
out.push(this._align(line, width, align));
|
||||
ftor[no].push(out.length - 1);
|
||||
rtof.push(no);
|
||||
if (line.length > mwidth) mwidth = line.length;
|
||||
}
|
||||
|
||||
out.rtof = rtof;
|
||||
out.ftor = ftor;
|
||||
out.fake = lines;
|
||||
out.real = out;
|
||||
out.mwidth = mwidth;
|
||||
|
||||
return out;
|
||||
};
|
||||
|
@ -2486,19 +2489,6 @@ Element.prototype.__defineGetter__('tpadding', function() {
|
|||
* Rendering - here be dragons
|
||||
*/
|
||||
|
||||
Element.prototype._getShrinkSize = function() {
|
||||
// TODO: Possibly move this to parseContent.
|
||||
return {
|
||||
height: this._clines.length,
|
||||
width: this._clines.reduce(function(current, line) {
|
||||
line = line.replace(/\x1b\[[\d;]*m/g, '');
|
||||
return line.length > current
|
||||
? line.length
|
||||
: current;
|
||||
}, 0)
|
||||
};
|
||||
};
|
||||
|
||||
Element.prototype._getShrinkBox = function(xi, xl, yi, yl) {
|
||||
if (!this.children.length) {
|
||||
return { xi: xi, xl: xi, yi: yi, yl: yi };
|
||||
|
@ -2547,9 +2537,8 @@ Element.prototype._getShrinkBox = function(xi, xl, yi, yl) {
|
|||
};
|
||||
|
||||
Element.prototype._getShrinkContent = function(xi, xl, yi, yl) {
|
||||
var hw = this._getShrinkSize()
|
||||
, h = hw.height
|
||||
, w = hw.width;
|
||||
var h = this._clines.length
|
||||
, w = this._clines.mwidth;
|
||||
|
||||
if (this.position.width == null
|
||||
&& (this.position.left == null
|
||||
|
|
Loading…
Reference in New Issue