From 9871df2e94a011ae6071ade9913ececf82f9f132 Mon Sep 17 00:00:00 2001 From: Ayman Bagabas Date: Mon, 18 Nov 2024 09:52:19 -0500 Subject: [PATCH] refactor: use the latest v2 packages --- cmd/soft/browse/browse.go | 27 ++-- cmd/soft/main.go | 4 +- go.mod | 32 +++-- go.sum | 52 ++++--- pkg/ssh/cmd/blob.go | 5 +- pkg/ssh/cmd/commit.go | 5 +- pkg/ssh/cmd/repo.go | 7 +- pkg/ssh/middleware.go | 13 +- pkg/ssh/session.go | 26 ++-- pkg/ssh/ssh.go | 9 +- pkg/ssh/ui.go | 25 ++-- pkg/ui/common/common.go | 22 ++- pkg/ui/common/component.go | 5 +- pkg/ui/common/error.go | 2 +- pkg/ui/common/style.go | 5 +- pkg/ui/components/code/code.go | 28 +--- pkg/ui/components/footer/footer.go | 8 +- pkg/ui/components/header/header.go | 2 +- pkg/ui/components/selector/selector.go | 46 +++---- pkg/ui/components/statusbar/statusbar.go | 10 +- pkg/ui/components/tabs/tabs.go | 25 ++-- pkg/ui/components/viewport/viewport.go | 34 ++--- pkg/ui/keymap/keymap.go | 2 +- pkg/ui/pages/repo/files.go | 6 +- pkg/ui/pages/repo/filesitem.go | 10 +- pkg/ui/pages/repo/log.go | 8 +- pkg/ui/pages/repo/logitem.go | 8 +- pkg/ui/pages/repo/readme.go | 6 +- pkg/ui/pages/repo/refs.go | 6 +- pkg/ui/pages/repo/refsitem.go | 8 +- pkg/ui/pages/repo/repo.go | 54 ++++---- pkg/ui/pages/repo/stash.go | 8 +- pkg/ui/pages/repo/stashitem.go | 6 +- pkg/ui/pages/selection/item.go | 14 +- pkg/ui/pages/selection/selection.go | 16 +-- pkg/ui/styles/styles.go | 168 ++++++++++++----------- 36 files changed, 328 insertions(+), 384 deletions(-) diff --git a/cmd/soft/browse/browse.go b/cmd/soft/browse/browse.go index eebf28893885e9844dccd6787f03e613c67e8ffd..10fd15d19f4964e1d6184fb055933561949035ba 100644 --- a/cmd/soft/browse/browse.go +++ b/cmd/soft/browse/browse.go @@ -5,9 +5,9 @@ import ( "path/filepath" "time" - "github.com/charmbracelet/bubbles/key" - tea "github.com/charmbracelet/bubbletea" - "github.com/charmbracelet/lipgloss" + "github.com/charmbracelet/bubbles/v2/key" + tea "github.com/charmbracelet/bubbletea/v2" + "github.com/charmbracelet/lipgloss/v2" "github.com/charmbracelet/soft-serve/git" "github.com/charmbracelet/soft-serve/pkg/proto" "github.com/charmbracelet/soft-serve/pkg/ui/common" @@ -39,9 +39,8 @@ var Command = &cobra.Command{ // Bubble Tea uses Termenv default output so we have to use the same // thing here. - output := lipgloss.DefaultRenderer() ctx := cmd.Context() - c := common.NewCommon(ctx, output, 0, 0) + c := common.NewCommon(ctx, 0, 0) c.HideCloneCmd = true comps := []common.TabComponent{ repo.NewReadme(c), @@ -166,16 +165,14 @@ func (m *model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { m.common.Zone.Close() return m, tea.Quit } - case tea.MouseMsg: - if msg.Action != tea.MouseActionPress { - break - } - switch msg.Button { - case tea.MouseButtonLeft: - switch { - case m.common.Zone.Get("footer").InBounds(msg): - cmds = append(cmds, footer.ToggleFooterCmd) - } + case tea.MouseClickMsg: + mouse := msg.Mouse() + switch mouse.Button { + case tea.MouseLeft: + // 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/cmd/soft/main.go b/cmd/soft/main.go index 9849e8a268f22fba46644af33b1ee140f79f16a2..1abf8c2f8572476f0b0dd07deb8576f4395188b2 100644 --- a/cmd/soft/main.go +++ b/cmd/soft/main.go @@ -7,6 +7,7 @@ import ( "runtime/debug" "strconv" + "github.com/charmbracelet/colorprofile" "github.com/charmbracelet/log" "github.com/charmbracelet/soft-serve/cmd/soft/admin" "github.com/charmbracelet/soft-serve/cmd/soft/browse" @@ -18,7 +19,6 @@ import ( "github.com/charmbracelet/soft-serve/pkg/version" mcobra "github.com/muesli/mango-cobra" "github.com/muesli/roff" - "github.com/muesli/termenv" "github.com/spf13/cobra" "go.uber.org/automaxprocs/maxprocs" ) @@ -67,7 +67,7 @@ var ( func init() { if noColor, _ := strconv.ParseBool(os.Getenv("SOFT_SERVE_NO_COLOR")); noColor { - common.DefaultColorProfile = termenv.Ascii + common.DefaultColorProfile = colorprofile.NoTTY } rootCmd.AddCommand( diff --git a/go.mod b/go.mod index 7390c6b3a6879c4cf46901d2c7cd42939ae57039..f9b88720be7645aeeb57209a25e1338ea633ac9a 100644 --- a/go.mod +++ b/go.mod @@ -2,11 +2,8 @@ module github.com/charmbracelet/soft-serve go 1.23.0 -toolchain go1.24.1 - require ( - github.com/charmbracelet/bubbles v0.20.0 - github.com/charmbracelet/bubbletea v1.3.4 + github.com/charmbracelet/bubbletea v1.3.4 // indirect github.com/charmbracelet/glamour v0.9.1 github.com/charmbracelet/lipgloss v1.1.0 github.com/charmbracelet/wish v1.4.6 @@ -22,12 +19,18 @@ require ( github.com/alecthomas/chroma/v2 v2.15.0 github.com/aymanbagabas/git-module v1.8.4-0.20231101154130-8d27204ac6d2 github.com/caarlos0/duration v0.0.0-20240108180406-5d492514f3c7 - github.com/caarlos0/env/v11 v11.3.1 + github.com/caarlos0/env/v11 v11.2.2 + github.com/charmbracelet/bubbles/v2 v2.0.0-alpha.2.0.20250318132216-bd20b89a3e80 + github.com/charmbracelet/bubbletea/v2 v2.0.0-alpha.2.0.20250318133619-2ce107c85fed + github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc github.com/charmbracelet/git-lfs-transfer v0.1.1-0.20240708204110-bacbfdb68d92 - github.com/charmbracelet/keygen v0.5.3 - github.com/charmbracelet/log v0.4.1 - github.com/charmbracelet/ssh v0.0.0-20250213143314-8712ec3ff3ef - github.com/go-jose/go-jose/v3 v3.0.4 + github.com/charmbracelet/keygen v0.5.1 + github.com/charmbracelet/lipgloss/v2 v2.0.0-alpha.2.0.20250313133401-58331b1fff40 + github.com/charmbracelet/log v0.4.1-0.20241101171137-e66b83d34ed9 + github.com/charmbracelet/ssh v0.0.0-20250128164007-98fd5ae11894 + github.com/charmbracelet/wish/v2 v2.0.0-20250319172925-3ae4bfe9c24e + github.com/charmbracelet/x/ansi v0.8.0 + github.com/go-jose/go-jose/v3 v3.0.3 github.com/gobwas/glob v0.2.3 github.com/golang-jwt/jwt/v5 v5.2.1 github.com/google/go-querystring v1.1.0 @@ -45,7 +48,7 @@ require ( github.com/rogpeppe/go-internal v1.14.1 github.com/spf13/cobra v1.9.1 go.uber.org/automaxprocs v1.6.0 - golang.org/x/crypto v0.36.0 + golang.org/x/crypto v0.35.0 golang.org/x/sync v0.12.0 gopkg.in/yaml.v3 v3.0.1 modernc.org/sqlite v1.36.1 @@ -58,12 +61,11 @@ require ( github.com/aymerick/douceur v0.2.0 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect - github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc // indirect - github.com/charmbracelet/x/ansi v0.8.0 // indirect - github.com/charmbracelet/x/cellbuf v0.0.13-0.20250311204145-2c3ea96c31dd // indirect + github.com/charmbracelet/log/v2 v2.0.0-20250226163916-c379e29ff706 // indirect + github.com/charmbracelet/x/cellbuf v0.0.13 // indirect github.com/charmbracelet/x/conpty v0.1.0 // indirect github.com/charmbracelet/x/errors v0.0.0-20240725160154-f9f6568126ec // indirect - github.com/charmbracelet/x/input v0.3.1 // indirect + github.com/charmbracelet/x/input v0.3.4 // indirect github.com/charmbracelet/x/term v0.2.1 // indirect github.com/charmbracelet/x/termios v0.1.0 // indirect github.com/charmbracelet/x/windows v0.2.0 // indirect @@ -100,7 +102,7 @@ require ( github.com/yuin/goldmark v1.7.8 // indirect github.com/yuin/goldmark-emoji v1.0.5 // indirect golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect - golang.org/x/net v0.36.0 // indirect + golang.org/x/net v0.35.0 // indirect golang.org/x/sys v0.31.0 // indirect golang.org/x/term v0.30.0 // indirect golang.org/x/text v0.23.0 // indirect diff --git a/go.sum b/go.sum index 0dd0ca32a23b86e764e8fe5a9fc89367e92e5e44..637ac4dc47b78ce32a54134bf35278415a3a6970 100644 --- a/go.sum +++ b/go.sum @@ -22,42 +22,50 @@ github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/caarlos0/duration v0.0.0-20240108180406-5d492514f3c7 h1:kJP/C2eL9DCKrCOlX6lPVmAUAb6U4u9xllgws1kP9ds= github.com/caarlos0/duration v0.0.0-20240108180406-5d492514f3c7/go.mod h1:mSkwb/eZEwOJJJ4tqAKiuhLIPe0e9+FKhlU0oMCpbf8= -github.com/caarlos0/env/v11 v11.3.1 h1:cArPWC15hWmEt+gWk7YBi7lEXTXCvpaSdCiZE2X5mCA= -github.com/caarlos0/env/v11 v11.3.1/go.mod h1:qupehSf/Y0TUTsxKywqRt/vJjN5nz6vauiYEUUr8P4U= +github.com/caarlos0/env/v11 v11.2.2 h1:95fApNrUyueipoZN/EhA8mMxiNxrBwDa+oAZrMWl3Kg= +github.com/caarlos0/env/v11 v11.2.2/go.mod h1:JBfcdeQiBoI3Zh1QRAWfe+tpiNTmDtcCj/hHHHMx0vc= github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/charmbracelet/bubbles v0.20.0 h1:jSZu6qD8cRQ6k9OMfR1WlM+ruM8fkPWkHvQWD9LIutE= -github.com/charmbracelet/bubbles v0.20.0/go.mod h1:39slydyswPy+uVOHZ5x/GjwVAFkCsV8IIVy+4MhzwwU= +github.com/charmbracelet/bubbles/v2 v2.0.0-alpha.2.0.20250318132216-bd20b89a3e80 h1:RlfUmUVZpshOB7YP4sdnIymgXb6tXhHeQ2854afgKoU= +github.com/charmbracelet/bubbles/v2 v2.0.0-alpha.2.0.20250318132216-bd20b89a3e80/go.mod h1:OQsv1nZAu5v8GtZqNTqS4yY5mfR0VgImkpe2F0QYEfs= github.com/charmbracelet/bubbletea v1.3.4 h1:kCg7B+jSCFPLYRA52SDZjr51kG/fMUEoPoZrkaDHyoI= github.com/charmbracelet/bubbletea v1.3.4/go.mod h1:dtcUCyCGEX3g9tosuYiut3MXgY/Jsv9nKVdibKKRRXo= +github.com/charmbracelet/bubbletea/v2 v2.0.0-alpha.2.0.20250318133619-2ce107c85fed h1:Fsn31oc6fmX7YgfZ1Am+19HVorJ8Bf6wJTebVNLcQP0= +github.com/charmbracelet/bubbletea/v2 v2.0.0-alpha.2.0.20250318133619-2ce107c85fed/go.mod h1:ks5r0VCpADtYFlNU15krnFIbMn545yV3U6ee6UJrlto= github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc h1:4pZI35227imm7yK2bGPcfpFEmuY1gc2YSTShr4iJBfs= github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc/go.mod h1:X4/0JoqgTIPSFcRA/P6INZzIuyqdFY5rm8tb41s9okk= github.com/charmbracelet/git-lfs-transfer v0.1.1-0.20240708204110-bacbfdb68d92 h1:KtQlsiHfY3K4AoIEh0yUE/wCLHteZ9EzV1hKmx+p7U8= github.com/charmbracelet/git-lfs-transfer v0.1.1-0.20240708204110-bacbfdb68d92/go.mod h1:UrXUCm3xLQkq15fu7qlXHUMlrhdlXHoi13KH2Dfiits= github.com/charmbracelet/glamour v0.9.1 h1:Q7PdJLOx8EoepsXUvW6Puz5WQ3YUElIGQdYKrIpiGLA= github.com/charmbracelet/glamour v0.9.1/go.mod h1:+SHvIS8qnwhgTpVMiXwn7OfGomSqff1cHBCI8jLOetk= -github.com/charmbracelet/keygen v0.5.3 h1:2MSDC62OUbDy6VmjIE2jM24LuXUvKywLCmaJDmr/Z/4= -github.com/charmbracelet/keygen v0.5.3/go.mod h1:TcpNoMAO5GSmhx3SgcEMqCrtn8BahKhB8AlwnLjRUpk= +github.com/charmbracelet/keygen v0.5.1 h1:zBkkYPtmKDVTw+cwUyY6ZwGDhRxXkEp0Oxs9sqMLqxI= +github.com/charmbracelet/keygen v0.5.1/go.mod h1:zznJVmK/GWB6dAtjluqn2qsttiCBhA5MZSiwb80fcHw= github.com/charmbracelet/lipgloss v1.1.0 h1:vYXsiLHVkK7fp74RkV7b2kq9+zDLoEU4MZoFqR/noCY= github.com/charmbracelet/lipgloss v1.1.0/go.mod h1:/6Q8FR2o+kj8rz4Dq0zQc3vYf7X+B0binUUBwA0aL30= -github.com/charmbracelet/log v0.4.1 h1:6AYnoHKADkghm/vt4neaNEXkxcXLSV2g1rdyFDOpTyk= -github.com/charmbracelet/log v0.4.1/go.mod h1:pXgyTsqsVu4N9hGdHmQ0xEA4RsXof402LX9ZgiITn2I= -github.com/charmbracelet/ssh v0.0.0-20250213143314-8712ec3ff3ef h1:dNZwn4is5svUd+sQEGsrXtp7VwD2ipYaCkKMzcpAEIE= -github.com/charmbracelet/ssh v0.0.0-20250213143314-8712ec3ff3ef/go.mod h1:hg+I6gvlMl16nS9ZzQNgBIrrCasGwEw0QiLsDcP01Ko= +github.com/charmbracelet/lipgloss/v2 v2.0.0-alpha.2.0.20250313133401-58331b1fff40 h1:9IxBdCOOJoJ1PYXgxWXJCk3Fkl7h2n+b7VtY+5BbIuQ= +github.com/charmbracelet/lipgloss/v2 v2.0.0-alpha.2.0.20250313133401-58331b1fff40/go.mod h1:XhU7tcZRWVGzkjWQ6XYRH7tIVqYuWLx6XLjVqAz+7FU= +github.com/charmbracelet/log v0.4.1-0.20241101171137-e66b83d34ed9 h1:m72jc7WwobapT4NLVVAjejNsz26f2UQ2Mz74uTq/Tro= +github.com/charmbracelet/log v0.4.1-0.20241101171137-e66b83d34ed9/go.mod h1:soIjG88SDQxYFpbhYXbrDTPbd/07bfo66OjADdnY5HE= +github.com/charmbracelet/log/v2 v2.0.0-20250226163916-c379e29ff706 h1:WkwO6Ks3mSIGnGuSdKl9qDSyfbYK50z2wc2gGMggegE= +github.com/charmbracelet/log/v2 v2.0.0-20250226163916-c379e29ff706/go.mod h1:mjJGp00cxcfvD5xdCa+bso251Jt4owrQvuimJtVmEmM= +github.com/charmbracelet/ssh v0.0.0-20250128164007-98fd5ae11894 h1:Ffon9TbltLGBsT6XE//YvNuu4OAaThXioqalhH11xEw= +github.com/charmbracelet/ssh v0.0.0-20250128164007-98fd5ae11894/go.mod h1:hg+I6gvlMl16nS9ZzQNgBIrrCasGwEw0QiLsDcP01Ko= github.com/charmbracelet/wish v1.4.6 h1:27WRqMTUmyFoZASoaAaEe78Je7LTU4VqyoBxnl4d9XA= github.com/charmbracelet/wish v1.4.6/go.mod h1:RRy2LFW3WQ3tlPmMMGgEeSMDVlFd5yqklGBVZWQSHmk= +github.com/charmbracelet/wish/v2 v2.0.0-20250319172925-3ae4bfe9c24e h1:WjrZFTFMjmm9dyc+KzXpY8z2viWdwShU6Qqqu3ixAss= +github.com/charmbracelet/wish/v2 v2.0.0-20250319172925-3ae4bfe9c24e/go.mod h1:olUvE0hW+a8zFU1vNvlEm6PJS+ElY1V5pcaV5pjzaGI= github.com/charmbracelet/x/ansi v0.8.0 h1:9GTq3xq9caJW8ZrBTe0LIe2fvfLR/bYXKTx2llXn7xE= github.com/charmbracelet/x/ansi v0.8.0/go.mod h1:wdYl/ONOLHLIVmQaxbIYEC/cRKOQyjTkowiI4blgS9Q= -github.com/charmbracelet/x/cellbuf v0.0.13-0.20250311204145-2c3ea96c31dd h1:vy0GVL4jeHEwG5YOXDmi86oYw2yuYUGqz6a8sLwg0X8= -github.com/charmbracelet/x/cellbuf v0.0.13-0.20250311204145-2c3ea96c31dd/go.mod h1:xe0nKWGd3eJgtqZRaN9RjMtK7xUYchjzPr7q6kcvCCs= +github.com/charmbracelet/x/cellbuf v0.0.13 h1:/KBBKHuVRbq1lYx5BzEHBAFBP8VcQzJejZ/IA3iR28k= +github.com/charmbracelet/x/cellbuf v0.0.13/go.mod h1:xe0nKWGd3eJgtqZRaN9RjMtK7xUYchjzPr7q6kcvCCs= github.com/charmbracelet/x/conpty v0.1.0 h1:4zc8KaIcbiL4mghEON8D72agYtSeIgq8FSThSPQIb+U= github.com/charmbracelet/x/conpty v0.1.0/go.mod h1:rMFsDJoDwVmiYM10aD4bH2XiRgwI7NYJtQgl5yskjEQ= github.com/charmbracelet/x/errors v0.0.0-20240725160154-f9f6568126ec h1:O8c7pFFK0imuHH5JBqv5smlbVoFn4CZKGjtvCQKu1WE= github.com/charmbracelet/x/errors v0.0.0-20240725160154-f9f6568126ec/go.mod h1:2P0UgXMEa6TsToMSuFqKFQR+fZTO9CNGUNokkPatT/0= -github.com/charmbracelet/x/exp/golden v0.0.0-20240815200342-61de596daa2b h1:MnAMdlwSltxJyULnrYbkZpp4k58Co7Tah3ciKhSNo0Q= -github.com/charmbracelet/x/exp/golden v0.0.0-20240815200342-61de596daa2b/go.mod h1:wDlXFlCrmJ8J+swcL/MnGUuYnqgQdW9rhSD61oNMb6U= -github.com/charmbracelet/x/input v0.3.1 h1:TE4s3fTRj+OUpJ86dKphrN99+NgBnto//EkWncMJQIg= -github.com/charmbracelet/x/input v0.3.1/go.mod h1:4w9jS/NW62WrHSdmjbpzydvnbqkd+mtyK8WOWbHCdvs= +github.com/charmbracelet/x/exp/golden v0.0.0-20250207160936-21c02780d27a h1:FsHEJ52OC4VuTzU8t+n5frMjLvpYWEznSr/u8tnkCYw= +github.com/charmbracelet/x/exp/golden v0.0.0-20250207160936-21c02780d27a/go.mod h1:wDlXFlCrmJ8J+swcL/MnGUuYnqgQdW9rhSD61oNMb6U= +github.com/charmbracelet/x/input v0.3.4 h1:Mujmnv/4DaitU0p+kIsrlfZl/UlmeLKw1wAP3e1fMN0= +github.com/charmbracelet/x/input v0.3.4/go.mod h1:JI8RcvdZWQIhn09VzeK3hdp4lTz7+yhiEdpEQtZN+2c= github.com/charmbracelet/x/term v0.2.1 h1:AQeHeLZ1OqSXhrAWpYUtZyX1T3zVxfpZuEQMIQaGIAQ= github.com/charmbracelet/x/term v0.2.1/go.mod h1:oQ4enTYFV7QN4m0i9mzHrViD7TQKvNEEkHUMCmsxdUg= github.com/charmbracelet/x/termios v0.1.0 h1:y4rjAHeFksBAfGbkRDmVinMg7x7DELIGAFbdNvxg97k= @@ -84,8 +92,8 @@ github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66D github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376/go.mod h1:an3vInlBmSxCcxctByoQdvwPiA7DTK7jaaFDBTtu0ic= github.com/go-git/go-git/v5 v5.14.0 h1:/MD3lCrGjCen5WfEAzKg00MJJffKhC8gzS80ycmCi60= github.com/go-git/go-git/v5 v5.14.0/go.mod h1:Z5Xhoia5PcWA3NF8vRLURn9E5FRhSl7dGj9ItW3Wk5k= -github.com/go-jose/go-jose/v3 v3.0.4 h1:Wp5HA7bLQcKnf6YYao/4kpRpVMp/yf6+pJKV8WFSaNY= -github.com/go-jose/go-jose/v3 v3.0.4/go.mod h1:5b+7YgP7ZICgJDBdfjZaIt+H/9L9T/YQrVfLAMboGkQ= +github.com/go-jose/go-jose/v3 v3.0.3 h1:fFKWeig/irsp7XD2zBxvnmA/XaRWp5V3CBsZXJF7G7k= +github.com/go-jose/go-jose/v3 v3.0.3/go.mod h1:5b+7YgP7ZICgJDBdfjZaIt+H/9L9T/YQrVfLAMboGkQ= github.com/go-logfmt/logfmt v0.6.0 h1:wGYYu3uicYdqXVgoYbvnkrPVXkuLM1p1ifugDMEdRi4= github.com/go-logfmt/logfmt v0.6.0/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= github.com/go-sql-driver/mysql v1.8.1 h1:LedoTUt/eveggdHS9qUFC1EFSa8bU2+1pZjSRpvNJ1Y= @@ -228,8 +236,8 @@ go.uber.org/automaxprocs v1.6.0/go.mod h1:ifeIMSnPZuznNm6jmdzmU3/bfk01Fe2fotchwE golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= -golang.org/x/crypto v0.36.0 h1:AnAEvhDddvBdpY+uR+MyHmuZzzNqXSe/GvuDeob5L34= -golang.org/x/crypto v0.36.0/go.mod h1:Y4J0ReaxCR1IMaabaSMugxJES1EpwhBHhv2bDHklZvc= +golang.org/x/crypto v0.35.0 h1:b15kiHdrGCHrP6LvwaQ3c03kgNhhiMgvlhxHQhmg2Xs= +golang.org/x/crypto v0.35.0/go.mod h1:dy7dXNW32cAb/6/PRuTNsix8T+vJAqvuIy5Bli/x0YQ= golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 h1:2dVuKD2vS7b0QIHQbpyTISPd0LeHDbnYEryqj5Q1ug8= golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56/go.mod h1:M4RDyNAINzryxdtnbRXRL/OHtkFuWGRjvuhBJpk2IlY= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= @@ -241,8 +249,8 @@ golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= -golang.org/x/net v0.36.0 h1:vWF2fRbw4qslQsQzgFqZff+BItCvGFQqKzKIzx1rmoA= -golang.org/x/net v0.36.0/go.mod h1:bFmbeoIPfrw4sMHNhb4J9f6+tPziuGjq7Jk/38fxi1I= +golang.org/x/net v0.35.0 h1:T5GQRQb2y08kTAByq9L4/bz8cipCdA8FbRTXewonqY8= +golang.org/x/net v0.35.0/go.mod h1:EglIi67kWsHKlRzzVMUD93VMSWGFOMSZgxFjparz1Qk= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= diff --git a/pkg/ssh/cmd/blob.go b/pkg/ssh/cmd/blob.go index 9678a37a49ce426f3e6a910c04a7f804159d95ee..45e0affb2ad7c0cc9b9a82efecf0fc8e177e63d7 100644 --- a/pkg/ssh/cmd/blob.go +++ b/pkg/ssh/cmd/blob.go @@ -3,7 +3,6 @@ package cmd import ( "fmt" - "github.com/charmbracelet/lipgloss" "github.com/charmbracelet/soft-serve/git" "github.com/charmbracelet/soft-serve/pkg/backend" "github.com/charmbracelet/soft-serve/pkg/ui/common" @@ -12,12 +11,12 @@ import ( ) // blobCommand returns a command that prints the contents of a file. -func blobCommand(renderer *lipgloss.Renderer) *cobra.Command { +func blobCommand() *cobra.Command { var linenumber bool var color bool var raw bool - styles := styles.DefaultStyles(renderer) + styles := styles.DefaultStyles() cmd := &cobra.Command{ Use: "blob REPOSITORY [REFERENCE] [PATH]", Aliases: []string{"cat", "show"}, diff --git a/pkg/ssh/cmd/commit.go b/pkg/ssh/cmd/commit.go index 52af6725a53692f7310a75cc6efbce33d0c8492b..4f91b2fed9ef2ca334d266ee4c43b8770ac73a06 100644 --- a/pkg/ssh/cmd/commit.go +++ b/pkg/ssh/cmd/commit.go @@ -6,7 +6,6 @@ import ( "time" gansi "github.com/charmbracelet/glamour/ansi" - "github.com/charmbracelet/lipgloss" "github.com/charmbracelet/soft-serve/git" "github.com/charmbracelet/soft-serve/pkg/backend" "github.com/charmbracelet/soft-serve/pkg/ui/common" @@ -15,7 +14,7 @@ import ( ) // commitCommand returns a command that prints the contents of a commit. -func commitCommand(renderer *lipgloss.Renderer) *cobra.Command { +func commitCommand() *cobra.Command { var color bool var patchOnly bool @@ -55,7 +54,7 @@ func commitCommand(renderer *lipgloss.Renderer) *cobra.Command { return err } - commonStyle := styles.DefaultStyles(renderer) + commonStyle := styles.DefaultStyles() style := commonStyle.Log s := strings.Builder{} diff --git a/pkg/ssh/cmd/repo.go b/pkg/ssh/cmd/repo.go index 6a2bb541e62e5ac97da0516bb28440a91ccfbe19..fa3e72ff9a3098b40314acbca119c86628f9850c 100644 --- a/pkg/ssh/cmd/repo.go +++ b/pkg/ssh/cmd/repo.go @@ -4,14 +4,13 @@ import ( "fmt" "strings" - "github.com/charmbracelet/lipgloss" "github.com/charmbracelet/soft-serve/pkg/backend" "github.com/charmbracelet/soft-serve/pkg/proto" "github.com/spf13/cobra" ) // RepoCommand returns a command for managing repositories. -func RepoCommand(renderer *lipgloss.Renderer) *cobra.Command { +func RepoCommand() *cobra.Command { cmd := &cobra.Command{ Use: "repo", Aliases: []string{"repos", "repository", "repositories"}, @@ -19,10 +18,10 @@ func RepoCommand(renderer *lipgloss.Renderer) *cobra.Command { } cmd.AddCommand( - blobCommand(renderer), + blobCommand(), branchCommand(), collabCommand(), - commitCommand(renderer), + commitCommand(), createCommand(), deleteCommand(), descriptionCommand(), diff --git a/pkg/ssh/middleware.go b/pkg/ssh/middleware.go index 1bd93f99c0c81122f18c956056fa07cebaedee96..0bfb4c483a9bd5dfeadc23686841f0343a3e6110 100644 --- a/pkg/ssh/middleware.go +++ b/pkg/ssh/middleware.go @@ -2,7 +2,6 @@ package ssh import ( "fmt" - "os" "time" "github.com/charmbracelet/log" @@ -14,9 +13,7 @@ import ( "github.com/charmbracelet/soft-serve/pkg/sshutils" "github.com/charmbracelet/soft-serve/pkg/store" "github.com/charmbracelet/ssh" - "github.com/charmbracelet/wish" - bm "github.com/charmbracelet/wish/bubbletea" - "github.com/muesli/termenv" + "github.com/charmbracelet/wish/v2" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promauto" "github.com/spf13/cobra" @@ -91,12 +88,6 @@ func CommandMiddleware(sh ssh.Handler) ssh.Handler { ctx := s.Context() cfg := config.FromContext(ctx) - renderer := bm.MakeRenderer(s) - if testrun, ok := os.LookupEnv("SOFT_SERVE_NO_COLOR"); ok && testrun == "1" { - // Disable colors when running tests. - renderer.SetColorProfile(termenv.Ascii) - } - args := s.Command() cliCommandCounter.WithLabelValues(cmd.CommandName(args)).Inc() rootCmd := &cobra.Command{ @@ -111,7 +102,7 @@ func CommandMiddleware(sh ssh.Handler) ssh.Handler { cmd.GitUploadPackCommand(), cmd.GitUploadArchiveCommand(), cmd.GitReceivePackCommand(), - cmd.RepoCommand(renderer), + cmd.RepoCommand(), cmd.SettingsCommand(), cmd.UserCommand(), cmd.InfoCommand(), diff --git a/pkg/ssh/session.go b/pkg/ssh/session.go index aecd4619511e977c7367d069d2900fb4b5d1a3f1..067acb4286c9eb1526d6245192abe4b1f9c981ed 100644 --- a/pkg/ssh/session.go +++ b/pkg/ssh/session.go @@ -4,16 +4,16 @@ import ( "os" "time" - tea "github.com/charmbracelet/bubbletea" + tea "github.com/charmbracelet/bubbletea/v2" + "github.com/charmbracelet/colorprofile" "github.com/charmbracelet/soft-serve/pkg/access" "github.com/charmbracelet/soft-serve/pkg/backend" "github.com/charmbracelet/soft-serve/pkg/config" "github.com/charmbracelet/soft-serve/pkg/proto" "github.com/charmbracelet/soft-serve/pkg/ui/common" "github.com/charmbracelet/ssh" - "github.com/charmbracelet/wish" - bm "github.com/charmbracelet/wish/bubbletea" - "github.com/muesli/termenv" + "github.com/charmbracelet/wish/v2" + bm "github.com/charmbracelet/wish/v2/bubbletea" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promauto" ) @@ -54,15 +54,6 @@ func SessionHandler(s ssh.Session) *tea.Program { } } - renderer := bm.MakeRenderer(s) - if testrun, ok := os.LookupEnv("SOFT_SERVE_NO_COLOR"); ok && testrun == "1" { - // Disable colors when running tests. - renderer.SetColorProfile(termenv.Ascii) - } - - c := common.NewCommon(ctx, renderer, pty.Window.Width, pty.Window.Height) - c.SetValue(common.ConfigKey, cfg) - m := NewUI(c, initialRepo) opts := bm.MakeOptions(s) opts = append(opts, tea.WithAltScreen(), @@ -70,6 +61,15 @@ func SessionHandler(s ssh.Session) *tea.Program { tea.WithMouseCellMotion(), tea.WithContext(ctx), ) + + if testrun, ok := os.LookupEnv("SOFT_SERVE_NO_COLOR"); ok && testrun == "1" { + // Disable colors when running tests. + opts = append(opts, tea.WithColorProfile(colorprofile.NoTTY)) + } + + c := common.NewCommon(ctx, pty.Window.Width, pty.Window.Height) + c.SetValue(common.ConfigKey, cfg) + m := NewUI(c, initialRepo) p := tea.NewProgram(m, opts...) tuiSessionCounter.WithLabelValues(initialRepo, pty.Term).Inc() diff --git a/pkg/ssh/ssh.go b/pkg/ssh/ssh.go index f63b0d3897f53b95af494a99ee0a4dc00d872ddf..6ce1f7d113a8066db3c6960a0fb4ea2de37a570f 100644 --- a/pkg/ssh/ssh.go +++ b/pkg/ssh/ssh.go @@ -16,11 +16,10 @@ import ( "github.com/charmbracelet/soft-serve/pkg/db" "github.com/charmbracelet/soft-serve/pkg/proto" "github.com/charmbracelet/soft-serve/pkg/store" - "github.com/charmbracelet/soft-serve/pkg/ui/common" "github.com/charmbracelet/ssh" - "github.com/charmbracelet/wish" - bm "github.com/charmbracelet/wish/bubbletea" - rm "github.com/charmbracelet/wish/recover" + "github.com/charmbracelet/wish/v2" + bm "github.com/charmbracelet/wish/v2/bubbletea" + rm "github.com/charmbracelet/wish/v2/recover" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promauto" gossh "golang.org/x/crypto/ssh" @@ -71,7 +70,7 @@ func NewSSHServer(ctx context.Context) (*SSHServer, error) { rm.MiddlewareWithLogger( logger, // BubbleTea middleware. - bm.MiddlewareWithProgramHandler(SessionHandler, common.DefaultColorProfile), + bm.MiddlewareWithProgramHandler(SessionHandler), // CLI middleware. CommandMiddleware, // Logging middleware. diff --git a/pkg/ssh/ui.go b/pkg/ssh/ui.go index 31f6a259cc2e677ac6b90ca2667c5ffee105cde4..f58c00398a0ffb4e7ad1f4ae3291093aa475dd9d 100644 --- a/pkg/ssh/ui.go +++ b/pkg/ssh/ui.go @@ -3,10 +3,10 @@ package ssh import ( "errors" - "github.com/charmbracelet/bubbles/key" - "github.com/charmbracelet/bubbles/list" - tea "github.com/charmbracelet/bubbletea" - "github.com/charmbracelet/lipgloss" + "github.com/charmbracelet/bubbles/v2/key" + "github.com/charmbracelet/bubbles/v2/list" + tea "github.com/charmbracelet/bubbletea/v2" + "github.com/charmbracelet/lipgloss/v2" "github.com/charmbracelet/soft-serve/git" "github.com/charmbracelet/soft-serve/pkg/proto" "github.com/charmbracelet/soft-serve/pkg/ui/common" @@ -203,16 +203,13 @@ func (ui *UI) Update(msg tea.Msg) (tea.Model, tea.Cmd) { // Always show the footer on selection page. ui.showFooter = true } - case tea.MouseMsg: - if msg.Action != tea.MouseActionPress { - break - } - switch msg.Button { - case tea.MouseButtonLeft: - switch { - case ui.common.Zone.Get("footer").InBounds(msg): - cmds = append(cmds, footer.ToggleFooterCmd) - } + case tea.MouseClickMsg: + switch msg.Mouse().Button { + case tea.MouseLeft: + // 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 93d40f57328aa1d191dc5115e12b16f1f86d0c9d..df16d027c1042c3061b19fe89b655aa3cedf3081 100644 --- a/pkg/ui/common/common.go +++ b/pkg/ui/common/common.go @@ -5,7 +5,6 @@ import ( "fmt" "github.com/alecthomas/chroma/v2/lexers" - "github.com/charmbracelet/lipgloss" "github.com/charmbracelet/log" "github.com/charmbracelet/soft-serve/git" "github.com/charmbracelet/soft-serve/pkg/backend" @@ -14,7 +13,6 @@ import ( "github.com/charmbracelet/soft-serve/pkg/ui/styles" "github.com/charmbracelet/ssh" zone "github.com/lrstanley/bubblezone" - "github.com/muesli/termenv" ) type contextKey struct { @@ -34,27 +32,23 @@ type Common struct { Styles *styles.Styles KeyMap *keymap.KeyMap Zone *zone.Manager - Renderer *lipgloss.Renderer - Output *termenv.Output Logger *log.Logger HideCloneCmd bool } // NewCommon returns a new Common struct. -func NewCommon(ctx context.Context, out *lipgloss.Renderer, width, height int) Common { +func NewCommon(ctx context.Context, width, height int) Common { if ctx == nil { ctx = context.TODO() } return Common{ - ctx: ctx, - Width: width, - Height: height, - Renderer: out, - Output: out.Output(), - Styles: styles.DefaultStyles(out), - KeyMap: keymap.DefaultKeyMap(), - Zone: zone.New(), - Logger: log.FromContext(ctx).WithPrefix("ui"), + ctx: ctx, + Width: width, + Height: height, + Styles: styles.DefaultStyles(), + KeyMap: keymap.DefaultKeyMap(), + Zone: zone.New(), + Logger: log.FromContext(ctx).WithPrefix("ui"), } } diff --git a/pkg/ui/common/component.go b/pkg/ui/common/component.go index 6fe7761f9b9c85cabae967b5246d361cb811d363..4b152a4ba81080af791446601d06133847d80102 100644 --- a/pkg/ui/common/component.go +++ b/pkg/ui/common/component.go @@ -1,13 +1,14 @@ package common import ( - "github.com/charmbracelet/bubbles/help" - tea "github.com/charmbracelet/bubbletea" + "github.com/charmbracelet/bubbles/v2/help" + tea "github.com/charmbracelet/bubbletea/v2" ) // Component represents a Bubble Tea model that implements a SetSize function. type Component interface { tea.Model + tea.ViewModel help.KeyMap SetSize(width, height int) } diff --git a/pkg/ui/common/error.go b/pkg/ui/common/error.go index 753f5f26f77fc778157c2dc5d3c7b06440a29b8e..926df1d9ac7610b2a34648290e62c28a7d9d9629 100644 --- a/pkg/ui/common/error.go +++ b/pkg/ui/common/error.go @@ -3,7 +3,7 @@ package common import ( "errors" - tea "github.com/charmbracelet/bubbletea" + tea "github.com/charmbracelet/bubbletea/v2" ) // ErrMissingRepo indicates that the requested repository could not be found. diff --git a/pkg/ui/common/style.go b/pkg/ui/common/style.go index 06d7ce3d2c9e4b61f2dd827051dd351f4bdca861..62239d0a5c9a122679362e17f6942b834eec4690 100644 --- a/pkg/ui/common/style.go +++ b/pkg/ui/common/style.go @@ -1,13 +1,14 @@ package common import ( + "github.com/charmbracelet/colorprofile" gansi "github.com/charmbracelet/glamour/ansi" "github.com/charmbracelet/glamour/styles" "github.com/muesli/termenv" ) // DefaultColorProfile is the default color profile used by the SSH server. -var DefaultColorProfile = termenv.ANSI256 +var DefaultColorProfile = colorprofile.ANSI256 func strptr(s string) *string { return &s @@ -39,7 +40,7 @@ func StyleRenderer() gansi.RenderContext { // DefaultColorProfile and styles. func StyleRendererWithStyles(styles gansi.StyleConfig) gansi.RenderContext { return gansi.NewRenderContext(gansi.Options{ - ColorProfile: DefaultColorProfile, + ColorProfile: termenv.ANSI256, Styles: styles, }) } diff --git a/pkg/ui/components/code/code.go b/pkg/ui/components/code/code.go index af7697260fc7d327f1791ded0ab84f69f8c86c72..50e56f4aff0112ac095c5788227b3c9112bfe9f0 100644 --- a/pkg/ui/components/code/code.go +++ b/pkg/ui/components/code/code.go @@ -6,10 +6,10 @@ import ( "sync" "github.com/alecthomas/chroma/v2/lexers" - tea "github.com/charmbracelet/bubbletea" + tea "github.com/charmbracelet/bubbletea/v2" "github.com/charmbracelet/glamour" gansi "github.com/charmbracelet/glamour/ansi" - "github.com/charmbracelet/lipgloss" + "github.com/charmbracelet/lipgloss/v2" "github.com/charmbracelet/soft-serve/pkg/ui/common" vp "github.com/charmbracelet/soft-serve/pkg/ui/components/viewport" "github.com/muesli/termenv" @@ -110,7 +110,7 @@ func (r *Code) Init() tea.Cmd { if r.sidenote != "" { lines := strings.Split(r.sidenote, "\n") - sideNoteWidth := int(math.Ceil(float64(r.Model.Width) * r.SideNotePercent)) + sideNoteWidth := int(math.Ceil(float64(r.Model.Width()) * r.SideNotePercent)) for i, l := range lines { lines[i] = common.TruncateString(l, sideNoteWidth) } @@ -121,7 +121,7 @@ func (r *Code) Init() tea.Cmd { // https://github.com/muesli/reflow/issues/43 // // TODO: solve this upstream in Glamour/Reflow. - content = r.common.Renderer.NewStyle().Width(w).Render(content) + content = lipgloss.NewStyle().Width(w).Render(content) r.Viewport.Model.SetContent(content) @@ -169,26 +169,6 @@ func (r *Code) HalfViewUp() { r.Viewport.HalfViewUp() } -// ViewUp moves the viewport up by a page. -func (r *Code) ViewUp() []string { - return r.Viewport.ViewUp() -} - -// ViewDown moves the viewport down by a page. -func (r *Code) ViewDown() []string { - return r.Viewport.ViewDown() -} - -// LineUp moves the viewport up by the given number of lines. -func (r *Code) LineUp(n int) []string { - return r.Viewport.LineUp(n) -} - -// LineDown moves the viewport down by the given number of lines. -func (r *Code) LineDown(n int) []string { - return r.Viewport.LineDown(n) -} - // ScrollPercent returns the viewport's scroll percentage. func (r *Code) ScrollPercent() float64 { return r.Viewport.ScrollPercent() diff --git a/pkg/ui/components/footer/footer.go b/pkg/ui/components/footer/footer.go index 44c800f420e1913c72f1289a00b7d273269a8247..05e1160dedbe717a213de8907fbbb65dccc5bd4e 100644 --- a/pkg/ui/components/footer/footer.go +++ b/pkg/ui/components/footer/footer.go @@ -1,10 +1,10 @@ package footer import ( - "github.com/charmbracelet/bubbles/help" - "github.com/charmbracelet/bubbles/key" - tea "github.com/charmbracelet/bubbletea" - "github.com/charmbracelet/lipgloss" + "github.com/charmbracelet/bubbles/v2/help" + "github.com/charmbracelet/bubbles/v2/key" + tea "github.com/charmbracelet/bubbletea/v2" + "github.com/charmbracelet/lipgloss/v2" "github.com/charmbracelet/soft-serve/pkg/ui/common" ) diff --git a/pkg/ui/components/header/header.go b/pkg/ui/components/header/header.go index 7de511426f6da83252b84884c4fa3a64fd992e65..63e47a4911f6618c31448cdbc8c902e80314be11 100644 --- a/pkg/ui/components/header/header.go +++ b/pkg/ui/components/header/header.go @@ -3,7 +3,7 @@ package header import ( "strings" - tea "github.com/charmbracelet/bubbletea" + tea "github.com/charmbracelet/bubbletea/v2" "github.com/charmbracelet/soft-serve/pkg/ui/common" ) diff --git a/pkg/ui/components/selector/selector.go b/pkg/ui/components/selector/selector.go index 72239d4083847a2ccd72c7d0e10ea9bfa90e10ba..45cb031b8bd9b3ff8c928dbe07edf9b4628f5bf3 100644 --- a/pkg/ui/components/selector/selector.go +++ b/pkg/ui/components/selector/selector.go @@ -3,9 +3,9 @@ package selector import ( "sync" - "github.com/charmbracelet/bubbles/key" - "github.com/charmbracelet/bubbles/list" - tea "github.com/charmbracelet/bubbletea" + "github.com/charmbracelet/bubbles/v2/key" + "github.com/charmbracelet/bubbles/v2/list" + tea "github.com/charmbracelet/bubbletea/v2" "github.com/charmbracelet/soft-serve/pkg/ui/common" ) @@ -230,29 +230,27 @@ func (s *Selector) Init() tea.Cmd { func (s *Selector) Update(msg tea.Msg) (tea.Model, tea.Cmd) { cmds := make([]tea.Cmd, 0) switch msg := msg.(type) { - case tea.MouseMsg: - if msg.Action != tea.MouseActionPress { - break - } - switch msg.Button { - case tea.MouseButtonWheelUp: + case tea.MouseClickMsg: + m := msg.Mouse() + switch m.Button { + case tea.MouseWheelUp: s.CursorUp() - case tea.MouseButtonWheelDown: + case tea.MouseWheelDown: s.CursorDown() - case tea.MouseButtonLeft: - 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.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 + // } + // } } case tea.KeyMsg: filterState := s.FilterState() diff --git a/pkg/ui/components/statusbar/statusbar.go b/pkg/ui/components/statusbar/statusbar.go index 20a5735e12da1729616ea9ead98ccfcadfda6a47..f913e644a2230ea4a3d6f1b46f9e7850de45a02e 100644 --- a/pkg/ui/components/statusbar/statusbar.go +++ b/pkg/ui/components/statusbar/statusbar.go @@ -1,10 +1,10 @@ package statusbar import ( - tea "github.com/charmbracelet/bubbletea" - "github.com/charmbracelet/lipgloss" + tea "github.com/charmbracelet/bubbletea/v2" + "github.com/charmbracelet/lipgloss/v2" "github.com/charmbracelet/soft-serve/pkg/ui/common" - "github.com/muesli/reflow/truncate" + "github.com/charmbracelet/x/ansi" ) // Model is a status bar model. @@ -75,12 +75,12 @@ func (s *Model) View() string { } branch := st.StatusBarBranch.Render(s.extra) maxWidth := s.common.Width - w(key) - w(info) - w(branch) - w(help) - v := truncate.StringWithTail(s.value, uint(maxWidth-st.StatusBarValue.GetHorizontalFrameSize()), "…") //nolint:gosec + v := ansi.Truncate(s.value, maxWidth-st.StatusBarValue.GetHorizontalFrameSize(), "…") value := st.StatusBarValue. Width(maxWidth). Render(v) - return s.common.Renderer.NewStyle().MaxWidth(s.common.Width). + return lipgloss.NewStyle().MaxWidth(s.common.Width). Render( lipgloss.JoinHorizontal(lipgloss.Top, key, diff --git a/pkg/ui/components/tabs/tabs.go b/pkg/ui/components/tabs/tabs.go index bd31566216326910b991f732813daef756e733f2..2756595a361de3a4b2505bb86311ba8a7adfbd27 100644 --- a/pkg/ui/components/tabs/tabs.go +++ b/pkg/ui/components/tabs/tabs.go @@ -3,8 +3,8 @@ package tabs import ( "strings" - tea "github.com/charmbracelet/bubbletea" - "github.com/charmbracelet/lipgloss" + tea "github.com/charmbracelet/bubbletea/v2" + "github.com/charmbracelet/lipgloss/v2" "github.com/charmbracelet/soft-serve/pkg/ui/common" ) @@ -63,18 +63,15 @@ func (t *Tabs) Update(msg tea.Msg) (tea.Model, tea.Cmd) { t.activeTab = (t.activeTab - 1 + len(t.tabs)) % len(t.tabs) cmds = append(cmds, t.activeTabCmd) } - case tea.MouseMsg: - if msg.Action != tea.MouseActionPress { - break - } + case tea.MouseClickMsg: switch msg.Button { - case tea.MouseButtonLeft: - for i, tab := range t.tabs { - if t.common.Zone.Get(tab).InBounds(msg) { - t.activeTab = i - cmds = append(cmds, t.activeTabCmd) - } - } + 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) + // } + // } } case SelectTabMsg: tab := int(msg) @@ -109,7 +106,7 @@ func (t *Tabs) View() string { s.WriteString(sep.String()) } } - return t.common.Renderer.NewStyle(). + return lipgloss.NewStyle(). MaxWidth(t.common.Width). Render(s.String()) } diff --git a/pkg/ui/components/viewport/viewport.go b/pkg/ui/components/viewport/viewport.go index cd7b6c90951fc4293581ac976eef6dcbf067f637..c2355ae76b143eac896bd26ffed00e561bbab73e 100644 --- a/pkg/ui/components/viewport/viewport.go +++ b/pkg/ui/components/viewport/viewport.go @@ -1,9 +1,9 @@ package viewport import ( - "github.com/charmbracelet/bubbles/key" - "github.com/charmbracelet/bubbles/viewport" - tea "github.com/charmbracelet/bubbletea" + "github.com/charmbracelet/bubbles/v2/key" + "github.com/charmbracelet/bubbles/v2/viewport" + tea "github.com/charmbracelet/bubbletea/v2" "github.com/charmbracelet/soft-serve/pkg/ui/common" ) @@ -15,7 +15,9 @@ type Viewport struct { // New returns a new Viewport. func New(c common.Common) *Viewport { - vp := viewport.New(c.Width, c.Height) + vp := viewport.New() + vp.SetWidth(c.Width) + vp.SetHeight(c.Height) vp.MouseWheelEnabled = true return &Viewport{ common: c, @@ -26,8 +28,8 @@ func New(c common.Common) *Viewport { // SetSize implements common.Component. func (v *Viewport) SetSize(width, height int) { v.common.SetSize(width, height) - v.Model.Width = width - v.Model.Height = height + v.Model.SetWidth(width) + v.Model.SetHeight(height) } // Init implements tea.Model. @@ -81,26 +83,6 @@ func (v *Viewport) HalfViewUp() { v.Model.HalfViewUp() } -// ViewUp moves the viewport up by a page. -func (v *Viewport) ViewUp() []string { - return v.Model.ViewUp() -} - -// ViewDown moves the viewport down by a page. -func (v *Viewport) ViewDown() []string { - return v.Model.ViewDown() -} - -// LineUp moves the viewport up by the given number of lines. -func (v *Viewport) LineUp(n int) []string { - return v.Model.LineUp(n) -} - -// LineDown moves the viewport down by the given number of lines. -func (v *Viewport) LineDown(n int) []string { - return v.Model.LineDown(n) -} - // ScrollPercent returns the viewport's scroll percentage. func (v *Viewport) ScrollPercent() float64 { return v.Model.ScrollPercent() diff --git a/pkg/ui/keymap/keymap.go b/pkg/ui/keymap/keymap.go index ae09eaad7344c615d91fd92c92c1b36d634341a1..ad5d8fa736c7c9bda1c8b534d15fed084602ef76 100644 --- a/pkg/ui/keymap/keymap.go +++ b/pkg/ui/keymap/keymap.go @@ -1,6 +1,6 @@ package keymap -import "github.com/charmbracelet/bubbles/key" +import "github.com/charmbracelet/bubbles/v2/key" // KeyMap is a map of key bindings for the UI. type KeyMap struct { diff --git a/pkg/ui/pages/repo/files.go b/pkg/ui/pages/repo/files.go index fd43969fe7d07644542e105985a6081c18b34b58..7a73750b06abe63897a5f2df7688b262be516222 100644 --- a/pkg/ui/pages/repo/files.go +++ b/pkg/ui/pages/repo/files.go @@ -7,9 +7,9 @@ import ( "strings" gitm "github.com/aymanbagabas/git-module" - "github.com/charmbracelet/bubbles/key" - "github.com/charmbracelet/bubbles/spinner" - tea "github.com/charmbracelet/bubbletea" + "github.com/charmbracelet/bubbles/v2/key" + "github.com/charmbracelet/bubbles/v2/spinner" + tea "github.com/charmbracelet/bubbletea/v2" "github.com/charmbracelet/soft-serve/git" "github.com/charmbracelet/soft-serve/pkg/proto" "github.com/charmbracelet/soft-serve/pkg/ui/common" diff --git a/pkg/ui/pages/repo/filesitem.go b/pkg/ui/pages/repo/filesitem.go index ca399fa1b74986f152d7005919048f2ab79762e0..d821eb74d3728f72e04f4cf42245fe76182d4045 100644 --- a/pkg/ui/pages/repo/filesitem.go +++ b/pkg/ui/pages/repo/filesitem.go @@ -6,10 +6,10 @@ import ( "io/fs" "strings" - "github.com/charmbracelet/bubbles/key" - "github.com/charmbracelet/bubbles/list" - tea "github.com/charmbracelet/bubbletea" - "github.com/charmbracelet/lipgloss" + "github.com/charmbracelet/bubbles/v2/key" + "github.com/charmbracelet/bubbles/v2/list" + tea "github.com/charmbracelet/bubbletea/v2" + "github.com/charmbracelet/lipgloss/v2" "github.com/charmbracelet/soft-serve/git" "github.com/charmbracelet/soft-serve/pkg/ui/common" "github.com/dustin/go-humanize" @@ -139,7 +139,7 @@ func (d FileItemDelegate) Render(w io.Writer, m list.Model, index int, listItem name = nameStyle.Render(name) size = sizeStyle.Render(size) modeStr := modeStyle.Render(mode.String()) - truncate := d.common.Renderer.NewStyle().MaxWidth(m.Width() - + truncate := lipgloss.NewStyle().MaxWidth(m.Width() - s.Selector.GetHorizontalFrameSize() - s.Selector.GetWidth()) //nolint:errcheck diff --git a/pkg/ui/pages/repo/log.go b/pkg/ui/pages/repo/log.go index 8de8aa78d07c45ecc49529487d2729e089240813..1caabb4d6ba4ff42d6f91df56c723809c97bb8d4 100644 --- a/pkg/ui/pages/repo/log.go +++ b/pkg/ui/pages/repo/log.go @@ -5,11 +5,11 @@ import ( "strings" "time" - "github.com/charmbracelet/bubbles/key" - "github.com/charmbracelet/bubbles/spinner" - tea "github.com/charmbracelet/bubbletea" + "github.com/charmbracelet/bubbles/v2/key" + "github.com/charmbracelet/bubbles/v2/spinner" + tea "github.com/charmbracelet/bubbletea/v2" gansi "github.com/charmbracelet/glamour/ansi" - "github.com/charmbracelet/lipgloss" + "github.com/charmbracelet/lipgloss/v2" "github.com/charmbracelet/soft-serve/git" "github.com/charmbracelet/soft-serve/pkg/proto" "github.com/charmbracelet/soft-serve/pkg/ui/common" diff --git a/pkg/ui/pages/repo/logitem.go b/pkg/ui/pages/repo/logitem.go index 0ff4da6814fd62c8be3fe4e9f4a741ace3cda6ca..d95fe865bb0987c2ed09f2a6bc1a3f7ff922d71e 100644 --- a/pkg/ui/pages/repo/logitem.go +++ b/pkg/ui/pages/repo/logitem.go @@ -6,10 +6,10 @@ import ( "strings" "time" - "github.com/charmbracelet/bubbles/key" - "github.com/charmbracelet/bubbles/list" - tea "github.com/charmbracelet/bubbletea" - "github.com/charmbracelet/lipgloss" + "github.com/charmbracelet/bubbles/v2/key" + "github.com/charmbracelet/bubbles/v2/list" + tea "github.com/charmbracelet/bubbletea/v2" + "github.com/charmbracelet/lipgloss/v2" "github.com/charmbracelet/soft-serve/git" "github.com/charmbracelet/soft-serve/pkg/ui/common" "github.com/muesli/reflow/truncate" diff --git a/pkg/ui/pages/repo/readme.go b/pkg/ui/pages/repo/readme.go index 74c5be2f4dd163466972c31704b130c20d5c3083..8978effcda5e4cac341c95007da99f54f3d926f8 100644 --- a/pkg/ui/pages/repo/readme.go +++ b/pkg/ui/pages/repo/readme.go @@ -4,9 +4,9 @@ import ( "fmt" "path/filepath" - "github.com/charmbracelet/bubbles/key" - "github.com/charmbracelet/bubbles/spinner" - tea "github.com/charmbracelet/bubbletea" + "github.com/charmbracelet/bubbles/v2/key" + "github.com/charmbracelet/bubbles/v2/spinner" + tea "github.com/charmbracelet/bubbletea/v2" "github.com/charmbracelet/soft-serve/pkg/backend" "github.com/charmbracelet/soft-serve/pkg/proto" "github.com/charmbracelet/soft-serve/pkg/ui/common" diff --git a/pkg/ui/pages/repo/refs.go b/pkg/ui/pages/repo/refs.go index f6d9c56d84303d66f9e94aa5aa44e51afb367523..f30f8f735d0496d03aba55d08d670e939674c38c 100644 --- a/pkg/ui/pages/repo/refs.go +++ b/pkg/ui/pages/repo/refs.go @@ -5,9 +5,9 @@ import ( "sort" "strings" - "github.com/charmbracelet/bubbles/key" - "github.com/charmbracelet/bubbles/spinner" - tea "github.com/charmbracelet/bubbletea" + "github.com/charmbracelet/bubbles/v2/key" + "github.com/charmbracelet/bubbles/v2/spinner" + tea "github.com/charmbracelet/bubbletea/v2" "github.com/charmbracelet/soft-serve/git" "github.com/charmbracelet/soft-serve/pkg/proto" "github.com/charmbracelet/soft-serve/pkg/ui/common" diff --git a/pkg/ui/pages/repo/refsitem.go b/pkg/ui/pages/repo/refsitem.go index 7bb10d6e94fb4013789f6c4f4c4dfd7935d8d09d..aaed5e7e51afbadf03579074d43670acd6438879 100644 --- a/pkg/ui/pages/repo/refsitem.go +++ b/pkg/ui/pages/repo/refsitem.go @@ -6,10 +6,10 @@ import ( "strings" "time" - "github.com/charmbracelet/bubbles/key" - "github.com/charmbracelet/bubbles/list" - tea "github.com/charmbracelet/bubbletea" - "github.com/charmbracelet/lipgloss" + "github.com/charmbracelet/bubbles/v2/key" + "github.com/charmbracelet/bubbles/v2/list" + tea "github.com/charmbracelet/bubbletea/v2" + "github.com/charmbracelet/lipgloss/v2" "github.com/charmbracelet/soft-serve/git" "github.com/charmbracelet/soft-serve/pkg/ui/common" "github.com/dustin/go-humanize" diff --git a/pkg/ui/pages/repo/repo.go b/pkg/ui/pages/repo/repo.go index adeaeed35ccd33460a5358895c286c6b43e70de2..b68c8084a359087e223a1c082aaa1fdfdce36f82 100644 --- a/pkg/ui/pages/repo/repo.go +++ b/pkg/ui/pages/repo/repo.go @@ -4,15 +4,14 @@ import ( "fmt" "strings" - "github.com/charmbracelet/bubbles/help" - "github.com/charmbracelet/bubbles/key" - "github.com/charmbracelet/bubbles/spinner" - tea "github.com/charmbracelet/bubbletea" - "github.com/charmbracelet/lipgloss" + "github.com/charmbracelet/bubbles/v2/help" + "github.com/charmbracelet/bubbles/v2/key" + "github.com/charmbracelet/bubbles/v2/spinner" + tea "github.com/charmbracelet/bubbletea/v2" + "github.com/charmbracelet/lipgloss/v2" "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" @@ -177,29 +176,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.MouseMsg: - if msg.Action != tea.MouseActionPress { - break - } + case tea.MouseClickMsg: switch msg.Button { - case tea.MouseButtonLeft: - switch { - case r.common.Zone.Get("repo-help").InBounds(msg): - cmds = append(cmds, footer.ToggleFooterCmd) - } - case tea.MouseButtonRight: - switch { - case r.common.Zone.Get("repo-main").InBounds(msg): - cmds = append(cmds, goBackCmd) - } + case tea.MouseLeft: + // 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 msg := msg.(type) { @@ -212,7 +208,7 @@ func (r *Repo) Update(msg tea.Msg) (tea.Model, tea.Cmd) { case CopyMsg: txt := msg.Text if cfg := r.common.Config(); cfg != nil { - r.common.Output.Copy(txt) + cmds = append(cmds, tea.SetClipboard(txt)) } r.statusbar.SetStatus("", msg.Message, "", "") case ReadmeMsg: @@ -326,7 +322,7 @@ func (r *Repo) headerView() string { if r.selectedRepo == nil { return "" } - truncate := r.common.Renderer.NewStyle().MaxWidth(r.common.Width) + truncate := lipgloss.NewStyle().MaxWidth(r.common.Width) header := r.selectedRepo.ProjectName() if header == "" { header = r.selectedRepo.Name() diff --git a/pkg/ui/pages/repo/stash.go b/pkg/ui/pages/repo/stash.go index 667026b7baebc1556a3572049b6a4fb24b40e80a..37f8a1a85b5341a56884f0cb71c44e71dcc88c4d 100644 --- a/pkg/ui/pages/repo/stash.go +++ b/pkg/ui/pages/repo/stash.go @@ -4,10 +4,10 @@ import ( "fmt" gitm "github.com/aymanbagabas/git-module" - "github.com/charmbracelet/bubbles/key" - "github.com/charmbracelet/bubbles/spinner" - tea "github.com/charmbracelet/bubbletea" - "github.com/charmbracelet/lipgloss" + "github.com/charmbracelet/bubbles/v2/key" + "github.com/charmbracelet/bubbles/v2/spinner" + tea "github.com/charmbracelet/bubbletea/v2" + "github.com/charmbracelet/lipgloss/v2" "github.com/charmbracelet/soft-serve/git" "github.com/charmbracelet/soft-serve/pkg/proto" "github.com/charmbracelet/soft-serve/pkg/ui/common" diff --git a/pkg/ui/pages/repo/stashitem.go b/pkg/ui/pages/repo/stashitem.go index e6b6a9a822f12310c28b12d7be33e4ce4f517e92..77dd1a9274ff09fabdd1afff63f558236658eed3 100644 --- a/pkg/ui/pages/repo/stashitem.go +++ b/pkg/ui/pages/repo/stashitem.go @@ -5,9 +5,9 @@ import ( "io" gitm "github.com/aymanbagabas/git-module" - "github.com/charmbracelet/bubbles/key" - "github.com/charmbracelet/bubbles/list" - tea "github.com/charmbracelet/bubbletea" + "github.com/charmbracelet/bubbles/v2/key" + "github.com/charmbracelet/bubbles/v2/list" + tea "github.com/charmbracelet/bubbletea/v2" "github.com/charmbracelet/soft-serve/pkg/ui/common" ) diff --git a/pkg/ui/pages/selection/item.go b/pkg/ui/pages/selection/item.go index 1842d7243ac18ac997861a130d5ffc9efb34d51e..4b338bda5d68c44bbf1c7e2a11c38dedda0811f0 100644 --- a/pkg/ui/pages/selection/item.go +++ b/pkg/ui/pages/selection/item.go @@ -7,10 +7,10 @@ import ( "strings" "time" - "github.com/charmbracelet/bubbles/key" - "github.com/charmbracelet/bubbles/list" - tea "github.com/charmbracelet/bubbletea" - "github.com/charmbracelet/lipgloss" + "github.com/charmbracelet/bubbles/v2/key" + "github.com/charmbracelet/bubbles/v2/list" + tea "github.com/charmbracelet/bubbletea/v2" + "github.com/charmbracelet/lipgloss/v2" "github.com/charmbracelet/soft-serve/pkg/proto" "github.com/charmbracelet/soft-serve/pkg/ui/common" "github.com/dustin/go-humanize" @@ -139,8 +139,10 @@ func (d *ItemDelegate) Update(msg tea.Msg, m *list.Model) tea.Cmd { switch { case key.Matches(msg, d.common.KeyMap.Copy): d.copiedIdx = idx - d.common.Output.Copy(item.Command()) - return m.SetItem(idx, item) + return tea.Batch( + tea.SetClipboard(item.Command()), + m.SetItem(idx, item), + ) } } return nil diff --git a/pkg/ui/pages/selection/selection.go b/pkg/ui/pages/selection/selection.go index 7144244c710c089626502be333b872b22a208ea7..3ced323a69c692f446d2988ee54347aab9a1c79d 100644 --- a/pkg/ui/pages/selection/selection.go +++ b/pkg/ui/pages/selection/selection.go @@ -4,10 +4,10 @@ import ( "fmt" "sort" - "github.com/charmbracelet/bubbles/key" - "github.com/charmbracelet/bubbles/list" - tea "github.com/charmbracelet/bubbletea" - "github.com/charmbracelet/lipgloss" + "github.com/charmbracelet/bubbles/v2/key" + "github.com/charmbracelet/bubbles/v2/list" + tea "github.com/charmbracelet/bubbletea/v2" + "github.com/charmbracelet/lipgloss/v2" "github.com/charmbracelet/soft-serve/pkg/access" "github.com/charmbracelet/soft-serve/pkg/backend" "github.com/charmbracelet/soft-serve/pkg/ui/common" @@ -51,7 +51,7 @@ func New(c common.Common) *Selection { ts[i] = b.String() } t := tabs.New(c, ts) - t.TabSeparator = c.Renderer.NewStyle() + t.TabSeparator = lipgloss.NewStyle() t.TabInactive = c.Styles.TopLevelNormalTab t.TabActive = c.Styles.TopLevelActiveTab t.TabDot = c.Styles.TopLevelActiveTabDot @@ -289,15 +289,15 @@ func (s *Selection) View() string { wm, hm := s.getMargins() switch s.activePane { case selectorPane: - ss := s.common.Renderer.NewStyle(). + ss := lipgloss.NewStyle(). Width(s.common.Width - wm). Height(s.common.Height - hm) view = ss.Render(s.selector.View()) case readmePane: - rs := s.common.Renderer.NewStyle(). + rs := lipgloss.NewStyle(). Height(s.common.Height - hm) status := fmt.Sprintf("☰ %.f%%", s.readme.ScrollPercent()*100) - readmeStatus := s.common.Renderer.NewStyle(). + readmeStatus := lipgloss.NewStyle(). Align(lipgloss.Right). Width(s.common.Width - wm). Foreground(s.common.Styles.InactiveBorderColor). diff --git a/pkg/ui/styles/styles.go b/pkg/ui/styles/styles.go index 293b152a2027e9a659242a4219ed7ecbaebaa215..46b8cff040150d5be3d9d98d72a6370bd47c59eb 100644 --- a/pkg/ui/styles/styles.go +++ b/pkg/ui/styles/styles.go @@ -1,7 +1,9 @@ package styles import ( - "github.com/charmbracelet/lipgloss" + "image/color" + + "github.com/charmbracelet/lipgloss/v2" ) // XXX: For now, this is in its own package so that it can be shared between @@ -9,8 +11,8 @@ import ( // Styles defines styles for the UI. type Styles struct { - ActiveBorderColor lipgloss.Color - InactiveBorderColor lipgloss.Color + ActiveBorderColor color.Color + InactiveBorderColor color.Color App lipgloss.Style ServerName lipgloss.Style @@ -165,7 +167,7 @@ type Styles struct { } // DefaultStyles returns default styles for the UI. -func DefaultStyles(r *lipgloss.Renderer) *Styles { +func DefaultStyles() *Styles { highlightColor := lipgloss.Color("210") highlightColorDim := lipgloss.Color("174") selectorColor := lipgloss.Color("167") @@ -176,10 +178,10 @@ func DefaultStyles(r *lipgloss.Renderer) *Styles { s.ActiveBorderColor = lipgloss.Color("62") s.InactiveBorderColor = lipgloss.Color("241") - s.App = r.NewStyle(). + s.App = lipgloss.NewStyle(). Margin(1, 2) - s.ServerName = r.NewStyle(). + s.ServerName = lipgloss.NewStyle(). Height(1). MarginLeft(1). MarginBottom(1). @@ -188,29 +190,29 @@ func DefaultStyles(r *lipgloss.Renderer) *Styles { Foreground(lipgloss.Color("229")). Bold(true) - s.TopLevelNormalTab = r.NewStyle(). + s.TopLevelNormalTab = lipgloss.NewStyle(). MarginRight(2) s.TopLevelActiveTab = s.TopLevelNormalTab. Foreground(lipgloss.Color("36")) - s.TopLevelActiveTabDot = r.NewStyle(). + s.TopLevelActiveTabDot = lipgloss.NewStyle(). Foreground(lipgloss.Color("36")) - s.RepoSelector.Normal.Base = r.NewStyle(). + s.RepoSelector.Normal.Base = lipgloss.NewStyle(). PaddingLeft(1). Border(lipgloss.Border{Left: " "}, false, false, false, true). Height(3) - s.RepoSelector.Normal.Title = r.NewStyle().Bold(true) + s.RepoSelector.Normal.Title = lipgloss.NewStyle().Bold(true) - s.RepoSelector.Normal.Desc = r.NewStyle(). + s.RepoSelector.Normal.Desc = lipgloss.NewStyle(). Foreground(lipgloss.Color("243")) - s.RepoSelector.Normal.Command = r.NewStyle(). + s.RepoSelector.Normal.Command = lipgloss.NewStyle(). Foreground(lipgloss.Color("132")) - s.RepoSelector.Normal.Updated = r.NewStyle(). + s.RepoSelector.Normal.Updated = lipgloss.NewStyle(). Foreground(lipgloss.Color("243")) s.RepoSelector.Active.Base = s.RepoSelector.Normal.Base. @@ -229,78 +231,78 @@ func DefaultStyles(r *lipgloss.Renderer) *Styles { s.RepoSelector.Active.Command = s.RepoSelector.Normal.Command. Foreground(lipgloss.Color("204")) - s.MenuItem = r.NewStyle(). + s.MenuItem = lipgloss.NewStyle(). PaddingLeft(1). Border(lipgloss.Border{ Left: " ", }, false, false, false, true). Height(3) - s.MenuLastUpdate = r.NewStyle(). + s.MenuLastUpdate = lipgloss.NewStyle(). Foreground(lipgloss.Color("241")). Align(lipgloss.Right) - s.Repo.Base = r.NewStyle() + s.Repo.Base = lipgloss.NewStyle() - s.Repo.Title = r.NewStyle(). + s.Repo.Title = lipgloss.NewStyle(). Padding(0, 2) - s.Repo.Command = r.NewStyle(). + s.Repo.Command = lipgloss.NewStyle(). Foreground(lipgloss.Color("168")) - s.Repo.Body = r.NewStyle(). + s.Repo.Body = lipgloss.NewStyle(). Margin(1, 0) - s.Repo.Header = r.NewStyle(). + s.Repo.Header = lipgloss.NewStyle(). MaxHeight(2). Border(lipgloss.NormalBorder(), false, false, true, false). BorderForeground(lipgloss.Color("236")) - s.Repo.HeaderName = r.NewStyle(). + s.Repo.HeaderName = lipgloss.NewStyle(). Foreground(lipgloss.Color("212")). Bold(true) - s.Repo.HeaderDesc = r.NewStyle(). + s.Repo.HeaderDesc = lipgloss.NewStyle(). Foreground(lipgloss.Color("243")) - s.Footer = r.NewStyle(). + s.Footer = lipgloss.NewStyle(). MarginTop(1). Padding(0, 1). Height(1) - s.Branch = r.NewStyle(). + s.Branch = lipgloss.NewStyle(). Foreground(lipgloss.Color("203")). Background(lipgloss.Color("236")). Padding(0, 1) - s.HelpKey = r.NewStyle(). + s.HelpKey = lipgloss.NewStyle(). Foreground(lipgloss.Color("241")) - s.HelpValue = r.NewStyle(). + s.HelpValue = lipgloss.NewStyle(). Foreground(lipgloss.Color("239")) - s.HelpDivider = r.NewStyle(). + s.HelpDivider = lipgloss.NewStyle(). Foreground(lipgloss.Color("237")). SetString(" • ") - s.URLStyle = r.NewStyle(). + s.URLStyle = lipgloss.NewStyle(). MarginLeft(1). Foreground(lipgloss.Color("168")) - s.Error = r.NewStyle(). + s.Error = lipgloss.NewStyle(). MarginTop(2) - s.ErrorTitle = r.NewStyle(). + s.ErrorTitle = lipgloss.NewStyle(). Foreground(lipgloss.Color("230")). Background(lipgloss.Color("204")). Bold(true). Padding(0, 1) - s.ErrorBody = r.NewStyle(). + s.ErrorBody = lipgloss.NewStyle(). Foreground(lipgloss.Color("252")). MarginLeft(2) - s.LogItem.Normal.Base = r.NewStyle(). + s.LogItem.Normal.Base = lipgloss.NewStyle(). Border(lipgloss.Border{ Left: " ", }, false, false, false, true). @@ -315,113 +317,113 @@ func DefaultStyles(r *lipgloss.Renderer) *Styles { s.LogItem.Active.Hash = s.LogItem.Normal.Hash. Foreground(hashColor) - s.LogItem.Active.Hash = r.NewStyle(). + s.LogItem.Active.Hash = lipgloss.NewStyle(). Bold(true). Foreground(highlightColor) - s.LogItem.Normal.Title = r.NewStyle(). + s.LogItem.Normal.Title = lipgloss.NewStyle(). Foreground(lipgloss.Color("105")) - s.LogItem.Active.Title = r.NewStyle(). + s.LogItem.Active.Title = lipgloss.NewStyle(). Foreground(highlightColor). Bold(true) - s.LogItem.Normal.Desc = r.NewStyle(). + s.LogItem.Normal.Desc = lipgloss.NewStyle(). Foreground(lipgloss.Color("246")) - s.LogItem.Active.Desc = r.NewStyle(). + s.LogItem.Active.Desc = lipgloss.NewStyle(). Foreground(lipgloss.Color("95")) s.LogItem.Active.Keyword = s.LogItem.Active.Desc. Foreground(highlightColorDim) - s.LogItem.Normal.Hash = r.NewStyle(). + s.LogItem.Normal.Hash = lipgloss.NewStyle(). Foreground(hashColor) - s.LogItem.Active.Hash = r.NewStyle(). + s.LogItem.Active.Hash = lipgloss.NewStyle(). Foreground(highlightColor) - s.Log.Commit = r.NewStyle(). + s.Log.Commit = lipgloss.NewStyle(). Margin(0, 2) - s.Log.CommitHash = r.NewStyle(). + s.Log.CommitHash = lipgloss.NewStyle(). Foreground(hashColor). Bold(true) - s.Log.CommitBody = r.NewStyle(). + s.Log.CommitBody = lipgloss.NewStyle(). MarginTop(1). MarginLeft(2) - s.Log.CommitStatsAdd = r.NewStyle(). + s.Log.CommitStatsAdd = lipgloss.NewStyle(). Foreground(lipgloss.Color("42")). Bold(true) - s.Log.CommitStatsDel = r.NewStyle(). + s.Log.CommitStatsDel = lipgloss.NewStyle(). Foreground(lipgloss.Color("203")). Bold(true) - s.Log.Paginator = r.NewStyle(). + s.Log.Paginator = lipgloss.NewStyle(). Margin(0). Align(lipgloss.Center) - s.Ref.Normal.Item = r.NewStyle() + s.Ref.Normal.Item = lipgloss.NewStyle() - s.Ref.ItemSelector = r.NewStyle(). + s.Ref.ItemSelector = lipgloss.NewStyle(). Foreground(selectorColor). SetString("> ") - s.Ref.Active.Item = r.NewStyle(). + s.Ref.Active.Item = lipgloss.NewStyle(). Foreground(highlightColorDim) - s.Ref.Normal.Base = r.NewStyle() + s.Ref.Normal.Base = lipgloss.NewStyle() - s.Ref.Active.Base = r.NewStyle() + s.Ref.Active.Base = lipgloss.NewStyle() - s.Ref.Normal.ItemTag = r.NewStyle(). + s.Ref.Normal.ItemTag = lipgloss.NewStyle(). Foreground(lipgloss.Color("39")) - s.Ref.Active.ItemTag = r.NewStyle(). + s.Ref.Active.ItemTag = lipgloss.NewStyle(). Bold(true). Foreground(highlightColor) - s.Ref.Active.Item = r.NewStyle(). + s.Ref.Active.Item = lipgloss.NewStyle(). Bold(true). Foreground(highlightColor) - s.Ref.Normal.ItemDesc = r.NewStyle(). + s.Ref.Normal.ItemDesc = lipgloss.NewStyle(). Faint(true) - s.Ref.Active.ItemDesc = r.NewStyle(). + s.Ref.Active.ItemDesc = lipgloss.NewStyle(). Foreground(highlightColor). Faint(true) - s.Ref.Normal.ItemHash = r.NewStyle(). + s.Ref.Normal.ItemHash = lipgloss.NewStyle(). Foreground(hashColor). Bold(true) - s.Ref.Active.ItemHash = r.NewStyle(). + s.Ref.Active.ItemHash = lipgloss.NewStyle(). Foreground(highlightColor). Bold(true) s.Ref.Paginator = s.Log.Paginator - s.Ref.Selector = r.NewStyle() + s.Ref.Selector = lipgloss.NewStyle() s.Tree.Selector = s.Tree.Normal.FileName. Width(1). Foreground(selectorColor) - s.Tree.Normal.FileName = r.NewStyle(). + s.Tree.Normal.FileName = lipgloss.NewStyle(). MarginLeft(1) s.Tree.Active.FileName = s.Tree.Normal.FileName. Bold(true). Foreground(highlightColor) - s.Tree.Normal.FileDir = r.NewStyle(). + s.Tree.Normal.FileDir = lipgloss.NewStyle(). Foreground(lipgloss.Color("39")) - s.Tree.Active.FileDir = r.NewStyle(). + s.Tree.Active.FileDir = lipgloss.NewStyle(). Foreground(highlightColor) s.Tree.Normal.FileMode = s.Tree.Active.FileName. @@ -437,87 +439,87 @@ func DefaultStyles(r *lipgloss.Renderer) *Styles { s.Tree.Active.FileSize = s.Tree.Normal.FileName. Foreground(highlightColorDim) - s.Tree.FileContent = r.NewStyle() + s.Tree.FileContent = lipgloss.NewStyle() s.Tree.Paginator = s.Log.Paginator - s.Tree.Blame.Hash = r.NewStyle(). + s.Tree.Blame.Hash = lipgloss.NewStyle(). Foreground(hashColor). Bold(true) - s.Tree.Blame.Message = r.NewStyle() + s.Tree.Blame.Message = lipgloss.NewStyle() - s.Tree.Blame.Who = r.NewStyle(). + s.Tree.Blame.Who = lipgloss.NewStyle(). Faint(true) - s.Spinner = r.NewStyle(). + s.Spinner = lipgloss.NewStyle(). MarginTop(1). MarginLeft(2). Foreground(lipgloss.Color("205")) - s.SpinnerContainer = r.NewStyle() + s.SpinnerContainer = lipgloss.NewStyle() - s.NoContent = r.NewStyle(). + s.NoContent = lipgloss.NewStyle(). MarginTop(1). MarginLeft(2). Foreground(lipgloss.Color("242")) - s.StatusBar = r.NewStyle(). + s.StatusBar = lipgloss.NewStyle(). Height(1) - s.StatusBarKey = r.NewStyle(). + s.StatusBarKey = lipgloss.NewStyle(). Bold(true). Padding(0, 1). Background(lipgloss.Color("206")). Foreground(lipgloss.Color("228")) - s.StatusBarValue = r.NewStyle(). + s.StatusBarValue = lipgloss.NewStyle(). Padding(0, 1). Background(lipgloss.Color("235")). Foreground(lipgloss.Color("243")) - s.StatusBarInfo = r.NewStyle(). + s.StatusBarInfo = lipgloss.NewStyle(). Padding(0, 1). Background(lipgloss.Color("212")). Foreground(lipgloss.Color("230")) - s.StatusBarBranch = r.NewStyle(). + s.StatusBarBranch = lipgloss.NewStyle(). Padding(0, 1). Background(lipgloss.Color("62")). Foreground(lipgloss.Color("230")) - s.StatusBarHelp = r.NewStyle(). + s.StatusBarHelp = lipgloss.NewStyle(). Padding(0, 1). Background(lipgloss.Color("237")). Foreground(lipgloss.Color("243")) - s.Tabs = r.NewStyle(). + s.Tabs = lipgloss.NewStyle(). Height(1) - s.TabInactive = r.NewStyle() + s.TabInactive = lipgloss.NewStyle() - s.TabActive = r.NewStyle(). + s.TabActive = lipgloss.NewStyle(). Underline(true). Foreground(lipgloss.Color("36")) - s.TabSeparator = r.NewStyle(). + s.TabSeparator = lipgloss.NewStyle(). SetString("│"). Padding(0, 1). Foreground(lipgloss.Color("238")) - s.Code.LineDigit = r.NewStyle().Foreground(lipgloss.Color("239")) + s.Code.LineDigit = lipgloss.NewStyle().Foreground(lipgloss.Color("239")) - s.Code.LineBar = r.NewStyle().Foreground(lipgloss.Color("236")) + s.Code.LineBar = lipgloss.NewStyle().Foreground(lipgloss.Color("236")) - s.Stash.Normal.Message = r.NewStyle().MarginLeft(1) + s.Stash.Normal.Message = lipgloss.NewStyle().MarginLeft(1) s.Stash.Active.Message = s.Stash.Normal.Message.Foreground(selectorColor) - s.Stash.Title = r.NewStyle(). + s.Stash.Title = lipgloss.NewStyle(). Foreground(hashColor). Bold(true) - s.Stash.Selector = r.NewStyle(). + s.Stash.Selector = lipgloss.NewStyle(). Width(1). Foreground(selectorColor)