@@ -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):
@@ -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)
+}
@@ -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 ""
}
@@ -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 {
@@ -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()
}
@@ -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 ""
}