Browse Source

Add List.SetSelectedTextAttributes

merge-requests/2/head
Trevor Slocum 2 years ago
parent
commit
66d2785058
  1. 3
      CHANGELOG
  2. 14
      list.go

3
CHANGELOG

@ -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

@ -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)
}
}

Loading…
Cancel
Save