diff --git a/cmd/soft/browse/browse.go b/cmd/soft/browse/browse.go index 10fd15d19f4964e1d6184fb055933561949035ba..4ab28cb2fb84dc30873241d1cf366fe9d73bed35 100644 --- a/cmd/soft/browse/browse.go +++ b/cmd/soft/browse/browse.go @@ -169,10 +169,10 @@ func (m *model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { mouse := msg.Mouse() switch mouse.Button { case tea.MouseLeft: - // switch { - // case m.common.Zone.Get("footer").InBounds(msg): - // cmds = append(cmds, footer.ToggleFooterCmd) - // } + switch { + case m.common.Zone.Get("footer").InBounds(msg): + cmds = append(cmds, footer.ToggleFooterCmd) + } } case footer.ToggleFooterMsg: m.footer.SetShowAll(!m.footer.ShowAll()) diff --git a/go.mod b/go.mod index f9b88720be7645aeeb57209a25e1338ea633ac9a..be57b5809e22f70b2999fca8c3688a8178bdd212 100644 --- a/go.mod +++ b/go.mod @@ -57,6 +57,7 @@ require ( require ( github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be // indirect github.com/atotto/clipboard v0.1.4 // indirect + github.com/aymanbagabas/bubblezone/v2 v2.0.0-20250319214444-bb232f16d5e3 // indirect github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect github.com/aymerick/douceur v0.2.0 // indirect github.com/beorn7/perks v1.0.1 // indirect diff --git a/go.sum b/go.sum index 637ac4dc47b78ce32a54134bf35278415a3a6970..919a7c3772c3b02ad1f01ad250635e548716fd49 100644 --- a/go.sum +++ b/go.sum @@ -10,6 +10,8 @@ github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFI github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be/go.mod h1:ySMOLuWl6zY27l47sB3qLNK6tF2fkHG55UZxx8oIVo4= github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z4= github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI= +github.com/aymanbagabas/bubblezone/v2 v2.0.0-20250319214444-bb232f16d5e3 h1:1z2ihw0YUYUhNmRaavyXvG9ZU/9Tj0vj6sA3z5DFIJ8= +github.com/aymanbagabas/bubblezone/v2 v2.0.0-20250319214444-bb232f16d5e3/go.mod h1:sJwqZoo/BSKSizmr0pSJ758RuRsnjlkrOaxPtwlWtOs= github.com/aymanbagabas/git-module v1.8.4-0.20231101154130-8d27204ac6d2 h1:3w5KT+shE3hzWhORGiu2liVjEoaCEXm9uZP47+Gw4So= github.com/aymanbagabas/git-module v1.8.4-0.20231101154130-8d27204ac6d2/go.mod h1:d4gQ7/3/S2sPq4NnKdtAgUOVr6XtLpWFtxyVV5/+76U= github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k= diff --git a/pkg/ssh/ui.go b/pkg/ssh/ui.go index f58c00398a0ffb4e7ad1f4ae3291093aa475dd9d..89d5ee5f6fe07af8fbd89793319f7d96573e96c8 100644 --- a/pkg/ssh/ui.go +++ b/pkg/ssh/ui.go @@ -206,10 +206,10 @@ func (ui *UI) Update(msg tea.Msg) (tea.Model, tea.Cmd) { case tea.MouseClickMsg: switch msg.Mouse().Button { case tea.MouseLeft: - // switch { - // case ui.common.Zone.Get("footer").InBounds(msg): - // cmds = append(cmds, footer.ToggleFooterCmd) - // } + switch { + case ui.common.Zone.Get("footer").InBounds(msg): + cmds = append(cmds, footer.ToggleFooterCmd) + } } } case footer.ToggleFooterMsg: diff --git a/pkg/ui/common/common.go b/pkg/ui/common/common.go index df16d027c1042c3061b19fe89b655aa3cedf3081..76b6ac488e8f71f21b5fb94c054f137331146bd7 100644 --- a/pkg/ui/common/common.go +++ b/pkg/ui/common/common.go @@ -5,6 +5,7 @@ import ( "fmt" "github.com/alecthomas/chroma/v2/lexers" + zone "github.com/aymanbagabas/bubblezone/v2" "github.com/charmbracelet/log" "github.com/charmbracelet/soft-serve/git" "github.com/charmbracelet/soft-serve/pkg/backend" @@ -12,7 +13,6 @@ import ( "github.com/charmbracelet/soft-serve/pkg/ui/keymap" "github.com/charmbracelet/soft-serve/pkg/ui/styles" "github.com/charmbracelet/ssh" - zone "github.com/lrstanley/bubblezone" ) type contextKey struct { diff --git a/pkg/ui/components/selector/selector.go b/pkg/ui/components/selector/selector.go index 45cb031b8bd9b3ff8c928dbe07edf9b4628f5bf3..ff43816bb5fd6dd749008fee496b014085b5c8a7 100644 --- a/pkg/ui/components/selector/selector.go +++ b/pkg/ui/components/selector/selector.go @@ -238,19 +238,19 @@ func (s *Selector) Update(msg tea.Msg) (tea.Model, tea.Cmd) { case tea.MouseWheelDown: s.CursorDown() case tea.MouseLeft: - // curIdx := s.Index() - // for i, item := range s.Items() { - // item, _ := item.(IdentifiableItem) - // // Check each item to see if it's in bounds. - // if item != nil && s.common.Zone.Get(item.ID()).InBounds(msg) { - // if i == curIdx { - // cmds = append(cmds, s.SelectItemCmd) - // } else { - // s.Select(i) - // } - // break - // } - // } + curIdx := s.Index() + for i, item := range s.Items() { + item, _ := item.(IdentifiableItem) + // Check each item to see if it's in bounds. + if item != nil && s.common.Zone.Get(item.ID()).InBounds(msg) { + if i == curIdx { + cmds = append(cmds, s.SelectItemCmd) + } else { + s.Select(i) + } + break + } + } } case tea.KeyMsg: filterState := s.FilterState() diff --git a/pkg/ui/components/tabs/tabs.go b/pkg/ui/components/tabs/tabs.go index 2756595a361de3a4b2505bb86311ba8a7adfbd27..51aec590e5c06da697408cb89ef2ffbb586e5853 100644 --- a/pkg/ui/components/tabs/tabs.go +++ b/pkg/ui/components/tabs/tabs.go @@ -66,12 +66,12 @@ func (t *Tabs) Update(msg tea.Msg) (tea.Model, tea.Cmd) { case tea.MouseClickMsg: switch msg.Button { case tea.MouseLeft: - // for i, tab := range t.tabs { - // if t.common.Zone.Get(tab).InBounds(msg) { - // t.activeTab = i - // cmds = append(cmds, t.activeTabCmd) - // } - // } + 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) diff --git a/pkg/ui/pages/repo/repo.go b/pkg/ui/pages/repo/repo.go index b68c8084a359087e223a1c082aaa1fdfdce36f82..5aba643528281850c17a85e8faef09c5b4dd9b6e 100644 --- a/pkg/ui/pages/repo/repo.go +++ b/pkg/ui/pages/repo/repo.go @@ -12,6 +12,7 @@ import ( "github.com/charmbracelet/soft-serve/git" "github.com/charmbracelet/soft-serve/pkg/proto" "github.com/charmbracelet/soft-serve/pkg/ui/common" + "github.com/charmbracelet/soft-serve/pkg/ui/components/footer" "github.com/charmbracelet/soft-serve/pkg/ui/components/selector" "github.com/charmbracelet/soft-serve/pkg/ui/components/statusbar" "github.com/charmbracelet/soft-serve/pkg/ui/components/tabs" @@ -176,26 +177,26 @@ func (r *Repo) Update(msg tea.Msg) (tea.Model, tea.Cmd) { if cmd != nil { cmds = append(cmds, cmd) } - // if r.selectedRepo != nil { - // urlID := fmt.Sprintf("%s-url", r.selectedRepo.Name()) - // cmd := r.common.CloneCmd(r.common.Config().SSH.PublicURL, r.selectedRepo.Name()) - // if msg, ok := msg.(tea.MouseMsg); ok && r.common.Zone.Get(urlID).InBounds(msg) { - // cmds = append(cmds, copyCmd(cmd, "Command copied to clipboard")) - // } - // } + if r.selectedRepo != nil { + urlID := fmt.Sprintf("%s-url", r.selectedRepo.Name()) + cmd := r.common.CloneCmd(r.common.Config().SSH.PublicURL, r.selectedRepo.Name()) + if msg, ok := msg.(tea.MouseMsg); ok && r.common.Zone.Get(urlID).InBounds(msg) { + cmds = append(cmds, copyCmd(cmd, "Command copied to clipboard")) + } + } switch msg := msg.(type) { case tea.MouseClickMsg: switch msg.Button { case tea.MouseLeft: - // switch { - // case r.common.Zone.Get("repo-help").InBounds(msg): - // cmds = append(cmds, footer.ToggleFooterCmd) - // } + switch { + case r.common.Zone.Get("repo-help").InBounds(msg): + cmds = append(cmds, footer.ToggleFooterCmd) + } case tea.MouseRight: - // switch { - // case r.common.Zone.Get("repo-main").InBounds(msg): - // cmds = append(cmds, goBackCmd) - // } + switch { + case r.common.Zone.Get("repo-main").InBounds(msg): + cmds = append(cmds, goBackCmd) + } } } switch msg := msg.(type) {