mirror of
https://github.com/embarklabs/neo-blessed.git
synced 2025-02-03 14:45:33 +00:00
add more events to lists.
This commit is contained in:
parent
b05f3cc185
commit
36c726006f
@ -2990,6 +2990,7 @@ Element.prototype.setLabel = function(options) {
|
||||
};
|
||||
|
||||
Element.prototype.removeLabel = function() {
|
||||
if (!this._label) return;
|
||||
this._label.detach();
|
||||
delete this._label;
|
||||
};
|
||||
@ -3072,6 +3073,7 @@ Element.prototype.setHover = function(options) {
|
||||
};
|
||||
|
||||
Element.prototype.removeHover = function() {
|
||||
if (!this._hover) return;
|
||||
this._hover.detach();
|
||||
delete this._hover;
|
||||
};
|
||||
@ -5346,6 +5348,8 @@ List.prototype.appendItem = function(item) {
|
||||
self.screen.render();
|
||||
});
|
||||
}
|
||||
|
||||
this.emit('add item');
|
||||
};
|
||||
|
||||
List.prototype.find =
|
||||
@ -5423,6 +5427,7 @@ List.prototype.removeItem = function(child) {
|
||||
this.select(i - 1);
|
||||
}
|
||||
}
|
||||
this.emit('remove item');
|
||||
};
|
||||
|
||||
List.prototype.clearItems = function() {
|
||||
@ -5461,6 +5466,8 @@ List.prototype.setItems = function(items) {
|
||||
} else {
|
||||
this.select(Math.min(selected, items.length - 1));
|
||||
}
|
||||
|
||||
this.emit('set items');
|
||||
};
|
||||
|
||||
List.prototype.select = function(index) {
|
||||
@ -5492,6 +5499,9 @@ List.prototype.select = function(index) {
|
||||
this.value = helpers.cleanTags(this.ritems[this.selected]);
|
||||
if (!this.parent) return;
|
||||
this.scrollTo(this.selected);
|
||||
|
||||
// XXX Move `action` and `select` events here.
|
||||
this.emit('select item', this.items[this.selected], this.selected);
|
||||
};
|
||||
|
||||
List.prototype.move = function(offset) {
|
||||
@ -6513,6 +6523,8 @@ FileManager.prototype.refresh = function(cwd, callback) {
|
||||
self.select(0);
|
||||
self.screen.render();
|
||||
|
||||
self.emit('refresh');
|
||||
|
||||
if (callback) callback();
|
||||
});
|
||||
};
|
||||
@ -7223,6 +7235,8 @@ Listbar.prototype.setItems = function(commands) {
|
||||
commands.forEach(function(cmd) {
|
||||
self.add(cmd);
|
||||
});
|
||||
|
||||
this.emit('set items');
|
||||
};
|
||||
|
||||
Listbar.prototype.add =
|
||||
@ -7341,6 +7355,8 @@ Listbar.prototype.appendItem = function(item, callback) {
|
||||
self.screen.render();
|
||||
});
|
||||
}
|
||||
|
||||
this.emit('add item');
|
||||
};
|
||||
|
||||
Listbar.prototype.render = function() {
|
||||
@ -7417,6 +7433,9 @@ Listbar.prototype.select = function(offset) {
|
||||
this.leftOffset -= diff;
|
||||
}
|
||||
}
|
||||
|
||||
// XXX Move `action` and `select` events here.
|
||||
this.emit('select item', el, offset);
|
||||
};
|
||||
|
||||
Listbar.prototype.removeItem = function(child) {
|
||||
@ -7433,6 +7452,8 @@ Listbar.prototype.removeItem = function(child) {
|
||||
this.select(i - 1);
|
||||
}
|
||||
}
|
||||
|
||||
this.emit('remove item');
|
||||
};
|
||||
|
||||
Listbar.prototype.move = function(offset) {
|
||||
@ -7456,6 +7477,7 @@ Listbar.prototype.selectTab = function(index) {
|
||||
this.select(index);
|
||||
this.screen.render();
|
||||
}
|
||||
this.emit('select tab', item, index);
|
||||
};
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user