border measures.

This commit is contained in:
Christopher Jeffrey 2013-06-01 06:08:18 -05:00
parent 493004b521
commit 210d956214
1 changed files with 51 additions and 11 deletions

View File

@ -396,6 +396,50 @@ Element.prototype.__defineGetter__('rbottom', function() {
return this.position.bottom;
});
/**
* Border Measures
*/
Element.prototype.__defineGetter__('bheight', function() {
return this.height - (this.parent.border ? 1 : 0);
});
Element.prototype.__defineGetter__('bwidth', function() {
return this.width - (this.parent.border ? 1 : 0);
});
Element.prototype.__defineGetter__('bleft', function() {
return this.left + (this.parent.border ? 1 : 0);
});
Element.prototype.__defineGetter__('bright', function() {
return this.right + (this.parent.border ? 1 : 0);
});
Element.prototype.__defineGetter__('btop', function() {
return this.top + (this.parent.border ? 1 : 0);
});
Element.prototype.__defineGetter__('bbottom', function() {
return this.bottom + (this.parent.border ? 1 : 0);
});
Element.prototype.__defineGetter__('brleft', function() {
return this.rleft + (this.parent.border ? 1 : 0);
});
Element.prototype.__defineGetter__('brright', function() {
return this.rright + (this.parent.border ? 1 : 0);
});
Element.prototype.__defineGetter__('brtop', function() {
return this.rtop + (this.parent.border ? 1 : 0);
});
Element.prototype.__defineGetter__('brbottom', function() {
return this.rbottom + (this.parent.border ? 1 : 0);
});
/**
* Box
*/
@ -429,15 +473,6 @@ Box.prototype.render = function() {
for (yi = this.top; yi < yl; yi++) {
for (xi = this.left; xi < xl; xi++) {
if (this.border && (yi === this.top || xi === this.left || yi === yl - 1 || xi === xl - 1)) {
/*
if (this.border && (
(yi === this.top && this.border.top !== false)
|| (xi === this.left && this.border.left !== false)
|| (yi === yl - 1 && this.border.bottom !== false)
|| (xi === xl - 1 && this.border.right !== false))) {
*/
attr = ((this.border.bold << 18) + (this.border.underline << 18)) | (this.border.fg << 9) | this.border.bg;
if (this.border.type === 'ascii') {
if (yi === this.top) {
@ -470,6 +505,11 @@ Box.prototype.render = function() {
this.children.forEach(function(el) {
el.render();
});
//var o = { x: 0, y: 0 };
//this.children.forEach(function(el) {
// el.render(o);
//});
};
/**
@ -513,7 +553,7 @@ Text.prototype.render = function() {
var ended = -1;
for (yi = this.top; yi < yl; yi++) {
for (; yi < yl; yi++) {
for (xi = this.left; xi < xl; xi++) {
cell = lines[yi][xi];
attr = ((this.bold << 18) + (this.underline << 18)) | (this.fg << 9) | this.bg;
@ -608,7 +648,7 @@ List.prototype.add = function(item) {
fg: this.fg,
bg: this.bg,
content: item.content,
top: this.children.length + 1,
top: this.children.length + (this.border ? 1 : 0),
left: (this.border ? 1 : 0) + 1,
full: true,
height: 1