41 lines
799 B
Go
41 lines
799 B
Go
package views
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/derailed/k9s/internal/config"
|
|
"github.com/derailed/tview"
|
|
)
|
|
|
|
type crumbsView struct {
|
|
*tview.TextView
|
|
|
|
styles *config.Styles
|
|
}
|
|
|
|
func newCrumbsView(styles *config.Styles) *crumbsView {
|
|
v := crumbsView{styles: styles, TextView: tview.NewTextView()}
|
|
{
|
|
v.SetBackgroundColor(styles.BgColor())
|
|
v.SetTextAlign(tview.AlignLeft)
|
|
v.SetBorderPadding(0, 0, 1, 1)
|
|
v.SetDynamicColors(true)
|
|
}
|
|
|
|
return &v
|
|
}
|
|
|
|
func (v *crumbsView) update(crumbs []string) {
|
|
v.Clear()
|
|
last, bgColor := len(crumbs)-1, v.styles.Frame().Crumb.BgColor
|
|
for i, c := range crumbs {
|
|
if i == last {
|
|
bgColor = v.styles.Frame().Crumb.ActiveColor
|
|
}
|
|
fmt.Fprintf(v, "[%s:%s:b] <%s> [-:%s:-] ",
|
|
v.styles.Frame().Crumb.FgColor,
|
|
bgColor, c,
|
|
v.styles.Body().BgColor)
|
|
}
|
|
}
|