mirror of
https://github.com/embarklabs/neo-blessed.git
synced 2025-01-22 08:48:53 +00:00
fix scroll rendering for children with padding.
This commit is contained in:
parent
c4a7f05025
commit
52a9f5d182
@ -2864,7 +2864,8 @@ Element.prototype._getCoords = function(get) {
|
||||
, noright
|
||||
, notop
|
||||
, nobot
|
||||
, ppos;
|
||||
, ppos
|
||||
, b;
|
||||
|
||||
// Attempt to shrink the element base on the
|
||||
// size of the content and child elements.
|
||||
@ -2900,30 +2901,37 @@ Element.prototype._getCoords = function(get) {
|
||||
|
||||
if (!ppos) return;
|
||||
|
||||
// TODO: Figure out how to fix base (and cbase to only
|
||||
// take into account the *parent's* padding.
|
||||
|
||||
yi -= ppos.base;
|
||||
yl -= ppos.base;
|
||||
|
||||
if (yi < ppos.yi + this.parent.itop) {
|
||||
if (yl - 1 < ppos.yi + this.parent.itop) {
|
||||
b = this.parent.border ? 1 : 0;
|
||||
|
||||
if (yi < ppos.yi + b) {
|
||||
if (yl - 1 < ppos.yi + b) {
|
||||
// Is above.
|
||||
return;
|
||||
} else {
|
||||
// Is partially covered above.
|
||||
notop = true;
|
||||
v = ppos.yi - yi;
|
||||
v += this.parent.itop - this.itop;
|
||||
if (this.border) v--;
|
||||
if (this.parent.border) v++;
|
||||
base += v;
|
||||
yi += v;
|
||||
}
|
||||
} else if (yl > ppos.yl - this.parent.ibottom) {
|
||||
if (yi > ppos.yl - 1 - this.parent.ibottom) {
|
||||
} else if (yl > ppos.yl - b) {
|
||||
if (yi > ppos.yl - 1 - b) {
|
||||
// Is below.
|
||||
return;
|
||||
} else {
|
||||
// Is partially covered below.
|
||||
nobot = true;
|
||||
v = yl - ppos.yl;
|
||||
v += this.parent.ibottom - this.ibottom;
|
||||
if (this.border) v--;
|
||||
if (this.parent.border) v++;
|
||||
yl -= v;
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ screen = blessed.screen({
|
||||
|
||||
var box = blessed.box({
|
||||
parent: screen,
|
||||
//padding: 2,
|
||||
scrollable: true,
|
||||
left: 'center',
|
||||
top: 'center',
|
||||
@ -21,7 +22,7 @@ var box = blessed.box({
|
||||
keys: true,
|
||||
vi: true,
|
||||
alwaysScroll: true,
|
||||
scrollbar_: {
|
||||
scrollbar: {
|
||||
ch: ' ',
|
||||
inverse: true
|
||||
}
|
||||
@ -30,6 +31,7 @@ var box = blessed.box({
|
||||
var text = blessed.box({
|
||||
parent: box,
|
||||
content: 'hello1\nhello2\nhello3\nhello4',
|
||||
padding: 2,
|
||||
style: {
|
||||
bg: 'red'
|
||||
},
|
||||
@ -42,6 +44,7 @@ var text = blessed.box({
|
||||
var text2 = blessed.box({
|
||||
parent: box,
|
||||
content: 'world',
|
||||
padding: 1,
|
||||
style: {
|
||||
bg: 'red'
|
||||
},
|
||||
@ -55,6 +58,7 @@ var box2 = blessed.box({
|
||||
parent: box,
|
||||
scrollable: true,
|
||||
content: 'foo-one\nfoo-two\nfoo-three',
|
||||
padding: 2,
|
||||
left: 'center',
|
||||
top: 20,
|
||||
width: '80%',
|
||||
|
Loading…
x
Reference in New Issue
Block a user