diff --git a/lib/program.js b/lib/program.js index 013effc..cc292cf 100644 --- a/lib/program.js +++ b/lib/program.js @@ -1586,7 +1586,8 @@ Program.prototype.resetColors = function(param) { if (this.has('Cr')) { return this.put.Cr(param); } - return this._write('\x1b]112;' + param + '\x07'); + return this._write('\x1b]112\x07'); + //return this._write('\x1b]112;' + param + '\x07'); }; // OSC Ps ; Pt ST @@ -1723,10 +1724,10 @@ Program.prototype.eraseInDisplay = function(param) { }; Program.prototype.clear = function() { - this.x = this.y = 0; + this.x = 0; + this.y = 0; if (this.tput) return this.put.clear(); return this._write('\x1b[H\x1b[J'); - // return this.ed('all'); }; // CSI Ps K Erase in Line (EL). @@ -2973,29 +2974,30 @@ Program.prototype.decscusr = Program.prototype.setCursorStyle = function(param) { switch (param) { case 'blinking block': - param = '0'; - param = '1'; + param = 1; break; case 'block': case 'steady block': - param = '2'; + param = 2; break; case 'blinking underline': - param = '3'; + param = 3; break; case 'underline': case 'steady underline': - param = '4'; + param = 4; break; case 'blinking bar': - param = '5'; + param = 5; break; case 'bar': case 'steady bar': - param = '6'; + param = 6; break; } - // extended tput.Se for param=2 + if (param === 2 && this.has('Se')) { + return this.put.Se(); + } if (this.has('Ss')) { return this.put.Ss(param); } diff --git a/lib/widget.js b/lib/widget.js index adf1560..0b41f8b 100644 --- a/lib/widget.js +++ b/lib/widget.js @@ -2646,6 +2646,24 @@ Element.prototype._getCoords = function(get) { if (el.scrollable) break; } + // Attempt to shrink the element base on the + // size of the content and child elements. + if (this.shrink) { + coords = this._getShrink(xi, xl, yi, yl); + xi = coords.xi, xl = coords.xl; + yi = coords.yi, yl = coords.yl; + var p = this.screen.program; + if (this.content === 'foo') { + p.sc(); + p.cup(1, 0); + p.el(); + p.write(JSON.stringify({ + yi: yi, yl: yl + })); + p.rc(); + } + } + // Check to make sure we're visible and // inside of the visible scroll area. // NOTE: Lists have a property where only @@ -2658,76 +2676,67 @@ Element.prototype._getCoords = function(get) { // We only do this when `get` is true, because that gets this.parent.lpos. // If it's false, the parent's position is calculated on the spot. var _cb = el.childBase; - if (get) { + if (0) if (get) { yi += this.parent.lpos._cb; // childbase of main scrollable element. yl += this.parent.lpos._cb; } - if (0) if (get) { - var _el = this; - while (_el = _el.parent) { - if (!_el.lpos) continue; - yi += _el.lpos._cb; - yl += _el.lpos._cb; - } - } - - ryi = yi - el._getTop(get) - el.itop; // maybe plus - ryl = yl - el._getTop(get) - el.ibottom; - visible = el._getHeight(get) - el.iheight; - - if (ryi < el.childBase) { - if (ryl > el.childBase) { - // Is partially covered above. - v = ryl - el.childBase; - v = (ryl - ryi) - v; - base = (this.childBase || 0) + v; - yi += v; - } else { - // Is above. - return; - } - } else if (ryi >= el.childBase + visible) { - // Is below. - return; - } else if (ryl > el.childBase + visible) { - // Is partially covered below. - v = el.childBase + visible + (yl - yi) - ryl; - yl = yi + v; - } - - //yi -= el.childBase; - //yl -= el.childBase; - var _el = this; - while (_el = _el.parent) { + if (0) while (_el = _el.parent) { if (_el.scrollable) { yi -= _el.childBase; yl -= _el.childBase; + break; } } + if (this.parent.scrollable) { + //yi -= this.parent.childBase; + //yl -= this.parent.childBase; + yi -= this.parent.lpos.base; + yl -= this.parent.lpos.base; + } + + if (yi < this.parent.lpos.yi + this.parent.itop) { + if (yl - 1 < this.parent.lpos.yi + this.parent.itop) { + // Is above. + return; + } else { + // Is partially covered below. + v = (this.parent.lpos.yi + this.parent.itop) - yi; + base = (this.childBase || 0) + v; + yi += v; + } + } else if (yl > this.parent.lpos.yl - this.parent.ibottom) { + if (yi > this.parent.lpos.yl - 1 - this.parent.ibottom) { + // Is below. + return; + } else { + // Is partially covered below. + v = yl - (this.parent.lpos.yl - this.parent.ibottom); + yl -= v; + } + } + + // Shouldn't be necessary. + if (yi >= yl) return; + var p = this.screen.program; if (this.content === 'foo') { p.sc(); - p.cup(p.rows - 1, 0); + p.cup(0, 0); + p.el(); p.write(JSON.stringify({ - yi: yi, yl: yl, ryi: ryi, ryl: ryl, - cb: el.childBase, - pcb: this.parent.lpos._cb + yi: yi, yl: yl, + //pyi: this.parent.lpos.yi, + //pyl: this.parent.lpos.yl, + //cb: el.childBase, + //pcb: this.parent.lpos._cb })); p.rc(); } } - // Attempt to shrink the element base on the - // size of the content and child elements. - if (this.shrink) { - coords = this._getShrink(xi, xl, yi, yl); - xi = coords.xi, xl = coords.xl; - yi = coords.yi, yl = coords.yl; - } - return { xi: xi, xl: xl, @@ -2748,6 +2757,11 @@ Element.prototype.render = function() { var coords = this._getCoords(true); if (!coords) return; + //if (!coords) { + // delete this.lpos; + // return; + //} + var lines = this.screen.lines , xi = coords.xi , xl = coords.xl diff --git a/test/widget-scrollable-boxes.js b/test/widget-scrollable-boxes.js index bc57a61..75282df 100644 --- a/test/widget-scrollable-boxes.js +++ b/test/widget-scrollable-boxes.js @@ -59,7 +59,7 @@ var box2 = blessed.box({ top: 20, width: '80%', height: 9, - border: { + border_: { type: 'ascii' }, style: { @@ -89,9 +89,11 @@ var box3 = blessed.box({ top: 2, content: 'foo', shrink: true, + //height: 2, + //width: 3, //width: '80%', //height: 5, - border: { + border_: { type: 'ascii' }, style: {