1
0
mirror of https://github.com/rivo/tview.git synced 2025-05-01 22:18:30 +08:00

Fix unselected list color

This commit is contained in:
eeeXun 2024-05-27 23:18:55 +08:00
parent 037df494fb
commit 95779c15c5

View File

@ -506,12 +506,16 @@ func (l *List) Draw(screen tcell.Screen) {
} }
// Main text. // Main text.
var printedWidth int
var style tcell.Style
selected := index == l.currentItem && (!l.selectedFocusOnly || l.HasFocus()) selected := index == l.currentItem && (!l.selectedFocusOnly || l.HasFocus())
style := l.mainTextStyle
if selected { if selected {
style = l.selectedStyle style = l.selectedStyle
_, _, printedWidth = printWithStyle(screen, item.MainText, x, y, l.horizontalOffset, width, AlignLeft, style, false)
} else {
style = l.mainTextStyle
_, _, printedWidth = printWithStyle(screen, item.MainText, x, y, l.horizontalOffset, width, AlignLeft, style, true)
} }
_, _, printedWidth := printWithStyle(screen, item.MainText, x, y, l.horizontalOffset, width, AlignLeft, style, false)
if printedWidth > maxWidth { if printedWidth > maxWidth {
maxWidth = printedWidth maxWidth = printedWidth
} }