fix tree items possibly getting the wrong foreground or background
This commit is contained in:
@@ -20,9 +20,7 @@ func (ti TreeItem) String() string {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ti TreeItem) TreeItemStyle(active bool) (uiterm.Attribute, uiterm.Attribute) {
|
func (ti TreeItem) TreeItemStyle(fg, bg uiterm.Attribute, active bool) (uiterm.Attribute, uiterm.Attribute) {
|
||||||
fg := uiterm.ColorDefault
|
|
||||||
bg := uiterm.ColorBlack
|
|
||||||
if ti.Channel != nil {
|
if ti.Channel != nil {
|
||||||
fg |= uiterm.AttrBold
|
fg |= uiterm.AttrBold
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type TreeItem interface {
|
type TreeItem interface {
|
||||||
TreeItemStyle(active bool) (Attribute, Attribute)
|
TreeItemStyle(fg, bg Attribute, active bool) (Attribute, Attribute)
|
||||||
String() string
|
String() string
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,7 +122,7 @@ func (t *Tree) uiDraw() {
|
|||||||
if reader != nil && level*2 <= dx {
|
if reader != nil && level*2 <= dx {
|
||||||
if ch, _, err := reader.ReadRune(); err == nil {
|
if ch, _, err := reader.ReadRune(); err == nil {
|
||||||
chr = ch
|
chr = ch
|
||||||
fg, bg = item.TreeItemStyle(t.active && t.activeLine == dy)
|
fg, bg = item.TreeItemStyle(fg, bg, t.active && t.activeLine == dy)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
termbox.SetCell(x, y, chr, termbox.Attribute(fg), termbox.Attribute(bg))
|
termbox.SetCell(x, y, chr, termbox.Attribute(fg), termbox.Attribute(bg))
|
||||||
|
|||||||
Reference in New Issue
Block a user