rename _lastPos to lpos.
This commit is contained in:
parent
29cd1a376f
commit
e13f0ce5d4
|
@ -268,9 +268,13 @@ The base element.
|
|||
- **bg, fg** - border foreground and background, must be numbers (-1 for
|
||||
default).
|
||||
- **bold, underline** - border attributes.
|
||||
- **style** - contains attributes (e.g. `fg/bg/underline`). see above.
|
||||
- **position** - raw width, height, and offsets.
|
||||
- **content** - text content.
|
||||
- **hidden** - whether the element is hidden or not.
|
||||
- **visible** - whether the element is visible or not.
|
||||
- **detached** - whether the element is attached to a screen in its ancestry
|
||||
somewhere.
|
||||
- **fg, bg** - foreground and background, must be numbers (-1 for default).
|
||||
- **bold, underline** - attributes.
|
||||
- **width** - calculated width.
|
||||
|
|
|
@ -407,7 +407,7 @@ Screen.prototype._listenMouse = function(el) {
|
|||
// && !el.hasAncestor(self.focused)) continue;
|
||||
|
||||
// Get the true coordinates.
|
||||
ret = el._lastPos;
|
||||
ret = el.lpos;
|
||||
if (!ret) continue;
|
||||
left = ret.xi;
|
||||
top = ret.yi;
|
||||
|
@ -672,7 +672,7 @@ Screen.prototype.deleteTop = function(top, bottom) {
|
|||
// performance hit of slow-rendering scrollable
|
||||
// boxes with clean sides?
|
||||
Screen.prototype.cleanSides = function(el) {
|
||||
var pos = el._lastPos;
|
||||
var pos = el.lpos;
|
||||
|
||||
if (!pos) {
|
||||
return false;
|
||||
|
@ -1379,10 +1379,6 @@ function Element(options) {
|
|||
height: options.height || null
|
||||
};
|
||||
|
||||
// TODO: Possibly add padding/margins?
|
||||
// this.position.padding = options.padding || 0;
|
||||
// this.position.margin = options.margin || 0;
|
||||
|
||||
this.style = options.style;
|
||||
|
||||
if (!this.style) {
|
||||
|
@ -1657,12 +1653,12 @@ Element.prototype.removeKey = function() {
|
|||
};
|
||||
|
||||
Element.prototype.clearPos = function() {
|
||||
if (this._lastPos && !this._lastPos.cleared) {
|
||||
if (this.lpos && !this.lpos.cleared) {
|
||||
// optimize by making sure we only clear once.
|
||||
this._lastPos.cleared = true;
|
||||
this.lpos.cleared = true;
|
||||
this.screen.clearRegion(
|
||||
this._lastPos.xi, this._lastPos.xl,
|
||||
this._lastPos.yi, this._lastPos.yl);
|
||||
this.lpos.xi, this.lpos.xl,
|
||||
this.lpos.yi, this.lpos.yl);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -2172,7 +2168,7 @@ Box.prototype.render = function(stop) {
|
|||
// method.
|
||||
if (stop) return ret;
|
||||
|
||||
this._lastPos = ret;
|
||||
this.lpos = ret;
|
||||
|
||||
battr = this.border
|
||||
? this.sattr(this.style.border, this.style.border.fg, this.style.border.bg)
|
||||
|
@ -2391,11 +2387,11 @@ Box.prototype.render = function(stop) {
|
|||
// screen.render();
|
||||
// box.left++;
|
||||
// box.insertTop('foobar');
|
||||
// Things will break because we're using _lastPos instead of render(true).
|
||||
// Maybe _lastPos could be updated on .left, .right, etc setters?
|
||||
// Things will break because we're using lpos instead of render(true).
|
||||
// Maybe lpos could be updated on .left, .right, etc setters?
|
||||
|
||||
Box.prototype.insertLine = function(i, line) {
|
||||
var pos = this._lastPos || 0;
|
||||
var pos = this.lpos || 0;
|
||||
|
||||
if (typeof line === 'string') line = [line];
|
||||
|
||||
|
@ -2425,7 +2421,7 @@ Box.prototype.insertLine = function(i, line) {
|
|||
};
|
||||
|
||||
Box.prototype.deleteLine = function(i, n) {
|
||||
var pos = this._lastPos || 0;
|
||||
var pos = this.lpos || 0;
|
||||
|
||||
var reset = true
|
||||
, n = n || 1;
|
||||
|
@ -2624,7 +2620,7 @@ ScrollableBox.prototype.scroll = function(offset) {
|
|||
}
|
||||
|
||||
// Optimize scrolling with CSR + IL/DL.
|
||||
p = this._lastPos;
|
||||
p = this.lpos;
|
||||
if (this.childBase !== base && this.screen.cleanSides(this)) {
|
||||
t = p.yi + (this.border ? 1 : 0) + this.padding;
|
||||
b = p.yl - (this.border ? 1 : 0) - this.padding - 1;
|
||||
|
@ -4600,7 +4596,7 @@ Listbar.prototype.render = function(stop) {
|
|||
|
||||
Listbar.prototype.select = function(offset) {
|
||||
var self = this
|
||||
, width = this._lastPos ? this._lastPos.xl - this._lastPos.xi : this.width
|
||||
, width = this.lpos ? this.lpos.xl - this.lpos.xi : this.width
|
||||
, drawn = 0
|
||||
, visible = 0
|
||||
, el;
|
||||
|
@ -4615,7 +4611,7 @@ Listbar.prototype.select = function(offset) {
|
|||
|
||||
this.items.forEach(function(el, i) {
|
||||
if (i < self.leftBase) return;
|
||||
drawn += (el._lastPos ? el._lastPos.xl - el._lastPos.xi : el.width) + 3;
|
||||
drawn += (el.lpos ? el.lpos.xl - el.lpos.xi : el.width) + 3;
|
||||
if (drawn <= width) visible++;
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue