diff --git a/gui.go b/gui.go index 89015e6..4bd5a7d 100644 --- a/gui.go +++ b/gui.go @@ -1020,6 +1020,14 @@ func (g *Gui) drawTitle(v *View, fgColor, bgColor Attribute) error { } tabs := v.Tabs + prefix := v.TitlePrefix + if prefix != "" { + if len(v.FrameRunes) > 0 { + prefix += string(v.FrameRunes[0]) + } else { + prefix += "─" + } + } separator := " - " charIndex := 0 currentTabStart := -1 @@ -1043,6 +1051,12 @@ func (g *Gui) drawTitle(v *View, fgColor, bgColor Attribute) error { str := strings.Join(tabs, separator) x := v.x0 + 2 + for _, ch := range prefix { + if err := g.SetRune(x, v.y0, ch, fgColor, bgColor); err != nil { + return err + } + x += runewidth.RuneWidth(ch) + } for i, ch := range str { if x < 0 { continue diff --git a/view.go b/view.go index 5c6fed9..707c321 100644 --- a/view.go +++ b/view.go @@ -122,6 +122,10 @@ type View struct { // If Frame is true, Title allows to configure a title for the view. Title string + // If non-empty, TitlePrefix is prepended to the title of a view regardless on + // the the currently selected tab (if any.) + TitlePrefix string + Tabs []string TabIndex int @@ -1348,7 +1352,10 @@ func (v *View) GetClickedTabIndex(x int) int { return 0 } - charX := 1 + charX := len(v.TitlePrefix) + 1 + if v.TitlePrefix != "" { + charX += 1 + } if x <= charX { return -1 }