Add List.SetSelectedTextAttributes

This commit is contained in:
Trevor Slocum 2020-04-28 14:59:40 -07:00
parent 233de43609
commit 66d2785058
2 changed files with 16 additions and 1 deletions

View File

@ -1,3 +1,6 @@
v1.4.6 (WIP)
- Add List.SetSelectedTextAttributes
v1.4.5 (2020-04-25)
- Add multithreading support
- Add ContextMenu (initially supported by List)

14
list.go
View File

@ -43,6 +43,9 @@ type List struct {
// The text color for selected items.
selectedTextColor tcell.Color
// The style attributes for selected items.
selectedTextAttributes tcell.AttrMask
// Visibility of the scroll bar.
scrollBarVisibility ScrollBarVisibility
@ -232,6 +235,15 @@ func (l *List) SetSelectedTextColor(color tcell.Color) *List {
return l
}
// SetSelectedTextAttributes sets the style attributes of selected items.
func (l *List) SetSelectedTextAttributes(attr tcell.AttrMask) *List {
l.Lock()
defer l.Unlock()
l.selectedTextAttributes = attr
return l
}
// SetSelectedBackgroundColor sets the background color of selected items.
func (l *List) SetSelectedBackgroundColor(color tcell.Color) *List {
l.Lock()
@ -695,7 +707,7 @@ func (l *List) Draw(screen tcell.Screen) {
if fg == l.mainTextColor {
fg = l.selectedTextColor
}
style = style.Background(l.selectedBackgroundColor).Foreground(fg)
style = style.Background(l.selectedBackgroundColor).Foreground(fg) | tcell.Style(l.selectedTextAttributes)
screen.SetContent(x+bx, y, m, c, style)
}
}