diff --git a/README.md b/README.md index ebb96f0..9840100 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/lib/widget.js b/lib/widget.js index 566aa59..f83f574 100644 --- a/lib/widget.js +++ b/lib/widget.js @@ -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; diff --git a/test/widget.js b/test/widget.js index 8140f2e..1c8ce5a 100644 --- a/test/widget.js +++ b/test/widget.js @@ -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',