From 7000c1109f66b7591e6056a82f270f57bf8ae6b5 Mon Sep 17 00:00:00 2001 From: Florrie Date: Thu, 13 Sep 2018 17:36:56 -0300 Subject: Show which item in a listing is selected, even if the listing isn't selected This is foundation for actively highlighting the result of a jump-to while typing. (Since your focus is on the ListingJumpElement, there needs to be some way to see which item would be selected in the GrouplikeListing. That's what this commit implements.) This also looks pretty nifty when you press M to open the context menu, if I do say so myself. --- ui.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'ui.js') diff --git a/ui.js b/ui.js index 1d8d2da..73a9732 100644 --- a/ui.js +++ b/ui.js @@ -949,8 +949,17 @@ class GrouplikeItemElement extends Button { } drawTo(writable) { - if (this.isSelected) { + const isCurrentInput = this.parent.inputs[this.parent.curIndex] === this + // This line's commented out for now, so it'll show as selected (but + // dimmed) even if you don't have the listing selected. To change that, + // uncomment this and add it to the isCurrentInput line. + // const isListingSelected = this.parent.parent.isSelected + const isSelfSelected = this.isSelected + + if (isSelfSelected) { writable.write(ansi.invert()) + } else if (isCurrentInput) { + writable.write(ansi.setAttributes([ansi.A_INVERT, ansi.A_DIM])) } writable.write(ansi.moveCursor(this.absTop, this.absLeft)) -- cgit 1.3.0-6-gf8a5