diff --git a/pkg/ssh/ui.go b/pkg/ssh/ui.go index 204b80181e5ea48eefa9a475e9919ad9606367a3..e08cc89a31f110b56a1f9b28da3b95ea518eac46 100644 --- a/pkg/ssh/ui.go +++ b/pkg/ssh/ui.go @@ -202,7 +202,7 @@ func (ui *UI) Update(msg tea.Msg) (tea.Model, tea.Cmd) { ui.showFooter = true } case tea.MouseClickMsg: - switch msg.Mouse().Button { + switch msg.Button { case tea.MouseLeft: switch { case ui.common.Zone.Get("footer").InBounds(msg): diff --git a/pkg/ui/common/common.go b/pkg/ui/common/common.go index 687939407f8af05cc703dbf0ef1a60cd01302836..d6e0a778474698ede31c66bad607789164c24499 100644 --- a/pkg/ui/common/common.go +++ b/pkg/ui/common/common.go @@ -117,3 +117,9 @@ func IsFileMarkdown(content, ext string) bool { } return lang == "markdown" } + +// ScrollPercent returns a string representing the scroll percentage of the +// viewport. +func ScrollPercent(position int) string { + return fmt.Sprintf("≡ %d%%", position) +} diff --git a/pkg/ui/pages/repo/files.go b/pkg/ui/pages/repo/files.go index 24275396a925976ebcd0d0babe0690bc34dc707d..88c9b5802dfcfcefcfb13f2d0cac2c8715c780e9 100644 --- a/pkg/ui/pages/repo/files.go +++ b/pkg/ui/pages/repo/files.go @@ -383,7 +383,7 @@ func (f *Files) StatusBarInfo() string { case filesViewFiles: return fmt.Sprintf("# %d/%d", f.selector.Index()+1, len(f.selector.VisibleItems())) case filesViewContent: - return fmt.Sprintf("☰ %d%%", f.code.ScrollPosition()) + return common.ScrollPercent(f.code.ScrollPosition()) default: return "" } diff --git a/pkg/ui/pages/repo/readme.go b/pkg/ui/pages/repo/readme.go index 8978effcda5e4cac341c95007da99f54f3d926f8..13f4cb4a2cf68c7248d4e02a044ea3c191f35942 100644 --- a/pkg/ui/pages/repo/readme.go +++ b/pkg/ui/pages/repo/readme.go @@ -1,7 +1,6 @@ package repo import ( - "fmt" "path/filepath" "github.com/charmbracelet/bubbles/v2/key" @@ -157,7 +156,7 @@ func (r *Readme) StatusBarValue() string { // StatusBarInfo implements statusbar.StatusBar. func (r *Readme) StatusBarInfo() string { - return fmt.Sprintf("☰ %d%%", r.code.ScrollPosition()) + return common.ScrollPercent(r.code.ScrollPosition()) } func (r *Readme) updateReadmeCmd() tea.Msg { diff --git a/pkg/ui/pages/repo/repo.go b/pkg/ui/pages/repo/repo.go index fead336729501513ada5c6d456d58281784f1ddc..e9e5535ee0bd46b6eab6bcec360715968491c757 100644 --- a/pkg/ui/pages/repo/repo.go +++ b/pkg/ui/pages/repo/repo.go @@ -271,10 +271,10 @@ func (r *Repo) Update(msg tea.Msg) (tea.Model, tea.Cmd) { // Update the status bar on these events // Must come after we've updated the active tab switch msg.(type) { - case RepoMsg, RefMsg, tabs.ActiveTabMsg, tea.KeyPressMsg, tea.MouseClickMsg, - FileItemsMsg, FileContentMsg, FileBlameMsg, selector.ActiveMsg, - LogItemsMsg, GoBackMsg, LogDiffMsg, EmptyRepoMsg, - StashListMsg, StashPatchMsg: + case RepoMsg, RefMsg, tabs.ActiveTabMsg, tea.KeyPressMsg, + tea.MouseClickMsg, tea.MouseWheelMsg, FileItemsMsg, FileContentMsg, + FileBlameMsg, selector.ActiveMsg, LogItemsMsg, GoBackMsg, LogDiffMsg, + EmptyRepoMsg, StashListMsg, StashPatchMsg: r.setStatusBarInfo() } diff --git a/pkg/ui/pages/repo/stash.go b/pkg/ui/pages/repo/stash.go index 9d0b874884c5f21534326468c07b159304070999..10b0bbf2b63b2bbbcfbbbf2f18f39acf7d4699b9 100644 --- a/pkg/ui/pages/repo/stash.go +++ b/pkg/ui/pages/repo/stash.go @@ -128,7 +128,7 @@ func (s *Stash) StatusBarInfo() string { } return fmt.Sprintf("p. %d/%d", s.list.Page()+1, totalPages) case stashStatePatch: - return fmt.Sprintf("☰ %d%%", s.code.ScrollPosition()) + return common.ScrollPercent(s.code.ScrollPosition()) default: return "" }