Change summary
ui/components/tabs/tabs.go | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
Detailed changes
@@ -63,6 +63,15 @@ func (t *Tabs) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
t.activeTab = (t.activeTab - 1 + len(t.tabs)) % len(t.tabs)
cmds = append(cmds, t.activeTabCmd)
}
+ case tea.MouseMsg:
+ if msg.Type == tea.MouseLeft {
+ for i, tab := range t.tabs {
+ if t.common.Zone.Get(tab).InBounds(msg) {
+ t.activeTab = i
+ cmds = append(cmds, t.activeTabCmd)
+ }
+ }
+ }
case SelectTabMsg:
tab := int(msg)
if tab >= 0 && tab < len(t.tabs) {
@@ -86,7 +95,12 @@ func (t *Tabs) View() string {
if t.UseDot {
s.WriteString(prefix)
}
- s.WriteString(style.Render(tab))
+ s.WriteString(
+ t.common.Zone.Mark(
+ tab,
+ style.Render(tab),
+ ),
+ )
if i != len(t.tabs)-1 {
s.WriteString(sep.String())
}