add invertSelected option to List. fixes #124.

This commit is contained in:
Christopher Jeffrey 2015-04-16 13:20:49 -07:00
parent 489aa2dbe3
commit 46a76abbdd
3 changed files with 7 additions and 2 deletions

View File

@ -695,6 +695,8 @@ A scrollable list which can display selectable items.
item that is found in `items`.
- __interactive__ - whether the list is interactive and can have items selected
(default: true).
- __invertSelected__ - whether to automatically override tags and invert fg of
item when selected (default: `true`).
##### Properties:

View File

@ -3969,7 +3969,8 @@ Element.prototype.render = function() {
attr = this.screen.attrCode(c[0], attr, dattr);
// Ignore foreground changes for selected items.
if (this.parent._isList && this.parent.interactive
&& this.parent.items[this.parent.selected] === this) {
&& this.parent.items[this.parent.selected] === this
&& this.parent.options.invertSelected !== false) {
attr = (attr & ~(0x1ff << 9)) | (dattr & (0x1ff << 9));
}
ch = content[ci] || bch;

View File

@ -69,9 +69,11 @@ var list = blessed.list({
height: '50%',
top: 'center',
left: 'center',
tags: true,
invertSelected: false,
items: [
'one',
'two',
'{red-fg}two{/red-fg}',
'three',
'four',
'five',