allow appending of listbar items while detached. fixes #148.

This commit is contained in:
Christopher Jeffrey 2015-07-17 18:52:07 -07:00
parent 67b6674558
commit 72ddc05fd1
2 changed files with 11 additions and 4 deletions

View File

@ -157,13 +157,18 @@ Listbar.prototype.addItem =
Listbar.prototype.appendItem = function(item, callback) {
var self = this
, prev = this.items[this.items.length - 1]
, drawn = prev ? prev.aleft + prev.width : 0
, drawn
, cmd
, title
, len;
if (!this.screen.autoPadding) {
drawn += this.ileft;
if (!this.parent) {
drawn = 0;
} else {
drawn = prev ? prev.aleft + prev.width : 0
if (!this.screen.autoPadding) {
drawn += this.ileft;
}
}
if (typeof item === 'object') {

View File

@ -18,7 +18,7 @@ var box = blessed.box({
});
var bar = blessed.listbar({
parent: screen,
//parent: screen,
bottom: 0,
left: 3,
right: 3,
@ -110,6 +110,8 @@ var bar = blessed.listbar({
}
});
screen.append(bar);
bar.focus();
screen.key('q', function() {