mirror of
https://github.com/embarklabs/neo-blessed.git
synced 2025-02-08 17:13:29 +00:00
allow appending of listbar items while detached. fixes #148.
This commit is contained in:
parent
67b6674558
commit
72ddc05fd1
@ -157,14 +157,19 @@ Listbar.prototype.addItem =
|
|||||||
Listbar.prototype.appendItem = function(item, callback) {
|
Listbar.prototype.appendItem = function(item, callback) {
|
||||||
var self = this
|
var self = this
|
||||||
, prev = this.items[this.items.length - 1]
|
, prev = this.items[this.items.length - 1]
|
||||||
, drawn = prev ? prev.aleft + prev.width : 0
|
, drawn
|
||||||
, cmd
|
, cmd
|
||||||
, title
|
, title
|
||||||
, len;
|
, len;
|
||||||
|
|
||||||
|
if (!this.parent) {
|
||||||
|
drawn = 0;
|
||||||
|
} else {
|
||||||
|
drawn = prev ? prev.aleft + prev.width : 0
|
||||||
if (!this.screen.autoPadding) {
|
if (!this.screen.autoPadding) {
|
||||||
drawn += this.ileft;
|
drawn += this.ileft;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (typeof item === 'object') {
|
if (typeof item === 'object') {
|
||||||
cmd = item;
|
cmd = item;
|
||||||
|
@ -18,7 +18,7 @@ var box = blessed.box({
|
|||||||
});
|
});
|
||||||
|
|
||||||
var bar = blessed.listbar({
|
var bar = blessed.listbar({
|
||||||
parent: screen,
|
//parent: screen,
|
||||||
bottom: 0,
|
bottom: 0,
|
||||||
left: 3,
|
left: 3,
|
||||||
right: 3,
|
right: 3,
|
||||||
@ -110,6 +110,8 @@ var bar = blessed.listbar({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
screen.append(bar);
|
||||||
|
|
||||||
bar.focus();
|
bar.focus();
|
||||||
|
|
||||||
screen.key('q', function() {
|
screen.key('q', function() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user