8e6fd530129a5f70535c7680bc9036ecd5c3cb8c

Author
Ayman Bagabas <ayman.bagabas@gmail.com>
Committer
Ayman Bagabas <ayman.bagabas@gmail.com>
Date

Message

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

Diff

 1diff --git a/pkg/ssh/ui.go b/pkg/ssh/ui.go
 2index 204b80181e5ea48eefa9a475e9919ad9606367a3..e08cc89a31f110b56a1f9b28da3b95ea518eac46 100644
 3--- a/pkg/ssh/ui.go
 4+++ b/pkg/ssh/ui.go
 5@@ -202,7 +202,7 @@ func (ui *UI) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
 6 			ui.showFooter = true
 7 		}
 8 	case tea.MouseClickMsg:
 9-		switch msg.Mouse().Button {
10+		switch msg.Button {
11 		case tea.MouseLeft:
12 			switch {
13 			case ui.common.Zone.Get("footer").InBounds(msg):
14diff --git a/pkg/ui/common/common.go b/pkg/ui/common/common.go
15index 687939407f8af05cc703dbf0ef1a60cd01302836..d6e0a778474698ede31c66bad607789164c24499 100644
16--- a/pkg/ui/common/common.go
17+++ b/pkg/ui/common/common.go
18@@ -117,3 +117,9 @@ func IsFileMarkdown(content, ext string) bool {
19 	}
20 	return lang == "markdown"
21 }
22+
23+// ScrollPercent returns a string representing the scroll percentage of the
24+// viewport.
25+func ScrollPercent(position int) string {
26+	return fmt.Sprintf("≡ %d%%", position)
27+}
28diff --git a/pkg/ui/pages/repo/files.go b/pkg/ui/pages/repo/files.go
29index 24275396a925976ebcd0d0babe0690bc34dc707d..88c9b5802dfcfcefcfb13f2d0cac2c8715c780e9 100644
30--- a/pkg/ui/pages/repo/files.go
31+++ b/pkg/ui/pages/repo/files.go
32@@ -383,7 +383,7 @@ func (f *Files) StatusBarInfo() string {
33 	case filesViewFiles:
34 		return fmt.Sprintf("# %d/%d", f.selector.Index()+1, len(f.selector.VisibleItems()))
35 	case filesViewContent:
36-		return fmt.Sprintf("☰ %d%%", f.code.ScrollPosition())
37+		return common.ScrollPercent(f.code.ScrollPosition())
38 	default:
39 		return ""
40 	}
41diff --git a/pkg/ui/pages/repo/readme.go b/pkg/ui/pages/repo/readme.go
42index 8978effcda5e4cac341c95007da99f54f3d926f8..13f4cb4a2cf68c7248d4e02a044ea3c191f35942 100644
43--- a/pkg/ui/pages/repo/readme.go
44+++ b/pkg/ui/pages/repo/readme.go
45@@ -1,7 +1,6 @@
46 package repo
47 
48 import (
49-	"fmt"
50 	"path/filepath"
51 
52 	"github.com/charmbracelet/bubbles/v2/key"
53@@ -157,7 +156,7 @@ func (r *Readme) StatusBarValue() string {
54 
55 // StatusBarInfo implements statusbar.StatusBar.
56 func (r *Readme) StatusBarInfo() string {
57-	return fmt.Sprintf("☰ %d%%", r.code.ScrollPosition())
58+	return common.ScrollPercent(r.code.ScrollPosition())
59 }
60 
61 func (r *Readme) updateReadmeCmd() tea.Msg {
62diff --git a/pkg/ui/pages/repo/repo.go b/pkg/ui/pages/repo/repo.go
63index fead336729501513ada5c6d456d58281784f1ddc..e9e5535ee0bd46b6eab6bcec360715968491c757 100644
64--- a/pkg/ui/pages/repo/repo.go
65+++ b/pkg/ui/pages/repo/repo.go
66@@ -271,10 +271,10 @@ func (r *Repo) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
67 	// Update the status bar on these events
68 	// Must come after we've updated the active tab
69 	switch msg.(type) {
70-	case RepoMsg, RefMsg, tabs.ActiveTabMsg, tea.KeyPressMsg, tea.MouseClickMsg,
71-		FileItemsMsg, FileContentMsg, FileBlameMsg, selector.ActiveMsg,
72-		LogItemsMsg, GoBackMsg, LogDiffMsg, EmptyRepoMsg,
73-		StashListMsg, StashPatchMsg:
74+	case RepoMsg, RefMsg, tabs.ActiveTabMsg, tea.KeyPressMsg,
75+		tea.MouseClickMsg, tea.MouseWheelMsg, FileItemsMsg, FileContentMsg,
76+		FileBlameMsg, selector.ActiveMsg, LogItemsMsg, GoBackMsg, LogDiffMsg,
77+		EmptyRepoMsg, StashListMsg, StashPatchMsg:
78 		r.setStatusBarInfo()
79 	}
80 
81diff --git a/pkg/ui/pages/repo/stash.go b/pkg/ui/pages/repo/stash.go
82index 9d0b874884c5f21534326468c07b159304070999..10b0bbf2b63b2bbbcfbbbf2f18f39acf7d4699b9 100644
83--- a/pkg/ui/pages/repo/stash.go
84+++ b/pkg/ui/pages/repo/stash.go
85@@ -128,7 +128,7 @@ func (s *Stash) StatusBarInfo() string {
86 		}
87 		return fmt.Sprintf("p. %d/%d", s.list.Page()+1, totalPages)
88 	case stashStatePatch:
89-		return fmt.Sprintf("☰ %d%%", s.code.ScrollPosition())
90+		return common.ScrollPercent(s.code.ScrollPosition())
91 	default:
92 		return ""
93 	}