fix(ui): use more accurate scroll percent symbol and improve status bar

Ayman Bagabas created

rendering

Change summary

pkg/ssh/ui.go               | 2 +-
pkg/ui/common/common.go     | 6 ++++++
pkg/ui/pages/repo/files.go  | 2 +-
pkg/ui/pages/repo/readme.go | 3 +--
pkg/ui/pages/repo/repo.go   | 8 ++++----
pkg/ui/pages/repo/stash.go  | 2 +-
6 files changed, 14 insertions(+), 9 deletions(-)

Detailed changes

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):

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)
+}

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 ""
 	}

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 {

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()
 	}
 

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 ""
 	}